diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2010-05-04 19:12:16 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2010-05-04 19:12:16 +0200 |
commit | 3e71abd8b5ab5fb17efc47d92792222e58498078 (patch) | |
tree | 7620606c75e4dd8cb5e6130bb90a63c9d61c980f | |
parent | 3d2743ae2097e08adf106ccef735ef9f7147c57c (diff) | |
download | kosten-3e71abd8b5ab5fb17efc47d92792222e58498078.tar.gz kosten-3e71abd8b5ab5fb17efc47d92792222e58498078.tar.bz2 kosten-3e71abd8b5ab5fb17efc47d92792222e58498078.zip |
Revert "Splitup date fields"
This reverts commit 3d2743ae2097e08adf106ccef735ef9f7147c57c.
Diffstat (limited to '')
-rw-r--r-- | model.py | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -52,9 +52,10 @@ class Expense (Entity): category = ManyToOne('Category', required = True, innerjoin = True) class SingleExpense (Expense): - year = ReqField(T.Integer) - month = ReqField(T.SmallInteger) - day = ReqField(T.SmallInteger) + date = ReqField(T.Date) + + year = ColumnProperty(lambda c: sql.extract('year', c.date)) + month = ColumnProperty(lambda c: sql.extract('month', c.date)) @classmethod def of_month (cls, month, year): @@ -65,17 +66,21 @@ class SingleExpense (Expense): return cls.query.filter(comp) class ConstExpense (Expense): - months = ReqField(T.SmallInteger) - start_year = ReqField(T.Integer) - start_month = ReqField(T.SmallInteger) - end_year = ReqField(T.Integer) - end_month = ReqField(T.SmallInteger) + months = ReqField(T.Integer) + start = ReqField(T.Date) + end = ReqField(T.Date) next = OneToOne('ConstExpense', inverse = 'prev') prev = ManyToOne('ConstExpense') monthly = ColumnProperty(lambda c: sql.cast(c.expense / c.months, ExpNum), deferred = True) + start_year = ColumnProperty(lambda c: sql.extract('year', c.start)) + start_month = ColumnProperty(lambda c: sql.extract('month', c.start)) + + end_year = ColumnProperty(lambda c: sql.extract('year', c.end)) + end_month = ColumnProperty(lambda c: sql.extract('month', c.end)) + @classmethod def of_month (cls, month, year): c1 = sql.or_( |