summaryrefslogtreecommitdiff
path: root/model.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-05-04 18:29:34 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-05-04 18:29:34 +0200
commit3d2743ae2097e08adf106ccef735ef9f7147c57c (patch)
tree46fe4408f474083087bf510e64fecb0407a54dd5 /model.py
parentdb1ce7022eafa61be72b839dcde5b0a03450e95c (diff)
downloadkosten-3d2743ae2097e08adf106ccef735ef9f7147c57c.tar.gz
kosten-3d2743ae2097e08adf106ccef735ef9f7147c57c.tar.bz2
kosten-3d2743ae2097e08adf106ccef735ef9f7147c57c.zip
Splitup date fields
Diffstat (limited to '')
-rw-r--r--model.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/model.py b/model.py
index 867849f..af2a97e 100644
--- a/model.py
+++ b/model.py
@@ -52,10 +52,9 @@ class Expense (Entity):
category = ManyToOne('Category', required = True, innerjoin = True)
class SingleExpense (Expense):
- date = ReqField(T.Date)
-
- year = ColumnProperty(lambda c: sql.extract('year', c.date))
- month = ColumnProperty(lambda c: sql.extract('month', c.date))
+ year = ReqField(T.Integer)
+ month = ReqField(T.SmallInteger)
+ day = ReqField(T.SmallInteger)
@classmethod
def of_month (cls, month, year):
@@ -66,21 +65,17 @@ class SingleExpense (Expense):
return cls.query.filter(comp)
class ConstExpense (Expense):
- months = ReqField(T.Integer)
- start = ReqField(T.Date)
- end = ReqField(T.Date)
+ months = ReqField(T.SmallInteger)
+ start_year = ReqField(T.Integer)
+ start_month = ReqField(T.SmallInteger)
+ end_year = ReqField(T.Integer)
+ end_month = ReqField(T.SmallInteger)
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_(