fixes for debit_or_credit in account tree grid report

This commit is contained in:
Nabin Hait 2014-03-05 11:30:28 +05:30
parent 53822ae9d0
commit 2b57ecbd6c
2 changed files with 7 additions and 7 deletions

View File

@ -148,16 +148,16 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
if(!ac.parent_account && me.apply_filter(ac, "company")) { if(!ac.parent_account && me.apply_filter(ac, "company")) {
if(me.pl_or_bs == "Balance Sheet") { if(me.pl_or_bs == "Balance Sheet") {
var valid_account = ac.is_pl_account!="Yes"; var valid_account = ac.is_pl_account!="Yes";
var do_addition_for = "Debit"; var do_addition_for = "Asset";
} else { } else {
var valid_account = ac.is_pl_account=="Yes"; var valid_account = ac.is_pl_account=="Yes";
var do_addition_for = "Credit"; var do_addition_for = "Income";
} }
if(valid_account) { if(valid_account) {
$.each(me.columns, function(i, col) { $.each(me.columns, function(i, col) {
if(col.formatter==me.currency_formatter) { if(col.formatter==me.currency_formatter) {
if(!net_profit[col.field]) net_profit[col.field] = 0; 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]; net_profit[col.field] += ac[col.field];
} else { } else {
net_profit[col.field] -= ac[col.field]; net_profit[col.field] -= ac[col.field];
@ -172,8 +172,8 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
} }
}, },
add_balance: function(field, account, gl) { add_balance: function(field, account, gl) {
account[field] = flt(account[field]) + account[field] = flt(account[field]) + ((in_list(["Asset", "Expense"],
((account.debit_or_credit == "Debit" ? 1 : -1) * (flt(gl.debit) - flt(gl.credit))) account.root_type) ? 1 : -1) * (flt(gl.debit) - flt(gl.credit)));
}, },
init_account: function(d) { init_account: function(d) {
// set 0 values for all columns // set 0 values for all columns

View File

@ -152,7 +152,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
// balance of previous fiscal_year should // balance of previous fiscal_year should
// not be part of opening of pl account balance // not be part of opening of pl account balance
} else { } else {
if(account.debit_or_credit=='Debit') { if(in_list(["Asset", "Expense"], account.root_type)) {
account.opening_debit += (v.debit - v.credit); account.opening_debit += (v.debit - v.credit);
} else { } else {
account.opening_credit += (v.credit - v.debit); account.opening_credit += (v.credit - v.debit);
@ -164,7 +164,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
account.credit += v.credit; account.credit += v.credit;
} }
// closing // 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; account.closing_debit = account.opening_debit + account.debit - account.credit;
} else { } else {
account.closing_credit = account.opening_credit - account.debit + account.credit; account.closing_credit = account.opening_credit - account.debit + account.credit;