summaryrefslogtreecommitdiff
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/templatetags/templatetags/expense_total.py25
1 files changed, 25 insertions, 0 deletions
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)