From 1dcfe174cc6c4281b07eb08d471e28721f5cf334 Mon Sep 17 00:00:00 2001 From: James Kachel Date: Thu, 14 Nov 2024 10:42:46 -0600 Subject: [PATCH] Add tax collection and blocked countries processing (#166) --- cart/templates/cart.html | 44 +- cart/templates/checkout_interstitial.html | 4 +- frontends/api/src/generated/v0/api.ts | 208 +- openapi/apps.py | 4 + openapi/specs/v0.yaml | 45 + payments/admin.py | 82 +- payments/api.py | 118 +- payments/constants.py | 10 + payments/dataclasses.py | 13 + payments/exceptions.py | 7 + payments/factories.py | 25 +- payments/hooks/basket_add.py | 78 + payments/hooks/basket_add_test.py | 183 ++ payments/hookspecs.py | 43 + payments/mail_api.py | 5 + payments/messages.py | 4 + ...counted_price_redeemeddiscount_and_more.py | 4 +- ...ed_country_tax_rate_update_basket_order.py | 218 +++ payments/models.py | 340 +++- payments/models_test.py | 156 ++ payments/tasks.py | 7 +- payments/utils.py | 14 +- payments/utils_test.py | 2 + payments/views/v0/__init__.py | 12 + poetry.lock | 1738 +++++++++-------- pyproject.toml | 17 +- system_meta/models.py | 8 + system_meta/views_test.py | 30 +- unified_ecommerce/celery.py | 3 +- unified_ecommerce/constants.py | 9 + unified_ecommerce/factories.py | 9 +- unified_ecommerce/plugin_manager.py | 2 + unified_ecommerce/settings.py | 20 + unified_ecommerce/test_utils.py | 9 +- unified_ecommerce/utils.py | 50 +- users/__init__.py | 0 users/admin.py | 71 + users/api.py | 122 ++ users/api_test.py | 140 ++ users/apps.py | 10 + users/dataclasses.py | 12 + users/factories.py | 21 + .../migrations/0001_add_userprofile_model.py | 45 + users/migrations/__init__.py | 0 users/models.py | 20 + 45 files changed, 3080 insertions(+), 882 deletions(-) create mode 100644 payments/dataclasses.py create mode 100644 payments/hooks/basket_add.py create mode 100644 payments/hooks/basket_add_test.py create mode 100644 payments/migrations/0009_add_blocked_country_tax_rate_update_basket_order.py create mode 100644 users/__init__.py create mode 100644 users/admin.py create mode 100644 users/api.py create mode 100644 users/api_test.py create mode 100644 users/apps.py create mode 100644 users/dataclasses.py create mode 100644 users/factories.py create mode 100644 users/migrations/0001_add_userprofile_model.py create mode 100644 users/migrations/__init__.py create mode 100644 users/models.py diff --git a/cart/templates/cart.html b/cart/templates/cart.html index 1ec1cf8a..8e115284 100644 --- a/cart/templates/cart.html +++ b/cart/templates/cart.html @@ -21,29 +21,61 @@ Product Price Quantity - Discount code + Discount Code + Subtotal + Tax Total {% if basket_items|length == 0 %} - No items in the basket. + No items in the basket. {% endif %} {% for item in basket_items %} {{ item.product }} - {{ item.product.price }} + {{ item.product.price_money }} {{ item.quantity }} - {{ item.best_discount_for_item_from_basket.discount_code }} - {{ item.price }} + + {% if item.best_discount_for_item_from_basket %} + {{ item.best_discount_for_item_from_basket.discount_code }} + {% endif %} + + + {% if item.best_discount_for_item_from_basket %} + {{ item.discounted_price_money }} + {% endif %} + + + {% if item.basket.tax_rate %} + {{ item.tax_money }} + {% else %} + None + {% endif %} + {{ item.total_price_money }} {% endfor %} - + + Totals: + + + + {{ basket.subtotal }} + + + {{ basket.tax }} + + + {{ basket.total }} + + + + Check Out diff --git a/cart/templates/checkout_interstitial.html b/cart/templates/checkout_interstitial.html index 797288eb..7a9938bf 100644 --- a/cart/templates/checkout_interstitial.html +++ b/cart/templates/checkout_interstitial.html @@ -21,6 +21,8 @@

Redirecting to the payment processor...

+ +
{% else %} {% for key, value in form.items %} @@ -33,7 +35,7 @@

Redirecting to the payment processor...