fixes #9098: don't skip calculation if income or expense is [] (#9267)

This commit is contained in:
tundebabzy
2017-06-14 10:27:34 +01:00
committed by Nabin Hait
parent 4c0f9dac94
commit 5c9dd42547

View File

@@ -34,7 +34,6 @@ def execute(filters=None):
return columns, data, None, chart return columns, data, None, chart
def get_net_profit_loss(income, expense, period_list, company): def get_net_profit_loss(income, expense, period_list, company):
if income and expense:
total = 0 total = 0
net_profit_loss = { net_profit_loss = {
"account_name": "'" + _("Net Profit / Loss") + "'", "account_name": "'" + _("Net Profit / Loss") + "'",
@@ -46,7 +45,10 @@ def get_net_profit_loss(income, expense, period_list, company):
has_value = False has_value = False
for period in period_list: for period in period_list:
net_profit_loss[period.key] = flt(income[-2][period.key] - expense[-2][period.key], 3) total_income = flt(income[-2][period.key], 3) if income else 0
total_expense = flt(expense[-2][period.key], 3) if expense else 0
net_profit_loss[period.key] = total_income - total_expense
if net_profit_loss[period.key]: if net_profit_loss[period.key]:
has_value=True has_value=True
@@ -57,6 +59,7 @@ def get_net_profit_loss(income, expense, period_list, company):
if has_value: if has_value:
return net_profit_loss return net_profit_loss
def get_chart_data(filters, columns, income, expense, net_profit_loss): def get_chart_data(filters, columns, income, expense, net_profit_loss):
x_intervals = ['x'] + [d.get("label") for d in columns[2:]] x_intervals = ['x'] + [d.get("label") for d in columns[2:]]