- c.total = self._total()
-
- year = date.today() - timedelta(days=365)
- this_year = date.today().replace(month=1, day=1)
- this_month = date.today().replace(day=1)
- last_month = (date.today() - timedelta(days=30)).replace(day=1)
-
- c.year_total, c.this_year_total, c.this_month_total = \
- [self._total(model.Expenditure.date >= i)
- for i in [year, this_year, this_month]]
+ periods = {}
+ periods['Total'] = (None, None)
+ periods['Past year'] = (date.today() - timedelta(days=365), None)
+ periods['Year to date'] = (date.today().replace(month=1, day=1), None)
+ periods['Month to date'] = (date.today().replace(day=1), None)
+ periods['Last month'] = ((date.today() -
+ timedelta(days=30)).replace(day=1),
+ periods['Month to date'][0])