Skip to content

Commit

Permalink
feat: add default tax handler
Browse files Browse the repository at this point in the history
  • Loading branch information
henri-hulski committed Mar 25, 2022
1 parent b3721ad commit a29598f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cartridge/shop/checkout.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Checkout process utilities.
"""
import decimal

from django.utils.translation import gettext_lazy as _
from mezzanine.accounts import ProfileNotConfigured, get_profile_for_user
from mezzanine.conf import settings
Expand Down Expand Up @@ -48,7 +50,18 @@ def default_tax_handler(request, order_form):
``cartridge.shop.utils.set_tax``. The Cart object is also
accessible via ``request.cart``
"""
set_tax(request, _("Tax"), 0)
settings.clear_cache()
if settings.SHOP_DEFAULT_TAX_RATE:
tax_rate = settings.SHOP_DEFAULT_TAX_RATE.strip("%")
if settings.SHOP_TAX_INCLUDED:
tax = request.cart.total_price() - (
request.cart.total_price() / decimal.Decimal(1 + float(tax_rate) / 100)
)
tax_type = _("Incl.") + " " + tax_rate + "% " + _("VAT")
else:
tax = request.cart.total_price() * decimal.Decimal(float(tax_rate) / 100)
tax_type = _("VAT") + " (" + tax_rate + "%)"
set_tax(request, tax_type, f"{tax:.2f}")


def default_payment_handler(request, order_form, order):
Expand Down

0 comments on commit a29598f

Please sign in to comment.