Merge pull request #5405 from nabinhait/chart-fix
[fix] Charts in report
This commit is contained in:
commit
5b7f6300c8
@ -259,19 +259,19 @@ class ReceivablePayableReport(object):
|
||||
def get_chart_data(self, columns, data):
|
||||
ageing_columns = columns[self.ageing_col_idx_start : self.ageing_col_idx_start+4]
|
||||
|
||||
range_totals = [[d.get("label")] for d in ageing_columns]
|
||||
|
||||
rows = []
|
||||
for d in data:
|
||||
for i in xrange(4):
|
||||
range_totals[i].append(d[self.ageing_col_idx_start + i])
|
||||
|
||||
rows.append(d[self.ageing_col_idx_start : self.ageing_col_idx_start+4])
|
||||
|
||||
if rows:
|
||||
rows.insert(0, [[d.get("label")] for d in ageing_columns])
|
||||
|
||||
return {
|
||||
"data": {
|
||||
'columns': range_totals
|
||||
'rows': rows
|
||||
},
|
||||
"chart_type": 'pie'
|
||||
}
|
||||
|
||||
|
||||
def execute(filters=None):
|
||||
args = {
|
||||
|
@ -76,16 +76,27 @@ def check_opening_balance(asset, liability, equity):
|
||||
def get_chart_data(columns, asset, liability, equity):
|
||||
x_intervals = ['x'] + [d.get("label") for d in columns[2:]]
|
||||
|
||||
asset_data, liability_data, equity_data = ["Assets"], ["Liabilities"], ["Equity"]
|
||||
asset_data, liability_data, equity_data = [], [], []
|
||||
|
||||
for p in columns[2:]:
|
||||
asset_data.append(asset[-2].get(p.get("fieldname")))
|
||||
liability_data.append(liability[-2].get(p.get("fieldname")))
|
||||
equity_data.append(equity[-2].get(p.get("fieldname")))
|
||||
if asset:
|
||||
asset_data.append(asset[-2].get(p.get("fieldname")))
|
||||
if liability:
|
||||
liability_data.append(liability[-2].get(p.get("fieldname")))
|
||||
if equity:
|
||||
equity_data.append(equity[-2].get(p.get("fieldname")))
|
||||
|
||||
columns = [x_intervals]
|
||||
if asset_data:
|
||||
columns.append(["Assets"] + asset_data)
|
||||
if liability_data:
|
||||
columns.append(["Liabilities"] + liability_data)
|
||||
if equity_data:
|
||||
columns.append(["Equity"] + equity_data)
|
||||
|
||||
return {
|
||||
"data": {
|
||||
'x': 'x',
|
||||
'columns': [x_intervals, asset_data, liability_data, equity_data]
|
||||
'columns': columns
|
||||
}
|
||||
}
|
@ -56,17 +56,28 @@ def get_net_profit_loss(income, expense, period_list, company):
|
||||
def get_chart_data(filters, columns, income, expense, net_profit_loss):
|
||||
x_intervals = ['x'] + [d.get("label") for d in columns[2:-1]]
|
||||
|
||||
income_data, expense_data, net_profit = ["Income"], ["Expense"], ["Net Profit/Loss"]
|
||||
income_data, expense_data, net_profit = [], [], []
|
||||
|
||||
for p in columns[2:]:
|
||||
income_data.append(income[-2].get(p.get("fieldname")))
|
||||
expense_data.append(expense[-2].get(p.get("fieldname")))
|
||||
net_profit.append(net_profit_loss.get(p.get("fieldname")))
|
||||
if income:
|
||||
income_data.append(income[-2].get(p.get("fieldname")))
|
||||
if expense:
|
||||
expense_data.append(expense[-2].get(p.get("fieldname")))
|
||||
if net_profit_loss:
|
||||
net_profit.append(net_profit_loss.get(p.get("fieldname")))
|
||||
|
||||
columns = [x_intervals]
|
||||
if income_data:
|
||||
columns.append(["Income"] + income_data)
|
||||
if expense_data:
|
||||
columns.append(["Expense"] + expense_data)
|
||||
if net_profit:
|
||||
columns.append(["Net Profit/Loss"] + net_profit)
|
||||
|
||||
chart = {
|
||||
"data": {
|
||||
'x': 'x',
|
||||
'columns': [x_intervals, income_data, expense_data, net_profit]
|
||||
'columns': columns
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user