From 2b57ecbd6ccce0c4bc68a52e3cc2f3db6cee852f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 5 Mar 2014 11:30:28 +0530 Subject: [PATCH] fixes for debit_or_credit in account tree grid report --- .../page/financial_analytics/financial_analytics.js | 10 +++++----- erpnext/public/js/account_tree_grid.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js index 470b3842ae..dcc4a5128a 100644 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.js +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js @@ -148,16 +148,16 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({ if(!ac.parent_account && me.apply_filter(ac, "company")) { if(me.pl_or_bs == "Balance Sheet") { var valid_account = ac.is_pl_account!="Yes"; - var do_addition_for = "Debit"; + var do_addition_for = "Asset"; } else { var valid_account = ac.is_pl_account=="Yes"; - var do_addition_for = "Credit"; + var do_addition_for = "Income"; } if(valid_account) { $.each(me.columns, function(i, col) { if(col.formatter==me.currency_formatter) { if(!net_profit[col.field]) net_profit[col.field] = 0; - if(ac.debit_or_credit==do_addition_for) { + if(ac.root_type==do_addition_for) { net_profit[col.field] += ac[col.field]; } else { net_profit[col.field] -= ac[col.field]; @@ -172,8 +172,8 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({ } }, add_balance: function(field, account, gl) { - account[field] = flt(account[field]) + - ((account.debit_or_credit == "Debit" ? 1 : -1) * (flt(gl.debit) - flt(gl.credit))) + account[field] = flt(account[field]) + ((in_list(["Asset", "Expense"], + account.root_type) ? 1 : -1) * (flt(gl.debit) - flt(gl.credit))); }, init_account: function(d) { // set 0 values for all columns diff --git a/erpnext/public/js/account_tree_grid.js b/erpnext/public/js/account_tree_grid.js index 6b234db694..b00f236db7 100644 --- a/erpnext/public/js/account_tree_grid.js +++ b/erpnext/public/js/account_tree_grid.js @@ -152,7 +152,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ // balance of previous fiscal_year should // not be part of opening of pl account balance } else { - if(account.debit_or_credit=='Debit') { + if(in_list(["Asset", "Expense"], account.root_type)) { account.opening_debit += (v.debit - v.credit); } else { account.opening_credit += (v.credit - v.debit); @@ -164,7 +164,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ account.credit += v.credit; } // closing - if(account.debit_or_credit=='Debit') { + if(in_list(["Asset", "Expense"], account.root_type)) { account.closing_debit = account.opening_debit + account.debit - account.credit; } else { account.closing_credit = account.opening_credit - account.debit + account.credit;