diff --git a/core/templates/core/user_account_detail.jinja b/core/templates/core/user_account_detail.jinja index 5c352b3c..19748bd2 100644 --- a/core/templates/core/user_account_detail.jinja +++ b/core/templates/core/user_account_detail.jinja @@ -21,7 +21,8 @@ - {% for i in customer.refillings.order_by('-date').all() %} + {% for i in customer.refillings.order_by('-date').filter( + date__year=year, date__month=month) %} {{ i.date|localtime|date(DATETIME_FORMAT) }} - {{ i.date|localtime|time(DATETIME_FORMAT) }} {{ i.counter }} @@ -51,7 +52,8 @@ - {% for i in customer.buyings.order_by('-date').all() %} + {% for i in customer.buyings.order_by('-date').all().filter( + date__year=year, date__month=month) %} {{ i.date|localtime|date(DATETIME_FORMAT) }} - {{ i.date|localtime|time(DATETIME_FORMAT) }} {{ i.counter }} @@ -79,7 +81,8 @@ - {% for i in customer.user.invoices.order_by('-date').all() %} + {% for i in customer.user.invoices.order_by('-date').all().filter( + date__year=year, date__month=month) %} {{ i.date|localtime|date(DATETIME_FORMAT) }} - {{ i.date|localtime|time(DATETIME_FORMAT) }} diff --git a/core/views/user.py b/core/views/user.py index dc7674cc..39ff5e68 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -328,11 +328,11 @@ class UserAccountView(UserAccountBase): def expense_by_month(self, obj, calc): stats = [] - for year in obj.datetimes('date', 'year', order='ASC'): + for year in obj.datetimes('date', 'year', order='DESC'): stats.append([]) i = 0 for month in obj.filter(date__year=year.year).datetimes( - 'date', 'month', order='ASC'): + 'date', 'month', order='DESC'): q = obj.filter( date__year=month.year, date__month=month.month @@ -391,6 +391,8 @@ class UserAccountDetailView(UserAccountBase, YearMixin, MonthMixin): def get_context_data(self, **kwargs): kwargs = super(UserAccountDetailView, self).get_context_data(**kwargs) kwargs['profile'] = self.object + kwargs['year'] = self.get_year() + kwargs['month'] = self.get_month() try: kwargs['customer'] = self.object.customer except: