summaryrefslogtreecommitdiff
path: root/controller.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--controller.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/controller.py b/controller.py
index 4e488dd..b853f2a 100644
--- a/controller.py
+++ b/controller.py
@@ -32,18 +32,14 @@ class Show:
month = int(month)
ssum = sql.functions.sum(SingleExpense.expense)
- csum = sql.functions.sum(ConstExpense.monthly)
+ query = SingleExpense.of_month(month, year)
- query = SingleExpense.of_month(month, year).\
- group_by(SingleExpense.category_id).\
- values(SingleExpense.category_id, ssum)
+ result = query.group_by(SingleExpense.category_id).\
+ values(SingleExpense.category_id, ssum)
- exps = [CatExpense(Category.query.get(c), s) for c,s in query]
+ exps = [CatExpense(Category.query.get(c), s, query.filter(SingleExpense.category_id == c)) for c,s in result]
- consts = ConstExpense.of_month(month, year).value(csum)
- if consts is None: consts = 0
-
- return MonthExpense(datetime.date(int(year), int(month), 1), consts, exps)
+ return MonthExpense(datetime.date(int(year), int(month), 1), exps)
def render(self, exps):
return render("show", exps = exps)