From ad37f276da3519f3f4b096b071cc629cc60c39f2 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Sep 2012 17:13:36 +0530 Subject: [PATCH 1/8] Created Chart of Accounts using Slick Grid and Tree --- .../page/chart_of_accounts/__init__.py | 0 .../chart_of_accounts/chart_of_accounts.css | 21 ++ .../chart_of_accounts/chart_of_accounts.html | 0 .../chart_of_accounts/chart_of_accounts.js | 201 ++++++++++++++++++ .../chart_of_accounts/chart_of_accounts.py | 25 +++ .../chart_of_accounts/chart_of_accounts.txt | 28 +++ public/images/collapse.gif | Bin 0 -> 846 bytes public/images/expand.gif | Bin 0 -> 851 bytes public/js/all-app.js | 8 +- public/js/all-web.js | 8 +- 10 files changed, 283 insertions(+), 8 deletions(-) create mode 100644 erpnext/accounts/page/chart_of_accounts/__init__.py create mode 100644 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css create mode 100644 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.html create mode 100644 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js create mode 100644 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py create mode 100644 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt create mode 100644 public/images/collapse.gif create mode 100644 public/images/expand.gif diff --git a/erpnext/accounts/page/chart_of_accounts/__init__.py b/erpnext/accounts/page/chart_of_accounts/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css new file mode 100644 index 0000000000..00e05d4994 --- /dev/null +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css @@ -0,0 +1,21 @@ +.cell-title { + font-weight: bold; +} + +.cell-effort-driven { + text-align: center; +} + +.toggle { + height: 9px; + width: 9px; + display: inline-block; +} + +.toggle.expand { + background: url(images/expand.gif) no-repeat center center; +} + +.toggle.collapse { + background: url(images/collapse.gif) no-repeat center center; +} \ No newline at end of file diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.html b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js new file mode 100644 index 0000000000..010b1fc1cd --- /dev/null +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js @@ -0,0 +1,201 @@ +// ERPNext - web based ERP (http://erpnext.com) +// Copyright (C) 2012 Web Notes Technologies Pvt Ltd +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/* todo + - load / display chart of accounts + - settings for company, start date, end data + - load balances + - open ledger on link +*/ + +wn.pages['chart-of-accounts'].onload = function(wrapper) { + wn.ui.make_app_page({ + parent: wrapper, + title: 'Chart of Accounts', + single_column: true + }); + wrapper.appframe.add_button("Refresh", function() {}, "icon-refresh").css("margin-right", "12px"); + erpnext.coa.company_select = wrapper.appframe.add_select("Company", ["Loading..."]); + wrapper.appframe.add_date("Opening Date"); + wrapper.appframe.add_date("Closing Date"); + + $('
\ +
').appendTo($(wrapper).find('.layout-main')); + + wn.call({ + module: "accounts", + page: "chart_of_accounts", + method: "get_companies", + callback: function(r) { + erpnext.coa.company_select.empty().add_options(r.message).change(); + } + }); + + erpnext.coa.company_select.change(function() { + erpnext.coa.load_slickgrid(); + erpnext.coa.load_data($(this).val()); + }); +} + +erpnext.coa = { + load_slickgrid: function() { + // load tree + wn.require('js/lib/jquery/jquery.ui.sortable'); + wn.require('js/lib/slickgrid/slick.grid.css'); + wn.require('js/lib/slickgrid/slick-default-theme.css'); + wn.require('js/lib/slickgrid/jquery.event.drag.min.js'); + wn.require('js/lib/slickgrid/slick.core.js'); + wn.require('js/lib/slickgrid/slick.formatters.js'); + wn.require('js/lib/slickgrid/slick.grid.js'); + wn.require('js/lib/slickgrid/slick.dataview.js'); + wn.dom.set_style('.slick-cell { font-size: 12px; }'); + }, + load_data: function(company) { + wn.call({ + module: "accounts", + page: "chart_of_accounts", + method: "get_chart", + args: {company: company}, + callback: function(r) { + erpnext.coa.prepare_data(r.message); + erpnext.coa.render() + } + }) + }, + prepare_data: function(indata) { + var data = []; + var parent_map = {}; + var data_by_name = {}; + $.each(indata, function(i, v) { + if(v[0]) { + var d = { + "id": v[0], + "name": v[0], + "parent": v[1], + "opening": Math.random() * 100, + "debits": Math.random() * 100, + "credits": Math.random() * 100 + }; + d["closing"] = d['opening'] + d['debits'] - d['credits']; + + data.push(d); + data_by_name[d.name] = d; + if(d.parent) { + parent_map[d.name] = d.parent; + } + } + }); + erpnext.coa.set_indent(data, parent_map); + erpnext.coa.data = data; + erpnext.coa.parent_map = parent_map; + erpnext.coa.data_by_name = data_by_name; + }, + set_indent: function(data, parent_map) { + $.each(data, function(i, d) { + var indent = 0; + var parent = parent_map[d.name]; + if(parent) { + while(parent) { + indent++; + parent = parent_map[parent]; + } + } + d.indent = indent; + }); + }, + render: function() { + // initialize the model + erpnext.coa.dataView = new Slick.Data.DataView({ inlineFilters: true }); + erpnext.coa.dataView.beginUpdate(); + erpnext.coa.dataView.setItems(erpnext.coa.data); + erpnext.coa.dataView.setFilter(erpnext.coa.filter) + erpnext.coa.dataView.endUpdate(); + + var columns = [ + {id: "name", name: "Account", field: "name", width: 400, cssClass: "cell-title", + formatter: erpnext.coa.account_formatter}, + {id: "opening", name: "Opening", field: "opening"}, + {id: "debits", name: "Debits", field: "debits"}, + {id: "credits", name: "Credits", field: "credits"}, + {id: "closing", name: "Closing", field: "closing"} + ]; + + var options = { + editable: false, + enableColumnReorder: false + }; + + // initialize the grid + var grid = new Slick.Grid("#chart-of-accounts", erpnext.coa.dataView, columns, options); + erpnext.coa.add_events(grid); + }, + add_events: function(grid) { + grid.onClick.subscribe(function (e, args) { + if ($(e.target).hasClass("toggle")) { + var item = erpnext.coa.dataView.getItem(args.row); + if (item) { + if (!item._collapsed) { + item._collapsed = true; + } else { + item._collapsed = false; + } + + erpnext.coa.dataView.updateItem(item.id, item); + } + e.stopImmediatePropagation(); + } + }); + + erpnext.coa.dataView.onRowsChanged.subscribe(function (e, args) { + grid.invalidateRows(args.rows); + grid.render(); + }); + + erpnext.coa.dataView.onRowCountChanged.subscribe(function (e, args) { + grid.updateRowCount(); + grid.render(); + }); + + }, + filter: function(item) { + if (item.parent) { + var parent = item.parent; + while (parent) { + if (erpnext.coa.data_by_name[parent]._collapsed) { + return false; + } + parent = erpnext.coa.parent_map[parent]; + } + } + return true; + }, + account_formatter: function (row, cell, value, columnDef, dataContext) { + value = value.replace(/&/g,"&").replace(//g,">"); + var data = erpnext.coa.data; + var spacer = ""; + var idx = erpnext.coa.dataView.getIdxById(dataContext.id); + if (data[idx + 1] && data[idx + 1].indent > data[idx].indent) { + if (dataContext._collapsed) { + return spacer + "  " + value; + } else { + return spacer + "  " + value; + } + } else { + return spacer + "  " + value; + } + } +} diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py new file mode 100644 index 0000000000..b3c21872ee --- /dev/null +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py @@ -0,0 +1,25 @@ +import webnotes + +@webnotes.whitelist() +def get_chart(): + company = webnotes.form_dict.get('company') + return webnotes.conn.sql("""select name, parent_account from + tabAccount where company=%s and docstatus < 2 order by lft""", company) + +@webnotes.whitelist() +def get_companies(): + """get a list of companies based on permission""" + + # check if match permission exists + res = webnotes.conn.sql("""select role, `match` from `tabDocPerm` + where parent='Account' and permlevel=0 and `read`=1""", as_dict=1) + + match = any((r["match"] for r in res + if r["role"] in webnotes.user.roles and r["match"]=="company")) + + # if match == company is specified and companies are specified in user defaults + if match and webnotes.user.get_defaults().get("company"): + return webnotes.user.get_defaults().get("company") + else: + return [r[0] for r in webnotes.conn.sql("""select name from tabCompany + where docstatus!=2""")] diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt new file mode 100644 index 0000000000..e9d5ab5065 --- /dev/null +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt @@ -0,0 +1,28 @@ +# Page, chart-of-accounts +[ + + # These values are common in all dictionaries + { + 'creation': '2012-09-12 14:43:52', + 'docstatus': 0, + 'modified': '2012-09-12 14:43:53', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Page + { + 'doctype': 'Page', + 'module': u'Accounts', + 'name': '__common__', + 'page_name': u'Chart of Accounts', + 'standard': u'Yes', + 'title': u'Chart of Accounts' + }, + + # Page, chart-of-accounts + { + 'doctype': 'Page', + 'name': u'chart-of-accounts' + } +] \ No newline at end of file diff --git a/public/images/collapse.gif b/public/images/collapse.gif new file mode 100644 index 0000000000000000000000000000000000000000..01e691450c48632dc92a40a8c2b509bf99987225 GIT binary patch literal 846 zcmZ?wbhEHb$FyaIl$)g-gQVfI}k_i-?$k!^A~S3=)P?0Tm31hZvXy UI%HM~I5JIC=Ul}jAi!V^09i~Z*8l(j literal 0 HcmV?d00001 diff --git a/public/images/expand.gif b/public/images/expand.gif new file mode 100644 index 0000000000000000000000000000000000000000..1b24ef1248de55c6140895f6760758a1579f14cf GIT binary patch literal 851 zcmZ?wbhEHb$FyaIl$)g-gPK!J(0fMMMlpH!w1DF=kxpFl=aGX3~-h X>0od?I!Q%XL14k81*aJp85yhr3QsCm literal 0 HcmV?d00001 diff --git a/public/js/all-app.js b/public/js/all-app.js index 5876391adb..50e3ca2a2a 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -183,7 +183,7 @@ return cookies[c];} wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);') $(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);') $(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){$.fn.add_options=function(options_list){for(var i=0;i').html(label).attr('value',value).appendTo(this);} -$(this).val(options_list[0].value||options_list[0]);} +return $(this).val(options_list[0].value||options_list[0]);} $.fn.set_working=function(){var ele=this.get(0);$(ele).attr('disabled','disabled');if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.loading_img=$('').insertAfter(ele);}} $.fn.done_working=function(){var ele=this.get(0);$(ele).attr('disabled',null);if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery); @@ -854,10 +854,10 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w \ ×\ ').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();}) -if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){if(!this.$w.find('.appframe-toolbar').length) -this.$w.append('
');args={label:label,icon:''};if(icon){args.icon='';} +if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.$w.find('.appframe-toolbar'));return this.buttons[label];},clear_buttons:function(){this.$w.find('.appframe-toolbar').empty();}});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\ + %(icon)s %(label)s',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) +this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\
\
');}else{$(opts.parent).html('
\ diff --git a/public/js/all-web.js b/public/js/all-web.js index 8f682f14c6..2454dded70 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -70,7 +70,7 @@ return cookies[c];} wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);') $(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);') $(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){$.fn.add_options=function(options_list){for(var i=0;i').html(label).attr('value',value).appendTo(this);} -$(this).val(options_list[0].value||options_list[0]);} +return $(this).val(options_list[0].value||options_list[0]);} $.fn.set_working=function(){var ele=this.get(0);$(ele).attr('disabled','disabled');if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.loading_img=$('').insertAfter(ele);}} $.fn.done_working=function(){var ele=this.get(0);$(ele).attr('disabled',null);if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery); @@ -513,10 +513,10 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w \ ×\
').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();}) -if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){if(!this.$w.find('.appframe-toolbar').length) -this.$w.append('
');args={label:label,icon:''};if(icon){args.icon='';} +if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.$w.find('.appframe-toolbar'));return this.buttons[label];},clear_buttons:function(){this.$w.find('.appframe-toolbar').empty();}});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\ + %(icon)s %(label)s',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) +this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\
\
');}else{$(opts.parent).html('
\ From 0fa8e33835c8bcd9152cce6101b645523873c4fc Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Sep 2012 18:14:12 +0530 Subject: [PATCH 2/8] chart of accounts: balances calculation --- .../chart_of_accounts/chart_of_accounts.js | 74 ++++++++++++++++--- .../chart_of_accounts/chart_of_accounts.py | 9 ++- public/js/all-app.js | 4 +- public/js/all-web.js | 4 +- 4 files changed, 73 insertions(+), 18 deletions(-) diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js index 010b1fc1cd..43fe56c310 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js @@ -27,10 +27,11 @@ wn.pages['chart-of-accounts'].onload = function(wrapper) { title: 'Chart of Accounts', single_column: true }); - wrapper.appframe.add_button("Refresh", function() {}, "icon-refresh").css("margin-right", "12px"); erpnext.coa.company_select = wrapper.appframe.add_select("Company", ["Loading..."]); - wrapper.appframe.add_date("Opening Date"); - wrapper.appframe.add_date("Closing Date"); + erpnext.coa.opening_date = wrapper.appframe.add_date("Opening Date") + .val(dateutil.str_to_user(sys_defaults.year_start_date)); + erpnext.coa.closing_date = wrapper.appframe.add_date("Closing Date") + .val(dateutil.obj_to_user(new Date())); $('
\
').appendTo($(wrapper).find('.layout-main')); @@ -48,6 +49,9 @@ wn.pages['chart-of-accounts'].onload = function(wrapper) { erpnext.coa.load_slickgrid(); erpnext.coa.load_data($(this).val()); }); + + erpnext.coa.opening_date.change(erpnext.coa.refresh); + erpnext.coa.closing_date.change(erpnext.coa.refresh); } erpnext.coa = { @@ -63,6 +67,10 @@ erpnext.coa = { wn.require('js/lib/slickgrid/slick.dataview.js'); wn.dom.set_style('.slick-cell { font-size: 12px; }'); }, + refresh: function() { + erpnext.coa.prepare_balances(); + erpnext.coa.render(); + }, load_data: function(company) { wn.call({ module: "accounts", @@ -70,12 +78,14 @@ erpnext.coa = { method: "get_chart", args: {company: company}, callback: function(r) { - erpnext.coa.prepare_data(r.message); - erpnext.coa.render() + erpnext.coa.gl = r.message.gl; + erpnext.coa.prepare_chart(r.message.chart); + erpnext.coa.prepare_balances(); + erpnext.coa.render(); } }) }, - prepare_data: function(indata) { + prepare_chart: function(indata) { var data = []; var parent_map = {}; var data_by_name = {}; @@ -85,11 +95,12 @@ erpnext.coa = { "id": v[0], "name": v[0], "parent": v[1], - "opening": Math.random() * 100, - "debits": Math.random() * 100, - "credits": Math.random() * 100 + "opening": 0, + "debit": 0, + "credit": 0, + "closing": 0, + "debit_or_credit": v[2], }; - d["closing"] = d['opening'] + d['debits'] - d['credits']; data.push(d); data_by_name[d.name] = d; @@ -103,6 +114,44 @@ erpnext.coa = { erpnext.coa.parent_map = parent_map; erpnext.coa.data_by_name = data_by_name; }, + prepare_balances: function() { + var gl = erpnext.coa.gl; + var opening_date = dateutil.user_to_obj(erpnext.coa.opening_date.val()); + var closing_date = dateutil.user_to_obj(erpnext.coa.closing_date.val()); + $.each(erpnext.coa.data, function(i, v) { + v.opening = v.debit = v.credit = v.closing = 0; + }); + $.each(gl, function(i, v) { + var posting_date = dateutil.str_to_obj(v[0]); + var account = erpnext.coa.data_by_name[v[1]]; + // opening + if (posting_date < opening_date) { + if (account.debit_or_credit === "Debit") { + account.opening += (v[2] - v[3]); + } else { + account.opening += (v[3] - v[2]); + } + } else if (opening_date <= posting_date && posting_date <= closing_date) { + // in between + account.debit += v[2]; + account.credit += v[3]; + } + // closing + if (account.debit_or_credit === "Debit") { + account.closing = account.opening + account.debit - account.credit; + } else { + account.closing = account.opening + account.credit - account.debit; + } + }); + + // format amount + $.each(erpnext.coa.data, function(i, v) { + v.opening = fmt_money(v.opening); + v.debit = fmt_money(v.debit); + v.credit = fmt_money(v.credit); + v.closing = fmt_money(v.closing); + }); + }, set_indent: function(data, parent_map) { $.each(data, function(i, d) { var indent = 0; @@ -128,8 +177,8 @@ erpnext.coa = { {id: "name", name: "Account", field: "name", width: 400, cssClass: "cell-title", formatter: erpnext.coa.account_formatter}, {id: "opening", name: "Opening", field: "opening"}, - {id: "debits", name: "Debits", field: "debits"}, - {id: "credits", name: "Credits", field: "credits"}, + {id: "debit", name: "Debit", field: "debit"}, + {id: "credit", name: "Credit", field: "credit"}, {id: "closing", name: "Closing", field: "closing"} ]; @@ -141,6 +190,7 @@ erpnext.coa = { // initialize the grid var grid = new Slick.Grid("#chart-of-accounts", erpnext.coa.dataView, columns, options); erpnext.coa.add_events(grid); + erpnext.coa.grid = grid; }, add_events: function(grid) { grid.onClick.subscribe(function (e, args) { diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py index b3c21872ee..620368f079 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py @@ -3,8 +3,13 @@ import webnotes @webnotes.whitelist() def get_chart(): company = webnotes.form_dict.get('company') - return webnotes.conn.sql("""select name, parent_account from - tabAccount where company=%s and docstatus < 2 order by lft""", company) + res = {} + res["chart"] = webnotes.conn.sql("""select name, parent_account, debit_or_credit from + tabAccount where company=%s and docstatus < 2 order by lft""", (company, )) + res["gl"] = webnotes.conn.sql("""select posting_date, account, ifnull(debit, 0), ifnull(credit, 0) + from `tabGL Entry` where company=%s and ifnull(is_cancelled, "No") = "No" + order by posting_date""", (company, )) + return res @webnotes.whitelist() def get_companies(): diff --git a/public/js/all-app.js b/public/js/all-app.js index 50e3ca2a2a..7ab9092a96 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -492,7 +492,7 @@ return val;},full_str:function(){var d=new Date();return d.getFullYear()+'-'+(d. else if(user_fmt=='dd/mm/yyyy'){var d=d.split('/');return d[2]+'-'+d[1]+'-'+d[0];} else if(user_fmt=='yyyy-mm-dd'){return d;} else if(user_fmt=='mm/dd/yyyy'){var d=d.split('/');return d[2]+'-'+d[0]+'-'+d[1];} -else if(user_fmt=='mm-dd-yyyy'){var d=d.split('-');return d[2]+'-'+d[0]+'-'+d[1];}},global_date_format:function(d){if(d.substr)d=this.str_to_obj(d);return nth(d.getDate())+' '+month_list_full[d.getMonth()]+' '+d.getFullYear();},get_today:function(){var today=new Date();var m=(today.getMonth()+1)+'';if(m.length==1)m='0'+m;var d=today.getDate()+'';if(d.length==1)d='0'+d;return today.getFullYear()+'-'+m+'-'+d;},get_cur_time:function(){var d=new Date();var hh=d.getHours()+'' +else if(user_fmt=='mm-dd-yyyy'){var d=d.split('-');return d[2]+'-'+d[0]+'-'+d[1];}},user_to_obj:function(d){return dateutil.str_to_obj(dateutil.user_to_str(d));},global_date_format:function(d){if(d.substr)d=this.str_to_obj(d);return nth(d.getDate())+' '+month_list_full[d.getMonth()]+' '+d.getFullYear();},get_today:function(){var today=new Date();var m=(today.getMonth()+1)+'';if(m.length==1)m='0'+m;var d=today.getDate()+'';if(d.length==1)d='0'+d;return today.getFullYear()+'-'+m+'-'+d;},get_cur_time:function(){var d=new Date();var hh=d.getHours()+'' var mm=cint(d.getMinutes()/5)*5+'' return(hh.length==1?'0'+hh:hh)+':'+(mm.length==1?'0'+mm:mm);}} wn.datetime.only_date=function(val){if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');var d=tmp[0].split('-');}else{var d=val.split('-');} @@ -857,7 +857,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) -this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\ +this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\
\
');}else{$(opts.parent).html('
\ diff --git a/public/js/all-web.js b/public/js/all-web.js index 2454dded70..33c47a2358 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -379,7 +379,7 @@ return val;},full_str:function(){var d=new Date();return d.getFullYear()+'-'+(d. else if(user_fmt=='dd/mm/yyyy'){var d=d.split('/');return d[2]+'-'+d[1]+'-'+d[0];} else if(user_fmt=='yyyy-mm-dd'){return d;} else if(user_fmt=='mm/dd/yyyy'){var d=d.split('/');return d[2]+'-'+d[0]+'-'+d[1];} -else if(user_fmt=='mm-dd-yyyy'){var d=d.split('-');return d[2]+'-'+d[0]+'-'+d[1];}},global_date_format:function(d){if(d.substr)d=this.str_to_obj(d);return nth(d.getDate())+' '+month_list_full[d.getMonth()]+' '+d.getFullYear();},get_today:function(){var today=new Date();var m=(today.getMonth()+1)+'';if(m.length==1)m='0'+m;var d=today.getDate()+'';if(d.length==1)d='0'+d;return today.getFullYear()+'-'+m+'-'+d;},get_cur_time:function(){var d=new Date();var hh=d.getHours()+'' +else if(user_fmt=='mm-dd-yyyy'){var d=d.split('-');return d[2]+'-'+d[0]+'-'+d[1];}},user_to_obj:function(d){return dateutil.str_to_obj(dateutil.user_to_str(d));},global_date_format:function(d){if(d.substr)d=this.str_to_obj(d);return nth(d.getDate())+' '+month_list_full[d.getMonth()]+' '+d.getFullYear();},get_today:function(){var today=new Date();var m=(today.getMonth()+1)+'';if(m.length==1)m='0'+m;var d=today.getDate()+'';if(d.length==1)d='0'+d;return today.getFullYear()+'-'+m+'-'+d;},get_cur_time:function(){var d=new Date();var hh=d.getHours()+'' var mm=cint(d.getMinutes()/5)*5+'' return(hh.length==1?'0'+hh:hh)+':'+(mm.length==1?'0'+mm:mm);}} wn.datetime.only_date=function(val){if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');var d=tmp[0].split('-');}else{var d=val.split('-');} @@ -516,7 +516,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) -this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\ +this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\
\
');}else{$(opts.parent).html('
\ From 588a98a10f89f5d9e37efa3f743a27f585201042 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Sep 2012 19:00:14 +0530 Subject: [PATCH 3/8] fixes to chart_of_accounts, added opening + pl condition --- .../chart_of_accounts/chart_of_accounts.js | 41 ++++++++++++++++--- .../chart_of_accounts/chart_of_accounts.py | 15 +++++-- public/js/all-app.js | 2 +- public/js/all-web.js | 2 +- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js index 43fe56c310..7cf5648b93 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js @@ -41,7 +41,8 @@ wn.pages['chart-of-accounts'].onload = function(wrapper) { page: "chart_of_accounts", method: "get_companies", callback: function(r) { - erpnext.coa.company_select.empty().add_options(r.message).change(); + erpnext.coa.company_select.empty().add_options(r.message.companies).change(); + erpnext.coa.fiscal_years = r.message.fiscal_years; } }); @@ -100,6 +101,7 @@ erpnext.coa = { "credit": 0, "closing": 0, "debit_or_credit": v[2], + "is_pl": v[3] }; data.push(d); @@ -118,18 +120,27 @@ erpnext.coa = { var gl = erpnext.coa.gl; var opening_date = dateutil.user_to_obj(erpnext.coa.opening_date.val()); var closing_date = dateutil.user_to_obj(erpnext.coa.closing_date.val()); + var fiscal_year = erpnext.coa.get_fiscal_year(opening_date, closing_date); + if (!fiscal_year) return; + $.each(erpnext.coa.data, function(i, v) { v.opening = v.debit = v.credit = v.closing = 0; }); + $.each(gl, function(i, v) { var posting_date = dateutil.str_to_obj(v[0]); var account = erpnext.coa.data_by_name[v[1]]; // opening - if (posting_date < opening_date) { - if (account.debit_or_credit === "Debit") { - account.opening += (v[2] - v[3]); + if (posting_date < opening_date || v[4] === "Yes") { + if (account.is_pl === "Yes" && posting_date <= dateutil.str_to_obj(fiscal_year[1])) { + // balance of previous fiscal_year should + // not be part of opening of pl account balance } else { - account.opening += (v[3] - v[2]); + if (account.debit_or_credit === "Debit") { + account.opening += (v[2] - v[3]); + } else { + account.opening += (v[3] - v[2]); + } } } else if (opening_date <= posting_date && posting_date <= closing_date) { // in between @@ -152,6 +163,26 @@ erpnext.coa = { v.closing = fmt_money(v.closing); }); }, + get_fiscal_year: function(opening_date, closing_date) { + if (opening_date > closing_date) { + msgprint("Opening Date should be before Closing Date"); + return; + } + + var fiscal_year = null; + $.each(erpnext.coa.fiscal_years, function(i, v) { + if (opening_date >= dateutil.str_to_obj(v[1]) && + closing_date <= dateutil.str_to_obj(v[2])) { + fiscal_year = v; + } + }); + + if (!fiscal_year) { + msgprint("Opening Date and Closing Date should be within same Fiscal Year"); + return; + } + return fiscal_year; + }, set_indent: function(data, parent_map) { $.each(data, function(i, d) { var indent = 0; diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py index 620368f079..14984fbdb9 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py @@ -4,9 +4,10 @@ import webnotes def get_chart(): company = webnotes.form_dict.get('company') res = {} - res["chart"] = webnotes.conn.sql("""select name, parent_account, debit_or_credit from + res["chart"] = webnotes.conn.sql("""select name, parent_account, debit_or_credit, is_pl_account from tabAccount where company=%s and docstatus < 2 order by lft""", (company, )) - res["gl"] = webnotes.conn.sql("""select posting_date, account, ifnull(debit, 0), ifnull(credit, 0) + res["gl"] = webnotes.conn.sql("""select posting_date, account, ifnull(debit, 0), + ifnull(credit, 0), ifnull(is_opening, 'No') from `tabGL Entry` where company=%s and ifnull(is_cancelled, "No") = "No" order by posting_date""", (company, )) return res @@ -23,8 +24,14 @@ def get_companies(): if r["role"] in webnotes.user.roles and r["match"]=="company")) # if match == company is specified and companies are specified in user defaults + res = {} if match and webnotes.user.get_defaults().get("company"): - return webnotes.user.get_defaults().get("company") + res["companies"] = webnotes.user.get_defaults().get("company") else: - return [r[0] for r in webnotes.conn.sql("""select name from tabCompany + res["companies"] = [r[0] for r in webnotes.conn.sql("""select name from tabCompany where docstatus!=2""")] + res["fiscal_years"] = webnotes.conn.sql("""select name, year_start_date, + adddate(year_start_date, interval 1 year) + from `tabFiscal Year` where docstatus!=2 + order by year_start_date asc""") + return res diff --git a/public/js/all-app.js b/public/js/all-app.js index 7ab9092a96..0ae6190b40 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -856,7 +856,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w
').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();}) if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) + %(icon)s %(label)s',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar&&this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\
\ diff --git a/public/js/all-web.js b/public/js/all-web.js index 33c47a2358..911e6abe17 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -515,7 +515,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w
').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();}) if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) + %(icon)s %(label)s',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar&&this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\
\ From fd1c166f5b32b89737be8f9cdab1dcfce804dfbf Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 13 Sep 2012 10:21:29 +0530 Subject: [PATCH 4/8] late loading js (require) files in localStorage, brought back versions (simpler) --- .../chart_of_accounts/chart_of_accounts.js | 10 + public/css/all-app.css | 211 ++++++++++++++++++ public/js/all-app.js | 17 +- public/js/all-web.js | 17 +- 4 files changed, 231 insertions(+), 24 deletions(-) diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js index 7cf5648b93..74523be5f4 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js @@ -33,6 +33,13 @@ wn.pages['chart-of-accounts'].onload = function(wrapper) { erpnext.coa.closing_date = wrapper.appframe.add_date("Closing Date") .val(dateutil.obj_to_user(new Date())); + erpnext.coa.waiting = $('
\ +

Building Trial Balance Report. \ + Please wait for a few moments

\ +
\ +
') + .appendTo($(wrapper).find('.layout-main')); + $('
\
').appendTo($(wrapper).find('.layout-main')); @@ -41,6 +48,7 @@ wn.pages['chart-of-accounts'].onload = function(wrapper) { page: "chart_of_accounts", method: "get_companies", callback: function(r) { + erpnext.coa.waiting.toggle(); erpnext.coa.company_select.empty().add_options(r.message.companies).change(); erpnext.coa.fiscal_years = r.message.fiscal_years; } @@ -197,6 +205,8 @@ erpnext.coa = { }); }, render: function() { + erpnext.coa.waiting.toggle(false); + // initialize the model erpnext.coa.dataView = new Slick.Data.DataView({ inlineFilters: true }); erpnext.coa.dataView.beginUpdate(); diff --git a/public/css/all-app.css b/public/css/all-app.css index dcc21384f7..ab3ad36582 100644 --- a/public/css/all-app.css +++ b/public/css/all-app.css @@ -1919,6 +1919,217 @@ button.btn.small, input[type="submit"].btn.small { margin-bottom: 0; } +/* + * lib/css/bootstrap/progress.css + */ +@-webkit-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-moz-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-ms-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +@-o-keyframes progress-bar-stripes { + from { + background-position: 0 0; + } + to { + background-position: 40px 0; + } +} + +@keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} + +.progress { + height: 20px; + margin-bottom: 20px; + overflow: hidden; + background-color: #f7f7f7; + background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9)); + background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9); + background-image: linear-gradient(to bottom, #f5f5f5, #f9f9f9); + background-repeat: repeat-x; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0); + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); +} + +.progress .bar { + float: left; + width: 0; + height: 100%; + font-size: 12px; + color: #ffffff; + text-align: center; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #0e90d2; + background-image: -moz-linear-gradient(top, #149bdf, #0480be); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be)); + background-image: -webkit-linear-gradient(top, #149bdf, #0480be); + background-image: -o-linear-gradient(top, #149bdf, #0480be); + background-image: linear-gradient(to bottom, #149bdf, #0480be); + background-repeat: repeat-x; + filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0); + -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-transition: width 0.6s ease; + -moz-transition: width 0.6s ease; + -o-transition: width 0.6s ease; + transition: width 0.6s ease; +} + +.progress .bar + .bar { + -webkit-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -moz-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); + box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15); +} + +.progress-striped .bar { + background-color: #149bdf; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + -webkit-background-size: 40px 40px; + -moz-background-size: 40px 40px; + -o-background-size: 40px 40px; + background-size: 40px 40px; +} + +.progress.active .bar { + -webkit-animation: progress-bar-stripes 2s linear infinite; + -moz-animation: progress-bar-stripes 2s linear infinite; + -ms-animation: progress-bar-stripes 2s linear infinite; + -o-animation: progress-bar-stripes 2s linear infinite; + animation: progress-bar-stripes 2s linear infinite; +} + +.progress-danger .bar, +.progress .bar-danger { + background-color: #dd514c; + background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35)); + background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35); + background-image: -o-linear-gradient(top, #ee5f5b, #c43c35); + background-image: linear-gradient(to bottom, #ee5f5b, #c43c35); + background-repeat: repeat-x; + filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffc43c35', GradientType=0); +} + +.progress-danger.progress-striped .bar, +.progress-striped .bar-danger { + background-color: #ee5f5b; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-success .bar, +.progress .bar-success { + background-color: #5eb95e; + background-image: -moz-linear-gradient(top, #62c462, #57a957); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957)); + background-image: -webkit-linear-gradient(top, #62c462, #57a957); + background-image: -o-linear-gradient(top, #62c462, #57a957); + background-image: linear-gradient(to bottom, #62c462, #57a957); + background-repeat: repeat-x; + filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff57a957', GradientType=0); +} + +.progress-success.progress-striped .bar, +.progress-striped .bar-success { + background-color: #62c462; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-info .bar, +.progress .bar-info { + background-color: #4bb1cf; + background-image: -moz-linear-gradient(top, #5bc0de, #339bb9); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9)); + background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9); + background-image: -o-linear-gradient(top, #5bc0de, #339bb9); + background-image: linear-gradient(to bottom, #5bc0de, #339bb9); + background-repeat: repeat-x; + filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff339bb9', GradientType=0); +} + +.progress-info.progress-striped .bar, +.progress-striped .bar-info { + background-color: #5bc0de; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + +.progress-warning .bar, +.progress .bar-warning { + background-color: #faa732; + background-image: -moz-linear-gradient(top, #fbb450, #f89406); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406)); + background-image: -webkit-linear-gradient(top, #fbb450, #f89406); + background-image: -o-linear-gradient(top, #fbb450, #f89406); + background-image: linear-gradient(to bottom, #fbb450, #f89406); + background-repeat: repeat-x; + filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0); +} + +.progress-warning.progress-striped .bar, +.progress-striped .bar-warning { + background-color: #fbb450; + background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} + /* * lib/css/legacy/body.css */ diff --git a/public/js/all-app.js b/public/js/all-app.js index 0ae6190b40..f52272c8ef 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -134,22 +134,15 @@ if(!window.wn)wn={} wn.provide=function(namespace){var nsl=namespace.split('.');var l=nsl.length;var parent=window;for(var i=0;i Date: Thu, 13 Sep 2012 11:59:32 +0530 Subject: [PATCH 5/8] updates to gzip, chart of accounts --- .../chart_of_accounts/chart_of_accounts.js | 318 +++++++++++------- .../chart_of_accounts/chart_of_accounts.py | 15 +- 2 files changed, 203 insertions(+), 130 deletions(-) diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js index 74523be5f4..7ab1e5705c 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js @@ -27,43 +27,65 @@ wn.pages['chart-of-accounts'].onload = function(wrapper) { title: 'Chart of Accounts', single_column: true }); - erpnext.coa.company_select = wrapper.appframe.add_select("Company", ["Loading..."]); - erpnext.coa.opening_date = wrapper.appframe.add_date("Opening Date") - .val(dateutil.str_to_user(sys_defaults.year_start_date)); - erpnext.coa.closing_date = wrapper.appframe.add_date("Closing Date") - .val(dateutil.obj_to_user(new Date())); - erpnext.coa.waiting = $('
\ -

Building Trial Balance Report. \ - Please wait for a few moments

\ -
\ -
') - .appendTo($(wrapper).find('.layout-main')); - - $('
\ -
').appendTo($(wrapper).find('.layout-main')); - - wn.call({ - module: "accounts", - page: "chart_of_accounts", - method: "get_companies", - callback: function(r) { - erpnext.coa.waiting.toggle(); - erpnext.coa.company_select.empty().add_options(r.message.companies).change(); - erpnext.coa.fiscal_years = r.message.fiscal_years; - } - }); - - erpnext.coa.company_select.change(function() { - erpnext.coa.load_slickgrid(); - erpnext.coa.load_data($(this).val()); - }); - - erpnext.coa.opening_date.change(erpnext.coa.refresh); - erpnext.coa.closing_date.change(erpnext.coa.refresh); + erpnext.coa.make_page(wrapper); + erpnext.coa.load_companies(); } - erpnext.coa = { + make_page: function(wrapper) { + erpnext.coa.company_select = wrapper.appframe + .add_select("Company", ["Loading..."]) + .change(function() { + erpnext.coa.chart = new erpnext.ChartOfAccounts(); + }); + + erpnext.coa.opening_date = wrapper.appframe.add_date("Opening Date") + .val(dateutil.str_to_user(sys_defaults.year_start_date)); + + var end_date = new Date(); + if(end_date > dateutil.str_to_obj(sys_defaults.year_end_date)) + end_date = sys_defaults.year_end_date; + + erpnext.coa.closing_date = wrapper.appframe.add_date("Closing Date") + .val(dateutil.obj_to_user(end_date)); + + erpnext.coa.refresh_btn = wrapper.appframe.add_button("Refresh", function() { + erpnext.coa.chart = new erpnext.ChartOfAccounts(); + }, "icon-refresh"); + + + + erpnext.coa.waiting = $('
\ +

Building Trial Balance Report. \ + Please wait for a few moments

\ +
\ +
') + .appendTo($(wrapper).find('.layout-main')); + + $('
\ +
').appendTo($(wrapper).find('.layout-main')); + + }, + load_companies: function() { + wn.call({ + module: "accounts", + page: "chart_of_accounts", + method: "get_companies", + callback: function(r) { + erpnext.coa.waiting.toggle(); + erpnext.coa.company_select.empty().add_options(r.message.companies) + .val(sys_defaults.company || r.message.companies[0]).change(); + erpnext.coa.fiscal_years = r.message.fiscal_years; + } + }); + } +}; + +erpnext.ChartOfAccounts = Class.extend({ + init: function() { + this.load_slickgrid(); + this.load_data($(erpnext.coa.company_select).val()); + }, load_slickgrid: function() { // load tree wn.require('js/lib/jquery/jquery.ui.sortable'); @@ -77,20 +99,20 @@ erpnext.coa = { wn.dom.set_style('.slick-cell { font-size: 12px; }'); }, refresh: function() { - erpnext.coa.prepare_balances(); - erpnext.coa.render(); + this.prepare_balances(); + this.render(); }, load_data: function(company) { + var me = this; wn.call({ module: "accounts", page: "chart_of_accounts", method: "get_chart", args: {company: company}, callback: function(r) { - erpnext.coa.gl = r.message.gl; - erpnext.coa.prepare_chart(r.message.chart); - erpnext.coa.prepare_balances(); - erpnext.coa.render(); + me.gl = r.message.gl; + me.prepare_chart(r.message.chart); + me.refresh(); } }) }, @@ -104,92 +126,125 @@ erpnext.coa = { "id": v[0], "name": v[0], "parent": v[1], - "opening": 0, + "debit_or_credit": v[2], + "opening_debit": 0, + "opening_credit": 0, "debit": 0, "credit": 0, - "closing": 0, - "debit_or_credit": v[2], + "closing_debit": 0, + "closing_credit": 0, "is_pl": v[3] }; - + data.push(d); data_by_name[d.name] = d; if(d.parent) { parent_map[d.name] = d.parent; - } + } } }); - erpnext.coa.set_indent(data, parent_map); - erpnext.coa.data = data; - erpnext.coa.parent_map = parent_map; - erpnext.coa.data_by_name = data_by_name; + this.set_indent(data, parent_map); + this.data = data; + this.parent_map = parent_map; + this.data_by_name = data_by_name; }, prepare_balances: function() { - var gl = erpnext.coa.gl; - var opening_date = dateutil.user_to_obj(erpnext.coa.opening_date.val()); - var closing_date = dateutil.user_to_obj(erpnext.coa.closing_date.val()); - var fiscal_year = erpnext.coa.get_fiscal_year(opening_date, closing_date); - if (!fiscal_year) return; + var gl = this.gl; + var me = this; - $.each(erpnext.coa.data, function(i, v) { - v.opening = v.debit = v.credit = v.closing = 0; + this.opening_date = dateutil.user_to_obj(erpnext.coa.opening_date.val()); + this.closing_date = dateutil.user_to_obj(erpnext.coa.closing_date.val()); + this.set_fiscal_year(); + if (!this.fiscal_year) return; + + $.each(this.data, function(i, v) { + v.opening_debit = v.opening_credit = v.debit + = v.credit = v.closing_debit = v.closing_credit = 0; }); $.each(gl, function(i, v) { + v[1] = me.data[v[1]].name; var posting_date = dateutil.str_to_obj(v[0]); - var account = erpnext.coa.data_by_name[v[1]]; - // opening - if (posting_date < opening_date || v[4] === "Yes") { - if (account.is_pl === "Yes" && posting_date <= dateutil.str_to_obj(fiscal_year[1])) { - // balance of previous fiscal_year should - // not be part of opening of pl account balance - } else { - if (account.debit_or_credit === "Debit") { - account.opening += (v[2] - v[3]); - } else { - account.opening += (v[3] - v[2]); - } - } - } else if (opening_date <= posting_date && posting_date <= closing_date) { - // in between - account.debit += v[2]; - account.credit += v[3]; - } - // closing - if (account.debit_or_credit === "Debit") { - account.closing = account.opening + account.debit - account.credit; - } else { - account.closing = account.opening + account.credit - account.debit; - } + var account = me.data_by_name[v[1]]; + me.update_balances(account, posting_date, v) }); + this.update_groups(); + this.format_balances(); + }, + update_balances: function(account, posting_date, v) { + // opening + if (posting_date < this.opening_date || v[4] === "Y") { + if (account.is_pl === "Yes" && posting_date <= dateutil.str_to_obj(this.fiscal_year[1])) { + // balance of previous fiscal_year should + // not be part of opening of pl account balance + } else { + if(account.debit_or_credit=='D') { + account.opening_debit += (v[2] - v[3]); + } else { + account.opening_credit += (v[3] - v[2]); + } + } + } else if (this.opening_date <= posting_date && posting_date <= this.closing_date) { + // in between + account.debit += v[2]; + account.credit += v[3]; + } + // closing + if(account.debit_or_credit=='D') { + account.closing_debit = account.opening_debit + account.debit - account.credit; + } else { + account.closing_credit = account.opening_credit - account.debit + account.credit; + } + }, + update_groups: function() { + // update groups + var me= this; + $.each(this.data, function(i, account) { + // update groups + var parent = me.parent_map[account.name]; + while(parent) { + parent_account = me.data_by_name[parent]; + parent_account.opening_debit += account.opening_debit; + parent_account.opening_credit += account.opening_credit; + parent_account.debit += account.debit; + parent_account.credit += account.credit; + parent_account.closing_debit += account.closing_debit; + parent_account.closing_credit += account.closing_credit; + parent = me.parent_map[parent]; + } + }); + }, + format_balances: function() { // format amount - $.each(erpnext.coa.data, function(i, v) { - v.opening = fmt_money(v.opening); + $.each(this.data, function(i, v) { + v.opening_debit = fmt_money(v.opening_debit); + v.opening_credit = fmt_money(v.opening_credit); v.debit = fmt_money(v.debit); v.credit = fmt_money(v.credit); - v.closing = fmt_money(v.closing); - }); + v.closing_debit = fmt_money(v.closing_debit); + v.closing_credit = fmt_money(v.closing_credit); + }); }, - get_fiscal_year: function(opening_date, closing_date) { - if (opening_date > closing_date) { + set_fiscal_year: function() { + if (this.opening_date > this.closing_date) { msgprint("Opening Date should be before Closing Date"); return; } - - var fiscal_year = null; + + this.fiscal_year = null; + var me = this; $.each(erpnext.coa.fiscal_years, function(i, v) { - if (opening_date >= dateutil.str_to_obj(v[1]) && - closing_date <= dateutil.str_to_obj(v[2])) { - fiscal_year = v; + if (me.opening_date >= dateutil.str_to_obj(v[1]) && + me.closing_date <= dateutil.str_to_obj(v[2])) { + me.fiscal_year = v; } }); - if (!fiscal_year) { + if (!this.fiscal_year) { msgprint("Opening Date and Closing Date should be within same Fiscal Year"); return; } - return fiscal_year; }, set_indent: function(data, parent_map) { $.each(data, function(i, d) { @@ -205,22 +260,19 @@ erpnext.coa = { }); }, render: function() { + var me = this; erpnext.coa.waiting.toggle(false); - - // initialize the model - erpnext.coa.dataView = new Slick.Data.DataView({ inlineFilters: true }); - erpnext.coa.dataView.beginUpdate(); - erpnext.coa.dataView.setItems(erpnext.coa.data); - erpnext.coa.dataView.setFilter(erpnext.coa.filter) - erpnext.coa.dataView.endUpdate(); + this.setup_dataview(); var columns = [ - {id: "name", name: "Account", field: "name", width: 400, cssClass: "cell-title", - formatter: erpnext.coa.account_formatter}, - {id: "opening", name: "Opening", field: "opening"}, - {id: "debit", name: "Debit", field: "debit"}, - {id: "credit", name: "Credit", field: "credit"}, - {id: "closing", name: "Closing", field: "closing"} + {id: "name", name: "Account", field: "name", width: 300, cssClass: "cell-title", + formatter: this.account_formatter}, + {id: "opening_debit", name: "Opening (Dr)", field: "opening_debit", width: 100}, + {id: "opening_credit", name: "Opening (Cr)", field: "opening_credit", width: 100}, + {id: "debit", name: "Debit", field: "debit", width: 100}, + {id: "credit", name: "Credit", field: "credit", width: 100}, + {id: "closing_debit", name: "Closing (Dr)", field: "closing_debit", width: 100}, + {id: "closing_credit", name: "Closing (Cr)", field: "closing_credit", width: 100} ]; var options = { @@ -229,14 +281,36 @@ erpnext.coa = { }; // initialize the grid - var grid = new Slick.Grid("#chart-of-accounts", erpnext.coa.dataView, columns, options); - erpnext.coa.add_events(grid); - erpnext.coa.grid = grid; + var grid = new Slick.Grid("#chart-of-accounts", this.dataView, columns, options); + this.add_events(grid); + this.grid = grid; + }, + setup_dataview: function() { + var me = this; + // initialize the model + this.dataView = new Slick.Data.DataView({ inlineFilters: true }); + this.dataView.beginUpdate(); + this.dataView.setItems(this.data); + this.dataView.setFilter(this.dataview_filter); + this.dataView.endUpdate(); + }, + dataview_filter: function(item) { + if (item.parent) { + var parent = item.parent; + while (parent) { + if (erpnext.coa.chart.data_by_name[parent]._collapsed) { + return false; + } + parent = erpnext.coa.chart.parent_map[parent]; + } + } + return true; }, add_events: function(grid) { + var me = this; grid.onClick.subscribe(function (e, args) { if ($(e.target).hasClass("toggle")) { - var item = erpnext.coa.dataView.getItem(args.row); + var item = me.dataView.getItem(args.row); if (item) { if (!item._collapsed) { item._collapsed = true; @@ -244,41 +318,29 @@ erpnext.coa = { item._collapsed = false; } - erpnext.coa.dataView.updateItem(item.id, item); + me.dataView.updateItem(item.id, item); } e.stopImmediatePropagation(); } }); - erpnext.coa.dataView.onRowsChanged.subscribe(function (e, args) { + this.dataView.onRowsChanged.subscribe(function (e, args) { grid.invalidateRows(args.rows); grid.render(); }); - erpnext.coa.dataView.onRowCountChanged.subscribe(function (e, args) { + this.dataView.onRowCountChanged.subscribe(function (e, args) { grid.updateRowCount(); grid.render(); }); }, - filter: function(item) { - if (item.parent) { - var parent = item.parent; - while (parent) { - if (erpnext.coa.data_by_name[parent]._collapsed) { - return false; - } - parent = erpnext.coa.parent_map[parent]; - } - } - return true; - }, account_formatter: function (row, cell, value, columnDef, dataContext) { value = value.replace(/&/g,"&").replace(//g,">"); - var data = erpnext.coa.data; + var data = erpnext.coa.chart.data; var spacer = ""; - var idx = erpnext.coa.dataView.getIdxById(dataContext.id); + var idx = erpnext.coa.chart.dataView.getIdxById(dataContext.id); if (data[idx + 1] && data[idx + 1].indent > data[idx].indent) { if (dataContext._collapsed) { return spacer + "  " + value; @@ -289,4 +351,4 @@ erpnext.coa = { return spacer + "  " + value; } } -} +}); diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py index 14984fbdb9..9979163860 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py @@ -4,12 +4,23 @@ import webnotes def get_chart(): company = webnotes.form_dict.get('company') res = {} - res["chart"] = webnotes.conn.sql("""select name, parent_account, debit_or_credit, is_pl_account from + res["chart"] = webnotes.conn.sql("""select name, parent_account, + if(debit_or_credit="Debit", "D", ""), + if(is_pl_account="Yes", "Y", "") from tabAccount where company=%s and docstatus < 2 order by lft""", (company, )) + res["gl"] = webnotes.conn.sql("""select posting_date, account, ifnull(debit, 0), ifnull(credit, 0), ifnull(is_opening, 'No') from `tabGL Entry` where company=%s and ifnull(is_cancelled, "No") = "No" - order by posting_date""", (company, )) + order by posting_date""", (company, ), as_list=1) + + idx_map = {} + for i in xrange(len(res["chart"])): + idx_map[res["chart"][i][0]] = i + + for d in res["gl"]: + d[1] = idx_map[d[1]] + return res @webnotes.whitelist() From 99e5ac34528663e1dcca7aea534a4a9f03f9aa1d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 13 Sep 2012 15:24:19 +0530 Subject: [PATCH 6/8] multi sort for stock ledger search criteria --- .../august_2012/reload_stock_ledger.py | 4 --- erpnext/patches/patch_list.py | 8 +++--- .../reload_criteria_stock_ledger.py | 7 +++++ .../Report/Stock Ledger/Stock Ledger.txt | 26 ------------------- .../stock_ledger/stock_ledger.txt | 6 ++--- public/js/all-app.js | 2 +- public/js/all-web.js | 2 +- public/js/report-legacy.js | 6 ++--- 8 files changed, 19 insertions(+), 42 deletions(-) delete mode 100644 erpnext/patches/august_2012/reload_stock_ledger.py create mode 100644 erpnext/patches/september_2012/reload_criteria_stock_ledger.py delete mode 100644 erpnext/stock/Report/Stock Ledger/Stock Ledger.txt diff --git a/erpnext/patches/august_2012/reload_stock_ledger.py b/erpnext/patches/august_2012/reload_stock_ledger.py deleted file mode 100644 index d0ec9ee889..0000000000 --- a/erpnext/patches/august_2012/reload_stock_ledger.py +++ /dev/null @@ -1,4 +0,0 @@ -def execute(): - import webnotes - from webnotes.modules import reload_doc - reload_doc('stock', 'Report', 'Stock Ledger') \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index e4eff963ef..3acd97d1f4 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -533,10 +533,6 @@ patch_list = [ 'patch_module': 'patches.august_2012', 'patch_file': 'remove_cash_flow_statement', }, - { - 'patch_module': 'patches.august_2012', - 'patch_file': 'reload_stock_ledger', - }, { 'patch_module': 'patches.september_2012', 'patch_file': 'stock_report_permissions_for_accounts', @@ -545,4 +541,8 @@ patch_list = [ 'patch_module': 'patches.september_2012', 'patch_file': 'communication_delete_permission', }, + { + 'patch_module': 'patches.september_2012', + 'patch_file': 'reload_criteria_stock_ledger', + }, ] diff --git a/erpnext/patches/september_2012/reload_criteria_stock_ledger.py b/erpnext/patches/september_2012/reload_criteria_stock_ledger.py new file mode 100644 index 0000000000..4e2e71af33 --- /dev/null +++ b/erpnext/patches/september_2012/reload_criteria_stock_ledger.py @@ -0,0 +1,7 @@ +def execute(): + import webnotes + from webnotes.modules import reload_doc + reload_doc('stock', 'Search Criteria', 'Stock Ledger') + + from webnotes.model import delete_doc + delete_doc("Report", "Stock Ledger") \ No newline at end of file diff --git a/erpnext/stock/Report/Stock Ledger/Stock Ledger.txt b/erpnext/stock/Report/Stock Ledger/Stock Ledger.txt deleted file mode 100644 index d0c5184bba..0000000000 --- a/erpnext/stock/Report/Stock Ledger/Stock Ledger.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Report, Stock Ledger -[ - - # These values are common in all dictionaries - { - 'creation': '2012-09-06 18:47:05', - 'docstatus': 0, - 'modified': '2012-09-06 18:48:22', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all Report - { - 'doctype': 'Report', - 'json': u'{"filters":[["Stock Ledger Entry","is_cancelled","=","No"]],"columns":[["item_code","Stock Ledger Entry"],["warehouse","Stock Ledger Entry"],["posting_date","Stock Ledger Entry"],["posting_time","Stock Ledger Entry"],["actual_qty","Stock Ledger Entry"],["bin_aqat","Stock Ledger Entry"],["voucher_type","Stock Ledger Entry"],["voucher_no","Stock Ledger Entry"]],"sort_by":"Stock Ledger Entry.posting_date","sort_order":"desc","sort_by_next":"Stock Ledger Entry.posting_time","sort_order_next":"desc"}', - 'name': '__common__', - 'ref_doctype': u'Stock Ledger Entry' - }, - - # Report, Stock Ledger - { - 'doctype': 'Report', - 'name': u'Stock Ledger' - } -] \ No newline at end of file diff --git a/erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt b/erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt index cee810b4f6..5f9cb8cead 100644 --- a/erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt +++ b/erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-16 11:42:44', + 'creation': '2012-09-13 15:18:44', 'docstatus': 0, - 'modified': '2012-04-16 16:00:35', + 'modified': '2012-09-13 15:19:44', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -23,7 +23,7 @@ 'module': u'Stock', 'name': '__common__', 'page_len': 50, - 'sort_by': u'`tabStock Ledger Entry`.`item_code`', + 'sort_by': u'`tabStock Ledger Entry`.`posting_date` DESC, `tabStock Ledger Entry`.`posting_time` DESC, `tabStock Ledger Entry`.`name` DESC', 'sort_order': u'DESC', 'standard': u'Yes' }, diff --git a/public/js/all-app.js b/public/js/all-app.js index f52272c8ef..18eeac0518 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -400,7 +400,7 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f * lib/js/core.js */ if(!console){var console={log:function(txt){}}} -window._version_number="031a31bad930de7f9e8157242afbcba4729d91ff9f957c0c897cafd6";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); +window._version_number="1e94c62f61174cfb7f98c2bdd377674ef06b81eff2e4d1c2dff88107";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); /* * lib/js/legacy/globals.js diff --git a/public/js/all-web.js b/public/js/all-web.js index 2c0b0aeae0..b2ba636fd2 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -287,7 +287,7 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f * lib/js/core.js */ if(!console){var console={log:function(txt){}}} -window._version_number="031a31bad930de7f9e8157242afbcba4729d91ff9f957c0c897cafd6";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); +window._version_number="1e94c62f61174cfb7f98c2bdd377674ef06b81eff2e4d1c2dff88107";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); /* * lib/js/legacy/globals.js diff --git a/public/js/report-legacy.js b/public/js/report-legacy.js index 5a3b93fa3d..925386e539 100644 --- a/public/js/report-legacy.js +++ b/public/js/report-legacy.js @@ -171,10 +171,10 @@ _r.DataTable.prototype.set_asc=function(icon){this.sort_icon.src='images/lib/ico _r.DataTable.prototype.set_sort_option_disabled=function(label,disabled){var s=this.sort_sel;if(disabled){for(var i=0;i Date: Thu, 13 Sep 2012 15:39:34 +0530 Subject: [PATCH 7/8] allow multisort with selectable sort order --- erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt | 6 +++--- public/js/all-app.js | 2 +- public/js/all-web.js | 2 +- public/js/report-legacy.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt b/erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt index 5f9cb8cead..b80578ef0c 100644 --- a/erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt +++ b/erpnext/stock/search_criteria/stock_ledger/stock_ledger.txt @@ -5,7 +5,7 @@ { 'creation': '2012-09-13 15:18:44', 'docstatus': 0, - 'modified': '2012-09-13 15:19:44', + 'modified': '2012-09-13 15:38:45', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -23,8 +23,8 @@ 'module': u'Stock', 'name': '__common__', 'page_len': 50, - 'sort_by': u'`tabStock Ledger Entry`.`posting_date` DESC, `tabStock Ledger Entry`.`posting_time` DESC, `tabStock Ledger Entry`.`name` DESC', - 'sort_order': u'DESC', + 'sort_by': u'`tabStock Ledger Entry`.`posting_date`, `tabStock Ledger Entry`.`posting_time`, `tabStock Ledger Entry`.`name`', + 'sort_order': u'ASC', 'standard': u'Yes' }, diff --git a/public/js/all-app.js b/public/js/all-app.js index 18eeac0518..c8548a72ac 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -400,7 +400,7 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f * lib/js/core.js */ if(!console){var console={log:function(txt){}}} -window._version_number="1e94c62f61174cfb7f98c2bdd377674ef06b81eff2e4d1c2dff88107";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); +window._version_number="6123c7881505af8bdcadcac363d143df24a587186c90a50f40a97664";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); /* * lib/js/legacy/globals.js diff --git a/public/js/all-web.js b/public/js/all-web.js index b2ba636fd2..fa7fd11a7b 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -287,7 +287,7 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f * lib/js/core.js */ if(!console){var console={log:function(txt){}}} -window._version_number="1e94c62f61174cfb7f98c2bdd377674ef06b81eff2e4d1c2dff88107";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); +window._version_number="6123c7881505af8bdcadcac363d143df24a587186c90a50f40a97664";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); /* * lib/js/legacy/globals.js diff --git a/public/js/report-legacy.js b/public/js/report-legacy.js index 925386e539..acf91bcfb2 100644 --- a/public/js/report-legacy.js +++ b/public/js/report-legacy.js @@ -171,7 +171,7 @@ _r.DataTable.prototype.set_asc=function(icon){this.sort_icon.src='images/lib/ico _r.DataTable.prototype.set_sort_option_disabled=function(label,disabled){var s=this.sort_sel;if(disabled){for(var i=0;i Date: Thu, 13 Sep 2012 19:40:56 +0530 Subject: [PATCH 8/8] created grid report, report dump and general ledger report --- .../chart_of_accounts/chart_of_accounts.js | 97 +++++++++++-------- .../chart_of_accounts/chart_of_accounts.py | 1 + .../accounts/page/general_ledger/__init__.py | 0 .../page/general_ledger/general_ledger.css | 0 .../page/general_ledger/general_ledger.html | 0 .../page/general_ledger/general_ledger.js | 65 +++++++++++++ .../page/general_ledger/general_ledger.py | 10 ++ .../page/general_ledger/general_ledger.txt | 28 ++++++ erpnext/startup/report_data_map.py | 37 +++++++ erpnext/startup/startup.py | 17 +++- public/css/all-app.css | 2 +- public/css/all-web.css | 2 +- public/js/all-app.js | 16 ++- public/js/all-web.js | 6 +- 14 files changed, 231 insertions(+), 50 deletions(-) create mode 100644 erpnext/accounts/page/general_ledger/__init__.py create mode 100644 erpnext/accounts/page/general_ledger/general_ledger.css create mode 100644 erpnext/accounts/page/general_ledger/general_ledger.html create mode 100644 erpnext/accounts/page/general_ledger/general_ledger.js create mode 100644 erpnext/accounts/page/general_ledger/general_ledger.py create mode 100644 erpnext/accounts/page/general_ledger/general_ledger.txt create mode 100644 erpnext/startup/report_data_map.py diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js index 7ab1e5705c..0e8e298f4c 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js @@ -38,6 +38,18 @@ erpnext.coa = { .change(function() { erpnext.coa.chart = new erpnext.ChartOfAccounts(); }); + + erpnext.coa.fiscal_year_select = wrapper.appframe + .add_select("Fiscal Year", ["Loading..."]).css("width", "100px") + .change(function() { + var selected_year = $(this).val(); + var fiscal_year = $.map(erpnext.coa.fiscal_years, function(v) { + return v[0] === selected_year ? v : null; + }); + erpnext.coa.opening_date.val(dateutil.str_to_user(fiscal_year[1])); + erpnext.coa.closing_date.val(dateutil.str_to_user(fiscal_year[2])); + erpnext.coa.refresh_btn.click(); + }) erpnext.coa.opening_date = wrapper.appframe.add_date("Opening Date") .val(dateutil.str_to_user(sys_defaults.year_start_date)); @@ -50,7 +62,7 @@ erpnext.coa = { .val(dateutil.obj_to_user(end_date)); erpnext.coa.refresh_btn = wrapper.appframe.add_button("Refresh", function() { - erpnext.coa.chart = new erpnext.ChartOfAccounts(); + erpnext.coa.chart.refresh(); }, "icon-refresh"); @@ -75,6 +87,9 @@ erpnext.coa = { erpnext.coa.waiting.toggle(); erpnext.coa.company_select.empty().add_options(r.message.companies) .val(sys_defaults.company || r.message.companies[0]).change(); + erpnext.coa.fiscal_year_select.empty() + .add_options($.map(r.message.fiscal_years, function(v) { return v[0]; })) + .val(sys_defaults.fiscal_year); erpnext.coa.fiscal_years = r.message.fiscal_years; } }); @@ -88,20 +103,44 @@ erpnext.ChartOfAccounts = Class.extend({ }, load_slickgrid: function() { // load tree - wn.require('js/lib/jquery/jquery.ui.sortable'); wn.require('js/lib/slickgrid/slick.grid.css'); wn.require('js/lib/slickgrid/slick-default-theme.css'); wn.require('js/lib/slickgrid/jquery.event.drag.min.js'); wn.require('js/lib/slickgrid/slick.core.js'); - wn.require('js/lib/slickgrid/slick.formatters.js'); wn.require('js/lib/slickgrid/slick.grid.js'); wn.require('js/lib/slickgrid/slick.dataview.js'); - wn.dom.set_style('.slick-cell { font-size: 12px; }'); + wn.dom.set_style('.slick-cell { font-size: 12px; }'); }, refresh: function() { this.prepare_balances(); this.render(); }, + render: function() { + var me = this; + erpnext.coa.waiting.toggle(false); + this.setup_dataview(); + + var columns = [ + {id: "name", name: "Account", field: "name", width: 300, cssClass: "cell-title", + formatter: this.account_formatter}, + {id: "opening_debit", name: "Opening (Dr)", field: "opening_debit", width: 100}, + {id: "opening_credit", name: "Opening (Cr)", field: "opening_credit", width: 100}, + {id: "debit", name: "Debit", field: "debit", width: 100}, + {id: "credit", name: "Credit", field: "credit", width: 100}, + {id: "closing_debit", name: "Closing (Dr)", field: "closing_debit", width: 100}, + {id: "closing_credit", name: "Closing (Cr)", field: "closing_credit", width: 100} + ]; + + var options = { + editable: false, + enableColumnReorder: false + }; + + // initialize the grid + var grid = new Slick.Grid("#chart-of-accounts", this.dataView, columns, options); + this.add_events(grid); + this.grid = grid; + }, load_data: function(company) { var me = this; wn.call({ @@ -112,6 +151,9 @@ erpnext.ChartOfAccounts = Class.extend({ callback: function(r) { me.gl = r.message.gl; me.prepare_chart(r.message.chart); + $.each(me.gl, function(i, v) { + v[1] = me.accounts[v[1]].name; + }); me.refresh(); } }) @@ -144,9 +186,9 @@ erpnext.ChartOfAccounts = Class.extend({ } }); this.set_indent(data, parent_map); - this.data = data; + this.accounts = data; this.parent_map = parent_map; - this.data_by_name = data_by_name; + this.accounts_by_name = data_by_name; }, prepare_balances: function() { var gl = this.gl; @@ -157,15 +199,14 @@ erpnext.ChartOfAccounts = Class.extend({ this.set_fiscal_year(); if (!this.fiscal_year) return; - $.each(this.data, function(i, v) { + $.each(this.accounts, function(i, v) { v.opening_debit = v.opening_credit = v.debit = v.credit = v.closing_debit = v.closing_credit = 0; }); $.each(gl, function(i, v) { - v[1] = me.data[v[1]].name; var posting_date = dateutil.str_to_obj(v[0]); - var account = me.data_by_name[v[1]]; + var account = me.accounts_by_name[v[1]]; me.update_balances(account, posting_date, v) }); @@ -200,11 +241,11 @@ erpnext.ChartOfAccounts = Class.extend({ update_groups: function() { // update groups var me= this; - $.each(this.data, function(i, account) { + $.each(this.accounts, function(i, account) { // update groups var parent = me.parent_map[account.name]; while(parent) { - parent_account = me.data_by_name[parent]; + parent_account = me.accounts_by_name[parent]; parent_account.opening_debit += account.opening_debit; parent_account.opening_credit += account.opening_credit; parent_account.debit += account.debit; @@ -217,7 +258,7 @@ erpnext.ChartOfAccounts = Class.extend({ }, format_balances: function() { // format amount - $.each(this.data, function(i, v) { + $.each(this.accounts, function(i, v) { v.opening_debit = fmt_money(v.opening_debit); v.opening_credit = fmt_money(v.opening_credit); v.debit = fmt_money(v.debit); @@ -259,38 +300,12 @@ erpnext.ChartOfAccounts = Class.extend({ d.indent = indent; }); }, - render: function() { - var me = this; - erpnext.coa.waiting.toggle(false); - this.setup_dataview(); - - var columns = [ - {id: "name", name: "Account", field: "name", width: 300, cssClass: "cell-title", - formatter: this.account_formatter}, - {id: "opening_debit", name: "Opening (Dr)", field: "opening_debit", width: 100}, - {id: "opening_credit", name: "Opening (Cr)", field: "opening_credit", width: 100}, - {id: "debit", name: "Debit", field: "debit", width: 100}, - {id: "credit", name: "Credit", field: "credit", width: 100}, - {id: "closing_debit", name: "Closing (Dr)", field: "closing_debit", width: 100}, - {id: "closing_credit", name: "Closing (Cr)", field: "closing_credit", width: 100} - ]; - - var options = { - editable: false, - enableColumnReorder: false - }; - - // initialize the grid - var grid = new Slick.Grid("#chart-of-accounts", this.dataView, columns, options); - this.add_events(grid); - this.grid = grid; - }, setup_dataview: function() { var me = this; // initialize the model this.dataView = new Slick.Data.DataView({ inlineFilters: true }); this.dataView.beginUpdate(); - this.dataView.setItems(this.data); + this.dataView.setItems(this.accounts); this.dataView.setFilter(this.dataview_filter); this.dataView.endUpdate(); }, @@ -298,7 +313,7 @@ erpnext.ChartOfAccounts = Class.extend({ if (item.parent) { var parent = item.parent; while (parent) { - if (erpnext.coa.chart.data_by_name[parent]._collapsed) { + if (erpnext.coa.chart.accounts_by_name[parent]._collapsed) { return false; } parent = erpnext.coa.chart.parent_map[parent]; @@ -337,7 +352,7 @@ erpnext.ChartOfAccounts = Class.extend({ }, account_formatter: function (row, cell, value, columnDef, dataContext) { value = value.replace(/&/g,"&").replace(//g,">"); - var data = erpnext.coa.chart.data; + var data = erpnext.coa.chart.accounts; var spacer = ""; var idx = erpnext.coa.chart.dataView.getIdxById(dataContext.id); diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py index 9979163860..59cd460e71 100644 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py @@ -41,6 +41,7 @@ def get_companies(): else: res["companies"] = [r[0] for r in webnotes.conn.sql("""select name from tabCompany where docstatus!=2""")] + res["fiscal_years"] = webnotes.conn.sql("""select name, year_start_date, adddate(year_start_date, interval 1 year) from `tabFiscal Year` where docstatus!=2 diff --git a/erpnext/accounts/page/general_ledger/__init__.py b/erpnext/accounts/page/general_ledger/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/page/general_ledger/general_ledger.css b/erpnext/accounts/page/general_ledger/general_ledger.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/page/general_ledger/general_ledger.html b/erpnext/accounts/page/general_ledger/general_ledger.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/page/general_ledger/general_ledger.js b/erpnext/accounts/page/general_ledger/general_ledger.js new file mode 100644 index 0000000000..d395612816 --- /dev/null +++ b/erpnext/accounts/page/general_ledger/general_ledger.js @@ -0,0 +1,65 @@ +wn.pages['general-ledger'].onload = function(wrapper) { + wn.ui.make_app_page({ + parent: wrapper, + title: 'General Ledger', + single_column: true + }); + + erpnext.general_ledger = new wn.views.GridReport({ + parent: $(wrapper).find('.layout-main'), + appframe: wrapper.appframe, + doctypes: ["Company", "Account", "GL Entry"], + filters: [ + {fieldtype:"Select", label: "Company", options:"Company", + filter: function(val, item) { + return item.company == val || val == "Select Company"; + }}, + {fieldtype:"Select", label: "Account", options:"Account", + filter: function(val, item) { + return item.account == val || val == "Select Account"; + }}, + {fieldtype:"Date", label: "From Date"}, + {fieldtype:"Label", label: "To"}, + {fieldtype:"Date", label: "To Date"}, + {fieldtype:"Button", label: "Refresh"}, + ], + setup: function() { + this.setup_filters(); + this.setup_columns(); + }, + setup_filters: function() { + var me = this; + // default filters + this.filter_inputs.company.val(sys_defaults.company); + this.filter_inputs.from_date.val(dateutil.str_to_user(sys_defaults.year_start_date)); + this.filter_inputs.to_date.val(dateutil.str_to_user(sys_defaults.year_end_date)); + this.filter_inputs.refresh.click(function() { me.refresh(); }) + }, + setup_columns: function() { + this.columns = [ + {id: "posting_date", name: "Posting Date", field: "posting_date", width: 100, + formatter: this.date_formatter}, + {id: "account", name: "Account", field: "account", width: 240}, + {id: "debit", name: "Debit", field: "debit", width: 100, + formatter: this.currency_formatter}, + {id: "credit", name: "Credit", field: "credit", width: 100, + formatter: this.currency_formatter}, + ]; + }, + prepare_data: function() { + this.prepare_data_view(wn.report_dump.data["GL Entry"]); + }, + dataview_filter: function(item) { + var filters = wn.cur_grid_report.filter_inputs; + for (i in filters) { + var filter = filters[i].get(0); + if(filter.opts.filter && !filter.opts.filter($(filter).val(), item)) { + return false; + } + } + return true; + }, + }); + +} + diff --git a/erpnext/accounts/page/general_ledger/general_ledger.py b/erpnext/accounts/page/general_ledger/general_ledger.py new file mode 100644 index 0000000000..f351978a5e --- /dev/null +++ b/erpnext/accounts/page/general_ledger/general_ledger.py @@ -0,0 +1,10 @@ +import webnotes + +@webnotes.whitelist() +def get_chart(): + company = webnotes.form_dict.get('company') + res = {} + res["chart"] = webnotes.conn.sql("""select name, parent_account, + if(debit_or_credit="Debit", "D", ""), + if(is_pl_account="Yes", "Y", "") from + tabAccount where company=%s and docstatus < 2 order by lft""", (company, )) \ No newline at end of file diff --git a/erpnext/accounts/page/general_ledger/general_ledger.txt b/erpnext/accounts/page/general_ledger/general_ledger.txt new file mode 100644 index 0000000000..c57ff0f3e2 --- /dev/null +++ b/erpnext/accounts/page/general_ledger/general_ledger.txt @@ -0,0 +1,28 @@ +# Page, general-ledger +[ + + # These values are common in all dictionaries + { + 'creation': '2012-09-13 13:50:13', + 'docstatus': 0, + 'modified': '2012-09-13 13:50:13', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Page + { + 'doctype': 'Page', + 'module': u'Accounts', + 'name': '__common__', + 'page_name': u'general-ledger', + 'standard': u'Yes', + 'title': u'General Ledger' + }, + + # Page, general-ledger + { + 'doctype': 'Page', + 'name': u'general-ledger' + } +] \ No newline at end of file diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py new file mode 100644 index 0000000000..aa23ade521 --- /dev/null +++ b/erpnext/startup/report_data_map.py @@ -0,0 +1,37 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +data_map = { + "Account": { + "columns": ["name", "parent_account", "lft", "rgt", "debit_or_credit", "is_pl_account", + "company"], + "order_by": "lft" + }, + "GL Entry": { + "columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening", + "company"], + "conditions": ["ifnull(is_cancelled, 'No')='No'"], + "order_by": "posting_date" + }, + "Company": { + "columns": ["name"], + "conditions": ["docstatus < 2"] + }, + "Fiscal Year": { + "columns": ["name", "year_start_date", + "adddate(year_start_date, interval 1 year) as year_end_date"] + } +} diff --git a/erpnext/startup/startup.py b/erpnext/startup/startup.py index 0ae31141fe..3d304927da 100644 --- a/erpnext/startup/startup.py +++ b/erpnext/startup/startup.py @@ -1,4 +1,19 @@ -from __future__ import unicode_literals +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + import webnotes def get_unread_messages(): diff --git a/public/css/all-app.css b/public/css/all-app.css index ab3ad36582..adf8ad267b 100644 --- a/public/css/all-app.css +++ b/public/css/all-app.css @@ -163,7 +163,7 @@ h6 { margin-top: 1px; } .btn-small { - padding: 5px 9px; + padding: 4px 9px; font-size: 11px; line-height: 16px; } diff --git a/public/css/all-web.css b/public/css/all-web.css index 971d32f636..6a77fac6f9 100644 --- a/public/css/all-web.css +++ b/public/css/all-web.css @@ -163,7 +163,7 @@ h6 { margin-top: 1px; } .btn-small { - padding: 5px 9px; + padding: 4px 9px; font-size: 11px; line-height: 16px; } diff --git a/public/js/all-app.js b/public/js/all-app.js index f52272c8ef..49d299cde1 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -176,7 +176,7 @@ return cookies[c];} wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);') $(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);') $(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){$.fn.add_options=function(options_list){for(var i=0;i').html(label).attr('value',value).appendTo(this);} -return $(this).val(options_list[0].value||options_list[0]);} +this.selectedIndex=0;return $(this);} $.fn.set_working=function(){var ele=this.get(0);$(ele).attr('disabled','disabled');if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.loading_img=$('').insertAfter(ele);}} $.fn.done_working=function(){var ele=this.get(0);$(ele).attr('disabled',null);if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery); @@ -400,7 +400,7 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f * lib/js/core.js */ if(!console){var console={log:function(txt){}}} -window._version_number="031a31bad930de7f9e8157242afbcba4729d91ff9f957c0c897cafd6";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); +window._version_number="820949d75a1ddbb59843ce9171e6c532b5f5e6650784839c2a66d84a";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); /* * lib/js/legacy/globals.js @@ -850,7 +850,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar&&this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) -this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\ +this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $(""+label+" ").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.toolbar);},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\
\
');}else{$(opts.parent).html('
\ @@ -1063,6 +1063,16 @@ me.list.run();});this.dialog.show();},add_column:function(c){var w=$('
\ ×\
').appendTo($(this.dialog.body).find('.column-list'));var fieldselect=new wn.ui.FieldSelect(w,this.doctype);fieldselect.$select.css('width','90%').val((c[1]||this.doctype)+"."+c[0]);w.find('.close').click(function(){$(this).parent().remove();});}}); +/* + * lib/js/wn/views/grid_report.js + */ +wn.provide("wn.report_dump");$.extend(wn.report_dump,{data:{},with_data:function(doctypes,callback){var missing=[];$.each(doctypes,function(i,v){if(!wn.report_dump.data[v])missing.push(v);}) +if(missing.length){wn.call({method:"webnotes.widgets.report_dump.get_data",args:{doctypes:missing},callback:function(r){$.each(r.message,function(doctype,doctype_data){var data=[];$.each(doctype_data.data,function(i,d){var row={};$.each(doctype_data.columns,function(idx,col){row[col]=d[idx];});row.id=doctype+"-"+i;data.push(row);});wn.report_dump.data[doctype]=data;});callback();}})}else{callback();}}});wn.provide("wn.views");wn.views.GridReport=Class.extend({init:function(opts){this.filter_inputs={};$.extend(this,opts);this.wrapper=$("
").appendTo(this.parent);this.id=wn.dom.set_unique_id(this.wrapper.get(0));if(this.filters){this.make_filters();} +this.make_waiting();this.import_slickgrid();var me=this;this.get_data();wn.cur_grid_report=this;},get_data:function(){var me=this;wn.report_dump.with_data(this.doctypes,function(){$.each(me.filter_inputs,function(i,v){var opts=v.get(0).opts;if(opts.fieldtype=="Select"&&inList(me.doctypes,opts.options)){$(v).add_options($.map(wn.report_dump.data[opts.options],function(d){return d.name;}));}});me.setup();me.refresh();});},make_waiting:function(){$('
\ +

Loading Report...

\ +
\ +
').appendTo(this.wrapper);},load_filters:function(callback){callback();},make_filters:function(){var me=this;$.each(this.filters,function(i,v){v.fieldname=v.fieldname||v.label.replace(/ /g,'_').toLowerCase();var input=null;if(v.fieldtype=='Select'){input=me.appframe.add_select(v.label,["Select "+v.options]);}else if(v.fieldtype=='Button'){input=me.appframe.add_button(v.label);}else if(v.fieldtype=='Date'){input=me.appframe.add_date(v.label);}else if(v.fieldtype=='Label'){input=me.appframe.add_label(v.label);} +input&&(input.get(0).opts=v);me.filter_inputs[v.fieldname]=input;});},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.require('js/lib/slickgrid/slick.dataview.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},refresh:function(){this.prepare_data();this.render();},render:function(){this.grid=new Slick.Grid("#"+this.id,this.dataView,this.columns,this.options);this.dataView.onRowsChanged.subscribe(function(e,args){grid.invalidateRows(args.rows);grid.render();});this.dataView.onRowCountChanged.subscribe(function(e,args){grid.updateRowCount();grid.render();});},prepare_data_view:function(items){this.dataView=new Slick.Data.DataView({inlineFilters:true});this.dataView.beginUpdate();this.dataView.setItems(items);this.dataView.setFilter(this.dataview_filter);this.dataView.endUpdate();},options:{editable:false,enableColumnReorder:false},dataview_filter:function(item){return true;},date_formatter:function(row,cell,value,columnDef,dataContext){return dateutil.str_to_user(value);},currency_formatter:function(row,cell,value,columnDef,dataContext){return"
"+fmt_money(value)+"
";}}) /* * lib/js/legacy/widgets/dialog.js */ diff --git a/public/js/all-web.js b/public/js/all-web.js index 2c0b0aeae0..eea537abb9 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -63,7 +63,7 @@ return cookies[c];} wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);') $(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);') $(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){$.fn.add_options=function(options_list){for(var i=0;i').html(label).attr('value',value).appendTo(this);} -return $(this).val(options_list[0].value||options_list[0]);} +this.selectedIndex=0;return $(this);} $.fn.set_working=function(){var ele=this.get(0);$(ele).attr('disabled','disabled');if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.loading_img=$('').insertAfter(ele);}} $.fn.done_working=function(){var ele=this.get(0);$(ele).attr('disabled',null);if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery); @@ -287,7 +287,7 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f * lib/js/core.js */ if(!console){var console={log:function(txt){}}} -window._version_number="031a31bad930de7f9e8157242afbcba4729d91ff9f957c0c897cafd6";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); +window._version_number="820949d75a1ddbb59843ce9171e6c532b5f5e6650784839c2a66d84a";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); /* * lib/js/legacy/globals.js @@ -509,7 +509,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},clear_buttons:function(){this.toolbar&&this.toolbar.empty();},add_toolbar:function(){if(!this.toolbar) -this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.add_label(label));},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\ +this.$w.append('
');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $(""+label+" ").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.toolbar);},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\
\
');}else{$(opts.parent).html('
\