Update profit_and_loss_statement.py
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
index d26a3fc..42dead4 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
@@ -10,8 +10,8 @@
def execute(filters=None):
period_list = get_period_list(filters.fiscal_year, filters.periodicity)
- income = get_data(filters.company, "Income", "Credit", period_list, ignore_closing_entries=True)
- expense = get_data(filters.company, "Expense", "Debit", period_list, ignore_closing_entries=True)
+ income = get_data(filters.company, "Income", "Credit", period_list, filters.accumulated_value, ignore_closing_entries=True)
+ expense = get_data(filters.company, "Expense", "Debit", period_list, filters.accumulated_value, ignore_closing_entries=True)
net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company)
data = []
@@ -20,7 +20,7 @@
if net_profit_loss:
data.append(net_profit_loss)
- columns = get_columns(period_list, filters.company)
+ columns = get_columns(filters.periodicity,period_list,filters.accumulated_value)
return columns, data
@@ -33,7 +33,17 @@
"currency": frappe.db.get_value("Company", company, "default_currency")
}
+ has_value = False
+
for period in period_list:
net_profit_loss[period.key] = flt(income[-2][period.key] - expense[-2][period.key], 3)
+
+ if net_profit_loss[period.key]:
+ has_value=True
+
+ total_column=total_column+net_profit_loss[period.key]
+ net_profit_loss["total"]=total_column
+
+ if has_value:
- return net_profit_loss
+ return net_profit_loss