[billreminder] Initial work to fetch categories total expense for reporting.
- From: Og B. Maciel <ogmaciel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [billreminder] Initial work to fetch categories total expense for reporting.
- Date: Tue, 24 Nov 2009 18:21:22 +0000 (UTC)
commit a1bd953da98f55eb40ae9dd88ff62d76ad758e34
Author: Og B. Maciel <ogmaciel gnome org>
Date: Tue Nov 24 13:04:14 2009 -0500
Initial work to fetch categories total expense for reporting.
src/lib/actions.py | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/lib/actions.py b/src/lib/actions.py
index 6a87f11..537a729 100644
--- a/src/lib/actions.py
+++ b/src/lib/actions.py
@@ -48,28 +48,27 @@ class Actions(object):
Return a list of categories and totals for the given month
"""
- total = 0.00
+ records = []
firstDay = scheduler.first_of_month(month, year)
lastDay = scheduler.last_of_month(month, year)
try:
session = self.dal.Session()
- # records is a tuple of type Decimal
- q = session.query(func.sum(Bill.amount)).filter(Bill.dueDate >= dt).filter(Bill.dueDate <= to)
+ # records is a tuple of Category.name and total as type Decimal
+ q = session.query(Category.name, func.sum(Bill.amount)).select_from(outerjoin(Bill, Category)).filter(Bill.dueDate >= dt).filter(Bill.dueDate <= to).group_by(Category.name)
+
if paid:
q = q.filter(Bill.paid == paid)
- # Got anything back?
- if q.count():
- # Result is of type Decimal and needs to be converted.
- total = float(q.one()[0])
+
+ records = q.all()
except Exception, e:
print str(e)
pass
finally:
session.close()
- return total
+ return records
def get_monthly_bills(self, month, year, paid=None):
"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]