Changeset - 3651d7a7fb2a
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2019-12-16 20:16:00
brettcsmith@brettcsmith.org
templatetags: Don't let the donation amount go negative.

To account for ticket vouchers.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
pinaxcon/templatetags/nbpy_tags.py
Show inline comments
...
 
@@ -29,25 +29,25 @@ def vat_rate():
 
def donation_income(context, invoice):
 
    ''' Calculates the donation income for a given invoice.
 

	
 
    Returns:
 
        the donation income.
 

	
 
    '''
 

	
 
    tickets = inventory.Product.objects.filter(category__id=settings.TICKET_PRODUCT_CATEGORY)
 
    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)
 

	
 

	
 
# TODO: include van/de/van der/de la/etc etc etc
 

	
 
@register.simple_tag
 
def name_split(name, split_characters=None):
 

	
 
    tokens = name.split()
 
    if split_characters is None or len(name) > split_characters:
 
        even_split = int((len(tokens) + 1) / 2)  # Round up.
0 comments (0 inline, 0 general)