From 3651d7a7fb2a89ec83c67afa843cda03ee783fbb Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Mon, 16 Dec 2019 15:16:00 -0500 Subject: [PATCH] templatetags: Don't let the donation amount go negative. To account for ticket vouchers. --- pinaxcon/templatetags/nbpy_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinaxcon/templatetags/nbpy_tags.py b/pinaxcon/templatetags/nbpy_tags.py index d360555..c99050d 100644 --- a/pinaxcon/templatetags/nbpy_tags.py +++ b/pinaxcon/templatetags/nbpy_tags.py @@ -38,7 +38,7 @@ def donation_income(context, invoice): cheapest_ticket = tickets.order_by('price').first() ticket_rbi = nonvat_price(cheapest_ticket) return sum( - (nonvat_price(ticket) - ticket_rbi + (max(nonvat_price(ticket) - ticket_rbi, 0) for ticket in invoice.lineitem_set.filter(product__in=tickets)), Decimal(0)).quantize(CENTS_QUANT)