summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-05-04 16:37:11 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-05-04 16:37:11 +0200
commit7861d3979a91e739522150667171611987856e9b (patch)
treef4ebd333dbc9e7a7555a11933e685331e94fb147
parentfc2b648989cd5afaff3c563dea739e90c19be331 (diff)
downloadkosten-7861d3979a91e739522150667171611987856e9b.tar.gz
kosten-7861d3979a91e739522150667171611987856e9b.tar.bz2
kosten-7861d3979a91e739522150667171611987856e9b.zip
Constant expenses should only be regarded with their monthly part
Diffstat (limited to '')
-rw-r--r--controller.py2
-rw-r--r--model.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/controller.py b/controller.py
index 0957692..73f0fc8 100644
--- a/controller.py
+++ b/controller.py
@@ -27,7 +27,7 @@ class Show:
def calc(self, year, month):
ssum = sql.functions.sum(SingleExpense.expense)
- csum = sql.functions.sum(ConstExpense.expense)
+ csum = sql.functions.sum(ConstExpense.monthly)
query = SingleExpense.of_month(month, year).\
group_by(SingleExpense.category_id).\
diff --git a/model.py b/model.py
index d37bf62..0d2489a 100644
--- a/model.py
+++ b/model.py
@@ -72,7 +72,7 @@ class ConstExpense (Expense):
next = OneToOne('ConstExpense', inverse = 'prev')
prev = ManyToOne('ConstExpense')
- monthly = ColumnProperty(lambda c: c.expense / c.months, deferred = True)
+ monthly = ColumnProperty(lambda c: sql.cast(c.expense / c.months, T.Numeric(scale = 2)), deferred = True)
start_year = ColumnProperty(lambda c: sql.extract('year', c.start))
start_month = ColumnProperty(lambda c: sql.extract('month', c.start))