Ejemplo n.º 1
0
def test_order_total():
    nzhops = Supplier.objects.create(name="NZ Hops")
    cryer = Supplier.objects.create(name="Cryer")
    Surcharge.objects.filter(id=1).update(surcharge_percentage=4.7, order_surcharge=12.70)
    grain = Grain.objects.create(name="munich", unit_cost=12.3, unit_size="sack", supplier=cryer)
    hop = Hop.objects.create(name="saaz", unit_cost=34.4, unit_size="100g", supplier=nzhops)
    total = order_total_incl_gst([grain, hop], [5, 6])
    expected_total = grain.unit_cost * 5 + hop.unit_cost * 6
    expected_total *= 1.047
    expected_total = add_gst(expected_total)
    expected_total += 12.70
    assert_equal(round(expected_total, 3), round(total, 3))
Ejemplo n.º 2
0
def order_total(formset):
    ingredient = lambda id_: get_ingredient(id=id_)
    ingredients = map(ingredient, [int(f['ingredient'].value()) for f in formset])
    quantities = [int(f['quantity'].value()) for f in formset]
    return utils.order_total_incl_gst(ingredients, quantities)