Skip to content

Commit

Permalink
issue #178 - update budget transactions by month Ajax data to handle …
Browse files Browse the repository at this point in the history
…split-budget Transactions
  • Loading branch information
jantman committed Mar 11, 2018
1 parent 517b41c commit 9f1bb94
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions biweeklybudget/flaskapp/views/budgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,17 @@ def _by_month(self):
),
Transaction.date.__le__(dt_now)
).all():
if t.budget_transactions[0].budget_id not in budget_names:
continue
budg_name = t.budget_transactions[0].budget.name
budgets_present.add(budg_name)
ds = t.date.strftime('%Y-%m')
if ds not in records:
records[ds] = {'date': ds}
if budg_name not in records[ds]:
records[ds][budg_name] = Decimal('0')
records[ds][budg_name] += t.budget_transactions[0].amount
for bt in t.budget_transactions:
if bt.budget_id not in budget_names:
continue
budg_name = bt.budget.name
budgets_present.add(budg_name)
ds = t.date.strftime('%Y-%m')
if ds not in records:
records[ds] = {'date': ds}
if budg_name not in records[ds]:
records[ds][budg_name] = Decimal('0')
records[ds][budg_name] += bt.amount
result = [records[k] for k in sorted(records.keys())]
res = {
'data': result,
Expand Down

0 comments on commit 9f1bb94

Please sign in to comment.