Files @ f1262837b436
Branch filter:

Location: CopyleftConf/copyleftconf-website/pinaxcon/templatetags/

Christopher Neugebauer
Merge branch 'master' into prod
from registrasion.models import commerce
from registrasion.controllers.category import CategoryController
from registrasion.controllers.item import ItemController

from decimal import Decimal
from django import template
from django.conf import settings
from django.db.models import Sum
from urllib import urlencode  # TODO: s/urllib/six.moves.urllib/

register = template.Library()

def donation_income(context, invoice):
    ''' Calculates the donation income for a given invoice.

        the donation income.


    # 15% (FSA) goes to Conservancy; 85% is real goods

    fsa_rate = Decimal("0.85")
    rbi_full_ticket = Decimal("68.00")
    rbi_early_bird_discount = Decimal("-21.35")
    rbi = []

    for line in invoice.lineitem_set.all():
        if == "Ticket":
            if"Unaffiliated Individual"):
                # Includes full price & discounts
                rbi.append(line.total_price * fsa_rate)
                if line.total_price > 0:
                elif line.total_price < 0:
        elif == "T-Shirt":
            rbi.append(line.total_price * fsa_rate)

    donation = (invoice.value - sum(rbi))
    return donation.quantize(Decimal('.01'))