summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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_(