show Net Profit only when company is selected

This commit is contained in:
Anand Doshi 2012-11-28 17:12:30 +05:30
parent 01bf10b8b6
commit 47514097be

View File

@ -142,42 +142,45 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
this.update_groups(); this.update_groups();
this.accounts_initialized = true; this.accounts_initialized = true;
// show Net Profit / Loss if(!me.is_default("company")) {
var net_profit = { // show Net Profit / Loss
company: me.company, var net_profit = {
id: "Net Profit / Loss", company: me.company,
name: "Net Profit / Loss", id: "Net Profit / Loss",
indent: 0, name: "Net Profit / Loss",
opening: 0, indent: 0,
checked: false, opening: 0,
is_pl_account: me.pl_or_bs=="Balance Sheet" ? "No" : "Yes", checked: false,
}; is_pl_account: me.pl_or_bs=="Balance Sheet" ? "No" : "Yes",
};
$.each(me.data, function(i, ac) { me.item_by_name[net_profit.name] = net_profit;
if(!ac.parent_account && me.apply_filter(ac, "company")) {
if(me.pl_or_bs == "Balance Sheet") { $.each(me.data, function(i, ac) {
var valid_account = ac.is_pl_account!="Yes"; if(!ac.parent_account && me.apply_filter(ac, "company")) {
var do_addition_for = "Debit"; if(me.pl_or_bs == "Balance Sheet") {
} else { 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 = "Credit"; } else {
} var valid_account = ac.is_pl_account=="Yes";
if(valid_account) { var do_addition_for = "Credit";
$.each(me.columns, function(i, col) { }
if(col.formatter==me.currency_formatter) { if(valid_account) {
if(!net_profit[col.field]) net_profit[col.field] = 0; $.each(me.columns, function(i, col) {
if(ac.debit_or_credit==do_addition_for) { if(col.formatter==me.currency_formatter) {
net_profit[col.field] += ac[col.field]; if(!net_profit[col.field]) net_profit[col.field] = 0;
} else { if(ac.debit_or_credit==do_addition_for) {
net_profit[col.field] -= ac[col.field]; net_profit[col.field] += ac[col.field];
} else {
net_profit[col.field] -= ac[col.field];
}
} }
} });
}); }
} }
} });
});
this.data.push(net_profit);
this.data.push(net_profit); }
}, },
add_balance: function(field, account, gl) { add_balance: function(field, account, gl) {
account[field] = flt(account[field]) + account[field] = flt(account[field]) +