You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

calculators.py 1.1KB

12345678910111213141516171819202122232425262728
  1. class OrderTotalCalculator(object):
  2. u"""Calculator class for calculating the order total."""
  3. def __init__(self, request):
  4. # We store a reference to the request as the total may
  5. # depend on the user or the other checkout data in the session.
  6. # Further, it is very likely that it will as shipping method
  7. # always changes the order total.
  8. self.request = request
  9. def order_total_incl_tax(self, basket, shipping_method=None):
  10. u"""Return order total including tax"""
  11. # Default to returning the total including tax - use
  12. # the request.user object if you want to not charge tax
  13. # to particular customers.
  14. total = basket.total_incl_tax
  15. if shipping_method:
  16. total += shipping_method.basket_charge_incl_tax()
  17. return total
  18. def order_total_excl_tax(self, basket, shipping_method=None):
  19. u"""Return order total excluding tax"""
  20. total = basket.total_excl_tax
  21. if shipping_method:
  22. total += shipping_method.basket_charge_excl_tax()
  23. return total