Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add missing quantize method on checkout in Avatax plugin
Damian Wcde3e89e8a0c
diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.pyindex 644af63aa7..f801cd391e 100644--- a/saleor/plugins/avatax/plugin.py+++ b/saleor/plugins/avatax/plugin.py@@ -7,7 +7,7 @@ from urllib.parse import urljoinfrom django.core.exceptions import ValidationErrorfrom prices import Money, TaxedMoney, TaxedMoneyRange-from ...core.taxes import TaxError, TaxType, zero_taxed_money+from ...core.taxes import TaxError, TaxType, quantize_price, zero_taxed_moneyfrom ...discount import DiscountInfofrom ..base_plugin import BasePlugin, ConfigurationTypeFieldfrom ..error_codes import PluginErrorCode@@ -139,7 +139,8 @@ class AvataxPlugin(BasePlugin):voucher_value = checkout.discountif voucher_value:total -= voucher_value- return max(total, zero_taxed_money(total.currency))+ total = max(total, zero_taxed_money(total.currency))+ return quantize_price(total, total.currency)def _calculate_checkout_subtotal(self, currency: str, lines: List[Dict]@@ -153,7 +154,10 @@ class AvataxPlugin(BasePlugin):sub_net += Decimal(line.get("lineAmount", 0.0))sub_total_gross = Money(sub_net + sub_tax, currency)sub_total_net = Money(sub_net, currency)- return TaxedMoney(net=sub_total_net, gross=sub_total_gross)++ return quantize_price(+ TaxedMoney(net=sub_total_net, gross=sub_total_gross), currency+ )def calculate_checkout_subtotal(self,@@ -168,7 +172,6 @@ class AvataxPlugin(BasePlugin):base_subtotal = previous_valueif not _validate_checkout(checkout):return base_subtotal-response = get_checkout_tax_data(checkout, discounts, self.config)if not response or "error" in response:return base_subtotal@@ -189,7 +192,10 @@ class AvataxPlugin(BasePlugin):shipping_gross = Money(amount=shipping_net + shipping_tax, currency=currency)shipping_net = Money(amount=shipping_net, currency=currency)- return TaxedMoney(net=shipping_net, gross=shipping_gross)++ return quantize_price(+ TaxedMoney(net=shipping_net, gross=shipping_gross), currency+ )def calculate_checkout_shipping(self,diff --git a/tests/plugins/test_avatax.py b/tests/plugins/test_avatax.pyindex 6a04bf5130..16a336a3db 100644--- a/tests/plugins/test_avatax.py+++ b/tests/plugins/test_avatax.py@@ -169,7 +169,6 @@ def test_calculate_checkout_shipping(shipping_price = manager.calculate_checkout_shipping(checkout_with_item, list(checkout_with_item), [discount_info])- shipping_price = quantize_price(shipping_price, shipping_price.currency)assert shipping_price == TaxedMoney(net=Money("8.13", "USD"), gross=Money("10.00", "USD"))