templatetags: Don't let the donation amount go negative.

To account for ticket vouchers.
This commit is contained in:
Brett Smith 2019-12-16 15:16:00 -05:00
parent 3f6e5ac3d1
commit 3651d7a7fb

View file

@ -38,7 +38,7 @@ def donation_income(context, invoice):
cheapest_ticket = tickets.order_by('price').first() cheapest_ticket = tickets.order_by('price').first()
ticket_rbi = nonvat_price(cheapest_ticket) ticket_rbi = nonvat_price(cheapest_ticket)
return sum( return sum(
(nonvat_price(ticket) - ticket_rbi (max(nonvat_price(ticket) - ticket_rbi, 0)
for ticket in invoice.lineitem_set.filter(product__in=tickets)), for ticket in invoice.lineitem_set.filter(product__in=tickets)),
Decimal(0)).quantize(CENTS_QUANT) Decimal(0)).quantize(CENTS_QUANT)