From 51b7f322cc261328f2b1ad3788ff6c2fb87a5efb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 2 Jun 2014 18:47:13 +0530 Subject: [PATCH 1/3] Closing balance fixes in trial balance. Fixes #1730 --- erpnext/public/js/account_tree_grid.js | 57 ++++++++++++++------------ 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/erpnext/public/js/account_tree_grid.js b/erpnext/public/js/account_tree_grid.js index 50924772d5..7002c1a1c5 100644 --- a/erpnext/public/js/account_tree_grid.js +++ b/erpnext/public/js/account_tree_grid.js @@ -5,12 +5,12 @@ // 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 . @@ -23,8 +23,8 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ appframe: wrapper.appframe, doctypes: ["Company", "Fiscal Year", "Account", "GL Entry", "Cost Center"], tree_grid: { - show: true, - parent_field: "parent_account", + show: true, + parent_field: "parent_account", formatter: function(item) { return repl("\ @@ -37,7 +37,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ }, setup_columns: function() { this.columns = [ - {id: "name", name: __("Account"), field: "name", width: 300, cssClass: "cell-title", + {id: "name", name: __("Account"), field: "name", width: 300, cssClass: "cell-title", formatter: this.tree_formatter}, {id: "opening_dr", name: __("Opening (Dr)"), field: "opening_dr", width: 100, formatter: this.currency_formatter}, @@ -62,7 +62,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ } return false; }}, - {fieldtype: "Select", label: __("Fiscal Year"), link:"Fiscal Year", + {fieldtype: "Select", label: __("Fiscal Year"), link:"Fiscal Year", default_value: "Select Fiscal Year..."}, {fieldtype: "Date", label: __("From Date")}, {fieldtype: "Label", label: __("To")}, @@ -105,21 +105,21 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ me.parent_map[d.name] = d.parent_account; } }); - + me.primary_data = [].concat(me.data); } - + me.data = [].concat(me.primary_data); $.each(me.data, function(i, d) { me.init_account(d); }); - + this.set_indent(); this.prepare_balances(); - + }, init_account: function(d) { - this.reset_item_values(d); + this.reset_item_values(d); }, prepare_balances: function() { @@ -132,7 +132,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ if (!this.fiscal_year) return; $.each(this.data, function(i, v) { - v.opening_dr = v.opening_cr = v.debit + v.opening_dr = v.opening_cr = v.debit = v.credit = v.closing_dr = v.closing_cr = 0; }); @@ -145,15 +145,16 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ this.update_groups(); }, update_balances: function(account, posting_date, v) { - var bal = flt(account.opening_dr) - flt(account.opening_cr) + flt(v.debit) - flt(v.credit); // opening if (posting_date < this.opening_date || v.is_opening === "Yes") { - if (account.report_type === "Profit and Loss" && + if (account.report_type === "Profit and Loss" && posting_date <= dateutil.str_to_obj(this.fiscal_year[1])) { - // balance of previous fiscal_year should + // balance of previous fiscal_year should // not be part of opening of pl account balance } else { - this.set_debit_or_credit(account, "opening", bal); + var opening_bal = flt(account.opening_dr) - flt(account.opening_cr) + + flt(v.debit) - flt(v.credit); + this.set_debit_or_credit(account, "opening", opening_bal); } } else if (this.opening_date <= posting_date && posting_date <= this.closing_date) { // in between @@ -161,7 +162,9 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ account.credit += flt(v.credit); } // closing - this.set_debit_or_credit(account, "closing", bal); + var closing_bal = flt(account.opening_dr) - flt(account.opening_cr) + + flt(account.debit) - flt(account.credit); + this.set_debit_or_credit(account, "closing", closing_bal); }, set_debit_or_credit: function(account, field, balance) { if(balance > 0) { @@ -184,25 +187,25 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ $.each(me.columns, function(c, col) { if (col.formatter == me.currency_formatter) { if(col.field=="opening_dr") { - var bal = flt(parent_account.opening_dr) - - flt(parent_account.opening_cr) + + var bal = flt(parent_account.opening_dr) - + flt(parent_account.opening_cr) + flt(account.opening_dr) - flt(account.opening_cr); me.set_debit_or_credit(parent_account, "opening", bal); } else if(col.field=="closing_dr") { - var bal = flt(parent_account.closing_dr) - - flt(parent_account.closing_cr) + + var bal = flt(parent_account.closing_dr) - + flt(parent_account.closing_cr) + flt(account.closing_dr) - flt(account.closing_cr); me.set_debit_or_credit(parent_account, "closing", bal); } else if(in_list(["debit", "credit"], col.field)) { - parent_account[col.field] = flt(parent_account[col.field]) + + parent_account[col.field] = flt(parent_account[col.field]) + flt(account[col.field]); } } }); parent = me.parent_map[parent]; - } + } } - }); + }); }, set_fiscal_year: function() { @@ -214,7 +217,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ this.fiscal_year = null; var me = this; $.each(frappe.report_dump.data["Fiscal Year"], function(i, v) { - if (me.opening_date >= dateutil.str_to_obj(v.year_start_date) && + if (me.opening_date >= dateutil.str_to_obj(v.year_start_date) && me.closing_date <= dateutil.str_to_obj(v.year_end_date)) { me.fiscal_year = v; } @@ -225,7 +228,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ return; } }, - + show_general_ledger: function(account) { frappe.route_options = { account: account, @@ -235,4 +238,4 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ }; frappe.set_route("query-report", "General Ledger"); } -}); \ No newline at end of file +}); From abb62c76d8b4f6191609e166857cfdaed6d1a057 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 3 Jun 2014 10:50:55 +0530 Subject: [PATCH 2/3] Removed allocated to field from serach fields in support ticket --- erpnext/support/doctype/support_ticket/support_ticket.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/support/doctype/support_ticket/support_ticket.json b/erpnext/support/doctype/support_ticket/support_ticket.json index 5ea9ac5c0d..fd97884626 100644 --- a/erpnext/support/doctype/support_ticket/support_ticket.json +++ b/erpnext/support/doctype/support_ticket/support_ticket.json @@ -237,7 +237,7 @@ ], "icon": "icon-ticket", "idx": 1, - "modified": "2014-05-21 06:15:26.988620", + "modified": "2014-06-03 10:49:47.781578", "modified_by": "Administrator", "module": "Support", "name": "Support Ticket", @@ -286,6 +286,6 @@ "write": 1 } ], - "search_fields": "status,customer,allocated_to,subject,raised_by", + "search_fields": "status,customer,subject,raised_by", "title_field": "subject" } \ No newline at end of file From b15764ef2c8cf867965e96b78bbc354ce05d396f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 3 Jun 2014 13:02:18 +0530 Subject: [PATCH 3/3] Translation issue fixed in analytics/grid report --- .../financial_analytics.js | 23 +++++---- .../page/trial_balance/trial_balance.js | 18 +++---- .../purchase_analytics/purchase_analytics.js | 31 ++++++----- erpnext/public/js/account_tree_grid.js | 13 ++--- erpnext/public/js/stock_analytics.js | 51 ++++++++++--------- .../page/sales_analytics/sales_analytics.js | 11 ++-- .../stock/page/stock_balance/stock_balance.js | 16 +++--- 7 files changed, 87 insertions(+), 76 deletions(-) diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js index 7d2cfb1179..df30d83861 100644 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.js +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js @@ -17,8 +17,9 @@ frappe.pages['financial-analytics'].onload = function(wrapper) { erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({ filters: [ { - fieldtype:"Select", label: __("PL or BS"), - options:["Profit and Loss", "Balance Sheet"], + fieldtype:"Select", label: __("PL or BS"), fieldname: "pl_or_bs", + options:[{"label": __("Profit and Loss"), "value": "Profit and Loss"}, + {"label": __("Balance Sheet"), "value": "Balance Sheet"}], filter: function(val, item, opts, me) { if(item._show) return true; @@ -31,19 +32,21 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({ } }, { - fieldtype:"Select", label: __("Company"), - link:"Company", default_value: "Select Company...", + fieldtype:"Select", label: __("Company"), fieldname: "company", + link:"Company", default_value: __("Select Company..."), filter: function(val, item, opts) { return item.company == val || val == opts.default_value || item._show; } }, - {fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year", - default_value: "Select Fiscal Year..."}, - {fieldtype:"Date", label: __("From Date")}, + {fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year", fieldname: "fiscal_year", + default_value: __("Select Fiscal Year...")}, + {fieldtype:"Date", label: __("From Date"), fieldname: "from_date"}, {fieldtype:"Label", label: __("To")}, - {fieldtype:"Date", label: __("To Date")}, - {fieldtype:"Select", label: __("Range"), - options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]}, + {fieldtype:"Date", label: __("To Date"), fieldname: "to_date"}, + {fieldtype:"Select", label: __("Range"), fieldname: "range", + options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"}, + {label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"}, + {label: __("Yearly"), value: "Yearly"}]}, {fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"}, {fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"} ], diff --git a/erpnext/accounts/page/trial_balance/trial_balance.js b/erpnext/accounts/page/trial_balance/trial_balance.js index 95818093f6..e73e1d4f3a 100644 --- a/erpnext/accounts/page/trial_balance/trial_balance.js +++ b/erpnext/accounts/page/trial_balance/trial_balance.js @@ -3,7 +3,7 @@ frappe.require("assets/erpnext/js/account_tree_grid.js"); -frappe.pages['trial-balance'].onload = function(wrapper) { +frappe.pages['trial-balance'].onload = function(wrapper) { frappe.ui.make_app_page({ parent: wrapper, title: __('Trial Balance'), @@ -13,26 +13,26 @@ frappe.pages['trial-balance'].onload = function(wrapper) { init: function(wrapper, title) { var me = this; this._super(wrapper, title); - + // period closing entry checkbox this.wrapper.bind("make", function() { $('
' + + class="with_period_closing_entry">' + __("With period closing entry") + '
') .appendTo(me.wrapper) .find("input").click(function() { me.refresh(); }); }); }, - + prepare_balances: function() { // store value of with closing entry this.with_period_closing_entry = this.wrapper .find(".with_period_closing_entry input:checked").length; this._super(); }, - + update_balances: function(account, posting_date, v) { - // for period closing voucher, + // for period closing voucher, // only consider them when adding "With Closing Entry is checked" if(v.voucher_type === "Period Closing Voucher") { if(this.with_period_closing_entry) { @@ -44,8 +44,8 @@ frappe.pages['trial-balance'].onload = function(wrapper) { }, }) erpnext.trial_balance = new TrialBalance(wrapper, 'Trial Balance'); - + wrapper.appframe.add_module_icon("Accounts") - -} \ No newline at end of file + +} diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.js b/erpnext/buying/page/purchase_analytics/purchase_analytics.js index 2e29d01a0a..f1c050d1ff 100644 --- a/erpnext/buying/page/purchase_analytics/purchase_analytics.js +++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.js @@ -86,21 +86,24 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ this.columns = std_columns.concat(this.columns); }, filters: [ - {fieldtype:"Select", label: __("Tree Type"), options:["Supplier Type", "Supplier", - "Item Group", "Item"], + {fieldtype:"Select", label: __("Tree Type"), fieldname: "tree_type", + options:["Supplier Type", "Supplier", "Item Group", "Item"], filter: function(val, item, opts, me) { return me.apply_zero_filter(val, item, opts, me); }}, - {fieldtype:"Select", label: __("Based On"), options:["Purchase Invoice", - "Purchase Order", "Purchase Receipt"]}, - {fieldtype:"Select", label: __("Value or Qty"), options:["Value", "Quantity"]}, - {fieldtype:"Select", label: __("Company"), link:"Company", - default_value: "Select Company..."}, - {fieldtype:"Date", label: __("From Date")}, + {fieldtype:"Select", label: __("Based On"), fieldname: "based_on", + options:["Purchase Invoice", "Purchase Order", "Purchase Receipt"]}, + {fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty", + options:["Value", "Quantity"]}, + {fieldtype:"Select", label: __("Company"), link:"Company", fieldname: "company", + default_value: __("Select Company...")}, + {fieldtype:"Date", label: __("From Date"), fieldname: "from_date"}, {fieldtype:"Label", label: __("To")}, - {fieldtype:"Date", label: __("To Date")}, - {fieldtype:"Select", label: __("Range"), - options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]}, + {fieldtype:"Date", label: __("To Date"), fieldname: "to_date"}, + {fieldtype:"Select", label: __("Range"), fieldname: "range", + options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"}, + {label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"}, + {label: __("Yearly"), value: "Yearly"}]}, {fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"}, {fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"} ], @@ -126,7 +129,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ // Set parent supplier type for tree view $.each(frappe.report_dump.data["Supplier Type"], function(i, v) { - v['parent_supplier_type'] = "All Supplier Types" + v['parent_supplier_type'] = __("All Supplier Types") }) frappe.report_dump.data["Supplier Type"] = [{ @@ -136,7 +139,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ frappe.report_dump.data["Supplier"].push({ name: __("Not Set"), - parent_supplier_type: "All Supplier Types", + parent_supplier_type: __("All Supplier Types"), id: "Not Set", }); @@ -219,7 +222,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ $.each(this.data, function(i, item) { var parent = me.parent_map[item.name]; while(parent) { - parent_group = me.item_by_name[parent]; + var parent_group = me.item_by_name[parent]; $.each(me.columns, function(c, col) { if (col.formatter == me.currency_formatter) { diff --git a/erpnext/public/js/account_tree_grid.js b/erpnext/public/js/account_tree_grid.js index 7002c1a1c5..87fb7a986b 100644 --- a/erpnext/public/js/account_tree_grid.js +++ b/erpnext/public/js/account_tree_grid.js @@ -55,18 +55,19 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ }, filters: [ - {fieldtype: "Select", label: __("Company"), link:"Company", default_value: "Select Company...", + {fieldtype: "Select", label: __("Company"), link:"Company", fieldname: "company", + default_value: __("Select Company..."), filter: function(val, item, opts, me) { if (item.company == val || val == opts.default_value) { return me.apply_zero_filter(val, item, opts, me); } return false; }}, - {fieldtype: "Select", label: __("Fiscal Year"), link:"Fiscal Year", - default_value: "Select Fiscal Year..."}, - {fieldtype: "Date", label: __("From Date")}, + {fieldtype: "Select", label: "Fiscal Year", link:"Fiscal Year", fieldname: "fiscal_year", + default_value: __("Select Fiscal Year...")}, + {fieldtype: "Date", label: __("From Date"), fieldname: "from_date"}, {fieldtype: "Label", label: __("To")}, - {fieldtype: "Date", label: __("To Date")}, + {fieldtype: "Date", label: __("To Date"), fieldname: "to_date"}, {fieldtype: "Button", label: __("Refresh"), icon:"icon-refresh icon-white", cssClass:"btn-info"}, {fieldtype: "Button", label: __("Reset Filters"), icon: "icon-filter"}, @@ -83,7 +84,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ me.filter_inputs.to_date.val(dateutil.str_to_user(v.year_end_date)); } }); - me.set_route(); + me.refresh(); }); me.show_zero_check() if(me.ignore_closing_entry) me.ignore_closing_entry(); diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js index 7c15dba2a5..d4f43e98b9 100644 --- a/erpnext/public/js/stock_analytics.js +++ b/erpnext/public/js/stock_analytics.js @@ -10,11 +10,11 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ page: wrapper, parent: $(wrapper).find('.layout-main'), appframe: wrapper.appframe, - doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", + doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", "Fiscal Year", "Serial No"], tree_grid: { - show: true, - parent_field: "parent_item_group", + show: true, + parent_field: "parent_item_group", formatter: function(item) { if(!item.is_group) { return repl("