Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add taxes to undiscounted order prices (#14095)
Jakuba8e6a4dd55fe
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5473bfae5c..8adc67ebd0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,8 @@ All notable, unreleased changes to this project will be documented in this file.### GraphQL API+- Add taxes to undiscounted prices - #14095 by @jakubkuc+### Saleor Apps### Other changesdiff --git a/saleor/checkout/complete_checkout.py b/saleor/checkout/complete_checkout.pyindex 37890c949e..f7530a25dc 100644--- a/saleor/checkout/complete_checkout.py+++ b/saleor/checkout/complete_checkout.py@@ -88,6 +88,7 @@ from .models import Checkoutfrom .utils import (get_checkout_metadata,get_or_create_checkout_metadata,+ get_taxed_undiscounted_price,get_voucher_for_checkout_info,)@@ -227,12 +228,6 @@ def _create_line_for_order(line_info=checkout_line_info,channel=checkout_info.channel,)- undiscounted_unit_price = TaxedMoney(- net=undiscounted_base_unit_price, gross=undiscounted_base_unit_price- )- undiscounted_total_price = TaxedMoney(- net=undiscounted_base_total_price, gross=undiscounted_base_total_price- )# total price after applying all discounts - sales and voucherstotal_line_price = calculations.checkout_line_total(manager=manager,@@ -253,6 +248,20 @@ def _create_line_for_order(lines=lines,checkout_line_info=checkout_line_info,)+ # unit price before applying discounts+ undiscounted_unit_price = get_taxed_undiscounted_price(+ undiscounted_base_unit_price,+ unit_price,+ tax_rate,+ prices_entered_with_tax,+ )+ # total price before applying discounts+ undiscounted_total_price = get_taxed_undiscounted_price(+ undiscounted_base_total_price,+ total_line_price,+ tax_rate,+ prices_entered_with_tax,+ )voucher_code = Noneif checkout_line_info.voucher:diff --git a/saleor/checkout/tests/test_order_from_checkout.py b/saleor/checkout/tests/test_order_from_checkout.pyindex fc02d54dff..1b113fe54a 100644--- a/saleor/checkout/tests/test_order_from_checkout.py+++ b/saleor/checkout/tests/test_order_from_checkout.py@@ -4,10 +4,11 @@ from unittest import mockimport before_afterimport pytestfrom django.test import override_settings-from prices import TaxedMoney+from prices import Money, TaxedMoneyfrom ...checkout.models import Checkout, CheckoutLinefrom ...core.exceptions import InsufficientStock+from ...core.prices import quantize_pricefrom ...core.taxes import zero_money, zero_taxed_moneyfrom ...giftcard import GiftCardEventsfrom ...giftcard.models import GiftCard, GiftCardEvent@@ -678,6 +679,60 @@ def test_create_order_from_checkout_store_shipping_prices()+def test_create_order_from_checkout_valid_undiscounted_prices(+ checkout_with_items_and_shipping, shipping_method, customer_user, app+):+ # given+ checkout = checkout_with_items_and_shipping+ tc = checkout.channel.tax_configuration+ tc.country_exceptions.all().delete()+ tc.tax_calculation_strategy = "FLAT_RATES"+ tc.prices_entered_with_tax = False+ tc.save()+ line = checkout.lines.first()+ product = line.variant.product+ product.tax_class.country_rates.update_or_create(+ country=checkout.shipping_address.country.code, defaults={"rate": 7.75}+ )+ manager = get_plugins_manager()+ lines, _ = fetch_checkout_lines(checkout)++ checkout_info = fetch_checkout_info(checkout, lines, manager, [])++ # when+ order = create_order_from_checkout(+ checkout_info=checkout_info,+ manager=manager,+ user=None,+ app=app,+ )++ # then+ for line in order.lines.all():+ expected_gross = quantize_price(+ Money((line.base_unit_price.amount * (1 + line.tax_rate)), line.currency),+ line.currency,+ )+ expected_undiscounted_unit_price = TaxedMoney(+ net=line.base_unit_price,+ gross=expected_gross,+ )++ assert line.undiscounted_unit_price == expected_undiscounted_unit_price+ expected_total_gross = quantize_price(+ Money(+ (line.base_unit_price.amount * (1 + line.tax_rate)) * line.quantity,+ line.currency,+ ),+ line.currency,+ )+ expected_undiscounted_total_price = TaxedMoney(+ net=line.base_unit_price * line.quantity,+ gross=expected_total_gross,+ )+ assert line.undiscounted_total_price == expected_undiscounted_total_price++def test_create_order_from_store_shipping_prices_with_free_shipping_voucher(checkout_with_voucher_free_shipping,shipping_method,@@ -793,6 +848,60 @@ def test_note_in_created_order_checkout_deleted_in_the_meantime(assert order is None[email protected]("saleor.checkout.calculations.checkout_line_total")[email protected]("saleor.checkout.calculations.checkout_line_unit_price")+def test_create_order_from_checkout_update_undiscounted_prices_match(+ mock_unit,+ mock_total,+ checkout_with_items_and_shipping,+ shipping_method,+ customer_user,+ app,+):+ # given+ checkout = checkout_with_items_and_shipping+ tc = checkout.channel.tax_configuration+ tc.country_exceptions.all().delete()+ tc.tax_calculation_strategy = "TAX_APP"+ tc.prices_entered_with_tax = False+ tc.save()++ # mock tax app returning different prices than local calculations+ expected_price = TaxedMoney(+ net=Money("35.000", "USD"),+ gross=Money("37.720", "USD"),+ )+ mock_unit.return_value = expected_price+ mock_total.return_value = expected_price++ manager = get_plugins_manager()+ country_code = checkout.shipping_address.country.code+ line = checkout.lines.first()+ line.quantity = 1+ line.save()+ product = line.variant.product+ channel_listing = line.variant.channel_listings.first()++ channel_listing.price = Money("35.000", "USD")+ channel_listing.save()+ product.tax_class.country_rates.update_or_create(+ country=country_code, defaults={"rate": 7.75}+ )+ lines, _ = fetch_checkout_lines(checkout)+ checkout_info = fetch_checkout_info(checkout, lines, manager, [])++ # when+ order = create_order_from_checkout(+ checkout_info=checkout_info,+ manager=manager,+ user=None,+ app=app,+ )+ line = order.lines.first()+ assert line.unit_price == line.undiscounted_unit_price+ assert line.total_price == line.undiscounted_total_price++def test_create_order_product_on_promotion(checkout_with_item_on_promotion,customer_user,diff --git a/saleor/checkout/tests/test_utils.py b/saleor/checkout/tests/test_utils.pynew file mode 100644index 0000000000..7667303e0c--- /dev/null+++ b/saleor/checkout/tests/test_utils.py@@ -0,0 +1,52 @@+from decimal import Decimal++import pytest+from prices import Money, TaxedMoney++from ..utils import get_taxed_undiscounted_price++BASE = Money("35.00", "USD")+++ ("price", "tax_rate", "prices_entered_with_tax", "result"),+ [+ # result should not be calculated but taken from price+ (+ TaxedMoney(gross=Money("43.74", "USD"), net=BASE),+ Decimal(0.25),+ False,+ TaxedMoney(gross=Money("43.74", "USD"), net=BASE),+ ),+ # result should be calculated and different from price+ (+ TaxedMoney(gross=Money("43.74", "USD"), net=Money("36.00", "USD")),+ Decimal(0.25),+ False,+ TaxedMoney(gross=Money("43.75", "USD"), net=BASE),+ ),+ # result should not be calculated and taken from price+ (+ TaxedMoney(gross=BASE, net=Money("26.26", "USD")),+ Decimal(0.25),+ True,+ TaxedMoney(gross=BASE, net=Money("26.26", "USD")),+ ),+ # result should be calculated and different from price+ (+ TaxedMoney(gross=Money("36.00", "USD"), net=Money("26.26", "USD")),+ Decimal(0.25),+ True,+ TaxedMoney(gross=BASE, net=Money("28.00", "USD")),+ ),+ ],+)+def test_get_taxed_undiscounted_price(price, tax_rate, prices_entered_with_tax, result):+ result_price = get_taxed_undiscounted_price(+ undiscounted_base_price=BASE,+ price=price,+ tax_rate=tax_rate,+ prices_entered_with_tax=prices_entered_with_tax,+ )++ assert result_price == resultdiff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 8af0a461d2..f123d8302f 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -7,10 +7,11 @@ import graphenefrom django.core.exceptions import ValidationErrorfrom django.db.models import prefetch_related_objectsfrom django.utils import timezone-from prices import Money+from prices import Money, TaxedMoneyfrom ..account.models import Userfrom ..core.exceptions import ProductNotPublished+from ..core.prices import quantize_pricefrom ..core.taxes import zero_taxed_moneyfrom ..core.utils.promo_code import (InvalidPromoCode,@@ -36,6 +37,7 @@ from ..product import models as product_modelsfrom ..shipping.interface import ShippingMethodDatafrom ..shipping.models import ShippingMethod, ShippingMethodChannelListingfrom ..shipping.utils import convert_to_shipping_method_data+from ..tax.calculations import calculate_flat_rate_taxfrom ..warehouse.availability import check_stock_and_preorder_quantityfrom ..warehouse.models import Warehousefrom ..warehouse.reservations import reserve_stocks_and_preorders@@ -960,3 +962,27 @@ def get_checkout_metadata(checkout: "Checkout"):return checkout.metadata_storageelse:return CheckoutMetadata(checkout=checkout)+++def get_taxed_undiscounted_price(+ undiscounted_base_price: "Money",+ price: "TaxedMoney",+ tax_rate: "Decimal",+ prices_entered_with_tax: bool,+):+ """Apply taxes to undiscounted base price.++ This function also prevents rounding difference between prices from tax-app and+ local calculations based on tax_rate that might occur in orders without discounts.+ """+ price_to_compare = price.gross if prices_entered_with_tax else price.net+ if undiscounted_base_price == price_to_compare:+ return price+ return quantize_price(+ calculate_flat_rate_tax(+ money=undiscounted_base_price,+ tax_rate=tax_rate * 100,+ prices_entered_with_tax=prices_entered_with_tax,+ ),+ undiscounted_base_price.currency,+ )diff --git a/saleor/graphql/order/tests/queries/test_order.py b/saleor/graphql/order/tests/queries/test_order.pyindex 6af07f1da4..3fe9498bd5 100644--- a/saleor/graphql/order/tests/queries/test_order.py+++ b/saleor/graphql/order/tests/queries/test_order.py@@ -100,6 +100,9 @@ query OrdersQuery {gross{amount}+ net{+ amount+ }}}discounts{@@ -918,10 +921,15 @@ def test_order_line_discount_query(unit_discount_amount = quantize_price(Decimal(line_with_discount["unitDiscount"]["amount"]), currency=order.currency)- undiscounted_unit_price = quantize_price(++ undiscounted_unit_price_gross = quantize_price(Decimal(line_with_discount["undiscountedUnitPrice"]["gross"]["amount"]),currency=order.currency,)+ undiscounted_unit_price_net = quantize_price(+ Decimal(line_with_discount["undiscountedUnitPrice"]["net"]["amount"]),+ currency=order.currency,+ )expected_unit_price_gross_amount = quantize_price(line.unit_price.gross.amount, currency=order.currency@@ -929,13 +937,21 @@ def test_order_line_discount_query(expected_unit_discount_amount = quantize_price(line.unit_discount.amount, currency=order.currency)- expected_undiscounted_unit_price = quantize_price(+ expected_undiscounted_unit_price_gross = quantize_price(line.undiscounted_unit_price.gross.amount, currency=order.currency)+ expected_calculated_gross = quantize_price(+ line.undiscounted_unit_price.net.amount * (line.tax_rate + 1), line.currency+ )+ expected_undiscounted_unit_price_net = quantize_price(+ line.undiscounted_unit_price.net.amount, currency=order.currency+ )assert unit_gross_amount == expected_unit_price_gross_amountassert unit_discount_amount == expected_unit_discount_amount- assert undiscounted_unit_price == expected_undiscounted_unit_price+ assert undiscounted_unit_price_gross == expected_undiscounted_unit_price_gross+ assert undiscounted_unit_price_net == expected_undiscounted_unit_price_net+ assert undiscounted_unit_price_gross == expected_calculated_grossdef test_order_query_in_pln_channel(diff --git a/saleor/graphql/order/tests/queries/test_order_line.py b/saleor/graphql/order/tests/queries/test_order_line.pyindex 82141c826e..cb09c6b6b2 100644--- a/saleor/graphql/order/tests/queries/test_order_line.py+++ b/saleor/graphql/order/tests/queries/test_order_line.py@@ -1,9 +1,13 @@-from unittest.mock import MagicMock+from decimal import Decimal+from unittest.mock import MagicMock, patchimport graphenefrom django.core.files import File-from prices import Money+from prices import Money, TaxedMoney+from .....core.prices import quantize_price+from .....order import OrderStatus+from .....order.interface import OrderTaxedPricesDatafrom .....thumbnail.models import Thumbnailfrom .....warehouse.models import Stockfrom ....core.enums import ThumbnailFormatEnum@@ -639,3 +643,117 @@ def test_order_line_tax_class_query_by_app(content = get_graphql_content(response)order_data = content["data"]["orders"]["edges"][0]["node"]assert order_data["lines"][0]["taxClass"]["id"]+++UNDISCOUNTED_PRICE_QUERY = """+ query OrdersQuery {+ orders(first: 1) {+ edges {+ node {+ lines {+ undiscountedUnitPrice {+ net {+ amount+ }+ gross {+ amount+ }+ }+ }+ }+ }+ }+ }+"""+++@patch("saleor.plugins.manager.PluginsManager.calculate_order_line_unit")+def test_order_query_undiscounted_prices_taxed(+ mocked_calculate_order_line_unit,+ staff_api_client,+ permission_group_all_perms_all_channels,+ fulfilled_order,+):+ # given++ order = fulfilled_order+ query = UNDISCOUNTED_PRICE_QUERY+ order.status = OrderStatus.UNCONFIRMED+ order.should_refresh_prices = True+ order.save(update_fields=["status", "should_refresh_prices"])+ tc = order.channel.tax_configuration+ tc.prices_entered_with_tax = False+ tc.save(update_fields=["prices_entered_with_tax"])+ line = order.lines.first()+ tax_rate = line.tax_rate+ permission_group_all_perms_all_channels.user_set.add(staff_api_client.user)++ line_undiscounted_price = TaxedMoney(+ line.undiscounted_base_unit_price,+ line.undiscounted_base_unit_price * (1 + tax_rate),+ )+ mocked_calculate_order_line_unit.return_value = OrderTaxedPricesData(+ undiscounted_price=line_undiscounted_price,+ price_with_discounts=line_undiscounted_price,+ )++ # set gross the same as net as to make sure prices were recalculated+ line.undiscounted_unit_price_gross_amount = line.undiscounted_unit_price_net_amount+ line.save(update_fields=["undiscounted_unit_price_gross_amount"])++ # when+ response = staff_api_client.post_graphql(query)++ # then++ content = get_graphql_content(response)+ order_data = content["data"]["orders"]["edges"][0]["node"]+ first_order_data_line_price = order_data["lines"][0]["undiscountedUnitPrice"]+ assert first_order_data_line_price["net"]["amount"] == line.unit_price.net.amount++ expected_gross = quantize_price(+ line.unit_price.net.amount * (tax_rate + 1), line.currency+ )+ result_gross = quantize_price(+ Decimal(first_order_data_line_price["gross"]["amount"]), line.currency+ )+ assert result_gross == expected_gross+++def test_order_query_undiscounted_prices_no_tax(+ staff_api_client, permission_group_all_perms_all_channels, order_with_lines+):+ # given+ order = order_with_lines+ query = UNDISCOUNTED_PRICE_QUERY+ order.status = OrderStatus.UNCONFIRMED+ order.should_refresh_prices = True+ order.save(update_fields=["status", "should_refresh_prices"])+ tc = order.channel.tax_configuration+ tc.country_exceptions.all().delete()+ tc.prices_entered_with_tax = False+ tc.tax_calculation_strategy = None+ tc.charge_taxes = False+ tc.save(+ update_fields=[+ "prices_entered_with_tax",+ "tax_calculation_strategy",+ "charge_taxes",+ ]+ )++ line = order.lines.first()+ line.undiscounted_unit_price_gross_amount = line.undiscounted_unit_price_net_amount+ line.tax_rate = Decimal(0)+ line.save()++ permission_group_all_perms_all_channels.user_set.add(staff_api_client.user)+ # when+ response = staff_api_client.post_graphql(query)++ # then+ content = get_graphql_content(response)+ order_data = content["data"]["orders"]["edges"][0]["node"]+ first_order_data_line_price = order_data["lines"][0]["undiscountedUnitPrice"]+ assert first_order_data_line_price["net"]["amount"] == line.unit_price.net.amount+ assert first_order_data_line_price["gross"]["amount"] == line.unit_price.net.amountdiff --git a/saleor/order/calculations.py b/saleor/order/calculations.pyindex 2303305d36..ebe93daed9 100644--- a/saleor/order/calculations.py+++ b/saleor/order/calculations.py@@ -13,6 +13,7 @@ from ..order import base_calculationsfrom ..payment.model_helpers import get_subtotalfrom ..plugins.manager import PluginsManagerfrom ..tax import TaxCalculationStrategy+from ..tax.calculations import calculate_flat_rate_taxfrom ..tax.calculations.order import update_order_prices_with_flat_ratesfrom ..tax.utils import (calculate_tax_rate,@@ -27,7 +28,10 @@ from .models import Order, OrderLinedef _recalculate_order_prices(- manager: PluginsManager, order: Order, lines: Iterable[OrderLine]+ manager: PluginsManager,+ order: Order,+ lines: Iterable[OrderLine],+ prices_entered_with_tax: bool,) -> None:"""Fetch taxes from plugins and recalculate order/lines prices.@@ -46,19 +50,23 @@ def _recalculate_order_prices(line_unit = manager.calculate_order_line_unit(order, line, variant, product)- line.undiscounted_unit_price = line_unit.undiscounted_priceline.unit_price = line_unit.price_with_discountsline_total = manager.calculate_order_line_total(order, line, variant, product)- line.undiscounted_total_price = line_total.undiscounted_priceundiscounted_subtotal += line_total.undiscounted_priceline.total_price = line_total.price_with_discountsline.tax_rate = manager.get_order_line_tax_rate(order, product, variant, None, line_unit.undiscounted_price)+ line.undiscounted_unit_price = get_undiscounted_price(+ line_unit, line.tax_rate, prices_entered_with_tax, line.currency+ )+ line.undiscounted_total_price = get_undiscounted_price(+ line_total, line.tax_rate, prices_entered_with_tax, line.currency+ )except TaxError:pass@@ -75,6 +83,26 @@ def _recalculate_order_prices(order.total = manager.calculate_order_total(order, lines)+def get_undiscounted_price(+ line_price: OrderTaxedPricesData, tax_rate, prices_entered_with_tax, currency+):+ if (+ tax_rate > 0+ and line_price.undiscounted_price.net == line_price.undiscounted_price.gross+ ):+ return quantize_price(+ calculate_flat_rate_tax(+ # It is calculated when net and gross are equal+ money=line_price.undiscounted_price.net,+ tax_rate=tax_rate,+ prices_entered_with_tax=prices_entered_with_tax,+ ),+ currency,+ )+ else:+ return line_price.undiscounted_price++def _update_order_discounts_and_base_undiscounted_total(order: Order, lines: Iterable[OrderLine]):@@ -309,7 +337,7 @@ def _calculate_and_add_tax(prices_entered_with_tax: bool,):if tax_calculation_strategy == TaxCalculationStrategy.TAX_APP:- _recalculate_order_prices(manager, order, lines)+ _recalculate_order_prices(manager, order, lines, prices_entered_with_tax)tax_data = manager.get_taxes_for_order(order)_apply_tax_data(order, lines, tax_data)else:diff --git a/saleor/order/tests/test_calculations.py b/saleor/order/tests/test_calculations.pyindex 746f9bcfd8..209c470b3f 100644--- a/saleor/order/tests/test_calculations.py+++ b/saleor/order/tests/test_calculations.py@@ -28,15 +28,19 @@ def order_lines(order_with_lines):@pytest.fixturedef tax_data(order_with_lines, order_lines):order = order_with_lines- tax_rate = Decimal("1.23")- shipping_tax_rate = Decimal("1.17")+ tax_rate = Decimal("0.23")+ shipping_tax_rate = Decimal("0.17")lines = []for i, line in enumerate(order_lines, start=1):line_tax_rate = tax_rate + Decimal(f"{i}") / 100lines.append(TaxLineData(- total_net_amount=line.total_price.net.amount,- total_gross_amount=line.total_price.net.amount * line_tax_rate,+ total_net_amount=quantize_price(+ line.total_price.net.amount, line.currency+ ),+ total_gross_amount=quantize_price(+ line.total_price.net.amount * (1 + line_tax_rate), line.currency+ ),tax_rate=line_tax_rate,))@@ -100,7 +104,7 @@ def test_recalculate_order_prices(order_with_lines, order_lines, tax_data):)# when- calculations._recalculate_order_prices(manager, order, lines)+ calculations._recalculate_order_prices(manager, order, lines, False)# thenassert order.total == total@@ -110,10 +114,20 @@ def test_recalculate_order_prices(order_with_lines, order_lines, tax_data):for line_unit, line_total, tax_rate, line in zip(unit_prices, total_prices, tax_rates, lines):+ undiscounted_unit_gross = line_unit.undiscounted_price.net.amount * (+ tax_rate + 1+ )+ undiscounted_total_gross = line_total.undiscounted_price.net.amount * (+ tax_rate + 1+ )assert line.unit_price == line_unit.price_with_discounts+ assert line.undiscounted_unit_price.net == line_unit.undiscounted_price.net+ assert line.undiscounted_unit_price.gross.amount == undiscounted_unit_grossassert line.undiscounted_unit_price == line_unit.undiscounted_priceassert line.total_price == line_total.price_with_discountsassert line.undiscounted_total_price == line_total.undiscounted_price+ assert line.undiscounted_total_price.net == line_total.undiscounted_price.net+ assert line.undiscounted_total_price.gross.amount == undiscounted_total_grossassert tax_rate == line.tax_rate@@ -149,7 +163,7 @@ def test_recalculate_order_prices_tax_error(manager = Mock(**manager_methods)# when- calculations._recalculate_order_prices(manager, order, lines)+ calculations._recalculate_order_prices(manager, order, lines, False)# then# no exception is raised@@ -200,7 +214,7 @@ def test_recalculate_order_prices_tax_error_line_prices()# when- calculations._recalculate_order_prices(manager, order, lines)+ calculations._recalculate_order_prices(manager, order, lines, False)# thenassert order.total == total@@ -216,10 +230,20 @@ def test_recalculate_order_prices_tax_error_line_prices(for line_unit, line_total, tax_rate, line in list(zip(unit_prices, total_prices, tax_rates, lines))[1:]:+ undiscounted_unit_gross = line_unit.undiscounted_price.net.amount * (+ tax_rate + 1+ )+ undiscounted_total_gross = line_total.undiscounted_price.net.amount * (+ tax_rate + 1+ )assert line.unit_price == line_unit.price_with_discounts+ assert line.undiscounted_unit_price.net == line_unit.undiscounted_price.net+ assert line.undiscounted_unit_price.gross.amount == undiscounted_unit_grossassert line.undiscounted_unit_price == line_unit.undiscounted_priceassert line.total_price == line_total.price_with_discountsassert line.undiscounted_total_price == line_total.undiscounted_price+ assert line.undiscounted_total_price.net == line_total.undiscounted_price.net+ assert line.undiscounted_total_price.gross.amount == undiscounted_total_grossassert tax_rate == line.tax_rate@@ -263,7 +287,7 @@ def test_recalculate_order_prices_tax_error_shipping_price()# when- calculations._recalculate_order_prices(manager, order, lines)+ calculations._recalculate_order_prices(manager, order, lines, False)# thenassert order.total == subtotal + old_shipping_price@@ -273,10 +297,20 @@ def test_recalculate_order_prices_tax_error_shipping_price(for line_unit, line_total, tax_rate, line in zip(unit_prices, total_prices, tax_rates, lines):+ undiscounted_unit_gross = line_unit.undiscounted_price.net.amount * (+ tax_rate + 1+ )+ undiscounted_total_gross = line_total.undiscounted_price.net.amount * (+ tax_rate + 1+ )assert line.unit_price == line_unit.price_with_discounts+ assert line.undiscounted_unit_price.net == line_unit.undiscounted_price.net+ assert line.undiscounted_unit_price.gross.amount == undiscounted_unit_grossassert line.undiscounted_unit_price == line_unit.undiscounted_priceassert line.total_price == line_total.price_with_discountsassert line.undiscounted_total_price == line_total.undiscounted_price+ assert line.undiscounted_total_price.net == line_total.undiscounted_price.net+ assert line.undiscounted_total_price.gross.amount == undiscounted_total_grossassert tax_rate == line.tax_rate@@ -341,7 +375,7 @@ def test_recalculate_order_prices_order_discounts_and_total_undiscounted_price_c)# when- calculations._recalculate_order_prices(manager, order, lines)+ calculations._recalculate_order_prices(manager, order, lines, False)# thenorder_discount.refresh_from_db()