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.

1234567891011121314151617181920212223242526272829303132
  1. class TaxNotKnown(Exception):
  2. """
  3. Exception for when a tax-inclusive price is requested but we don't know
  4. what the tax applicable is (yet).
  5. """
  6. class Price(object):
  7. """
  8. Simple price class that encapsulates a price and its tax information
  9. Attributes:
  10. incl_tax (Decimal): Price including taxes
  11. excl_tax (Decimal): Price excluding taxes
  12. tax (Decimal): Tax amount
  13. is_tax_known (bool): Whether tax is known
  14. currency (str): 3 character currency code
  15. """
  16. def __init__(self, currency, excl_tax, incl_tax=None, tax=None):
  17. self.currency = currency
  18. self.excl_tax = excl_tax
  19. if incl_tax is not None:
  20. self.incl_tax = incl_tax
  21. self.is_tax_known = True
  22. self.tax = incl_tax - excl_tax
  23. elif tax is not None:
  24. self.incl_tax = excl_tax + tax
  25. self.is_tax_known = True
  26. self.tax = tax
  27. else:
  28. self.is_tax_known = False