From 50fe80969b9ddbfa795b11e303430d58a8e10a8c Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 16 Mar 2015 22:31:32 -0400 Subject: added expense tracking app --- app/lib/templatetags/templatetags/expense_total.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/lib/templatetags/templatetags/expense_total.py (limited to 'app/lib') diff --git a/app/lib/templatetags/templatetags/expense_total.py b/app/lib/templatetags/templatetags/expense_total.py new file mode 100644 index 0000000..8bf0953 --- /dev/null +++ b/app/lib/templatetags/templatetags/expense_total.py @@ -0,0 +1,25 @@ +from decimal import Decimal +from django import template +from django.utils.safestring import mark_safe +register = template.Library() + +@register.filter +def expense_total(values): + """ + converts spaces to hyphens. + """ + total = 0 + for items in values: + for item in items['list']: + total += Decimal(item.amount) + return mark_safe(total) + +@register.filter +def cat_total(values): + """ + converts spaces to hyphens. + """ + total = 0 + for val in values: + total += Decimal(val.amount) + return mark_safe(total) -- cgit v1.2.3-70-g09d2