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.

applicator.py 677B

12345678910111213141516171819202122
  1. from decimal import Decimal as D
  2. from oscar.apps.checkout.applicator import (
  3. SurchargeApplicator as BaseSurchargeApplicator)
  4. from oscar.apps.checkout.surcharges import FlatCharge
  5. class SurchargeApplicator(BaseSurchargeApplicator):
  6. def get_surcharges(self, basket, **kwargs):
  7. return (
  8. FlatCharge(excl_tax=D("10.0"), incl_tax=D("10.0")),
  9. FlatCharge(excl_tax=D("10.0"), incl_tax=D("12.0")),
  10. )
  11. def is_applicable(self, surcharge, basket, **kwargs):
  12. if surcharge.incl_tax > surcharge.excl_tax:
  13. if basket.is_tax_known:
  14. return True
  15. else:
  16. return True
  17. return False