From d9c1052f5e602373d555c05f40c0010c38413407 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 17 Jul 2015 14:33:08 +0200 Subject: [PATCH] Use end of current month as end when not passed. --- accountant/api/models/operations.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accountant/api/models/operations.py b/accountant/api/models/operations.py index 0737b69..e6e2968 100644 --- a/accountant/api/models/operations.py +++ b/accountant/api/models/operations.py @@ -54,6 +54,8 @@ class Operation(db.Model): else: account_id = account.id + end = arrow.now().ceil('month').date() if not end else end + base_query = session.query( cls, case( @@ -123,6 +125,8 @@ class Operation(db.Model): else: account_id = account.id + end = end if end else arrow.now().ceil('month').date() + sold = func.sum(cls.value).over( order_by=[cls.operation_date, desc(cls.value), cls.label] )