Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Simple (flat rate) taxes API (#9784)

Marcin Gębala67df28935c55
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c572cefdf..1a88e41bc5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,12 +4,33 @@ All notable, unreleased changes to this project will be documented in this file.
# 3.9.0 [Unreleased]
+### Highlights
+
+- Flat tax rates - #9784 by @maarcingebala
+
+### Breaking changes
+
+- Drop Vatlayer plugin - #9784 by @maarcingebala
+ - The following fields are no longer used:
+ - `Product.chargeTaxes` - from now on, presence of `Product.taxClass` instance decides whether to charge taxes for a product. As a result, the "Charge Taxes" column in CSV product exports returns empty values.
+ - `Shop.chargeTaxesOnShipping` - from now on, presence of `ShippingMethod.taxClass` decides whether to charge taxes for a shipping method.
+ - `Shop.includeTaxesInPrices`, `Shop.displayGrossPrices` - configuration moved to `Channel.taxConfiguration`.
+ - Removed the following plugin manager methods:
+ - `assign_tax_code_to_object_meta`
+ - `apply_taxes_to_product`
+ - `fetch_taxes_data`
+ - `get_tax_rate_percentage_value`
+ - `update_taxes_for_order_lines`
+
+### GraphQL API
+
+- Add `attribute` field to `AttributeValueTranslatableContent` type. #11028 by @zedzior
+
+### Other changes
+
- Re-enable 5 minute database connection persistence by default - #11074 + #11100 by @NyanKiyoshi
<br/>Set `DB_CONN_MAX_AGE=0` to disable this behavior (adds overhead to requests)
- Bump cryptography to 38.0.3: use OpenSSL 3.0.7 - #11126 by @NyanKiyoshi
-- Add `attribute` field to `AttributeValueTranslatableContent` type. #11028 by @zedzior
-
-...
# 3.8.0
@@ -52,6 +73,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Add `iss` field to JWT tokens - #10842 by @korycins
- Drop `py` and `tox` dependencies from dev requirements - #11054 by @NyanKiyoshi
+
### Saleor Apps
- Add `iss` field to JWT tokens - #10842 by @korycins
diff --git a/conftest.py b/conftest.py
index c06c726f48..5910dfeb27 100644
--- a/conftest.py
+++ b/conftest.py
@@ -19,6 +19,7 @@ pytest_plugins = [
"saleor.graphql.giftcard.tests.benchmark.fixtures",
"saleor.graphql.webhook.tests.benchmark.fixtures",
"saleor.plugins.webhook.tests.subscription_webhooks.fixtures",
+ "saleor.tax.tests.fixtures",
]
if os.environ.get("PYTEST_DB_URL"):
diff --git a/poetry.lock b/poetry.lock
index bfd79734ad..f80e034739 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -86,7 +86,7 @@ python-versions = ">=3.5"
dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"]
docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"]
tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "zope.interface"]
-tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"]
+tests_no_zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"]
[[package]]
name = "authlib"
@@ -408,7 +408,7 @@ optional = false
python-versions = ">=3.6.0"
[package.extras]
-unicode-backport = ["unicodedata2"]
+unicode_backport = ["unicodedata2"]
[[package]]
name = "click"
@@ -1229,7 +1229,7 @@ text-unidecode = "*"
[package.extras]
dev = ["black (==19.10b0)", "coveralls", "django-filter (<2)", "django-filter (>=2)", "djangorestframework (>=3.6.3)", "flake8 (==3.7.9)", "flake8-black (==0.1.1)", "flake8-bugbear (==20.1.4)", "mock", "pytest (>=3.6.3)", "pytest-cov", "pytest-django (>=3.3.2)", "pytz"]
-rest-framework = ["djangorestframework (>=3.6.3)"]
+rest_framework = ["djangorestframework (>=3.6.3)"]
test = ["coveralls", "django-filter (<2)", "django-filter (>=2)", "djangorestframework (>=3.6.3)", "mock", "pytest (>=3.6.3)", "pytest-cov", "pytest-django (>=3.3.2)", "pytz"]
[[package]]
@@ -1442,9 +1442,9 @@ python-versions = ">=3.6.1,<4.0"
[package.extras]
colors = ["colorama (>=0.4.3,<0.5.0)"]
-pipfile-deprecated-finder = ["pipreqs", "requirementslib"]
+pipfile_deprecated_finder = ["pipreqs", "requirementslib"]
plugins = ["setuptools"]
-requirements-deprecated-finder = ["pip-api", "pipreqs"]
+requirements_deprecated_finder = ["pip-api", "pipreqs"]
[[package]]
name = "jaeger-client"
@@ -1765,7 +1765,7 @@ optional = false
python-versions = "*"
[[package]]
-name = "pillow"
+name = "Pillow"
version = "9.3.0"
description = "Python Imaging Library (Fork)"
category = "main"
@@ -2033,8 +2033,8 @@ pylint = ">=2.0,<3"
pylint-plugin-utils = ">=0.7"
[package.extras]
-for-tests = ["coverage", "django-tables2", "django-tastypie", "factory-boy", "pylint (>=2.13)", "pytest", "wheel"]
-with-django = ["Django"]
+for_tests = ["coverage", "django-tables2", "django-tastypie", "factory-boy", "pylint (>=2.13)", "pytest", "wheel"]
+with_django = ["Django"]
[[package]]
name = "pylint-plugin-utils"
@@ -2367,7 +2367,7 @@ urllib3 = ">=1.21.1,<1.27"
[package.extras]
socks = ["PySocks (>=1.5.6,!=1.5.7)"]
-use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
+use_chardet_on_py3 = ["chardet (>=3.0.2,<6)"]
[[package]]
name = "requests-oauthlib"
@@ -2452,7 +2452,7 @@ falcon = ["falcon (>=1.4)"]
fastapi = ["fastapi (>=0.79.0)"]
flask = ["blinker (>=1.1)", "flask (>=0.11)"]
httpx = ["httpx (>=0.16.0)"]
-pure-eval = ["asttokens", "executing", "pure-eval"]
+pure_eval = ["asttokens", "executing", "pure-eval"]
pyspark = ["pyspark (>=2.4.4)"]
quart = ["blinker (>=1.1)", "quart (>=0.16.1)"]
rq = ["rq (>=0.6)"]
@@ -3273,6 +3273,7 @@ click-repl = [
]
codecov = [
{file = "codecov-2.1.12-py2.py3-none-any.whl", hash = "sha256:585dc217dc3d8185198ceb402f85d5cb5dbfa0c5f350a5abcdf9e347776a5b47"},
+ {file = "codecov-2.1.12-py3.8.egg", hash = "sha256:782a8e5352f22593cbc5427a35320b99490eb24d9dcfa2155fd99d2b75cfb635"},
{file = "codecov-2.1.12.tar.gz", hash = "sha256:a0da46bb5025426da895af90938def8ee12d37fcbcbbbc15b6dc64cf7ebc51c1"},
]
colorama = [
@@ -4081,7 +4082,7 @@ phonenumberslite = [
{file = "phonenumberslite-8.13.0-py2.py3-none-any.whl", hash = "sha256:f72d16a3963e1ad2fcff3780aab5acbc4cea99a5df4df06404a268fa68f5c81f"},
{file = "phonenumberslite-8.13.0.tar.gz", hash = "sha256:ba3921bd7e6064a949865dbf41476a9665555fe548d88f345ab505503448efdd"},
]
-pillow = [
+Pillow = [
{file = "Pillow-9.3.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:0b7257127d646ff8676ec8a15520013a698d1fdc48bc2a79ba4e53df792526f2"},
{file = "Pillow-9.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b90f7616ea170e92820775ed47e136208e04c967271c9ef615b6fbd08d9af0e3"},
{file = "Pillow-9.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:68943d632f1f9e3dce98908e873b3a090f6cba1cbb1b892a9e8d97c938871fbe"},
@@ -4202,12 +4203,34 @@ psycopg2 = [
{file = "psycopg2-2.9.5.tar.gz", hash = "sha256:a5246d2e683a972e2187a8714b5c2cf8156c064629f9a9b1a873c1730d9e245a"},
]
pyasn1 = [
+ {file = "pyasn1-0.4.8-py2.4.egg", hash = "sha256:fec3e9d8e36808a28efb59b489e4528c10ad0f480e57dcc32b4de5c9d8c9fdf3"},
+ {file = "pyasn1-0.4.8-py2.5.egg", hash = "sha256:0458773cfe65b153891ac249bcf1b5f8f320b7c2ce462151f8fa74de8934becf"},
+ {file = "pyasn1-0.4.8-py2.6.egg", hash = "sha256:5c9414dcfede6e441f7e8f81b43b34e834731003427e5b09e4e00e3172a10f00"},
+ {file = "pyasn1-0.4.8-py2.7.egg", hash = "sha256:6e7545f1a61025a4e58bb336952c5061697da694db1cae97b116e9c46abcf7c8"},
{file = "pyasn1-0.4.8-py2.py3-none-any.whl", hash = "sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d"},
+ {file = "pyasn1-0.4.8-py3.1.egg", hash = "sha256:78fa6da68ed2727915c4767bb386ab32cdba863caa7dbe473eaae45f9959da86"},
+ {file = "pyasn1-0.4.8-py3.2.egg", hash = "sha256:08c3c53b75eaa48d71cf8c710312316392ed40899cb34710d092e96745a358b7"},
+ {file = "pyasn1-0.4.8-py3.3.egg", hash = "sha256:03840c999ba71680a131cfaee6fab142e1ed9bbd9c693e285cc6aca0d555e576"},
+ {file = "pyasn1-0.4.8-py3.4.egg", hash = "sha256:7ab8a544af125fb704feadb008c99a88805126fb525280b2270bb25cc1d78a12"},
+ {file = "pyasn1-0.4.8-py3.5.egg", hash = "sha256:e89bf84b5437b532b0803ba5c9a5e054d21fec423a89952a74f87fa2c9b7bce2"},
+ {file = "pyasn1-0.4.8-py3.6.egg", hash = "sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359"},
+ {file = "pyasn1-0.4.8-py3.7.egg", hash = "sha256:99fcc3c8d804d1bc6d9a099921e39d827026409a58f2a720dcdb89374ea0c776"},
{file = "pyasn1-0.4.8.tar.gz", hash = "sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba"},
]
pyasn1-modules = [
{file = "pyasn1-modules-0.2.8.tar.gz", hash = "sha256:905f84c712230b2c592c19470d3ca8d552de726050d1d1716282a1f6146be65e"},
+ {file = "pyasn1_modules-0.2.8-py2.4.egg", hash = "sha256:0fe1b68d1e486a1ed5473f1302bd991c1611d319bba158e98b106ff86e1d7199"},
+ {file = "pyasn1_modules-0.2.8-py2.5.egg", hash = "sha256:fe0644d9ab041506b62782e92b06b8c68cca799e1a9636ec398675459e031405"},
+ {file = "pyasn1_modules-0.2.8-py2.6.egg", hash = "sha256:a99324196732f53093a84c4369c996713eb8c89d360a496b599fb1a9c47fc3eb"},
+ {file = "pyasn1_modules-0.2.8-py2.7.egg", hash = "sha256:0845a5582f6a02bb3e1bde9ecfc4bfcae6ec3210dd270522fee602365430c3f8"},
{file = "pyasn1_modules-0.2.8-py2.py3-none-any.whl", hash = "sha256:a50b808ffeb97cb3601dd25981f6b016cbb3d31fbf57a8b8a87428e6158d0c74"},
+ {file = "pyasn1_modules-0.2.8-py3.1.egg", hash = "sha256:f39edd8c4ecaa4556e989147ebf219227e2cd2e8a43c7e7fcb1f1c18c5fd6a3d"},
+ {file = "pyasn1_modules-0.2.8-py3.2.egg", hash = "sha256:b80486a6c77252ea3a3e9b1e360bc9cf28eaac41263d173c032581ad2f20fe45"},
+ {file = "pyasn1_modules-0.2.8-py3.3.egg", hash = "sha256:65cebbaffc913f4fe9e4808735c95ea22d7a7775646ab690518c056784bc21b4"},
+ {file = "pyasn1_modules-0.2.8-py3.4.egg", hash = "sha256:15b7c67fabc7fc240d87fb9aabf999cf82311a6d6fb2c70d00d3d0604878c811"},
+ {file = "pyasn1_modules-0.2.8-py3.5.egg", hash = "sha256:426edb7a5e8879f1ec54a1864f16b882c2837bfd06eee62f2c982315ee2473ed"},
+ {file = "pyasn1_modules-0.2.8-py3.6.egg", hash = "sha256:cbac4bc38d117f2a49aeedec4407d23e8866ea4ac27ff2cf7fb3e5b570df19e0"},
+ {file = "pyasn1_modules-0.2.8-py3.7.egg", hash = "sha256:c29a5e5cc7a3f05926aff34e097e84f8589cd790ce0ed41b67aed6857b26aafd"},
]
pybars3 = [
{file = "pybars3-0.9.7.tar.gz", hash = "sha256:6ac847e905e53b9c5b936af112c910475e27bf767f79f4528c16f9af1ec0e252"},
@@ -4347,13 +4370,6 @@ pyyaml = [
{file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"},
{file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"},
{file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"},
- {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"},
- {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"},
- {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"},
- {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"},
- {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"},
- {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"},
- {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"},
{file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"},
{file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"},
{file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"},
diff --git a/saleor/checkout/base_calculations.py b/saleor/checkout/base_calculations.py
index a112eb988f..4dbb8c4b65 100644
--- a/saleor/checkout/base_calculations.py
+++ b/saleor/checkout/base_calculations.py
@@ -1,15 +1,14 @@
-"""Contain functions which are base for calculating checkout properties.
+"""Contains functions which are base for calculating checkout properties.
It's recommended to use functions from calculations.py module to take in account
plugin manager. Functions from this module return price without
-taxes(Money instead of TaxedMoney). If you don't need pre-taxed prices use functions
+taxes (Money instead of TaxedMoney). If you don't need pre-taxed prices use functions
from calculations.py.
"""
-from decimal import Decimal
from typing import TYPE_CHECKING, Iterable, Optional
-from prices import Money, TaxedMoney
+from prices import Money
from ..core.prices import quantize_price
from ..core.taxes import zero_money
@@ -236,11 +235,3 @@ def base_checkout_subtotal(
]
return sum(line_totals, zero_money(currency))
-
-
-def base_tax_rate(price: TaxedMoney):
- tax_rate = Decimal("0.0")
- # The condition will return False when unit_price.gross or unit_price.net is 0.0
- if not isinstance(price, Decimal) and all((price.gross, price.net)):
- tax_rate = price.tax / price.net
- return tax_rate
diff --git a/saleor/checkout/calculations.py b/saleor/checkout/calculations.py
index b54d05eeae..fef7b1e66c 100644
--- a/saleor/checkout/calculations.py
+++ b/saleor/checkout/calculations.py
@@ -9,14 +9,19 @@ from ..checkout import base_calculations
from ..core.prices import quantize_price
from ..core.taxes import TaxData, zero_taxed_money
from ..discount import DiscountInfo
-from ..site.models import Site
+from ..tax import TaxCalculationStrategy
+from ..tax.calculations.checkout import update_checkout_prices_with_flat_rates
+from ..tax.utils import (
+ calculate_tax_rate,
+ get_charge_taxes_for_checkout,
+ get_tax_calculation_strategy_for_checkout,
+ normalize_tax_rate_for_db,
+)
from .models import Checkout
if TYPE_CHECKING:
-
from ..account.models import Address
from ..plugins.manager import PluginsManager
- from ..site.models import SiteSettings
from .fetch import CheckoutInfo, CheckoutLineInfo
@@ -27,7 +32,6 @@ def checkout_shipping_price(
lines: Iterable["CheckoutLineInfo"],
address: Optional["Address"],
discounts: Optional[Iterable[DiscountInfo]] = None,
- site_settings: Optional["SiteSettings"] = None
) -> "TaxedMoney":
"""Return checkout shipping price.
@@ -40,7 +44,6 @@ def checkout_shipping_price(
lines=lines,
address=address,
discounts=discounts,
- site_settings=site_settings,
)
return quantize_price(checkout_info.checkout.shipping_price, currency)
@@ -74,7 +77,6 @@ def checkout_subtotal(
lines: Iterable["CheckoutLineInfo"],
address: Optional["Address"],
discounts: Optional[Iterable[DiscountInfo]] = None,
- site_settings: Optional["SiteSettings"] = None
) -> "TaxedMoney":
"""Return the total cost of all the checkout lines, taxes included.
@@ -87,7 +89,6 @@ def checkout_subtotal(
lines=lines,
address=address,
discounts=discounts,
- site_settings=site_settings,
)
return quantize_price(checkout_info.checkout.subtotal, currency)
@@ -98,7 +99,6 @@ def calculate_checkout_total_with_gift_cards(
lines: Iterable["CheckoutLineInfo"],
address: Optional["Address"],
discounts: Optional[Iterable[DiscountInfo]] = None,
- site_settings: Optional["SiteSettings"] = None,
) -> "TaxedMoney":
total = (
checkout_total(
@@ -107,7 +107,6 @@ def calculate_checkout_total_with_gift_cards(
lines=lines,
address=address,
discounts=discounts,
- site_settings=site_settings,
)
- checkout_info.checkout.get_total_gift_cards_balance()
)
@@ -122,7 +121,6 @@ def checkout_total(
lines: Iterable["CheckoutLineInfo"],
address: Optional["Address"],
discounts: Optional[Iterable[DiscountInfo]] = None,
- site_settings: Optional["SiteSettings"] = None
) -> "TaxedMoney":
"""Return the total cost of the checkout.
@@ -138,7 +136,6 @@ def checkout_total(
lines=lines,
address=address,
discounts=discounts,
- site_settings=site_settings,
)
return quantize_price(checkout_info.checkout.total, currency)
@@ -165,7 +162,6 @@ def checkout_line_total(
lines: Iterable["CheckoutLineInfo"],
checkout_line_info: "CheckoutLineInfo",
discounts: Iterable[DiscountInfo] = [],
- site_settings: Optional["SiteSettings"] = None
) -> TaxedMoney:
"""Return the total price of provided line, taxes included.
@@ -179,7 +175,6 @@ def checkout_line_total(
lines=lines,
address=address,
discounts=discounts,
- site_settings=site_settings,
)
checkout_line = _find_checkout_line_info(lines, checkout_line_info).line
return quantize_price(checkout_line.total_price, currency)
@@ -242,7 +237,6 @@ def fetch_checkout_prices_if_expired(
address: Optional["Address"] = None,
discounts: Optional[Iterable["DiscountInfo"]] = None,
force_update: bool = False,
- site_settings: "SiteSettings" = None,
) -> Tuple["CheckoutInfo", Iterable["CheckoutLineInfo"]]:
"""Fetch checkout prices with taxes.
@@ -252,31 +246,57 @@ def fetch_checkout_prices_if_expired(
Prices can be updated only if force_update == True, or if time elapsed from the
last price update is greater than settings.CHECKOUT_PRICES_TTL.
"""
- checkout = checkout_info.checkout
- if site_settings is None:
- site_settings = Site.objects.get_current().settings
+ checkout = checkout_info.checkout
if not force_update and checkout.price_expiration > timezone.now():
return checkout_info, lines
- if checkout.tax_exemption and not site_settings.include_taxes_in_prices:
- _get_checkout_base_prices(checkout, checkout_info, lines, discounts)
- else:
- # Taxes are applied to the discounted prices
- _apply_tax_data_from_plugins(
- checkout, manager, checkout_info, lines, address, discounts
- )
-
- tax_data = manager.get_taxes_for_checkout(
+ tax_configuration = checkout_info.tax_configuration
+ tax_calculation_strategy = get_tax_calculation_strategy_for_checkout(
+ checkout_info, lines
+ )
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
+ charge_taxes = get_charge_taxes_for_checkout(checkout_info, lines)
+ should_charge_tax = charge_taxes and not checkout.tax_exemption
+
+ if prices_entered_with_tax:
+ # If prices are entered with tax, we need to always calculate it anyway, to
+ # display the tax rate to the user.
+ _calculate_and_add_tax(
+ tax_calculation_strategy,
+ checkout,
+ manager,
checkout_info,
lines,
+ prices_entered_with_tax,
+ address,
+ discounts,
)
- if tax_data:
- _apply_tax_data_from_app(checkout, lines, tax_data)
- if checkout.tax_exemption and site_settings.include_taxes_in_prices:
- _exempt_taxes_in_checkout(checkout, lines)
+ if not should_charge_tax:
+ # If charge_taxes is disabled or checkout is exempt from taxes, remove the
+ # tax from the original gross prices.
+ _remove_tax(checkout, lines)
+
+ else:
+ # Prices are entered without taxes.
+ if should_charge_tax:
+ # Calculate taxes if charge_taxes is enabled and checkout is not exempt
+ # from taxes.
+ _calculate_and_add_tax(
+ tax_calculation_strategy,
+ checkout,
+ manager,
+ checkout_info,
+ lines,
+ prices_entered_with_tax,
+ address,
+ discounts,
+ )
+ else:
+ # Calculate net prices without taxes.
+ _get_checkout_base_prices(checkout, checkout_info, lines, discounts)
checkout.price_expiration = (
timezone.now() + settings.CHECKOUT_PRICES_TTL # type: ignore
@@ -299,7 +319,6 @@ def fetch_checkout_prices_if_expired(
],
using=settings.DATABASE_CONNECTION_DEFAULT_NAME,
)
-
checkout.lines.bulk_update(
[line_info.line for line_info in lines],
[
@@ -308,11 +327,35 @@ def fetch_checkout_prices_if_expired(
"tax_rate",
],
)
-
return checkout_info, lines
-def _exempt_taxes_in_checkout(checkout, lines_info):
+def _calculate_and_add_tax(
+ tax_calculation_strategy: str,
+ checkout: "Checkout",
+ manager: "PluginsManager",
+ checkout_info: "CheckoutInfo",
+ lines: Iterable["CheckoutLineInfo"],
+ prices_entered_with_tax: bool,
+ address: Optional["Address"] = None,
+ discounts: Optional[Iterable["DiscountInfo"]] = None,
+):
+ if tax_calculation_strategy == TaxCalculationStrategy.TAX_APP:
+ # Call the tax plugins.
+ _apply_tax_data_from_plugins(
+ checkout, manager, checkout_info, lines, address, discounts
+ )
+ # Get the taxes calculated with apps and apply to checkout.
+ tax_data = manager.get_taxes_for_checkout(checkout_info, lines)
+ _apply_tax_data(checkout, lines, tax_data)
+ elif tax_calculation_strategy == TaxCalculationStrategy.FLAT_RATES:
+ # Get taxes calculated with flat rates and apply to checkout.
+ update_checkout_prices_with_flat_rates(
+ checkout, checkout_info, lines, prices_entered_with_tax, address, discounts
+ )
+
+
+def _remove_tax(checkout, lines_info):
checkout.total_gross_amount = checkout.total_net_amount
checkout.subtotal_gross_amount = checkout.subtotal_net_amount
checkout.shipping_price_gross_amount = checkout.shipping_price_net_amount
@@ -341,9 +384,14 @@ def _calculate_checkout_subtotal(lines, currency):
)
-def _apply_tax_data_from_app(
- checkout: "Checkout", lines: Iterable["CheckoutLineInfo"], tax_data: TaxData
+def _apply_tax_data(
+ checkout: "Checkout",
+ lines: Iterable["CheckoutLineInfo"],
+ tax_data: Optional[TaxData],
) -> None:
+ if not tax_data:
+ return
+
currency = checkout.currency
for (line_info, tax_line_data) in zip(lines, tax_data.lines):
line = line_info.line
@@ -355,14 +403,9 @@ def _apply_tax_data_from_app(
),
currency,
)
- # We use % value in tax app input but on database we store
- # it as a fractional value.
- # e.g Tax app sends `10%` as `10` but in database it's stored as `0.1`
- line.tax_rate = tax_line_data.tax_rate / 100
-
- # We use % value in tax app input but on database we store it as a fractional value.
- # e.g Tax app sends `10%` as `10` but in database it's stored as `0.1`
- checkout.shipping_tax_rate = tax_data.shipping_tax_rate / 100
+ line.tax_rate = normalize_tax_rate_for_db(tax_line_data.tax_rate)
+
+ checkout.shipping_tax_rate = normalize_tax_rate_for_db(tax_data.shipping_tax_rate)
checkout.shipping_price = quantize_price(
TaxedMoney(
net=Money(tax_data.shipping_price_net_amount, currency),
@@ -457,8 +500,7 @@ def _get_checkout_base_prices(
unit_price = quantize_price(
TaxedMoney(net=unit_price_default, gross=unit_price_default), currency
)
-
- line.tax_rate = base_calculations.base_tax_rate(unit_price)
+ line.tax_rate = calculate_tax_rate(unit_price)
shipping_price_default = base_calculations.base_checkout_delivery_price(
checkout_info, lines
@@ -466,10 +508,7 @@ def _get_checkout_base_prices(
checkout.shipping_price = quantize_price(
TaxedMoney(shipping_price_default, shipping_price_default), currency
)
-
- checkout.shipping_tax_rate = base_calculations.base_tax_rate(
- checkout.shipping_price
- )
+ checkout.shipping_tax_rate = calculate_tax_rate(checkout.shipping_price)
subtotal_default = sum(
[line_info.line.total_price for line_info in lines], zero_taxed_money(currency)
diff --git a/saleor/checkout/complete_checkout.py b/saleor/checkout/complete_checkout.py
index fce7efc308..1b3860071a 100644
--- a/saleor/checkout/complete_checkout.py
+++ b/saleor/checkout/complete_checkout.py
@@ -48,11 +48,19 @@ from ..order.fetch import OrderInfo, OrderLineInfo
from ..order.models import Order, OrderLine
from ..order.notifications import send_order_confirmation
from ..order.search import prepare_order_search_vector_value
-from ..order.utils import update_order_authorize_data, update_order_charge_data
+from ..order.utils import (
+ update_order_authorize_data,
+ update_order_charge_data,
+ update_order_display_gross_prices,
+)
from ..payment import PaymentError, TransactionKind, gateway
from ..payment.models import Payment, Transaction
from ..payment.utils import fetch_customer_id, store_customer_id
from ..product.models import ProductTranslation, ProductVariantTranslation
+from ..tax.utils import (
+ get_shipping_tax_class_kwargs_for_order,
+ get_tax_class_kwargs_for_order_line,
+)
from ..warehouse.availability import check_stock_and_preorder_quantity_bulk
from ..warehouse.management import allocate_preorders, allocate_stocks
from ..warehouse.models import Reservation, Stock
@@ -131,11 +139,15 @@ def _process_shipping_data_for_order(
if checkout_info.user.addresses.filter(pk=shipping_address.pk).exists():
shipping_address = shipping_address.get_copy()
+ shipping_method = delivery_method_info.delivery_method
+ tax_class = getattr(shipping_method, "tax_class", None)
+
result: Dict[str, Any] = {
"shipping_address": shipping_address,
"base_shipping_price": base_shipping_price,
"shipping_price": shipping_price,
"weight": checkout_info.checkout.get_total_weight(lines),
+ **get_shipping_tax_class_kwargs_for_order(tax_class),
}
result.update(delivery_method_info.delivery_method_order_field)
result.update(delivery_method_info.delivery_method_name)
@@ -170,7 +182,7 @@ def _create_line_for_order(
discounts: Iterable[DiscountInfo],
products_translation: Dict[int, Optional[str]],
variants_translation: Dict[int, Optional[str]],
- taxes_included_in_prices: bool,
+ prices_entered_with_tax: bool,
) -> OrderLineInfo:
"""Create a line for the given order.
@@ -253,7 +265,7 @@ def _create_line_for_order(
voucher_code = checkout_line_info.voucher.code
discount_price = undiscounted_unit_price - unit_price
- if taxes_included_in_prices:
+ if prices_entered_with_tax:
discount_amount = discount_price.gross
else:
discount_amount = discount_price.net
@@ -267,6 +279,12 @@ def _create_line_for_order(
else:
unit_discount_reason = f"Voucher code: {voucher_code}"
+ tax_class = None
+ if product.tax_class_id:
+ tax_class = product.tax_class
+ else:
+ tax_class = product.product_type.tax_class
+
line = OrderLine(
product_name=product_name,
variant_name=variant_name,
@@ -292,6 +310,7 @@ def _create_line_for_order(
undiscounted_base_unit_price=undiscounted_base_unit_price,
metadata=checkout_line.metadata,
private_metadata=checkout_line.private_metadata,
+ **get_tax_class_kwargs_for_order_line(tax_class),
)
is_digital = line.is_digital
line_info = OrderLineInfo(
@@ -311,7 +330,7 @@ def _create_lines_for_order(
checkout_info: "CheckoutInfo",
lines: Iterable["CheckoutLineInfo"],
discounts: Iterable[DiscountInfo],
- taxes_included_in_prices: bool,
+ prices_entered_with_tax: bool,
) -> Iterable[OrderLineInfo]:
"""Create a lines for the given order.
@@ -369,7 +388,7 @@ def _create_lines_for_order(
discounts,
product_translations,
variants_translation,
- taxes_included_in_prices,
+ prices_entered_with_tax,
)
for checkout_line_info in lines
]
@@ -381,7 +400,7 @@ def _prepare_order_data(
checkout_info: "CheckoutInfo",
lines: Iterable["CheckoutLineInfo"],
discounts: Iterable["DiscountInfo"],
- taxes_included_in_prices: bool,
+ prices_entered_with_tax: bool,
) -> dict:
"""Run checks and return all the data from a given checkout to create an order.
@@ -438,7 +457,7 @@ def _prepare_order_data(
checkout_info,
lines,
discounts,
- taxes_included_in_prices,
+ prices_entered_with_tax,
)
# validate checkout gift cards
@@ -574,6 +593,9 @@ def _create_order(
# assign checkout payments to the order
checkout.payments.update(order=order)
+ # store current tax configuration
+ update_order_display_gross_prices(order)
+
# copy metadata from the checkout into the new order
order.metadata = checkout.metadata
if metadata_list:
@@ -679,13 +701,15 @@ def _get_order_data(
site_settings: "SiteSettings",
) -> dict:
"""Prepare data that will be converted to order and its lines."""
+ tax_configuration = checkout_info.tax_configuration
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
try:
order_data = _prepare_order_data(
manager=manager,
checkout_info=checkout_info,
lines=lines,
discounts=discounts,
- taxes_included_in_prices=site_settings.include_taxes_in_prices,
+ prices_entered_with_tax=prices_entered_with_tax,
)
except InsufficientStock as e:
error = prepare_insufficient_stock_checkout_validation_error(e)
@@ -762,13 +786,7 @@ def complete_checkout_pre_payment_part(
if site_settings is None:
site_settings = Site.objects.get_current().settings
- fetch_checkout_prices_if_expired(
- checkout_info,
- manager,
- lines,
- discounts=discounts,
- site_settings=site_settings,
- )
+ fetch_checkout_prices_if_expired(checkout_info, manager, lines, discounts=discounts)
checkout = checkout_info.checkout
channel_slug = checkout_info.channel.slug
@@ -901,14 +919,14 @@ def _create_order_lines_from_checkout_lines(
discounts: List["DiscountInfo"],
manager: "PluginsManager",
order_pk: Union[str, UUID],
- taxes_included_in_prices: bool,
+ prices_entered_with_tax: bool,
) -> List[OrderLineInfo]:
order_lines_info = _create_lines_for_order(
manager,
checkout_info,
lines,
discounts,
- taxes_included_in_prices,
+ prices_entered_with_tax,
)
order_lines = []
for line_info in order_lines_info:
@@ -1028,7 +1046,8 @@ def _create_order_from_checkout(
address = checkout_info.shipping_address or checkout_info.billing_address
reservation_enabled = is_reservation_enabled(site_settings)
- taxes_included_in_prices = site_settings.include_taxes_in_prices
+ tax_configuration = checkout_info.tax_configuration
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
# total
taxed_total = calculations.calculate_checkout_total_with_gift_cards(
@@ -1116,7 +1135,7 @@ def _create_order_from_checkout(
discounts=discounts,
manager=manager,
order_pk=order.pk,
- taxes_included_in_prices=taxes_included_in_prices,
+ prices_entered_with_tax=prices_entered_with_tax,
)
# allocations
@@ -1143,6 +1162,9 @@ def _create_order_from_checkout(
update_order_charge_data(order, with_save=False)
update_order_authorize_data(order, with_save=False)
+ # tax settings
+ update_order_display_gross_prices(order)
+
# order search
order.search_vector = FlatConcatSearchVector(
*prepare_order_search_vector_value(order)
diff --git a/saleor/checkout/fetch.py b/saleor/checkout/fetch.py
index 41b10b137a..207b740d2b 100644
--- a/saleor/checkout/fetch.py
+++ b/saleor/checkout/fetch.py
@@ -41,6 +41,7 @@ if TYPE_CHECKING:
ProductVariant,
ProductVariantChannelListing,
)
+ from ..tax.models import TaxClass, TaxConfiguration
from .models import Checkout, CheckoutLine
@@ -52,6 +53,7 @@ class CheckoutLineInfo:
product: "Product"
product_type: "ProductType"
collections: List["Collection"]
+ tax_class: Optional["TaxClass"] = None
voucher: Optional["Voucher"] = None
@@ -64,6 +66,7 @@ class CheckoutInfo:
shipping_address: Optional["Address"]
delivery_method_info: "DeliveryMethodBase"
all_shipping_methods: List["ShippingMethodData"]
+ tax_configuration: "TaxConfiguration"
valid_pick_up_points: List["Warehouse"]
voucher: Optional["Voucher"] = None
@@ -219,10 +222,12 @@ def fetch_checkout_lines(
"""Fetch checkout lines as CheckoutLineInfo objects."""
from .utils import get_voucher_for_checkout
- select_related_fields = ["variant__product__product_type"]
+ select_related_fields = ["variant__product__product_type__tax_class"]
prefetch_related_fields = [
"variant__product__collections",
"variant__product__channel_listings__channel",
+ "variant__product__product_type__tax_class__country_rates",
+ "variant__product__tax_class__country_rates",
"variant__channel_listings__channel",
]
if prefetch_variant_attributes:
@@ -262,6 +267,7 @@ def fetch_checkout_lines(
product=product,
product_type=product_type,
collections=collections,
+ tax_class=product.tax_class or product_type.tax_class,
)
)
continue
@@ -274,6 +280,7 @@ def fetch_checkout_lines(
product=product,
product_type=product_type,
collections=collections,
+ tax_class=product.tax_class or product_type.tax_class,
)
)
@@ -394,6 +401,7 @@ def fetch_checkout_info(
from .utils import get_voucher_for_checkout
channel = checkout.channel
+ tax_configuration = channel.tax_configuration
shipping_address = checkout.shipping_address
if shipping_channel_listings is None:
shipping_channel_listings = channel.shipping_method_listings.all()
@@ -407,6 +415,7 @@ def fetch_checkout_info(
billing_address=checkout.billing_address,
shipping_address=shipping_address,
delivery_method_info=delivery_method_info,
+ tax_configuration=tax_configuration,
all_shipping_methods=[],
valid_pick_up_points=[],
voucher=voucher,
diff --git a/saleor/checkout/tests/test_base_calculations.py b/saleor/checkout/tests/test_base_calculations.py
index fa038dde03..51459a18cb 100644
--- a/saleor/checkout/tests/test_base_calculations.py
+++ b/saleor/checkout/tests/test_base_calculations.py
@@ -5,9 +5,9 @@ from prices import Money, TaxedMoney
from ...discount import DiscountValueType, VoucherType
from ...discount.utils import get_product_discount_on_sale
from ...plugins.manager import get_plugins_manager
+from ...tax.utils import calculate_tax_rate
from ..base_calculations import (
base_checkout_total,
- base_tax_rate,
calculate_base_line_total_price,
calculate_base_line_unit_price,
)
@@ -736,12 +736,12 @@ def test_calculate_base_line_total_price_with_variant_on_sale_and_voucher_applie
def test_base_tax_rate_net_price_zero():
price = TaxedMoney(net=Money(0, "USD"), gross=Money(3, "USD"))
- assert base_tax_rate(price) == Decimal("0.0")
+ assert calculate_tax_rate(price) == Decimal("0.0")
def test_base_tax_rate_gross_price_zero():
price = TaxedMoney(net=Money(3, "USD"), gross=Money(0, "USD"))
- assert base_tax_rate(price) == Decimal("0.0")
+ assert calculate_tax_rate(price) == Decimal("0.0")
def test_base_checkout_total(checkout_with_item, shipping_method, voucher_percentage):
diff --git a/saleor/checkout/tests/test_calculations.py b/saleor/checkout/tests/test_calculations.py
index 6b73428d13..14a4a737d2 100644
--- a/saleor/checkout/tests/test_calculations.py
+++ b/saleor/checkout/tests/test_calculations.py
@@ -10,11 +10,13 @@ from prices import Money, TaxedMoney
from ...core.prices import quantize_price
from ...core.taxes import TaxData, TaxLineData, zero_taxed_money
from ...plugins.manager import get_plugins_manager
+from ...tax import TaxCalculationStrategy
+from ...tax.calculations.checkout import update_checkout_prices_with_flat_rates
from ..base_calculations import (
base_checkout_delivery_price,
calculate_base_line_total_price,
)
-from ..calculations import _apply_tax_data_from_app, fetch_checkout_prices_if_expired
+from ..calculations import _apply_tax_data, fetch_checkout_prices_if_expired
from ..fetch import CheckoutLineInfo, fetch_checkout_info, fetch_checkout_lines
@@ -51,7 +53,7 @@ def test_apply_tax_data(checkout_with_items, checkout_lines, tax_data):
lines = checkout_lines
# when
- _apply_tax_data_from_app(
+ _apply_tax_data(
checkout,
[
Mock(spec=CheckoutLineInfo, line=line, variant=line.variant)
@@ -121,7 +123,7 @@ def get_taxed_money(
@freeze_time("2020-12-12 12:00:00")
-@patch("saleor.checkout.calculations._apply_tax_data_from_app")
+@patch("saleor.checkout.calculations._apply_tax_data")
def test_fetch_checkout_prices_if_expired_plugins(
_mocked_from_app,
plugins_manager,
@@ -179,6 +181,46 @@ def test_fetch_checkout_prices_if_expired_plugins(
assert checkout_with_items.total == subtotal + shipping_price
+@patch(
+ "saleor.checkout.calculations.update_checkout_prices_with_flat_rates",
+ wraps=update_checkout_prices_with_flat_rates,
+)
[email protected]("prices_entered_with_tax", [True, False])
+def test_fetch_checkout_prices_if_expired_flat_rates(
+ mocked_update_checkout_prices_with_flat_rates,
+ checkout_with_items_and_shipping,
+ fetch_kwargs,
+ prices_entered_with_tax,
+):
+ # given
+ checkout = checkout_with_items_and_shipping
+ tc = checkout.channel.tax_configuration
+ tc.country_exceptions.all().delete()
+ tc.prices_entered_with_tax = prices_entered_with_tax
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.save()
+
+ country_code = checkout.shipping_address.country.code
+ for line in checkout.lines.all():
+ line.variant.product.tax_class.country_rates.update_or_create(
+ country=country_code, rate=23
+ )
+
+ checkout.shipping_method.tax_class.country_rates.update_or_create(
+ country=country_code, rate=23
+ )
+
+ # when
+ fetch_checkout_prices_if_expired(**fetch_kwargs)
+ checkout.refresh_from_db()
+ line = checkout.lines.first()
+
+ # then
+ mocked_update_checkout_prices_with_flat_rates.assert_called_once()
+ assert line.tax_rate == Decimal("0.2300")
+ assert checkout.shipping_tax_rate == Decimal("0.2300")
+
+
@freeze_time("2020-12-12 12:00:00")
def test_fetch_checkout_prices_if_expired_webhooks_success(
plugins_manager,
@@ -208,7 +250,7 @@ def test_fetch_checkout_prices_if_expired_webhooks_success(
@freeze_time("2020-12-12 12:00:00")
def test_fetch_checkout_prices_when_tax_exemption_and_include_taxes_in_prices(
- checkout_with_items_and_shipping, settings, site_settings
+ checkout_with_items_and_shipping, settings
):
"""Test tax exemption when taxes are included in prices.
@@ -230,6 +272,10 @@ def test_fetch_checkout_prices_when_tax_exemption_and_include_taxes_in_prices(
checkout.tax_exemption = True
checkout.save(update_fields=["price_expiration", "tax_exemption"])
+ tc = checkout.channel.tax_configuration
+ tc.prices_entered_with_tax = True
+ tc.save(update_fields=["prices_entered_with_tax"])
+
currency = checkout.currency
discounts = []
@@ -239,7 +285,6 @@ def test_fetch_checkout_prices_when_tax_exemption_and_include_taxes_in_prices(
"checkout_info": fetch_checkout_info(checkout, lines_info, discounts, manager),
"manager": manager,
"lines": lines_info,
- "site_settings": site_settings,
"address": checkout.shipping_address or checkout.billing_address,
"discounts": discounts,
}
@@ -271,7 +316,7 @@ def test_fetch_checkout_prices_when_tax_exemption_and_include_taxes_in_prices(
@freeze_time("2020-12-12 12:00:00")
def test_fetch_checkout_prices_when_tax_exemption_and_not_include_taxes_in_prices(
- checkout_with_items_and_shipping, settings, site_settings
+ checkout_with_items_and_shipping, settings
):
"""Test tax exemption when taxes are not included in prices.
@@ -286,8 +331,11 @@ def test_fetch_checkout_prices_when_tax_exemption_and_not_include_taxes_in_price
checkout.price_expiration = timezone.now()
checkout.tax_exemption = True
checkout.save(update_fields=["price_expiration", "tax_exemption"])
- site_settings.include_taxes_in_prices = False
- site_settings.save(update_fields=["include_taxes_in_prices"])
+
+ tc = checkout.channel.tax_configuration
+ tc.prices_entered_with_tax = False
+ tc.save(update_fields=["prices_entered_with_tax"])
+
currency = checkout.currency
discounts = []
@@ -297,7 +345,6 @@ def test_fetch_checkout_prices_when_tax_exemption_and_not_include_taxes_in_price
"checkout_info": checkout_info,
"manager": manager,
"lines": lines_info,
- "site_settings": site_settings,
"address": checkout.shipping_address or checkout.billing_address,
"discounts": discounts,
}
diff --git a/saleor/checkout/tests/test_checkout.py b/saleor/checkout/tests/test_checkout.py
index 14b8a4146e..f1fa9a13b2 100644
--- a/saleor/checkout/tests/test_checkout.py
+++ b/saleor/checkout/tests/test_checkout.py
@@ -288,6 +288,7 @@ def test_get_discount_for_checkout_value_voucher(
billing_address=None,
channel=channel_USD,
user=None,
+ tax_configuration=channel_USD.tax_configuration,
valid_pick_up_points=[],
delivery_method_info=get_delivery_method_info(None, None),
all_shipping_methods=[],
@@ -381,6 +382,7 @@ def test_get_discount_for_checkout_entire_order_voucher_not_applicable(
billing_address=None,
channel=channel_USD,
user=None,
+ tax_configuration=channel_USD.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
@@ -553,6 +555,7 @@ def test_get_discount_for_checkout_specific_products_voucher_not_applicable(
billing_address=None,
channel=channel_USD,
user=None,
+ tax_configuration=channel_USD.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
@@ -663,6 +666,7 @@ def test_get_discount_for_checkout_shipping_voucher(
billing_address=None,
channel=channel_USD,
user=None,
+ tax_configuration=channel_USD.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
@@ -714,6 +718,7 @@ def test_get_discount_for_checkout_shipping_voucher_all_countries(
billing_address=None,
channel=channel_USD,
user=None,
+ tax_configuration=channel_USD.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
@@ -759,6 +764,7 @@ def test_get_discount_for_checkout_shipping_voucher_limited_countries(
billing_address=None,
channel=channel_USD,
user=None,
+ tax_configuration=channel_USD.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
@@ -898,6 +904,7 @@ def test_get_discount_for_checkout_shipping_voucher_not_applicable(
billing_address=None,
channel=channel_USD,
user=None,
+ tax_configuration=channel_USD.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
diff --git a/saleor/checkout/tests/test_checkout_complete.py b/saleor/checkout/tests/test_checkout_complete.py
index a9dda54f79..f0fb3fcb77 100644
--- a/saleor/checkout/tests/test_checkout_complete.py
+++ b/saleor/checkout/tests/test_checkout_complete.py
@@ -73,7 +73,7 @@ def test_create_order_captured_payment_creates_expected_events(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user,
app=None,
@@ -222,7 +222,7 @@ def test_create_order_captured_payment_creates_expected_events_anonymous_user(
checkout_info=checkout_info,
lines=lines,
discounts=None,
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=None,
app=None,
@@ -366,7 +366,7 @@ def test_create_order_preauth_payment_creates_expected_events(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user,
app=None,
@@ -479,7 +479,7 @@ def test_create_order_preauth_payment_creates_expected_events_anonymous_user(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=None,
app=None,
@@ -567,7 +567,7 @@ def test_create_order_insufficient_stock(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
)
@@ -591,7 +591,7 @@ def test_create_order_doesnt_duplicate_order(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
)
order_1 = _create_order(
@@ -658,7 +658,7 @@ def test_create_order_with_gift_card(
checkout_info=checkout_info,
lines=lines,
discounts=None,
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user if not is_anonymous_user else None,
app=None,
@@ -709,7 +709,7 @@ def test_create_order_with_gift_card_partial_use(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user,
app=None,
@@ -773,7 +773,7 @@ def test_create_order_with_many_gift_cards(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user,
app=None,
@@ -864,7 +864,7 @@ def test_create_order_gift_card_bought(
checkout_info=checkout_info,
lines=lines,
discounts=None,
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user if not is_anonymous_user else None,
app=None,
@@ -945,7 +945,7 @@ def test_create_order_gift_card_bought_order_not_captured_gift_cards_not_sent(
checkout_info=checkout_info,
lines=lines,
discounts=None,
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user if not is_anonymous_user else None,
app=None,
@@ -1009,7 +1009,7 @@ def test_create_order_gift_card_bought_only_shippable_gift_card(
checkout_info=checkout_info,
lines=lines,
discounts=None,
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user if not is_anonymous_user else None,
app=None,
@@ -1069,7 +1069,7 @@ def test_create_order_gift_card_bought_do_not_fulfill_gift_cards_automatically(
checkout_info=checkout_info,
lines=lines,
discounts=None,
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user if not is_anonymous_user else None,
app=None,
@@ -1097,7 +1097,7 @@ def test_note_in_created_order(checkout_with_item, address, customer_user):
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user,
app=None,
@@ -1126,7 +1126,7 @@ def test_create_order_with_variant_tracking_false(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
)
order_1 = _create_order(
@@ -1180,7 +1180,7 @@ def test_create_order_use_translations(
checkout_info=checkout_info,
lines=lines,
discounts=[],
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
)
order_line = order_data["lines"][0].line
@@ -1469,6 +1469,41 @@ def test_process_shipping_data_for_order_dont_store_customer_click_and_collect_a
assert not customer_user.addresses.filter(**new_address_data).exists()
+def test_create_order_update_display_gross_prices(checkout_with_item, customer_user):
+ # given
+ checkout = checkout_with_item
+ channel = checkout.channel
+ tax_configuration = channel.tax_configuration
+
+ tax_configuration.display_gross_prices = False
+ tax_configuration.save()
+ tax_configuration.country_exceptions.all().delete()
+
+ manager = get_plugins_manager()
+ checkout_info = fetch_checkout_info(checkout, [], [], manager)
+ lines, _ = fetch_checkout_lines(checkout)
+ order_data = _prepare_order_data(
+ manager=manager,
+ checkout_info=checkout_info,
+ lines=lines,
+ discounts=[],
+ prices_entered_with_tax=True,
+ )
+
+ # when
+ order = _create_order(
+ checkout_info=checkout_info,
+ checkout_lines=lines,
+ order_data=order_data,
+ user=customer_user,
+ app=None,
+ manager=manager,
+ )
+
+ # then
+ assert not order.display_gross_prices
+
+
def test_create_order_store_shipping_prices(
checkout_with_items_and_shipping, shipping_method, customer_user
):
@@ -1504,7 +1539,7 @@ def test_create_order_store_shipping_prices(
checkout_info=checkout_info,
lines=lines,
discounts=None,
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user,
app=None,
@@ -1555,7 +1590,7 @@ def test_create_order_store_shipping_prices_with_free_shipping_voucher(
checkout_info=checkout_info,
lines=lines,
discounts=None,
- taxes_included_in_prices=True,
+ prices_entered_with_tax=True,
),
user=customer_user,
app=None,
diff --git a/saleor/checkout/tests/test_order_from_checkout.py b/saleor/checkout/tests/test_order_from_checkout.py
index bc6257ab28..000770a90b 100644
--- a/saleor/checkout/tests/test_order_from_checkout.py
+++ b/saleor/checkout/tests/test_order_from_checkout.py
@@ -2,6 +2,7 @@ from decimal import Decimal
from unittest import mock
import pytest
+from django.contrib.auth.models import AnonymousUser
from django.test import override_settings
from prices import TaxedMoney
@@ -566,6 +567,37 @@ def test_create_order_from_checkout_updates_total_charged_amount(
assert order.total_charged_amount == charged_value
+def test_create_order_from_checkout_update_display_gross_prices(
+ checkout_with_item, app
+):
+ # given
+ checkout = checkout_with_item
+ channel = checkout.channel
+ tax_configuration = channel.tax_configuration
+
+ tax_configuration.display_gross_prices = False
+ tax_configuration.save()
+ tax_configuration.country_exceptions.all().delete()
+
+ manager = get_plugins_manager()
+ checkout_info = fetch_checkout_info(checkout, [], [], manager)
+ checkout_lines, _ = fetch_checkout_lines(checkout)
+
+ # when
+ order = create_order_from_checkout(
+ checkout_info=checkout_info,
+ checkout_lines=checkout_lines,
+ discounts=[],
+ manager=manager,
+ user=AnonymousUser(),
+ app=app,
+ tracking_code="tracking_code",
+ )
+
+ # then
+ assert not order.display_gross_prices
+
+
def test_create_order_from_checkout_store_shipping_prices(
checkout_with_items_and_shipping, shipping_method, customer_user, app
):
diff --git a/saleor/core/management/commands/populatedb.py b/saleor/core/management/commands/populatedb.py
index 9ba9d42987..bb06a5dbd4 100644
--- a/saleor/core/management/commands/populatedb.py
+++ b/saleor/core/management/commands/populatedb.py
@@ -23,6 +23,7 @@ from ...utils.random_data import (
create_products_by_schema,
create_shipping_zones,
create_staffs,
+ create_tax_classes,
create_users,
create_vouchers,
create_warehouses,
@@ -115,6 +116,8 @@ class Command(BaseCommand):
self.stdout.write(msg)
for msg in create_checkout_with_custom_prices():
self.stdout.write(msg)
+ for msg in create_tax_classes():
+ self.stdout.write(msg)
for msg in create_checkout_with_same_variant_in_multiple_lines():
self.stdout.write(msg)
diff --git a/saleor/core/permissions/enums.py b/saleor/core/permissions/enums.py
index 48e7e58c9d..fa1ad3f630 100644
--- a/saleor/core/permissions/enums.py
+++ b/saleor/core/permissions/enums.py
@@ -88,13 +88,13 @@ PERMISSIONS_ENUMS = [
CheckoutPermissions,
ChannelPermissions,
DiscountPermissions,
- PluginsPermissions,
GiftcardPermissions,
MenuPermissions,
OrderPermissions,
PagePermissions,
PageTypePermissions,
PaymentPermissions,
+ PluginsPermissions,
ProductPermissions,
ProductTypePermissions,
ShippingPermissions,
diff --git a/saleor/core/taxes.py b/saleor/core/taxes.py
index 44f4ab2056..042d4018a6 100644
--- a/saleor/core/taxes.py
+++ b/saleor/core/taxes.py
@@ -1,9 +1,8 @@
from dataclasses import dataclass
from decimal import Decimal
-from typing import List, Union
+from typing import List
-from django.contrib.sites.models import Site
-from prices import Money, MoneyRange, TaxedMoney, TaxedMoneyRange
+from prices import Money, TaxedMoney
class TaxError(Exception):
@@ -23,35 +22,6 @@ def zero_taxed_money(currency: str) -> TaxedMoney:
return TaxedMoney(net=zero, gross=zero)
-def include_taxes_in_prices() -> bool:
- return Site.objects.get_current().settings.include_taxes_in_prices
-
-
-def display_gross_prices() -> bool:
- return Site.objects.get_current().settings.display_gross_prices
-
-
-def charge_taxes_on_shipping() -> bool:
- return Site.objects.get_current().settings.charge_taxes_on_shipping
-
-
-def get_display_price(
- base: Union[TaxedMoney, TaxedMoneyRange], display_gross: bool = False
-) -> Money:
- """Return the price amount that should be displayed based on settings."""
- if not display_gross:
- display_gross = display_gross_prices()
- if isinstance(base, TaxedMoneyRange):
- if display_gross:
- base = MoneyRange(start=base.start.gross, stop=base.stop.gross)
- else:
- base = MoneyRange(start=base.start.net, stop=base.stop.net)
-
- if isinstance(base, TaxedMoney):
- base = base.gross if display_gross else base.net
- return base
-
-
@dataclass(frozen=True)
class TaxType:
"""Dataclass for unifying tax type object that comes from tax gateway."""
diff --git a/saleor/core/templatetags/taxed_prices.py b/saleor/core/templatetags/taxed_prices.py
index a60a1d433c..5cdd946421 100644
--- a/saleor/core/templatetags/taxed_prices.py
+++ b/saleor/core/templatetags/taxed_prices.py
@@ -1,18 +1,30 @@
-from django import template
-from prices import MoneyRange, TaxedMoney, TaxedMoneyRange
+from typing import Union
-from ..taxes import get_display_price
+from django import template
+from prices import Money, MoneyRange, TaxedMoney, TaxedMoneyRange
register = template.Library()
[email protected]_tag("price.html", takes_context=True)
-def price(context, base, display_gross=None, html=True):
- if isinstance(base, (TaxedMoney, TaxedMoneyRange)):
- if display_gross is None:
- display_gross = context["site"].settings.display_gross_prices
+def _get_display_price(
+ base: Union[TaxedMoney, TaxedMoneyRange], display_gross: bool
+) -> Money:
+ """Return the price amount that should be displayed based on settings."""
+ if isinstance(base, TaxedMoneyRange):
+ if display_gross:
+ base = MoneyRange(start=base.start.gross, stop=base.stop.gross)
+ else:
+ base = MoneyRange(start=base.start.net, stop=base.stop.net)
- base = get_display_price(base, display_gross)
+ if isinstance(base, TaxedMoney):
+ base = base.gross if display_gross else base.net
+ return base
+
+
[email protected]_tag("price.html")
+def price(base, display_gross, html=True):
+ if isinstance(base, (TaxedMoney, TaxedMoneyRange)):
+ base = _get_display_price(base, display_gross)
is_range = isinstance(base, MoneyRange)
return {"price": base, "is_range": is_range, "html": html}
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 00dca1b7c8..4517cd26c3 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -90,6 +90,8 @@ from ...shipping.models import (
ShippingMethodType,
ShippingZone,
)
+from ...tax.models import TaxClass, TaxConfiguration
+from ...tax.utils import get_tax_class_kwargs_for_order_line
from ...warehouse import WarehouseClickAndCollectOption
from ...warehouse.management import increase_stock
from ...warehouse.models import PreorderAllocation, Stock, Warehouse
@@ -634,7 +636,6 @@ def create_order_lines(order, discounts, how_many=10):
)
warehouse = next(warehouse_iter)
increase_stock(line, warehouse, line.quantity, allocate=True)
- manager.update_taxes_for_order_lines(order, lines)
OrderLine.objects.bulk_update(
lines,
[
@@ -695,7 +696,6 @@ def create_order_lines_with_preorder(order, discounts, how_many=1):
quantity=line.quantity,
)
)
- manager.update_taxes_for_order_lines(order, lines)
PreorderAllocation.objects.bulk_create(preorder_allocations)
OrderLine.objects.bulk_update(
@@ -749,6 +749,7 @@ def _get_new_order_line(order, variant, channel, discounts):
base_unit_price=untaxed_unit_price,
undiscounted_base_unit_price=untaxed_unit_price,
tax_rate=0,
+ **get_tax_class_kwargs_for_order_line(product.tax_class),
)
@@ -989,6 +990,7 @@ def create_channel(channel_name, currency_code, slug=None, country=None):
"default_country": country,
},
)
+ TaxConfiguration.objects.get_or_create(channel=channel)
return f"Channel: {channel}"
@@ -1612,3 +1614,12 @@ def create_checkout_with_same_variant_in_multiple_lines():
"Created checkout with four lines and same variant in multiple lines "
f"Checkout token: {checkout_info.checkout.token}."
)
+
+
+def create_tax_classes():
+ names = ["Groceries", "Books"]
+ tax_classes = []
+ for name in names:
+ tax_classes.append(TaxClass(name=name))
+ TaxClass.objects.bulk_create(tax_classes)
+ yield f"Created tax classes: {names}"
diff --git a/saleor/csv/tests/export/products_data/test_get_products_data.py b/saleor/csv/tests/export/products_data/test_get_products_data.py
index eb15614777..37a27d5dd0 100644
--- a/saleor/csv/tests/export/products_data/test_get_products_data.py
+++ b/saleor/csv/tests/export/products_data/test_get_products_data.py
@@ -43,6 +43,7 @@ def test_get_products_data(product, product_with_image, collection, image, chann
value
for mapping in ProductExportFields.HEADERS_TO_FIELDS_MAPPING.values()
for value in mapping.values()
+ if value
)
warehouse_ids = [str(warehouse.pk) for warehouse in Warehouse.objects.all()]
attribute_ids = [str(attr.pk) for attr in Attribute.objects.all()]
@@ -78,7 +79,6 @@ def test_get_products_data(product, product_with_image, collection, image, chann
"description_as_str": json.dumps(product.description),
"category__slug": product.category.slug,
"product_type__name": product.product_type.name,
- "charge_taxes": product.charge_taxes,
"collections__slug": (
""
if not product.collections.all()
diff --git a/saleor/csv/utils/__init__.py b/saleor/csv/utils/__init__.py
index 99f1da4fed..208858a5d1 100644
--- a/saleor/csv/utils/__init__.py
+++ b/saleor/csv/utils/__init__.py
@@ -8,7 +8,7 @@ class ProductExportFields:
"description": "description_as_str",
"category": "category__slug",
"product type": "product_type__name",
- "charge taxes": "charge_taxes",
+ "charge taxes": "", # deprecated; remove in Saleor 4.0
"product weight": "product_weight",
"variant id": "variants__id",
"variant sku": "variants__sku",
diff --git a/saleor/csv/utils/product_headers.py b/saleor/csv/utils/product_headers.py
index 3dbe2b7452..43cf6ea463 100644
--- a/saleor/csv/utils/product_headers.py
+++ b/saleor/csv/utils/product_headers.py
@@ -56,7 +56,8 @@ def get_product_export_fields_and_headers(
for field in fields:
lookup_field = fields_mapping[field]
- export_fields.append(lookup_field)
+ if lookup_field:
+ export_fields.append(lookup_field)
file_headers.append(field)
return export_fields, file_headers
diff --git a/saleor/discount/tests/test_discounts.py b/saleor/discount/tests/test_discounts.py
index 09e3f0e026..eeb2b4410b 100644
--- a/saleor/discount/tests/test_discounts.py
+++ b/saleor/discount/tests/test_discounts.py
@@ -613,7 +613,12 @@ def test_validate_voucher_not_applicable_once_per_customer(
total_price = TaxedMoney(net=price, gross=price)
with pytest.raises(NotApplicable):
validate_voucher(
- voucher, total_price, 0, customer_user.email, channel_USD, customer_user
+ voucher,
+ total_price,
+ 0,
+ customer_user.email,
+ channel_USD,
+ customer_user,
)
diff --git a/saleor/discount/utils.py b/saleor/discount/utils.py
index f5e07c770e..01d0923b4f 100644
--- a/saleor/discount/utils.py
+++ b/saleor/discount/utils.py
@@ -22,7 +22,7 @@ from django.utils import timezone
from prices import Money, TaxedMoney, fixed_discount, percentage_discount
from ..channel.models import Channel
-from ..core.taxes import include_taxes_in_prices, zero_money
+from ..core.taxes import zero_money
from . import DiscountInfo
from .models import (
DiscountValueType,
@@ -231,7 +231,11 @@ def validate_voucher_in_order(order: "Order"):
customer_email = order.get_customer_email()
if not order.voucher:
return
- value = subtotal.gross if include_taxes_in_prices() else subtotal.net
+
+ tax_configuration = order.channel.tax_configuration
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
+
+ value = subtotal.gross if prices_entered_with_tax else subtotal.net
validate_voucher(
order.voucher, value, quantity, customer_email, order.channel, order.user
)
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.py
index 5f52217b35..d5eb157ce6 100644
--- a/saleor/graphql/api.py
+++ b/saleor/graphql/api.py
@@ -23,7 +23,7 @@ from .plugins.schema import PluginsMutations, PluginsQueries
from .product.schema import ProductMutations, ProductQueries
from .shipping.schema import ShippingMutations, ShippingQueries
from .shop.schema import ShopMutations, ShopQueries
-from .tax.schema import TaxMutations
+from .tax.schema import TaxMutations, TaxQueries
from .translations.schema import TranslationQueries
from .warehouse.schema import StockQueries, WarehouseMutations, WarehouseQueries
from .webhook.schema import WebhookMutations, WebhookQueries
@@ -51,6 +51,7 @@ class Query(
ShippingQueries,
ShopQueries,
StockQueries,
+ TaxQueries,
TranslationQueries,
WarehouseQueries,
WebhookQueries,
diff --git a/saleor/graphql/channel/mutations/channel_create.py b/saleor/graphql/channel/mutations/channel_create.py
index f1e1606454..d9524b4296 100644
--- a/saleor/graphql/channel/mutations/channel_create.py
+++ b/saleor/graphql/channel/mutations/channel_create.py
@@ -4,6 +4,7 @@ from django.utils.text import slugify
from ....channel import models
from ....core.permissions import ChannelPermissions
from ....core.tracing import traced_atomic_transaction
+from ....tax.models import TaxConfiguration
from ...account.enums import CountryCodeEnum
from ...core.descriptions import ADDED_IN_31, ADDED_IN_35, ADDED_IN_37, PREVIEW_FEATURE
from ...core.mutations import ModelMutation
@@ -104,5 +105,6 @@ class ChannelCreate(ModelMutation):
@classmethod
def post_save_action(cls, info, instance, cleaned_input):
+ TaxConfiguration.objects.create(channel=instance)
manager = load_plugin_manager(info.context)
cls.call_event(manager.channel_created, instance)
diff --git a/saleor/graphql/channel/tests/fixtures.py b/saleor/graphql/channel/tests/fixtures.py
index 91dfa83896..5b163432d9 100644
--- a/saleor/graphql/channel/tests/fixtures.py
+++ b/saleor/graphql/channel/tests/fixtures.py
@@ -3,12 +3,32 @@ from django.conf import settings
from ....channel import AllocationStrategy
from ....channel.models import Channel
+from ....tax import TaxCalculationStrategy
+from ....tax.models import TaxConfiguration
+
+
+def _create_channel_tax_configuration(channel):
+ # Use TAX_APP strategy, to enable calculations with plugins by default.
+ tax_configuration = TaxConfiguration.objects.create(
+ channel=channel,
+ metadata={"key": "value"},
+ private_metadata={"key": "value"},
+ tax_calculation_strategy=TaxCalculationStrategy.TAX_APP,
+ )
+ tax_configuration.country_exceptions.create(
+ country="PL",
+ tax_calculation_strategy=TaxCalculationStrategy.TAX_APP,
+ )
+ tax_configuration.country_exceptions.create(
+ country="DE",
+ tax_calculation_strategy=TaxCalculationStrategy.TAX_APP,
+ )
@pytest.fixture
def channel_USD(db):
slug = settings.DEFAULT_CHANNEL_SLUG
- return Channel.objects.create(
+ channel = Channel.objects.create(
name="Main Channel",
slug=slug,
currency_code="USD",
@@ -16,11 +36,13 @@ def channel_USD(db):
is_active=True,
allocation_strategy=AllocationStrategy.PRIORITIZE_HIGH_STOCK,
)
+ _create_channel_tax_configuration(channel)
+ return channel
@pytest.fixture
def other_channel_USD(db):
- return Channel.objects.create(
+ channel = Channel.objects.create(
name="Other Channel USD",
slug="other-usd",
currency_code="USD",
@@ -28,11 +50,13 @@ def other_channel_USD(db):
is_active=True,
allocation_strategy=AllocationStrategy.PRIORITIZE_HIGH_STOCK,
)
+ _create_channel_tax_configuration(channel)
+ return channel
@pytest.fixture
def channel_PLN(db):
- return Channel.objects.create(
+ channel = Channel.objects.create(
name="Channel PLN",
slug="c-pln",
currency_code="PLN",
@@ -40,11 +64,13 @@ def channel_PLN(db):
is_active=True,
allocation_strategy=AllocationStrategy.PRIORITIZE_HIGH_STOCK,
)
+ _create_channel_tax_configuration(channel)
+ return channel
@pytest.fixture
def channel_JPY(db):
- return Channel.objects.create(
+ channel = Channel.objects.create(
name="Channel=JPY",
slug="c-jpy",
currency_code="JPY",
@@ -52,3 +78,5 @@ def channel_JPY(db):
is_active=True,
allocation_strategy=AllocationStrategy.PRIORITIZE_HIGH_STOCK,
)
+ _create_channel_tax_configuration(channel)
+ return channel
diff --git a/saleor/graphql/channel/tests/mutations/test_channel_create.py b/saleor/graphql/channel/tests/mutations/test_channel_create.py
index d09d6ec979..780e04efe3 100644
--- a/saleor/graphql/channel/tests/mutations/test_channel_create.py
+++ b/saleor/graphql/channel/tests/mutations/test_channel_create.py
@@ -9,6 +9,7 @@ from freezegun import freeze_time
from .....channel.error_codes import ChannelErrorCode
from .....channel.models import Channel
from .....core.utils.json_serializer import CustomJsonEncoder
+from .....tax.models import TaxConfiguration
from .....webhook.event_types import WebhookEventAsyncType
from .....webhook.payloads import generate_meta, generate_requestor
from ....tests.utils import assert_no_permission, get_graphql_content
@@ -410,3 +411,29 @@ def test_channel_create_mutation_trigger_webhook(
channel,
SimpleLazyObject(lambda: staff_api_client.user),
)
+
+
+def test_channel_create_creates_tax_configuration(
+ permission_manage_channels, staff_api_client
+):
+ # given
+ slug = "channel-with-tax-config"
+ variables = {
+ "input": {
+ "name": "Channel with tax config",
+ "slug": slug,
+ "currencyCode": "USD",
+ "defaultCountry": "US",
+ }
+ }
+
+ # when
+ staff_api_client.post_graphql(
+ CHANNEL_CREATE_MUTATION,
+ variables=variables,
+ permissions=(permission_manage_channels,),
+ )
+
+ # then
+ channel = Channel.objects.get(slug=slug)
+ assert TaxConfiguration.objects.filter(channel=channel).exists()
diff --git a/saleor/graphql/checkout/dataloaders.py b/saleor/graphql/checkout/dataloaders.py
index 7489bd4cbd..094222417b 100644
--- a/saleor/graphql/checkout/dataloaders.py
+++ b/saleor/graphql/checkout/dataloaders.py
@@ -32,6 +32,7 @@ from ..shipping.dataloaders import (
ShippingMethodByIdLoader,
ShippingMethodChannelListingByChannelSlugLoader,
)
+from ..tax.dataloaders import TaxClassByVariantIdLoader, TaxConfigurationByChannelId
from ..warehouse.dataloaders import WarehouseByIdLoader
@@ -63,6 +64,7 @@ class CheckoutLinesInfoByCheckoutTokenLoader(DataLoader):
products,
product_types,
collections,
+ tax_classes,
channel_listings,
voucher_infos,
) = results
@@ -70,6 +72,7 @@ class CheckoutLinesInfoByCheckoutTokenLoader(DataLoader):
products_map = dict(zip(variants_pks, products))
product_types_map = dict(zip(variants_pks, product_types))
collections_map = dict(zip(variants_pks, collections))
+ tax_class_map = dict(zip(variants_pks, tax_classes))
channel_listings_map = dict(
zip(variant_ids_channel_ids, channel_listings)
)
@@ -92,6 +95,7 @@ class CheckoutLinesInfoByCheckoutTokenLoader(DataLoader):
product=products_map[line.variant_id],
product_type=product_types_map[line.variant_id],
collections=collections_map[line.variant_id],
+ tax_class=tax_class_map[line.variant_id],
)
for line in lines
]
@@ -125,6 +129,9 @@ class CheckoutLinesInfoByCheckoutTokenLoader(DataLoader):
collections = CollectionsByVariantIdLoader(self.context).load_many(
variants_pks
)
+ tax_classes = TaxClassByVariantIdLoader(self.context).load_many(
+ variants_pks
+ )
voucher_codes = {
checkout.voucher_code for checkout in checkouts if checkout.voucher_code
@@ -148,6 +155,7 @@ class CheckoutLinesInfoByCheckoutTokenLoader(DataLoader):
products,
product_types,
collections,
+ tax_classes,
channel_listings,
voucher_infos,
]
@@ -250,6 +258,10 @@ class CheckoutInfoByCheckoutTokenLoader(DataLoader):
if checkout.voucher_code
}
vouchers = VoucherByCodeLoader(self.context).load_many(voucher_codes)
+ channel_ids = [channel.id for channel in channels]
+ tax_configurations = TaxConfigurationByChannelId(
+ self.context
+ ).load_many(channel_ids)
def with_checkout_info(results):
(
@@ -259,6 +271,7 @@ class CheckoutInfoByCheckoutTokenLoader(DataLoader):
listings_for_channels,
collection_points,
vouchers,
+ tax_configurations,
) = results
address_map = {address.id: address for address in addresses}
user_map = {user.id: user for user in users}
@@ -271,6 +284,10 @@ class CheckoutInfoByCheckoutTokenLoader(DataLoader):
for collection_point in collection_points
}
voucher_map = {voucher.code: voucher for voucher in vouchers}
+ tax_configuration_by_channel_map = {
+ tax_configuration.channel_id: tax_configuration
+ for tax_configuration in tax_configurations
+ }
checkout_info_map = {}
for key, checkout, channel, checkout_lines in zip(
@@ -298,6 +315,9 @@ class CheckoutInfoByCheckoutTokenLoader(DataLoader):
checkout.shipping_address_id
),
delivery_method_info=delivery_method_info,
+ tax_configuration=tax_configuration_by_channel_map.get(
+ channel.id
+ ),
valid_pick_up_points=[],
all_shipping_methods=[],
voucher=voucher,
@@ -332,6 +352,7 @@ class CheckoutInfoByCheckoutTokenLoader(DataLoader):
shipping_method_channel_listings,
collection_points,
vouchers,
+ tax_configurations,
]
).then(with_checkout_info)
diff --git a/saleor/graphql/checkout/mutations/utils.py b/saleor/graphql/checkout/mutations/utils.py
index 3103af2e20..8ebb513430 100644
--- a/saleor/graphql/checkout/mutations/utils.py
+++ b/saleor/graphql/checkout/mutations/utils.py
@@ -277,7 +277,7 @@ def get_checkout(
)
if qs is None:
qs = models.Checkout.objects.select_related(
- "channel",
+ "channel__tax_configuration",
"shipping_method",
"collection_point",
"billing_address",
diff --git a/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
index 00e4b1a6a5..0574c26cdc 100644
--- a/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
+++ b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
@@ -171,6 +171,7 @@ FRAGMENT_CHECKOUT = (
discountName
translatedDiscountName
voucherCode
+ displayGrossPrices
}
"""
)
@@ -389,7 +390,7 @@ def test_create_checkout_with_reservations(
}
}
- with django_assert_num_queries(55):
+ with django_assert_num_queries(63):
response = api_client.post_graphql(query, variables)
assert get_graphql_content(response)["data"]["checkoutCreate"]
assert Checkout.objects.first().lines.count() == 1
@@ -407,7 +408,7 @@ def test_create_checkout_with_reservations(
}
}
- with django_assert_num_queries(55):
+ with django_assert_num_queries(63):
response = api_client.post_graphql(query, variables)
assert get_graphql_content(response)["data"]["checkoutCreate"]
assert Checkout.objects.first().lines.count() == 10
@@ -657,7 +658,7 @@ def test_update_checkout_lines_with_reservations(
reservation_length=5,
)
- with django_assert_num_queries(54):
+ with django_assert_num_queries(68):
variant_id = graphene.Node.to_global_id("ProductVariant", variants[0].pk)
variables = {
"id": to_global_id_or_none(checkout),
@@ -671,7 +672,7 @@ def test_update_checkout_lines_with_reservations(
assert not data["errors"]
# Updating multiple lines in checkout has same query count as updating one
- with django_assert_num_queries(54):
+ with django_assert_num_queries(68):
variables = {
"id": to_global_id_or_none(checkout),
"lines": [],
@@ -914,7 +915,7 @@ def test_add_checkout_lines_with_reservations(
new_lines.append({"quantity": 2, "variantId": variant_id})
# Adding multiple lines to checkout has same query count as adding one
- with django_assert_num_queries(53):
+ with django_assert_num_queries(67):
variables = {
"id": Node.to_global_id("Checkout", checkout.pk),
"lines": [new_lines[0]],
@@ -927,7 +928,7 @@ def test_add_checkout_lines_with_reservations(
checkout.lines.exclude(id=line.id).delete()
- with django_assert_num_queries(53):
+ with django_assert_num_queries(67):
variables = {
"id": Node.to_global_id("Checkout", checkout.pk),
"lines": new_lines,
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_add_promo_code.py b/saleor/graphql/checkout/tests/mutations/test_checkout_add_promo_code.py
index 120d9ca250..fbae1c0f58 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_add_promo_code.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_add_promo_code.py
@@ -202,8 +202,11 @@ def test_checkout_add_voucher_code_by_token_with_external_shipment(
def test_checkout_add_voucher_code_with_display_gross_prices(
api_client, checkout_with_item, voucher, site_settings, monkeypatch
):
- site_settings.display_gross_prices = True
- site_settings.save()
+ channel = checkout_with_item.channel
+ tc = channel.tax_configuration
+ tc.display_gross_prices = True
+ tc.save(update_fields=["display_gross_prices"])
+ tc.country_exceptions.all().delete()
previous_checkout_last_change = checkout_with_item.last_change
@@ -233,8 +236,11 @@ def test_checkout_add_voucher_code_with_display_gross_prices(
def test_checkout_add_voucher_code_without_display_gross_prices(
api_client, checkout_with_item, voucher, site_settings, monkeypatch
):
- site_settings.display_gross_prices = False
- site_settings.save()
+ channel = checkout_with_item.channel
+ tc = channel.tax_configuration
+ tc.display_gross_prices = False
+ tc.save(update_fields=["display_gross_prices"])
+ tc.country_exceptions.all().delete()
previous_checkout_last_change = checkout_with_item.last_change
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_complete.py b/saleor/graphql/checkout/tests/mutations/test_checkout_complete.py
index 972794cb9f..7f261a4f92 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_complete.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_complete.py
@@ -288,10 +288,25 @@ def test_checkout_complete(
assert order.total_authorized == zero_money(order.currency)
order_line = order.lines.first()
+ line_tax_class = order_line.tax_class
+ shipping_tax_class = shipping_method.tax_class
+
assert checkout_line_quantity == order_line.quantity
assert checkout_line_variant == order_line.variant
+
+ assert order_line.tax_class == line_tax_class
+ assert order_line.tax_class_name == line_tax_class.name
+ assert order_line.tax_class_metadata == line_tax_class.metadata
+ assert order_line.tax_class_private_metadata == line_tax_class.private_metadata
+
assert order.shipping_address == address
assert order.shipping_method == checkout.shipping_method
+ assert order.shipping_tax_rate is not None
+ assert order.shipping_tax_class_name == shipping_tax_class.name
+ assert order.shipping_tax_class_metadata == shipping_tax_class.metadata
+ assert (
+ order.shipping_tax_class_private_metadata == shipping_tax_class.private_metadata
+ )
assert order.payments.exists()
assert order.search_vector
order_payment = order.payments.first()
diff --git a/saleor/graphql/checkout/tests/mutations/test_order_create_from_checkout.py b/saleor/graphql/checkout/tests/mutations/test_order_create_from_checkout.py
index a33b64ebfb..9a027e9935 100644
--- a/saleor/graphql/checkout/tests/mutations/test_order_create_from_checkout.py
+++ b/saleor/graphql/checkout/tests/mutations/test_order_create_from_checkout.py
@@ -166,12 +166,27 @@ def test_order_from_checkout(
assert order.private_metadata == checkout.private_metadata
order_line = order.lines.first()
+ line_tax_class = order_line.variant.product.tax_class
+ shipping_tax_class = shipping_method.tax_class
+
assert checkout_line_quantity == order_line.quantity
assert checkout_line_variant == order_line.variant
assert checkout_line_metadata == order_line.metadata
assert checkout_line_private_metadata == order_line.private_metadata
+
+ assert order_line.tax_class == line_tax_class
+ assert order_line.tax_class_name == line_tax_class.name
+ assert order_line.tax_class_metadata == line_tax_class.metadata
+ assert order_line.tax_class_private_metadata == line_tax_class.private_metadata
+
assert order.shipping_address == address
assert order.shipping_method == checkout.shipping_method
+ assert order.shipping_tax_rate is not None
+ assert order.shipping_tax_class_name == shipping_tax_class.name
+ assert order.shipping_tax_class_metadata == shipping_tax_class.metadata
+ assert (
+ order.shipping_tax_class_private_metadata == shipping_tax_class.private_metadata
+ )
assert order.search_vector
gift_card.refresh_from_db()
diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.py
index 9ec99ca439..4ea3dcc59c 100644
--- a/saleor/graphql/checkout/tests/test_checkout.py
+++ b/saleor/graphql/checkout/tests/test_checkout.py
@@ -6,7 +6,6 @@ import graphene
import pytest
from django.core.exceptions import ValidationError
from django.db.models import Sum
-from django.test import override_settings
from django.utils import timezone
from django.utils.dateparse import parse_datetime
from django_countries.fields import Country
@@ -1308,7 +1307,8 @@ def test_fetch_checkout_invalid_token(user_api_client, channel_USD, checkout):
QUERY_CHECKOUT_PRICES = """
query getCheckout($id: ID) {
checkout(id: $id) {
- token,
+ displayGrossPrices
+ token
totalPrice {
currency
gross {
@@ -1535,6 +1535,42 @@ def test_checkout_prices_with_sales(user_api_client, checkout_with_item, discoun
)
+def test_checkout_display_gross_prices_use_default(user_api_client, checkout_with_item):
+ # given
+ variables = {"id": to_global_id_or_none(checkout_with_item)}
+ tax_config = checkout_with_item.channel.tax_configuration
+ tax_config.country_exceptions.all().delete()
+
+ # when
+ response = user_api_client.post_graphql(QUERY_CHECKOUT_PRICES, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["checkout"]
+
+ # then
+ assert data["displayGrossPrices"] == tax_config.display_gross_prices
+
+
+def test_checkout_display_gross_prices_use_country_exception(
+ user_api_client, checkout_with_item
+):
+ # given
+ variables = {"id": to_global_id_or_none(checkout_with_item)}
+ tax_config = checkout_with_item.channel.tax_configuration
+ tax_config.country_exceptions.all().delete()
+ country_code = checkout_with_item.get_country()
+ tax_country_config = tax_config.country_exceptions.create(
+ country=country_code, display_gross_prices=False
+ )
+
+ # when
+ response = user_api_client.post_graphql(QUERY_CHECKOUT_PRICES, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["checkout"]
+
+ # then
+ assert data["displayGrossPrices"] == tax_country_config.display_gross_prices
+
+
def test_checkout_prices_with_specific_voucher(
user_api_client, checkout_with_item_and_voucher_specific_products
):
@@ -1978,31 +2014,6 @@ def test_get_variant_data_from_checkout_line_variant_hidden_in_listings(
assert content["data"]["checkout"]["lines"][0]["variant"]["id"]
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_checkout_with_vatlayer_set(
- checkout_with_item, api_client, vatlayer, site_settings, shipping_zone
-):
- # given
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- query = QUERY_CHECKOUT
- checkout = checkout_with_item
- checkout.shipping_method = shipping_zone.shipping_methods.get()
- checkout.save()
-
- variant = checkout.lines.get().variant
- variant.product.channel_listings.update(visible_in_listings=False)
- variables = {"id": to_global_id_or_none(checkout)}
-
- # when
- response = api_client.post_graphql(query, variables)
-
- # then
- content = get_graphql_content(response)
- assert content["data"]["checkout"]["token"] == str(checkout.token)
-
-
QUERY_CHECKOUT_TRANSACTIONS = """
query getCheckout($id: ID) {
checkout(id: $id) {
diff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.py
index 52a071a728..499289d9d7 100644
--- a/saleor/graphql/checkout/types.py
+++ b/saleor/graphql/checkout/types.py
@@ -15,6 +15,7 @@ from ...core.permissions import (
from ...core.taxes import zero_taxed_money
from ...core.tracing import traced_resolver
from ...shipping.interface import ShippingMethodData
+from ...tax.utils import get_display_gross_prices
from ...warehouse import models as warehouse_models
from ...warehouse.reservations import is_reservation_enabled
from ..account.dataloaders import AddressByIdLoader
@@ -27,6 +28,7 @@ from ..core.descriptions import (
ADDED_IN_31,
ADDED_IN_34,
ADDED_IN_38,
+ ADDED_IN_39,
DEPRECATED_IN_3X_FIELD,
PREVIEW_FEATURE,
)
@@ -46,7 +48,11 @@ from ..product.dataloaders import (
ProductVariantByIdLoader,
)
from ..shipping.types import ShippingMethod
-from ..site.dataloaders import get_site_promise, load_site_callback
+from ..site.dataloaders import load_site_callback
+from ..tax.dataloaders import (
+ TaxConfigurationByChannelId,
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader,
+)
from ..utils import get_user_or_app_from_context
from ..warehouse.dataloaders import StocksReservationsByCheckoutTokenLoader
from ..warehouse.types import Warehouse
@@ -233,10 +239,9 @@ class CheckoutLine(ModelObjectType):
lines = CheckoutLinesInfoByCheckoutTokenLoader(info.context).load(
checkout.token
)
- site = get_site_promise(info.context)
def calculate_line_total_price(data):
- (discounts, checkout_info, lines, site) = data
+ (discounts, checkout_info, lines) = data
for line_info in lines:
if line_info.line.pk == root.pk:
return calculations.checkout_line_total(
@@ -245,11 +250,10 @@ class CheckoutLine(ModelObjectType):
lines=lines,
checkout_line_info=line_info,
discounts=discounts,
- site_settings=site.settings,
)
return None
- return Promise.all([discounts, checkout_info, lines, site]).then(
+ return Promise.all([discounts, checkout_info, lines]).then(
calculate_line_total_price
)
@@ -402,7 +406,6 @@ class Checkout(ModelObjectType):
description="The shipping method related with checkout.",
deprecation_reason=(f"{DEPRECATED_IN_3X_FIELD} Use `deliveryMethod` instead."),
)
-
delivery_method = graphene.Field(
DeliveryMethod,
description=(
@@ -411,7 +414,6 @@ class Checkout(ModelObjectType):
+ PREVIEW_FEATURE
),
)
-
subtotal_price = graphene.Field(
TaxedMoney,
description="The price of the checkout before shipping, with taxes included.",
@@ -437,7 +439,6 @@ class Checkout(ModelObjectType):
language_code = graphene.Field(
LanguageCodeEnum, description="Checkout language code.", required=True
)
-
transactions = NonNullList(
TransactionItem,
description=(
@@ -447,6 +448,13 @@ class Checkout(ModelObjectType):
+ PREVIEW_FEATURE
),
)
+ display_gross_prices = graphene.Boolean(
+ description=(
+ "Determines whether checkout prices should include taxes when displayed "
+ "in a storefront." + ADDED_IN_39 + PREVIEW_FEATURE
+ ),
+ required=True,
+ )
class Meta:
description = "Checkout object."
@@ -541,14 +549,13 @@ class Checkout(ModelObjectType):
manager = load_plugin_manager(info.context)
def calculate_total_price(data):
- address, lines, checkout_info, discounts, site = data
+ address, lines, checkout_info, discounts = data
taxed_total = calculations.calculate_checkout_total_with_gift_cards(
manager=manager,
checkout_info=checkout_info,
lines=lines,
address=address,
discounts=discounts,
- site_settings=site.settings,
)
return max(taxed_total, zero_taxed_money(root.currency))
@@ -561,8 +568,7 @@ class Checkout(ModelObjectType):
discounts = DiscountsByDateTimeLoader(info.context).load(
info.context.request_time
)
- site = get_site_promise(info.context)
- return Promise.all([address, lines, checkout_info, discounts, site]).then(
+ return Promise.all([address, lines, checkout_info, discounts]).then(
calculate_total_price
)
@@ -573,14 +579,13 @@ class Checkout(ModelObjectType):
manager = load_plugin_manager(info.context)
def calculate_subtotal_price(data):
- address, lines, checkout_info, discounts, site = data
+ address, lines, checkout_info, discounts = data
return calculations.checkout_subtotal(
manager=manager,
checkout_info=checkout_info,
lines=lines,
address=address,
discounts=discounts,
- site_settings=site.settings,
)
address_id = root.shipping_address_id or root.billing_address_id
@@ -592,9 +597,8 @@ class Checkout(ModelObjectType):
discounts = DiscountsByDateTimeLoader(info.context).load(
info.context.request_time
)
- site = get_site_promise(info.context)
- return Promise.all([address, lines, checkout_info, discounts, site]).then(
+ return Promise.all([address, lines, checkout_info, discounts]).then(
calculate_subtotal_price
)
@@ -605,14 +609,13 @@ class Checkout(ModelObjectType):
manager = load_plugin_manager(info.context)
def calculate_shipping_price(data):
- address, lines, checkout_info, discounts, site = data
+ address, lines, checkout_info, discounts = data
return calculations.checkout_shipping_price(
manager=manager,
checkout_info=checkout_info,
lines=lines,
address=address,
discounts=discounts,
- site_settings=site.settings,
)
address = (
@@ -625,9 +628,8 @@ class Checkout(ModelObjectType):
discounts = DiscountsByDateTimeLoader(info.context).load(
info.context.request_time
)
- site = get_site_promise(info.context)
- return Promise.all([address, lines, checkout_info, discounts, site]).then(
+ return Promise.all([address, lines, checkout_info, discounts]).then(
calculate_shipping_price
)
@@ -719,6 +721,33 @@ class Checkout(ModelObjectType):
def resolve_transactions(root: models.Checkout, info):
return TransactionItemsByCheckoutIDLoader(info.context).load(root.pk)
+ @staticmethod
+ def resolve_display_gross_prices(root: models.Checkout, info):
+ tax_config = TaxConfigurationByChannelId(info.context).load(root.channel_id)
+ country_code = root.get_country()
+
+ def load_tax_country_exceptions(tax_config):
+ tax_configs_per_country = (
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader(info.context).load(
+ tax_config.id
+ )
+ )
+
+ def calculate_display_gross_prices(tax_configs_per_country):
+ tax_config_country = next(
+ (
+ tc
+ for tc in tax_configs_per_country
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ return get_display_gross_prices(tax_config, tax_config_country)
+
+ return tax_configs_per_country.then(calculate_display_gross_prices)
+
+ return tax_config.then(load_tax_country_exceptions)
+
class CheckoutCountableConnection(CountableConnection):
class Meta:
diff --git a/saleor/graphql/core/types/common.py b/saleor/graphql/core/types/common.py
index 61996e8c71..81799f680f 100644
--- a/saleor/graphql/core/types/common.py
+++ b/saleor/graphql/core/types/common.py
@@ -6,7 +6,7 @@ from django.core.files.storage import default_storage
from ....core.tracing import traced_resolver
from ....core.utils import build_absolute_uri
from ...account.enums import AddressTypeEnum
-from ..descriptions import ADDED_IN_36, PREVIEW_FEATURE
+from ..descriptions import ADDED_IN_36, DEPRECATED_IN_3X_FIELD, PREVIEW_FEATURE
from ..enums import (
AccountErrorCode,
AppErrorCode,
@@ -65,7 +65,14 @@ class NonNullList(graphene.List):
class CountryDisplay(graphene.ObjectType):
code = graphene.String(description="Country code.", required=True)
country = graphene.String(description="Country name.", required=True)
- vat = graphene.Field(VAT, description="Country tax.")
+ vat = graphene.Field(
+ VAT,
+ description="Country tax.",
+ deprecation_reason=(
+ f"{DEPRECATED_IN_3X_FIELD} Use `TaxClassCountryRate` type to manage tax "
+ "rates per country."
+ ),
+ )
class LanguageDisplay(graphene.ObjectType):
diff --git a/saleor/graphql/core/types/taxes.py b/saleor/graphql/core/types/taxes.py
index 4178b42c22..5134febcf6 100644
--- a/saleor/graphql/core/types/taxes.py
+++ b/saleor/graphql/core/types/taxes.py
@@ -1,3 +1,4 @@
+from functools import partial
from typing import Union
import graphene
@@ -6,9 +7,10 @@ from promise import Promise
from ....checkout import base_calculations
from ....checkout.models import Checkout, CheckoutLine
from ....core.prices import quantize_price
-from ....core.taxes import include_taxes_in_prices
from ....discount import VoucherType
from ....order.models import Order, OrderLine
+from ....order.utils import get_order_country
+from ....tax.utils import get_charge_taxes
from ...account.dataloaders import AddressByIdLoader
from ...channel.dataloaders import ChannelByIdLoader
from ...channel.types import Channel
@@ -24,11 +26,15 @@ from ...discount.dataloaders import (
OrderDiscountsByOrderIDLoader,
)
from ...order import types as order_types
-from ...order.dataloaders import OrderLinesByOrderIdLoader
+from ...order.dataloaders import OrderByIdLoader, OrderLinesByOrderIdLoader
from ...product.dataloaders.products import (
ProductByVariantIdLoader,
ProductVariantByIdLoader,
)
+from ...tax.dataloaders import (
+ TaxConfigurationByChannelId,
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader,
+)
from .common import NonNullList
from .money import Money
@@ -135,19 +141,61 @@ class TaxableObjectLine(graphene.ObjectType):
@staticmethod
def resolve_charge_taxes(root: Union[CheckoutLine, OrderLine], info):
+ def load_tax_configuration(channel, country_code):
+ tax_config = TaxConfigurationByChannelId(info.context).load(channel.pk)
+
+ def load_tax_country_exceptions(tax_config):
+ tax_configs_per_country = (
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader(
+ info.context
+ ).load(tax_config.id)
+ )
- if not root.variant_id:
- # By default charge taxes are set to True
- return True
+ def calculate_charge_taxes(tax_configs_per_country):
+ tax_config_country = next(
+ (
+ tc
+ for tc in tax_configs_per_country
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ return get_charge_taxes(tax_config, tax_config_country)
- def get_charge_taxes(product):
- return product.charge_taxes
+ return tax_configs_per_country.then(calculate_charge_taxes)
- return (
- ProductByVariantIdLoader(info.context)
- .load(root.variant_id)
- .then(get_charge_taxes)
- )
+ return tax_config.then(load_tax_country_exceptions)
+
+ if isinstance(root, CheckoutLine):
+ checkout = CheckoutByTokenLoader(info.context).load(root.checkout_id)
+
+ def load_channel(checkout):
+ country_code = checkout.get_country()
+ load_tax_config_with_country = partial(
+ load_tax_configuration, country_code=country_code
+ )
+ return (
+ ChannelByIdLoader(info.context)
+ .load(checkout.channel_id)
+ .then(load_tax_config_with_country)
+ )
+
+ return checkout.then(load_channel)
+ else:
+ order = OrderByIdLoader(info.context).load(root.order_id)
+
+ def load_channel(order): # type: ignore
+ country_code = get_order_country(order)
+ load_tax_config_with_country = partial(
+ load_tax_configuration, country_code=country_code
+ )
+ return (
+ ChannelByIdLoader(info.context)
+ .load(order.channel_id)
+ .then(load_tax_config_with_country)
+ )
+
+ return order.then(load_channel)
@staticmethod
def resolve_unit_price(root: Union[CheckoutLine, OrderLine], info):
@@ -297,7 +345,8 @@ class TaxableObject(graphene.ObjectType):
@staticmethod
def resolve_prices_entered_with_tax(root: Union[Checkout, Order], info):
- return include_taxes_in_prices()
+ tax_config = TaxConfigurationByChannelId(info.context).load(root.channel_id)
+ return tax_config.then(lambda tc: tc.prices_entered_with_tax)
@staticmethod
def resolve_currency(root: Union[Checkout, Order], info):
diff --git a/saleor/graphql/core/utils/__init__.py b/saleor/graphql/core/utils/__init__.py
index ca675057e0..0ab5bded5e 100644
--- a/saleor/graphql/core/utils/__init__.py
+++ b/saleor/graphql/core/utils/__init__.py
@@ -223,6 +223,8 @@ def from_global_id_or_error(
'<type>:<UUID>' : Internal ID containing object type and UUID
Optionally validate the object type, if `only_type` is provided,
raise GraphQLError when `raise_error` is set to True.
+
+ Returns tuple: (type, id).
"""
try:
type_, id_ = graphene.Node.from_global_id(global_id)
diff --git a/saleor/graphql/csv/enums.py b/saleor/graphql/csv/enums.py
index 888e66f6c1..adcb5e8e0d 100644
--- a/saleor/graphql/csv/enums.py
+++ b/saleor/graphql/csv/enums.py
@@ -32,7 +32,7 @@ class ProductFieldEnum(graphene.Enum):
CATEGORY = "category"
PRODUCT_WEIGHT = "product weight"
COLLECTIONS = "collections"
- CHARGE_TAXES = "charge taxes"
+ CHARGE_TAXES = "charge taxes" # deprecated; remove in Saleor 4.0
PRODUCT_MEDIA = "product media"
VARIANT_ID = "variant id"
VARIANT_SKU = "variant sku"
diff --git a/saleor/graphql/meta/permissions.py b/saleor/graphql/meta/permissions.py
index 76a718b965..b745028f98 100644
--- a/saleor/graphql/meta/permissions.py
+++ b/saleor/graphql/meta/permissions.py
@@ -153,6 +153,13 @@ def gift_card_permissions(_info, _object_pk: Any) -> List[BasePermissionEnum]:
return [GiftcardPermissions.MANAGE_GIFT_CARD]
+def tax_permissions(_info, _object_pk: int) -> List[BasePermissionEnum]:
+ return [
+ CheckoutPermissions.HANDLE_TAXES,
+ CheckoutPermissions.MANAGE_TAXES,
+ ]
+
+
PUBLIC_META_PERMISSION_MAP = {
"App": app_permissions,
"Attribute": attribute_permissions,
@@ -178,6 +185,8 @@ PUBLIC_META_PERMISSION_MAP = {
"Sale": discount_permissions,
"ShippingMethodType": shipping_permissions,
"ShippingZone": shipping_permissions,
+ "TaxConfiguration": tax_permissions,
+ "TaxClass": tax_permissions,
"User": public_user_permissions,
"Voucher": discount_permissions,
"Warehouse": product_permissions,
@@ -210,6 +219,8 @@ PRIVATE_META_PERMISSION_MAP = {
"ShippingMethod": shipping_permissions,
"ShippingMethodType": shipping_permissions,
"ShippingZone": shipping_permissions,
+ "TaxConfiguration": tax_permissions,
+ "TaxClass": tax_permissions,
"User": private_user_permissions,
"Voucher": discount_permissions,
"Warehouse": product_permissions,
diff --git a/saleor/graphql/meta/resolvers.py b/saleor/graphql/meta/resolvers.py
index 341650e292..056efc2e4d 100644
--- a/saleor/graphql/meta/resolvers.py
+++ b/saleor/graphql/meta/resolvers.py
@@ -7,6 +7,7 @@ from ...attribute import models as attribute_models
from ...checkout import models as checkout_models
from ...core.exceptions import PermissionDenied
from ...core.models import ModelWithMetadata
+from ...core.permissions import one_of_permissions_or_auth_filter_required
from ...discount import models as discount_models
from ...giftcard import models as giftcard_models
from ...order import models as order_models
@@ -15,6 +16,7 @@ from ...payment import models as payment_models
from ...product import models as product_models
from ...shipping import models as shipping_models
from ...shipping.interface import ShippingMethodData
+from ...tax import models as tax_models
from ...warehouse import models as warehouse_models
from ..utils import get_user_or_app_from_context
from .permissions import PRIVATE_META_PERMISSION_MAP
@@ -37,37 +39,40 @@ def resolve_object_with_metadata_type(instance):
from ..payment import types as payment_types
from ..product import types as product_types
from ..shipping import types as shipping_types
+ from ..tax import types as tax_types
from ..warehouse import types as warehouse_types
if isinstance(instance, ModelWithMetadata):
MODEL_TO_TYPE_MAP = {
+ account_models.User: account_types.User,
app_models.App: app_types.App,
attribute_models.Attribute: attribute_types.Attribute,
- product_models.Category: product_types.Category,
checkout_models.Checkout: checkout_types.Checkout,
checkout_models.CheckoutLine: checkout_types.CheckoutLine,
- product_models.Collection: product_types.Collection,
- product_models.DigitalContent: product_types.DigitalContent,
- order_models.Fulfillment: order_types.Fulfillment,
+ discount_models.Sale: discount_types.Sale,
+ discount_models.Voucher: discount_types.Voucher,
giftcard_models.GiftCard: giftcard_types.GiftCard,
+ invoice_models.Invoice: invoice_types.Invoice,
+ menu_models.Menu: menu_types.Menu,
+ menu_models.MenuItem: menu_types.MenuItem,
+ order_models.Fulfillment: order_types.Fulfillment,
order_models.Order: order_types.Order,
order_models.OrderLine: order_types.OrderLine,
- invoice_models.Invoice: invoice_types.Invoice,
page_models.Page: page_types.Page,
page_models.PageType: page_types.PageType,
payment_models.Payment: payment_types.Payment,
payment_models.TransactionItem: payment_types.TransactionItem,
+ product_models.Category: product_types.Category,
+ product_models.Collection: product_types.Collection,
+ product_models.DigitalContent: product_types.DigitalContent,
product_models.Product: product_types.Product,
product_models.ProductType: product_types.ProductType,
product_models.ProductVariant: product_types.ProductVariant,
- menu_models.Menu: menu_types.Menu,
- menu_models.MenuItem: menu_types.MenuItem,
shipping_models.ShippingMethod: shipping_types.ShippingMethodType,
shipping_models.ShippingZone: shipping_types.ShippingZone,
- account_models.User: account_types.User,
+ tax_models.TaxClass: tax_types.TaxClass,
+ tax_models.TaxConfiguration: tax_types.TaxConfiguration,
warehouse_models.Warehouse: warehouse_types.Warehouse,
- discount_models.Sale: discount_types.Sale,
- discount_models.Voucher: discount_types.Voucher,
}
return MODEL_TO_TYPE_MAP.get(instance.__class__, None), instance.pk
@@ -101,7 +106,9 @@ def check_private_metadata_privilege(root: ModelWithMetadata, info):
raise PermissionDenied()
requester = get_user_or_app_from_context(info.context)
- if not requester or not requester.has_perms(required_permissions):
+ if not requester or not one_of_permissions_or_auth_filter_required(
+ info.context, required_permissions
+ ):
raise PermissionDenied()
diff --git a/saleor/graphql/order/mutations/draft_order_complete.py b/saleor/graphql/order/mutations/draft_order_complete.py
index b05d3175aa..17a362d548 100644
--- a/saleor/graphql/order/mutations/draft_order_complete.py
+++ b/saleor/graphql/order/mutations/draft_order_complete.py
@@ -14,7 +14,7 @@ from ....order.calculations import fetch_order_prices_if_expired
from ....order.error_codes import OrderErrorCode
from ....order.fetch import OrderInfo, OrderLineInfo
from ....order.search import prepare_order_search_vector_value
-from ....order.utils import get_order_country
+from ....order.utils import get_order_country, update_order_display_gross_prices
from ....warehouse.management import allocate_preorders, allocate_stocks
from ....warehouse.reservations import is_reservation_enabled
from ...app.dataloaders import load_app
@@ -92,6 +92,7 @@ class DraftOrderComplete(BaseMutation):
order.search_vector = FlatConcatSearchVector(
*prepare_order_search_vector_value(order)
)
+ update_order_display_gross_prices(order)
order.save()
channel = order.channel
diff --git a/saleor/graphql/order/mutations/draft_order_create.py b/saleor/graphql/order/mutations/draft_order_create.py
index a8c7268098..e6877b0842 100644
--- a/saleor/graphql/order/mutations/draft_order_create.py
+++ b/saleor/graphql/order/mutations/draft_order_create.py
@@ -18,6 +18,7 @@ from ....order.utils import (
create_order_line,
invalidate_order_prices,
recalculate_order_weight,
+ update_order_display_gross_prices,
)
from ...account.i18n import I18nMixin
from ...account.types import AddressInput
@@ -30,7 +31,6 @@ from ...core.types import NonNullList, OrderError
from ...plugins.dataloaders import load_plugin_manager
from ...product.types import ProductVariant
from ...shipping.utils import get_shipping_model_by_object_id
-from ...site.dataloaders import get_site_promise
from ..types import Order
from ..utils import (
OrderLineData,
@@ -116,7 +116,6 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
redirect_url = data.pop("redirect_url", None)
channel_id = data.pop("channel_id", None)
manager = load_plugin_manager(info.context)
- site = get_site_promise(info.context).get()
shipping_method = get_shipping_model_by_object_id(
object_id=data.pop("shipping_method", None), raise_error=False
)
@@ -145,8 +144,6 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
cleaned_input["shipping_method"] = shipping_method
cleaned_input["status"] = OrderStatus.DRAFT
cleaned_input["origin"] = OrderOrigin.DRAFT
- display_gross_prices = site.settings.display_gross_prices
- cleaned_input["display_gross_prices"] = display_gross_prices
cls.clean_addresses(
info, instance, cleaned_input, shipping_address, billing_address, manager
@@ -285,7 +282,7 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
instance.shipping_method_name = shipping_method.name
@staticmethod
- def _save_lines(info, instance, lines_data, app, site, manager):
+ def _save_lines(info, instance, lines_data, app, manager):
if lines_data:
lines = []
for line_data in lines_data:
@@ -293,7 +290,6 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
instance,
line_data,
manager,
- site.settings,
)
lines.append(new_line)
@@ -309,6 +305,12 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
def _commit_changes(cls, info, instance, cleaned_input, is_new_instance, app):
if shipping_method := cleaned_input["shipping_method"]:
instance.shipping_method_name = shipping_method.name
+ tax_class = shipping_method.tax_class
+ if tax_class:
+ instance.shipping_tax_class = tax_class
+ instance.shipping_tax_class_name = tax_class.name
+ instance.shipping_tax_class_private_metadata = tax_class.metadata
+ instance.shipping_tax_class_metadata = tax_class.private_metadata
super().save(info, instance, cleaned_input)
# Create draft created event if the instance is from scratch
@@ -330,20 +332,18 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
def save(cls, info, instance, cleaned_input):
manager = load_plugin_manager(info.context)
app = load_app(info.context)
- site = get_site_promise(info.context).get()
return cls._save_draft_order(
info,
instance,
cleaned_input,
is_new_instance=True,
app=app,
- site=site,
manager=manager,
)
@classmethod
def _save_draft_order(
- cls, info, instance, cleaned_input, *, is_new_instance, app, site, manager
+ cls, info, instance, cleaned_input, *, is_new_instance, app, manager
):
with traced_atomic_transaction():
# Process addresses
@@ -358,7 +358,7 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
try:
# Process any lines to add
cls._save_lines(
- info, instance, cleaned_input.get("lines_data"), app, site, manager
+ info, instance, cleaned_input.get("lines_data"), app, manager
)
except TaxError as tax_error:
raise ValidationError(
@@ -366,6 +366,8 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
code=OrderErrorCode.TAX_ERROR.value,
)
+ update_order_display_gross_prices(instance)
+
if is_new_instance:
cls.call_event(manager.draft_order_created, instance)
@@ -373,7 +375,12 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
cls.call_event(manager.draft_order_updated, instance)
# Post-process the results
- updated_fields = ["weight", "search_vector", "updated_at"]
+ updated_fields = [
+ "weight",
+ "search_vector",
+ "updated_at",
+ "display_gross_prices",
+ ]
if cls.should_invalidate_prices(instance, cleaned_input, is_new_instance):
invalidate_order_prices(instance)
updated_fields.append("should_refresh_prices")
diff --git a/saleor/graphql/order/mutations/draft_order_update.py b/saleor/graphql/order/mutations/draft_order_update.py
index 590d45cc8c..e4c5c4de58 100644
--- a/saleor/graphql/order/mutations/draft_order_update.py
+++ b/saleor/graphql/order/mutations/draft_order_update.py
@@ -7,7 +7,6 @@ from ....order.error_codes import OrderErrorCode
from ...app.dataloaders import load_app
from ...core.types import OrderError
from ...plugins.dataloaders import load_plugin_manager
-from ...site.dataloaders import get_site_promise
from ..types import Order
from .draft_order_create import DraftOrderCreate, DraftOrderInput
@@ -59,13 +58,11 @@ class DraftOrderUpdate(DraftOrderCreate):
def save(cls, info, instance, cleaned_input):
manager = load_plugin_manager(info.context)
app = load_app(info.context)
- site = get_site_promise(info.context).get()
return cls._save_draft_order(
info,
instance,
cleaned_input,
is_new_instance=False,
app=app,
- site=site,
manager=manager,
)
diff --git a/saleor/graphql/order/mutations/order_confirm.py b/saleor/graphql/order/mutations/order_confirm.py
index 40e6b86898..703a4cce33 100644
--- a/saleor/graphql/order/mutations/order_confirm.py
+++ b/saleor/graphql/order/mutations/order_confirm.py
@@ -8,6 +8,7 @@ from ....order import OrderStatus, models
from ....order.actions import order_captured, order_confirmed
from ....order.error_codes import OrderErrorCode
from ....order.fetch import fetch_order_info
+from ....order.utils import update_order_display_gross_prices
from ....payment import PaymentError, gateway
from ....payment.gateway import request_charge_action
from ...app.dataloaders import load_app
@@ -60,7 +61,8 @@ class OrderConfirm(ModelMutation):
def perform_mutation(cls, root, info, **data):
order = cls.get_instance(info, **data)
order.status = OrderStatus.UNFULFILLED
- order.save(update_fields=["status", "updated_at"])
+ update_order_display_gross_prices(order)
+ order.save(update_fields=["status", "updated_at", "display_gross_prices"])
order_info = fetch_order_info(order)
payment = order_info.payment
manager = load_plugin_manager(info.context)
diff --git a/saleor/graphql/order/mutations/order_line_discount_remove.py b/saleor/graphql/order/mutations/order_line_discount_remove.py
index 47161de84f..b983dcbecf 100644
--- a/saleor/graphql/order/mutations/order_line_discount_remove.py
+++ b/saleor/graphql/order/mutations/order_line_discount_remove.py
@@ -6,8 +6,6 @@ from ....order import events
from ....order.utils import invalidate_order_prices, remove_discount_from_order_line
from ...app.dataloaders import load_app
from ...core.types import OrderError
-from ...plugins.dataloaders import load_plugin_manager
-from ...site.dataloaders import get_site_promise
from ..types import Order, OrderLine
from .order_discount_common import OrderDiscountCommon
@@ -37,21 +35,13 @@ class OrderLineDiscountRemove(OrderDiscountCommon):
@classmethod
def perform_mutation(cls, _root, info, **data):
- site = get_site_promise(info.context).get()
- tax_included = site.settings.include_taxes_in_prices
order_line = cls.get_node_or_error(
info, data.get("order_line_id"), only_type=OrderLine
)
order = order_line.order
cls.validate(info, order)
- manager = load_plugin_manager(info.context)
with traced_atomic_transaction():
- remove_discount_from_order_line(
- order_line,
- order,
- manager=manager,
- tax_included=tax_included,
- )
+ remove_discount_from_order_line(order_line, order)
app = load_app(info.context)
events.order_line_discount_removed_event(
order=order,
diff --git a/saleor/graphql/order/mutations/order_line_discount_update.py b/saleor/graphql/order/mutations/order_line_discount_update.py
index 6c0b4f064c..de0b2c7fea 100644
--- a/saleor/graphql/order/mutations/order_line_discount_update.py
+++ b/saleor/graphql/order/mutations/order_line_discount_update.py
@@ -8,8 +8,6 @@ from ....order import events
from ....order.utils import invalidate_order_prices, update_discount_for_order_line
from ...app.dataloaders import load_app
from ...core.types import OrderError
-from ...plugins.dataloaders import load_plugin_manager
-from ...site.dataloaders import get_site_promise
from ..types import Order, OrderLine
from .order_discount_common import OrderDiscountCommon, OrderDiscountCommonInput
@@ -59,10 +57,7 @@ class OrderLineDiscountUpdate(OrderDiscountCommon):
reason = input.get("reason")
value_type = input.get("value_type")
value = input.get("value")
- manager = load_plugin_manager(info.context)
- site = get_site_promise(info.context).get()
order_line_before_update = copy.deepcopy(order_line)
- tax_included = site.settings.include_taxes_in_prices
app = load_app(info.context)
with traced_atomic_transaction():
update_discount_for_order_line(
@@ -71,8 +66,6 @@ class OrderLineDiscountUpdate(OrderDiscountCommon):
reason=reason,
value_type=value_type,
value=value,
- manager=manager,
- tax_included=tax_included,
)
if (
order_line_before_update.unit_discount_value != value
diff --git a/saleor/graphql/order/mutations/order_lines_create.py b/saleor/graphql/order/mutations/order_lines_create.py
index cebe720381..4193feb71c 100644
--- a/saleor/graphql/order/mutations/order_lines_create.py
+++ b/saleor/graphql/order/mutations/order_lines_create.py
@@ -22,7 +22,6 @@ from ...core.types import NonNullList, OrderError
from ...discount.dataloaders import load_discounts
from ...plugins.dataloaders import load_plugin_manager
from ...product.types import ProductVariant
-from ...site.dataloaders import get_site_promise
from ..types import Order, OrderLine
from ..utils import (
OrderLineData,
@@ -122,7 +121,7 @@ class OrderLinesCreate(EditableOrderValidationMixin, BaseMutation):
raise ValidationError(error)
@staticmethod
- def add_lines_to_order(order, lines_data, user, app, manager, settings, discounts):
+ def add_lines_to_order(order, lines_data, user, app, manager, discounts):
added_lines: List[OrderLine] = []
try:
for line_data in lines_data:
@@ -132,7 +131,6 @@ class OrderLinesCreate(EditableOrderValidationMixin, BaseMutation):
user,
app,
manager,
- settings,
discounts=discounts,
allocate_stock=order.is_unconfirmed(),
)
@@ -155,7 +153,6 @@ class OrderLinesCreate(EditableOrderValidationMixin, BaseMutation):
cls.validate_variants(order, variants)
app = load_app(info.context)
manager = load_plugin_manager(info.context)
- site = get_site_promise(info.context).get()
discounts = load_discounts(info.context)
with traced_atomic_transaction():
added_lines = cls.add_lines_to_order(
@@ -164,7 +161,6 @@ class OrderLinesCreate(EditableOrderValidationMixin, BaseMutation):
info.context.user,
app,
manager,
- site.settings,
discounts,
)
diff --git a/saleor/graphql/order/mutations/order_update_shipping.py b/saleor/graphql/order/mutations/order_update_shipping.py
index bf5dbcf369..1d587db0a5 100644
--- a/saleor/graphql/order/mutations/order_update_shipping.py
+++ b/saleor/graphql/order/mutations/order_update_shipping.py
@@ -98,6 +98,10 @@ class OrderUpdateShipping(EditableOrderValidationMixin, BaseMutation):
order.base_shipping_price = zero_money(order.currency)
order.shipping_price = zero_taxed_money(order.currency)
order.shipping_method_name = None
+ order.shipping_tax_class = None
+ order.shipping_tax_class_name = None
+ order.shipping_tax_class_private_metadata = {}
+ order.shipping_tax_class_metadata = {}
invalidate_order_prices(order)
order.save(
update_fields=[
@@ -107,6 +111,11 @@ class OrderUpdateShipping(EditableOrderValidationMixin, BaseMutation):
"shipping_price_gross_amount",
"base_shipping_price_amount",
"shipping_method_name",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_private_metadata",
+ "shipping_tax_class_metadata",
+ "shipping_tax_rate",
"should_refresh_prices",
"updated_at",
]
@@ -145,8 +154,15 @@ class OrderUpdateShipping(EditableOrderValidationMixin, BaseMutation):
clean_order_update_shipping(order, shipping_method_data, manager)
order.shipping_method = method
-
order.shipping_method_name = method.name
+
+ tax_class = method.tax_class
+ if tax_class:
+ order.shipping_tax_class = tax_class
+ order.shipping_tax_class_name = tax_class.name
+ order.shipping_tax_class_private_metadata = tax_class.private_metadata
+ order.shipping_tax_class_metadata = tax_class.metadata
+
order.base_shipping_price = shipping_method_data.price
invalidate_order_prices(order)
order.save(
@@ -154,6 +170,10 @@ class OrderUpdateShipping(EditableOrderValidationMixin, BaseMutation):
"currency",
"shipping_method",
"shipping_method_name",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_private_metadata",
+ "shipping_tax_class_metadata",
"base_shipping_price_amount",
"should_refresh_prices",
"updated_at",
diff --git a/saleor/graphql/order/tests/benchmark/test_order.py b/saleor/graphql/order/tests/benchmark/test_order.py
index 41e68a87d8..7a232dec2a 100644
--- a/saleor/graphql/order/tests/benchmark/test_order.py
+++ b/saleor/graphql/order/tests/benchmark/test_order.py
@@ -101,6 +101,7 @@ FRAGMENT_ORDER_DETAILS = (
shippingPrice {
...Price
}
+ displayGrossPrices
}
"""
)
diff --git a/saleor/graphql/order/tests/test_order.py b/saleor/graphql/order/tests/test_order.py
index 2b50f9547c..75a8c8f425 100644
--- a/saleor/graphql/order/tests/test_order.py
+++ b/saleor/graphql/order/tests/test_order.py
@@ -40,7 +40,11 @@ from ....order.search import (
prepare_order_search_vector_value,
update_order_search_vector,
)
-from ....order.utils import update_order_authorize_data, update_order_charge_data
+from ....order.utils import (
+ get_order_country,
+ update_order_authorize_data,
+ update_order_charge_data,
+)
from ....payment import ChargeStatus, PaymentError, TransactionAction, TransactionStatus
from ....payment.interface import TransactionActionData
from ....payment.models import Payment, TransactionEvent, TransactionItem
@@ -193,6 +197,19 @@ def test_orderline_query(staff_api_client, permission_manage_orders, fulfilled_o
key
value
}
+ taxClass {
+ name
+ }
+ taxClassName
+ taxClassMetadata {
+ key
+ value
+ }
+ taxClassPrivateMetadata {
+ key
+ value
+ }
+ taxRate
}
}
}
@@ -251,6 +268,122 @@ def test_orderline_query(staff_api_client, permission_manage_orders, fulfilled_o
}
]
+ line_tax_class = line.variant.product.tax_class
+ assert first_order_data_line["taxClass"]["name"] == line_tax_class.name
+ assert first_order_data_line["taxClassName"] == line_tax_class.name
+ assert (
+ first_order_data_line["taxClassMetadata"][0]["key"]
+ == list(line_tax_class.metadata.keys())[0]
+ )
+ assert (
+ first_order_data_line["taxClassMetadata"][0]["value"]
+ == list(line_tax_class.metadata.values())[0]
+ )
+ assert (
+ first_order_data_line["taxClassPrivateMetadata"][0]["key"]
+ == list(line_tax_class.private_metadata.keys())[0]
+ )
+ assert (
+ first_order_data_line["taxClassPrivateMetadata"][0]["value"]
+ == list(line_tax_class.private_metadata.values())[0]
+ )
+
+
+def test_denormalized_tax_class_in_orderline_query(
+ staff_api_client, permission_manage_orders, fulfilled_order
+):
+ # given
+ order = fulfilled_order
+ query = """
+ query OrdersQuery {
+ orders(first: 1) {
+ edges {
+ node {
+ lines {
+ thumbnail(size: 540) {
+ url
+ }
+ variant {
+ id
+ }
+ quantity
+ allocations {
+ id
+ quantity
+ warehouse {
+ id
+ }
+ }
+ unitPrice {
+ currency
+ gross {
+ amount
+ }
+ }
+ totalPrice {
+ currency
+ gross {
+ amount
+ }
+ }
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
+ taxClass {
+ name
+ }
+ taxClassName
+ taxClassMetadata {
+ key
+ value
+ }
+ taxClassPrivateMetadata {
+ key
+ value
+ }
+ taxRate
+ }
+ }
+ }
+ }
+ }
+ """
+
+ staff_api_client.user.user_permissions.add(permission_manage_orders)
+ line_tax_class = order.lines.first().tax_class
+ assert line_tax_class
+
+ # when
+ line_tax_class.delete()
+ response = staff_api_client.post_graphql(query)
+ content = get_graphql_content(response)
+
+ # then
+ line_data = content["data"]["orders"]["edges"][0]["node"]["lines"][0]
+ assert line_data["taxClass"] is None
+ assert line_data["taxClassName"] == line_tax_class.name
+ assert (
+ line_data["taxClassMetadata"][0]["key"]
+ == list(line_tax_class.metadata.keys())[0]
+ )
+ assert (
+ line_data["taxClassMetadata"][0]["value"]
+ == list(line_tax_class.metadata.values())[0]
+ )
+ assert (
+ line_data["taxClassPrivateMetadata"][0]["key"]
+ == list(line_tax_class.private_metadata.keys())[0]
+ )
+ assert (
+ line_data["taxClassPrivateMetadata"][0]["value"]
+ == list(line_tax_class.private_metadata.values())[0]
+ )
+
def test_order_line_with_allocations(
staff_api_client,
@@ -336,6 +469,18 @@ query OrdersQuery {
}
}
shippingTaxRate
+ shippingTaxClass {
+ name
+ }
+ shippingTaxClassName
+ shippingTaxClassMetadata {
+ key
+ value
+ }
+ shippingTaxClassPrivateMetadata {
+ key
+ value
+ }
lines {
id
unitPrice{
@@ -566,6 +711,25 @@ def test_order_query(
)
assert expected_price == shipping_price.gross
assert order_data["shippingTaxRate"] == float(shipping_tax_rate)
+ shipping_tax_class = order.shipping_method.tax_class
+ assert order_data["shippingTaxClass"]["name"] == shipping_tax_class.name
+ assert order_data["shippingTaxClassName"] == shipping_tax_class.name
+ assert (
+ order_data["shippingTaxClassMetadata"][0]["key"]
+ == list(shipping_tax_class.metadata.keys())[0]
+ )
+ assert (
+ order_data["shippingTaxClassMetadata"][0]["value"]
+ == list(shipping_tax_class.metadata.values())[0]
+ )
+ assert (
+ order_data["shippingTaxClassPrivateMetadata"][0]["key"]
+ == list(shipping_tax_class.private_metadata.keys())[0]
+ )
+ assert (
+ order_data["shippingTaxClassPrivateMetadata"][0]["value"]
+ == list(shipping_tax_class.private_metadata.values())[0]
+ )
assert order_data["shippingMethod"]["active"] is True
assert order_data["shippingMethod"]["message"] == ""
assert public_value == order_data["shippingMethod"]["metadata"][0]["value"]
@@ -605,6 +769,46 @@ def test_order_query(
assert order_data["deliveryMethod"]["id"] == order_data["shippingMethod"]["id"]
+def test_order_query_denormalized_shipping_tax_class_data(
+ staff_api_client,
+ permission_manage_orders,
+ permission_manage_shipping,
+ fulfilled_order,
+):
+ # given
+ order = fulfilled_order
+ staff_api_client.user.user_permissions.add(permission_manage_orders)
+ staff_api_client.user.user_permissions.add(permission_manage_shipping)
+ shipping_tax_class = order.shipping_method.tax_class
+ assert shipping_tax_class
+
+ # when
+ shipping_tax_class.delete()
+ response = staff_api_client.post_graphql(ORDERS_QUERY)
+ content = get_graphql_content(response)
+
+ # then
+ order_data = content["data"]["orders"]["edges"][0]["node"]
+ assert order_data["shippingTaxClass"] is None
+ assert order_data["shippingTaxClassName"] == shipping_tax_class.name
+ assert (
+ order_data["shippingTaxClassMetadata"][0]["key"]
+ == list(shipping_tax_class.metadata.keys())[0]
+ )
+ assert (
+ order_data["shippingTaxClassMetadata"][0]["value"]
+ == list(shipping_tax_class.metadata.values())[0]
+ )
+ assert (
+ order_data["shippingTaxClassPrivateMetadata"][0]["key"]
+ == list(shipping_tax_class.private_metadata.keys())[0]
+ )
+ assert (
+ order_data["shippingTaxClassPrivateMetadata"][0]["value"]
+ == list(shipping_tax_class.private_metadata.values())[0]
+ )
+
+
def test_order_query_total_price_is_0(
staff_api_client,
permission_manage_orders,
@@ -1537,6 +1741,7 @@ ORDER_CONFIRM_MUTATION = """
errors {
field
code
+ message
}
order {
status
@@ -1618,6 +1823,41 @@ def test_order_confirm(
)
+def test_order_confirm_update_display_gross_prices(
+ staff_api_client,
+ order_with_lines,
+ permission_manage_orders,
+):
+ # given
+ order = order_with_lines
+ order.status = OrderStatus.UNCONFIRMED
+ order.save(update_fields=["status"])
+ channel = order.channel
+ tax_config = channel.tax_configuration
+
+ # Change the current display_gross_prices to the opposite of what is set in the
+ # order.display_gross_prices.
+ new_display_gross_prices = not order.display_gross_prices
+
+ tax_config.display_gross_prices = new_display_gross_prices
+ tax_config.save()
+ tax_config.country_exceptions.all().delete()
+
+ # when
+ staff_api_client.user.user_permissions.add(permission_manage_orders)
+
+ response = staff_api_client.post_graphql(
+ ORDER_CONFIRM_MUTATION,
+ {"id": graphene.Node.to_global_id("Order", order.id)},
+ )
+ content = get_graphql_content(response)
+
+ # then
+ assert not content["data"]["orderConfirm"]["errors"]
+ order.refresh_from_db()
+ assert order.display_gross_prices == new_display_gross_prices
+
+
@patch("saleor.plugins.manager.PluginsManager.notify")
@patch("saleor.payment.gateway.capture")
def test_order_confirm_without_sku(
@@ -2506,6 +2746,7 @@ DRAFT_ORDER_CREATE_MUTATION = """
addressType
}
order {
+ id
discount {
amount
}
@@ -3535,6 +3776,51 @@ def test_draft_order_create_invalid_shipping_address(
assert errors[0]["addressType"] == AddressType.SHIPPING.upper()
+def test_draft_order_create_update_display_gross_prices(
+ staff_api_client,
+ permission_manage_orders,
+ variant,
+ channel_USD,
+ graphql_address_data,
+):
+ # given
+ # display_gross_prices is disabled and there is no country-specific configuration
+ # order.display_gross_prices should be also disabled as a result
+
+ tax_config = channel_USD.tax_configuration
+ tax_config.display_gross_prices = False
+ tax_config.save()
+ tax_config.country_exceptions.all().delete()
+
+ variant_0 = variant
+ query = DRAFT_ORDER_CREATE_MUTATION
+
+ variant_0_id = graphene.Node.to_global_id("ProductVariant", variant_0.id)
+ variant_list = [{"variantId": variant_0_id, "quantity": 2}]
+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)
+
+ variables = {
+ "lines": variant_list,
+ "billingAddress": graphql_address_data,
+ "shippingAddress": graphql_address_data,
+ "channel": channel_id,
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ query, variables, permissions=[permission_manage_orders]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ assert not content["data"]["draftOrderCreate"]["errors"]
+ order_id = content["data"]["draftOrderCreate"]["order"]["id"]
+ _, order_pk = graphene.Node.from_global_id(order_id)
+
+ order = Order.objects.get(id=order_pk)
+ assert not order.display_gross_prices
+
+
@patch("saleor.order.calculations.fetch_order_prices_if_expired")
def test_draft_order_create_price_recalculation(
mock_fetch_order_prices_if_expired,
@@ -4157,6 +4443,51 @@ def test_can_finalize_order_product_available_for_purchase_from_tomorrow(
assert errors[0]["orderLines"] == [graphene.Node.to_global_id("OrderLine", line.pk)]
+QUERY_ORDER_PRICES = """
+ query OrderQuery($id: ID!) {
+ order(id: $id) {
+ displayGrossPrices
+ }
+ }
+"""
+
+
+def test_order_display_gross_prices_use_default(user_api_client, order_with_lines):
+ # given
+ variables = {"id": graphene.Node.to_global_id("Order", order_with_lines.id)}
+ tax_config = order_with_lines.channel.tax_configuration
+ tax_config.country_exceptions.all().delete()
+
+ # when
+ response = user_api_client.post_graphql(QUERY_ORDER_PRICES, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["order"]
+
+ # then
+ assert data["displayGrossPrices"] == tax_config.display_gross_prices
+
+
+def test_order_display_gross_prices_use_country_exception(
+ user_api_client, order_with_lines
+):
+ # given
+ variables = {"id": graphene.Node.to_global_id("Order", order_with_lines.id)}
+ tax_config = order_with_lines.channel.tax_configuration
+ tax_config.country_exceptions.all().delete()
+ country_code = get_order_country(order_with_lines)
+ tax_country_config = tax_config.country_exceptions.create(
+ country=country_code, display_gross_prices=False
+ )
+
+ # when
+ response = user_api_client.post_graphql(QUERY_ORDER_PRICES, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["order"]
+
+ # then
+ assert data["displayGrossPrices"] == tax_country_config.display_gross_prices
+
+
def test_validate_draft_order(draft_order):
# should not raise any errors
assert validate_draft_order(draft_order, "US", get_plugins_manager()) is None
@@ -5092,6 +5423,35 @@ ORDER_LINES_CREATE_MUTATION = """
"""
+def test_draft_order_complete_display_gross_prices(
+ staff_api_client,
+ permission_manage_orders,
+ draft_order,
+):
+ # given
+ order = draft_order
+ channel = order.channel
+ tax_config = channel.tax_configuration
+
+ # Change the current display_gross_prices to the opposite of what is set in the
+ # order.display_gross_prices.
+ new_display_gross_prices = not order.display_gross_prices
+
+ tax_config.display_gross_prices = new_display_gross_prices
+ tax_config.save()
+ tax_config.country_exceptions.all().delete()
+
+ order_id = graphene.Node.to_global_id("Order", order.id)
+ variables = {"id": order_id}
+ response = staff_api_client.post_graphql(
+ DRAFT_ORDER_COMPLETE_MUTATION, variables, permissions=[permission_manage_orders]
+ )
+ content = get_graphql_content(response)
+ assert not content["data"]["draftOrderComplete"]["errors"]
+ order.refresh_from_db()
+ assert order.display_gross_prices == new_display_gross_prices
+
+
@patch("saleor.plugins.manager.PluginsManager.product_variant_out_of_stock")
def test_order_lines_create_with_out_of_stock_webhook(
product_variant_out_of_stock_webhook_mock,
@@ -7437,6 +7797,14 @@ def test_order_update_shipping(
assert order.shipping_tax_rate == Decimal("0.0")
assert order.shipping_method_name == shipping_method.name
+ shipping_tax_class = shipping_method.tax_class
+ assert order.shipping_tax_rate is not None
+ assert order.shipping_tax_class == shipping_tax_class
+ assert order.shipping_tax_class_metadata == shipping_tax_class.metadata
+ assert (
+ order.shipping_tax_class_private_metadata == shipping_tax_class.private_metadata
+ )
+
@pytest.mark.parametrize("status", [OrderStatus.UNCONFIRMED, OrderStatus.DRAFT])
def test_order_update_shipping_no_shipping_method_channel_listings(
@@ -7473,8 +7841,8 @@ def test_order_update_shipping_tax_included(
order_with_lines,
shipping_method,
staff_user,
- vatlayer,
):
+ # given
order = order_with_lines
order.status = OrderStatus.UNCONFIRMED
order.save(update_fields=["status"])
@@ -7483,6 +7851,14 @@ def test_order_update_shipping_tax_included(
address.country = "DE"
address.save()
+ tc = order.channel.tax_configuration
+ tc.country_exceptions.all().delete()
+ tc.tax_calculation_strategy = "FLAT_RATES"
+ tc.prices_entered_with_tax = True
+ tc.save()
+ shipping_method.tax_class.country_rates.get_or_create(country="DE", rate=19)
+
+ # when
query = ORDER_UPDATE_SHIPPING_QUERY
order_id = graphene.Node.to_global_id("Order", order.id)
method_id = graphene.Node.to_global_id("ShippingMethod", shipping_method.id)
@@ -7490,6 +7866,8 @@ def test_order_update_shipping_tax_included(
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_orders]
)
+
+ # then
content = get_graphql_content(response)
data = content["data"]["orderUpdateShipping"]
assert data["order"]["id"] == order_id
@@ -7542,6 +7920,10 @@ def test_order_update_shipping_clear_shipping_method(
assert order.shipping_price == zero_taxed_money(order.currency)
assert order.shipping_method_name is None
+ assert order.shipping_tax_class is None
+ assert order.shipping_tax_class_metadata == {}
+ assert order.shipping_tax_class_private_metadata == {}
+
def test_order_update_shipping_shipping_required(
staff_api_client, permission_manage_orders, order_with_lines, staff_user
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
index 69a2522a6b..7f8fa83e46 100644
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@ -42,6 +42,7 @@ from ...product.models import ALL_PRODUCTS_PERMISSIONS
from ...shipping.interface import ShippingMethodData
from ...shipping.models import ShippingMethodChannelListing
from ...shipping.utils import convert_to_shipping_method_data
+from ...tax.utils import get_display_gross_prices
from ...thumbnail.utils import get_image_or_proxy_url, get_thumbnail_size
from ..account.dataloaders import AddressByIdLoader, UserByUserIdLoader
from ..account.types import User
@@ -60,6 +61,7 @@ from ..core.descriptions import (
ADDED_IN_31,
ADDED_IN_34,
ADDED_IN_38,
+ ADDED_IN_39,
DEPRECATED_IN_3X_FIELD,
PREVIEW_FEATURE,
)
@@ -86,7 +88,8 @@ from ..giftcard.dataloaders import GiftCardsByOrderIdLoader
from ..giftcard.types import GiftCard
from ..invoice.dataloaders import InvoicesByOrderIdLoader
from ..invoice.types import Invoice
-from ..meta.types import ObjectWithMetadata
+from ..meta.resolvers import check_private_metadata_privilege, resolve_metadata
+from ..meta.types import MetadataItem, ObjectWithMetadata
from ..payment.enums import OrderAction, TransactionStatusEnum
from ..payment.types import Payment, PaymentChargeStatusEnum, TransactionItem
from ..plugins.dataloaders import load_plugin_manager
@@ -105,7 +108,12 @@ from ..shipping.dataloaders import (
ShippingMethodChannelListingByShippingMethodIdAndChannelSlugLoader,
)
from ..shipping.types import ShippingMethod
-from ..site.dataloaders import get_site_promise
+from ..tax.dataloaders import (
+ TaxClassByIdLoader,
+ TaxConfigurationByChannelId,
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader,
+)
+from ..tax.types import TaxClass
from ..warehouse.types import Allocation, Stock, Warehouse
from .dataloaders import (
AllocationsByOrderLineIdLoader,
@@ -581,6 +589,36 @@ class OrderLine(ModelObjectType):
DiscountValueTypeEnum,
description="Type of the discount: fixed or percent",
)
+ tax_class = PermissionsField(
+ TaxClass,
+ description="Denormalized tax class of the product in this order line."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE,
+ required=False,
+ permissions=[AuthorizationFilters.AUTHENTICATED_STAFF_USER],
+ )
+ tax_class_name = graphene.Field(
+ graphene.String,
+ description="Denormalized name of the tax class."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE,
+ required=False,
+ )
+ tax_class_metadata = NonNullList(
+ MetadataItem,
+ required=True,
+ description="Denormalized public metadata of the tax class."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE,
+ )
+ tax_class_private_metadata = NonNullList(
+ MetadataItem,
+ required=True,
+ description=(
+ "Denormalized private metadata of the tax class. Requires staff "
+ "permissions to access." + ADDED_IN_39 + PREVIEW_FEATURE
+ ),
+ )
class Meta:
description = "Represents order line of particular order."
@@ -697,7 +735,9 @@ class OrderLine(ModelObjectType):
def _resolve_tax_rate(data):
order, lines = data
- return calculations.order_line_tax_rate(order, root, manager, lines)
+ return calculations.order_line_tax_rate(
+ order, root, manager, lines
+ ) or Decimal(0)
order = OrderByIdLoader(info.context).load(root.order_id)
lines = OrderLinesByOrderIdLoader(info.context).load(root.order_id)
@@ -780,6 +820,23 @@ class OrderLine(ModelObjectType):
def resolve_allocations(root: models.OrderLine, info):
return AllocationsByOrderLineIdLoader(info.context).load(root.id)
+ @staticmethod
+ def resolve_tax_class(root: models.OrderLine, info):
+ return (
+ TaxClassByIdLoader(info.context).load(root.tax_class_id)
+ if root.tax_class_id
+ else None
+ )
+
+ @staticmethod
+ def resolve_tax_class_metadata(root: models.OrderLine, _info):
+ return resolve_metadata(root.tax_class_metadata)
+
+ @staticmethod
+ def resolve_tax_class_private_metadata(root: models.OrderLine, info):
+ check_private_metadata_privilege(root, info)
+ return resolve_metadata(root.tax_class_private_metadata)
+
class Order(ModelObjectType):
id = graphene.GlobalID(required=True)
@@ -914,7 +971,6 @@ class Order(ModelObjectType):
undiscounted_total = graphene.Field(
TaxedMoney, description="Undiscounted total amount of the order.", required=True
)
-
shipping_price = graphene.Field(
TaxedMoney, description="Total price of shipping.", required=True
)
@@ -923,11 +979,46 @@ class Order(ModelObjectType):
description="Shipping method for this order.",
deprecation_reason=(f"{DEPRECATED_IN_3X_FIELD} Use `deliveryMethod` instead."),
)
-
shipping_price = graphene.Field(
TaxedMoney, description="Total price of shipping.", required=True
)
- shipping_tax_rate = graphene.Float(required=True)
+ shipping_tax_rate = graphene.Float(
+ required=True, description="The shipping tax rate value."
+ )
+ shipping_tax_class = PermissionsField(
+ TaxClass,
+ description="Denormalized tax class assigned to the shipping method."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE,
+ required=False,
+ permissions=[AuthorizationFilters.AUTHENTICATED_STAFF_USER],
+ )
+ shipping_tax_class_name = graphene.Field(
+ graphene.String,
+ description=(
+ "Denormalized name of the tax class assigned to the shipping method."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE
+ ),
+ required=False,
+ )
+ shipping_tax_class_metadata = NonNullList(
+ MetadataItem,
+ required=True,
+ description=(
+ "Denormalized public metadata of the shipping method's tax class."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE
+ ),
+ )
+ shipping_tax_class_private_metadata = NonNullList(
+ MetadataItem,
+ required=True,
+ description=(
+ "Denormalized private metadata of the shipping method's tax class. "
+ "Requires staff permissions to access." + ADDED_IN_39 + PREVIEW_FEATURE
+ ),
+ )
token = graphene.String(
required=True,
deprecation_reason=(f"{DEPRECATED_IN_3X_FIELD} Use `id` instead."),
@@ -936,7 +1027,6 @@ class Order(ModelObjectType):
gift_cards = NonNullList(
GiftCard, description="List of user gift cards.", required=True
)
- display_gross_prices = graphene.Boolean(required=True)
customerNote = graphene.Boolean(required=True)
customer_note = graphene.String(required=True)
weight = graphene.Field(Weight, required=True)
@@ -1016,14 +1106,12 @@ class Order(ModelObjectType):
f"{DEPRECATED_IN_3X_FIELD} Use the `discounts` field instead."
),
)
-
translated_discount_name = graphene.String(
description="Translated discount name.",
deprecation_reason=(
f"{DEPRECATED_IN_3X_FIELD} Use the `discounts` field instead. "
),
)
-
discounts = NonNullList(
"saleor.graphql.discount.types.OrderDiscount",
description="List of all discounts assigned to the order.",
@@ -1035,6 +1123,13 @@ class Order(ModelObjectType):
default_value=[],
required=True,
)
+ display_gross_prices = graphene.Boolean(
+ description=(
+ "Determines whether checkout prices should include taxes when displayed "
+ "in a storefront." + ADDED_IN_39 + PREVIEW_FEATURE
+ ),
+ required=True,
+ )
class Meta:
description = "Represents an order in the shop."
@@ -1185,7 +1280,9 @@ class Order(ModelObjectType):
manager = load_plugin_manager(info.context)
def _resolve_shipping_tax_rate(lines):
- return calculations.order_shipping_tax_rate(root, manager, lines)
+ return calculations.order_shipping_tax_rate(
+ root, manager, lines
+ ) or Decimal(0)
return (
OrderLinesByOrderIdLoader(info.context)
@@ -1493,11 +1590,14 @@ class Order(ModelObjectType):
external_app_shipping_id = get_external_shipping_id(root)
if external_app_shipping_id:
+ tax_config = TaxConfigurationByChannelId(info.context).load(root.channel_id)
- def get_shipping_method(site):
- keep_gross = site.settings.include_taxes_in_prices
+ def with_tax_config(tax_config):
+ prices_entered_with_tax = tax_config.prices_entered_with_tax
price = (
- root.shipping_price_gross if keep_gross else root.shipping_price_net
+ root.shipping_price_gross
+ if prices_entered_with_tax
+ else root.shipping_price_net
)
return ShippingMethodData(
id=external_app_shipping_id,
@@ -1505,7 +1605,7 @@ class Order(ModelObjectType):
price=price,
)
- return get_site_promise(info.context).then(get_shipping_method)
+ return tax_config.then(with_tax_config)
if not root.shipping_method_id:
return None
@@ -1634,6 +1734,52 @@ class Order(ModelObjectType):
return validation_error_to_error_type(e, OrderError)
return []
+ @staticmethod
+ def resolve_display_gross_prices(root: models.Order, info):
+ tax_config = TaxConfigurationByChannelId(info.context).load(root.channel_id)
+ country_code = get_order_country(root)
+
+ def load_tax_country_exceptions(tax_config):
+ tax_configs_per_country = (
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader(info.context).load(
+ tax_config.id
+ )
+ )
+
+ def calculate_display_gross_prices(tax_configs_per_country):
+ tax_config_country = next(
+ (
+ tc
+ for tc in tax_configs_per_country
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ return get_display_gross_prices(tax_config, tax_config_country)
+
+ return tax_configs_per_country.then(calculate_display_gross_prices)
+
+ return tax_config.then(load_tax_country_exceptions)
+
+ @classmethod
+ def resolve_shipping_tax_class(cls, root: models.Order, info):
+ if root.shipping_method_id:
+ return cls.resolve_shipping_method(root, info).then(
+ lambda shipping_method_data: shipping_method_data.tax_class
+ if shipping_method_data
+ else None
+ )
+ return None
+
+ @staticmethod
+ def resolve_shipping_tax_class_metadata(root: models.Order, _info):
+ return resolve_metadata(root.shipping_tax_class_metadata)
+
+ @staticmethod
+ def resolve_shipping_tax_class_private_metadata(root: models.Order, info):
+ check_private_metadata_privilege(root, info)
+ return resolve_metadata(root.shipping_tax_class_private_metadata)
+
class OrderCountableConnection(CountableConnection):
class Meta:
diff --git a/saleor/graphql/page/sorters.py b/saleor/graphql/page/sorters.py
index 75ee726be9..1f1e8cb86e 100644
--- a/saleor/graphql/page/sorters.py
+++ b/saleor/graphql/page/sorters.py
@@ -41,8 +41,8 @@ class PageTypeSortField(graphene.Enum):
@property
def description(self):
if self.name in PageTypeSortField.__enum__._member_names_:
- sport_name = self.name.lower().replace("_", " ")
- return f"Sort page types by {sport_name}."
+ sort_name = self.name.lower().replace("_", " ")
+ return f"Sort page types by {sort_name}."
raise ValueError(f"Unsupported enum value: {self.value}")
diff --git a/saleor/graphql/product/mutations/product_type_create.py b/saleor/graphql/product/mutations/product_type_create.py
index 1ca156c144..2c4329be63 100644
--- a/saleor/graphql/product/mutations/product_type_create.py
+++ b/saleor/graphql/product/mutations/product_type_create.py
@@ -5,11 +5,11 @@ from ....attribute import AttributeType
from ....core.permissions import ProductTypePermissions
from ....product import ProductTypeKind, models
from ....product.error_codes import ProductErrorCode
+from ...core.descriptions import DEPRECATED_IN_3X_INPUT
from ...core.mutations import ModelMutation
from ...core.scalars import WeightScalar
from ...core.types import NonNullList, ProductError
from ...core.utils import validate_slug_and_generate_if_needed
-from ...plugins.dataloaders import load_plugin_manager
from ..enums import ProductTypeKindEnum
from ..types import ProductType
@@ -45,7 +45,20 @@ class ProductTypeInput(graphene.InputObjectType):
description="Determines if products are digital.", required=False
)
weight = WeightScalar(description="Weight of the ProductType items.")
- tax_code = graphene.String(description="Tax rate for enabled tax gateway.")
+ tax_code = graphene.String(
+ description=(
+ f"Tax rate for enabled tax gateway. {DEPRECATED_IN_3X_INPUT}. "
+ "Use tax classes to control the tax calculation for a product type."
+ )
+ )
+ tax_class = graphene.ID(
+ description=(
+ "ID of a tax class to assign to this product type. All products of this "
+ "product type would use this tax class, unless it's overridden in the "
+ "`Product` type."
+ ),
+ required=False,
+ )
class ProductTypeCreate(ModelMutation):
@@ -94,11 +107,6 @@ class ProductTypeCreate(ModelMutation):
error.code = ProductErrorCode.REQUIRED.value
raise ValidationError({"slug": error})
- tax_code = cleaned_input.pop("tax_code", "")
- if tax_code:
- manager = load_plugin_manager(info.context)
- manager.assign_tax_code_to_object_meta(instance, tax_code)
-
cls.validate_attributes(cleaned_input)
return cleaned_input
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index b1c3a71176..cfd49fdcaf 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -566,7 +566,11 @@ class ProductInput(graphene.InputObjectType):
attributes = NonNullList(AttributeValueInput, description="List of attributes.")
category = graphene.ID(description="ID of the product's category.", name="category")
charge_taxes = graphene.Boolean(
- description="Determine if taxes are being charged for the product."
+ description=(
+ "Determine if taxes are being charged for the product. "
+ f"{DEPRECATED_IN_3X_INPUT} Use `Channel.taxConfiguration` to configure "
+ "whether tax collection is enabled."
+ )
)
collections = NonNullList(
graphene.ID,
@@ -576,7 +580,19 @@ class ProductInput(graphene.InputObjectType):
description = JSONString(description="Product description." + RICH_CONTENT)
name = graphene.String(description="Product name.")
slug = graphene.String(description="Product slug.")
- tax_code = graphene.String(description="Tax rate for enabled tax gateway.")
+ tax_class = graphene.ID(
+ description=(
+ "ID of a tax class to assign to this product. If not provided, product "
+ "will use the tax class which is assigned to the product type."
+ ),
+ required=False,
+ )
+ tax_code = graphene.String(
+ description=(
+ f"Tax rate for enabled tax gateway. {DEPRECATED_IN_3X_INPUT} "
+ "Use tax classes to control the tax calculation for a product."
+ )
+ )
seo = SeoInput(description="Search engine optimization fields.")
weight = WeightScalar(description="Weight of the Product.", required=False)
rating = graphene.Float(description="Defines the product rating value.")
@@ -676,10 +692,6 @@ class ProductCreate(ModelMutation):
error.code = ProductErrorCode.REQUIRED.value
raise ValidationError({"slug": error})
- if "tax_code" in cleaned_input:
- manager = load_plugin_manager(info.context)
- manager.assign_tax_code_to_object_meta(instance, cleaned_input["tax_code"])
-
if attributes and product_type:
try:
cleaned_input["attributes"] = cls.clean_attributes(
diff --git a/saleor/graphql/product/tests/benchmark/test_product.py b/saleor/graphql/product/tests/benchmark/test_product.py
index 91316edca7..d926e1069b 100644
--- a/saleor/graphql/product/tests/benchmark/test_product.py
+++ b/saleor/graphql/product/tests/benchmark/test_product.py
@@ -139,6 +139,7 @@ def test_product_details(product_with_image, api_client, count_queries, channel_
}
}
}
+ displayGrossPrices
}
}
}
@@ -299,6 +300,7 @@ def test_retrieve_channel_listings(
}
}
}
+ displayGrossPrices
}
}
}
diff --git a/saleor/graphql/product/tests/mutations/test_product_create.py b/saleor/graphql/product/tests/mutations/test_product_create.py
index fadd0d5a70..59841213df 100644
--- a/saleor/graphql/product/tests/mutations/test_product_create.py
+++ b/saleor/graphql/product/tests/mutations/test_product_create.py
@@ -33,6 +33,9 @@ CREATE_PRODUCT_MUTATION = """
}
description
chargeTaxes
+ taxClass {
+ id
+ }
taxType {
taxCode
description
@@ -94,6 +97,7 @@ def test_create_product(
description_json,
permission_manage_products,
monkeypatch,
+ tax_classes,
):
# given
@@ -106,6 +110,7 @@ def test_create_product(
product_slug = "product-test-slug"
product_charge_taxes = True
product_tax_rate = "STANDARD"
+ tax_class_id = graphene.Node.to_global_id("TaxClass", tax_classes[0].pk)
# Mock tax interface with fake response from tax gateway
monkeypatch.setattr(
@@ -134,6 +139,7 @@ def test_create_product(
"slug": product_slug,
"description": description_json,
"chargeTaxes": product_charge_taxes,
+ "taxClass": tax_class_id,
"taxCode": product_tax_rate,
"attributes": [
{"id": color_attr_id, "values": [color_value_name]},
@@ -160,6 +166,7 @@ def test_create_product(
assert data["product"]["taxType"]["taxCode"] == product_tax_rate
assert data["product"]["productType"]["name"] == product_type.name
assert data["product"]["category"]["name"] == category.name
+ assert data["product"]["taxClass"]["id"] == tax_class_id
values = (
data["product"]["attributes"][0]["values"][0]["slug"],
data["product"]["attributes"][1]["values"][0]["slug"],
@@ -175,6 +182,36 @@ def test_create_product(
updated_webhook_mock.assert_not_called()
+def test_create_product_use_tax_class_from_product_type(
+ staff_api_client,
+ product_type,
+ permission_manage_products,
+ default_tax_class,
+ tax_classes,
+):
+ # given
+ default_tax_class_id = graphene.Node.to_global_id("TaxClass", default_tax_class.pk)
+ product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)
+ variables = {
+ "input": {
+ "productType": product_type_id,
+ "name": "Test Empty Tax Class",
+ "slug": "test-empty-tax-class",
+ }
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ CREATE_PRODUCT_MUTATION, variables, permissions=[permission_manage_products]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["productCreate"]
+ assert data["errors"] == []
+ assert data["product"]["taxClass"]["id"] == default_tax_class_id
+
+
def test_create_product_description_plaintext(
staff_api_client,
product_type,
@@ -759,7 +796,6 @@ def test_create_product_no_slug_in_input(
product_type,
category,
permission_manage_products,
- monkeypatch,
input_slug,
):
query = CREATE_PRODUCT_MUTATION
@@ -767,14 +803,6 @@ def test_create_product_no_slug_in_input(
product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)
category_id = graphene.Node.to_global_id("Category", category.pk)
product_name = "test name"
- product_tax_rate = "STANDARD"
-
- # Mock tax interface with fake response from tax gateway
- monkeypatch.setattr(
- PluginsManager,
- "get_tax_code_from_object_meta",
- lambda self, x: TaxType(description="", code=product_tax_rate),
- )
# test creating root product
variables = {
@@ -783,7 +811,6 @@ def test_create_product_no_slug_in_input(
"category": category_id,
"name": product_name,
"slug": input_slug,
- "taxCode": product_tax_rate,
}
}
@@ -795,7 +822,6 @@ def test_create_product_no_slug_in_input(
assert data["errors"] == []
assert data["product"]["name"] == product_name
assert data["product"]["slug"] == "test-name"
- assert data["product"]["taxType"]["taxCode"] == product_tax_rate
assert data["product"]["productType"]["name"] == product_type.name
assert data["product"]["category"]["name"] == category.name
@@ -804,28 +830,18 @@ def test_create_product_no_category_id(
staff_api_client,
product_type,
permission_manage_products,
- monkeypatch,
):
query = CREATE_PRODUCT_MUTATION
product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)
product_name = "test name"
- product_tax_rate = "STANDARD"
input_slug = "test-slug"
- # Mock tax interface with fake response from tax gateway
- monkeypatch.setattr(
- PluginsManager,
- "get_tax_code_from_object_meta",
- lambda self, x: TaxType(description="", code=product_tax_rate),
- )
-
variables = {
"input": {
"productType": product_type_id,
"name": product_name,
"slug": input_slug,
- "taxCode": product_tax_rate,
}
}
@@ -837,7 +853,6 @@ def test_create_product_no_category_id(
assert data["errors"] == []
assert data["product"]["name"] == product_name
assert data["product"]["slug"] == input_slug
- assert data["product"]["taxType"]["taxCode"] == product_tax_rate
assert data["product"]["productType"]["name"] == product_type.name
assert data["product"]["category"] is None
diff --git a/saleor/graphql/product/tests/mutations/test_product_type_create.py b/saleor/graphql/product/tests/mutations/test_product_type_create.py
index dcaf8fd6fb..c568f18c72 100644
--- a/saleor/graphql/product/tests/mutations/test_product_type_create.py
+++ b/saleor/graphql/product/tests/mutations/test_product_type_create.py
@@ -4,7 +4,6 @@ import graphene
import pytest
from .....attribute import AttributeType
-from .....plugins.manager import PluginsManager
from .....product.error_codes import ProductErrorCode
from .....product.models import ProductType
from ....tests.utils import get_graphql_content
@@ -15,6 +14,7 @@ PRODUCT_TYPE_CREATE_MUTATION = """
$name: String,
$slug: String,
$kind: ProductTypeKindEnum,
+ $taxClass: ID,
$taxCode: String,
$hasVariants: Boolean,
$isShippingRequired: Boolean,
@@ -26,6 +26,7 @@ PRODUCT_TYPE_CREATE_MUTATION = """
name: $name,
slug: $slug,
kind: $kind,
+ taxClass: $taxClass,
taxCode: $taxCode,
hasVariants: $hasVariants,
isShippingRequired: $isShippingRequired,
@@ -64,6 +65,9 @@ PRODUCT_TYPE_CREATE_MUTATION = """
}
}
+ taxClass {
+ id
+ }
}
errors {
field
@@ -82,9 +86,8 @@ def test_product_type_create_mutation(
product_type,
permission_manage_product_types_and_attributes,
monkeypatch,
- setup_vatlayer,
+ tax_classes,
):
- manager = PluginsManager(plugins=setup_vatlayer.PLUGINS)
query = PRODUCT_TYPE_CREATE_MUTATION
product_type_name = "test type"
@@ -100,16 +103,17 @@ def test_product_type_create_mutation(
variant_attributes_ids = [
graphene.Node.to_global_id("Attribute", att.id) for att in variant_attributes
]
+ tax_class_id = graphene.Node.to_global_id("TaxClass", tax_classes[0].pk)
variables = {
"name": product_type_name,
"slug": slug,
"kind": kind,
"hasVariants": has_variants,
- "taxCode": "wine",
"isShippingRequired": require_shipping,
"productAttributes": product_attributes_ids,
"variantAttributes": variant_attributes_ids,
+ "taxClass": tax_class_id,
}
initial_count = ProductType.objects.count()
response = staff_api_client.post_graphql(
@@ -138,10 +142,6 @@ def test_product_type_create_mutation(
[value.name for value in va.values.all()]
)
- new_instance = ProductType.objects.latest("pk")
- tax_code = manager.get_tax_code_from_object_meta(new_instance).code
- assert tax_code == "wine"
-
def test_product_type_create_mutation_optional_kind(
staff_api_client, permission_manage_product_types_and_attributes
@@ -164,10 +164,7 @@ def test_create_gift_card_product_type(
product_type,
permission_manage_product_types_and_attributes,
monkeypatch,
- setup_vatlayer,
):
- manager = PluginsManager(plugins=setup_vatlayer.PLUGINS)
-
query = PRODUCT_TYPE_CREATE_MUTATION
product_type_name = "test type"
slug = "test-type"
@@ -188,7 +185,6 @@ def test_create_gift_card_product_type(
"slug": slug,
"kind": kind,
"hasVariants": has_variants,
- "taxCode": "wine",
"isShippingRequired": require_shipping,
"productAttributes": product_attributes_ids,
"variantAttributes": variant_attributes_ids,
@@ -220,10 +216,6 @@ def test_create_gift_card_product_type(
[value.name for value in va.values.all()]
)
- new_instance = ProductType.objects.latest("pk")
- tax_code = manager.get_tax_code_from_object_meta(new_instance).code
- assert tax_code == "wine"
-
def test_create_product_type_with_rich_text_attribute(
staff_api_client,
@@ -497,7 +489,6 @@ def test_product_type_create_mutation_not_valid_attributes(
product_type,
permission_manage_product_types_and_attributes,
monkeypatch,
- setup_vatlayer,
):
# given
query = PRODUCT_TYPE_CREATE_MUTATION
@@ -528,7 +519,6 @@ def test_product_type_create_mutation_not_valid_attributes(
"slug": slug,
"kind": ProductTypeKindEnum.NORMAL.name,
"hasVariants": has_variants,
- "taxCode": "wine",
"isShippingRequired": require_shipping,
"productAttributes": product_attributes_ids,
"variantAttributes": variant_attributes_ids,
diff --git a/saleor/graphql/product/tests/mutations/test_product_type_update.py b/saleor/graphql/product/tests/mutations/test_product_type_update.py
index e86794c16f..03b817069f 100644
--- a/saleor/graphql/product/tests/mutations/test_product_type_update.py
+++ b/saleor/graphql/product/tests/mutations/test_product_type_update.py
@@ -15,6 +15,7 @@ mutation updateProductType(
$hasVariants: Boolean!,
$isShippingRequired: Boolean!,
$productAttributes: [ID!],
+ $taxClass: ID
) {
productTypeUpdate(
id: $id,
@@ -23,6 +24,7 @@ mutation updateProductType(
hasVariants: $hasVariants,
isShippingRequired: $isShippingRequired,
productAttributes: $productAttributes
+ taxClass: $taxClass
}) {
productType {
name
@@ -35,6 +37,9 @@ mutation updateProductType(
productAttributes {
id
}
+ taxClass {
+ id
+ }
}
errors {
code
@@ -51,6 +56,7 @@ def test_product_type_update_mutation(
product_type,
product,
permission_manage_product_types_and_attributes,
+ tax_classes,
):
query = PRODUCT_TYPE_UPDATE_MUTATION
product_type_name = "test type updated"
@@ -58,6 +64,7 @@ def test_product_type_update_mutation(
has_variants = True
require_shipping = False
product_type_id = graphene.Node.to_global_id("ProductType", product_type.id)
+ tax_class_id = graphene.Node.to_global_id("TaxClass", tax_classes[0].pk)
# Test scenario: remove all product attributes using [] as input
# but do not change variant attributes
@@ -73,6 +80,7 @@ def test_product_type_update_mutation(
"hasVariants": has_variants,
"isShippingRequired": require_shipping,
"productAttributes": product_attributes_ids,
+ "taxClass": tax_class_id,
}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_product_types_and_attributes]
@@ -85,6 +93,7 @@ def test_product_type_update_mutation(
assert data["isShippingRequired"] == require_shipping
assert not data["productAttributes"]
assert len(data["variantAttributes"]) == (variant_attributes.count())
+ assert data["taxClass"]["id"] == tax_class_id
def test_product_type_update_mutation_not_valid_attributes(
diff --git a/saleor/graphql/product/tests/queries/test_product_query.py b/saleor/graphql/product/tests/queries/test_product_query.py
index d5d672f07a..f3fa820ac0 100644
--- a/saleor/graphql/product/tests/queries/test_product_query.py
+++ b/saleor/graphql/product/tests/queries/test_product_query.py
@@ -1,5 +1,5 @@
from datetime import timedelta
-from unittest.mock import MagicMock, patch
+from unittest.mock import MagicMock
import graphene
import pytest
@@ -12,7 +12,6 @@ from .....attribute.models import AttributeValue
from .....attribute.utils import associate_attribute_values_to_instance
from .....core.units import WeightUnits
from .....product.models import ProductChannelListing, ProductVariantChannelListing
-from .....product.utils.availability import get_variant_availability
from .....tests.utils import dummy_editorjs
from .....thumbnail.models import Thumbnail
from .....warehouse.models import Stock
@@ -1523,44 +1522,6 @@ def test_product_variant_without_price_as_staff_with_permission(
assert variants_data[1]["pricing"] is None
-QUERY_GET_PRODUCT_VARIANTS_PRICING_NO_ADDRESS = """
- query getProductVariants($id: ID!, $channel: String) {
- product(id: $id, channel: $channel) {
- variants {
- id
- pricing {
- priceUndiscounted {
- gross {
- amount
- }
- }
- }
- }
- }
- }
-"""
-
-
-@patch(
- "saleor.graphql.product.types.products.get_variant_availability",
- wraps=get_variant_availability,
-)
-def test_product_variant_price_no_address(
- mock_get_variant_availability, user_api_client, variant, stock, channel_USD
-):
- channel_USD.default_country = "FR"
- channel_USD.save()
- product_id = graphene.Node.to_global_id("Product", variant.product.id)
- variables = {"id": product_id, "channel": channel_USD.slug}
- user_api_client.post_graphql(
- QUERY_GET_PRODUCT_VARIANTS_PRICING_NO_ADDRESS, variables
- )
- assert (
- mock_get_variant_availability.call_args[1]["country"]
- == channel_USD.default_country
- )
-
-
def test_get_product_with_sorted_attribute_values(
staff_api_client,
product,
diff --git a/saleor/graphql/product/tests/test_product_channel_listings_queries.py b/saleor/graphql/product/tests/test_product_channel_listings_queries.py
index a49e7b936e..845d582687 100644
--- a/saleor/graphql/product/tests/test_product_channel_listings_queries.py
+++ b/saleor/graphql/product/tests/test_product_channel_listings_queries.py
@@ -1,11 +1,18 @@
+from decimal import Decimal
from unittest import mock
import graphene
+import pytest
-from ....product.utils.availability import get_product_availability
+from ....tax import TaxCalculationStrategy
+from ....tax.models import TaxClassCountryRate, TaxConfigurationPerCountry
+from ....tax.utils import get_display_gross_prices
from ....warehouse.models import Warehouse
from ...tests.utils import get_graphql_content
+TAX_RATE_DE = 19
+TAX_RATE_PL = 23
+
QUERY_PRICING_ON_PRODUCT_CHANNEL_LISTING = """
fragment Pricing on ProductPricingInfo {
priceRangeUndiscounted {
@@ -16,6 +23,7 @@ fragment Pricing on ProductPricingInfo {
}
}
}
+ displayGrossPrices
}
query FetchProduct($id: ID, $channel: String, $address: AddressInput) {
product(id: $id, channel: $channel) {
@@ -51,13 +59,17 @@ def test_product_channel_listing_pricing_field(
warehouse.address = address_usa
warehouse.save()
+ country = "PL"
variables = {
"id": graphene.Node.to_global_id("Product", product.pk),
"channel": channel_USD.slug,
- "address": {"country": "PL"},
+ "address": {"country": country},
}
product.channel_listings.exclude(channel__slug=channel_USD.slug).delete()
+ tax_config = channel_USD.tax_configuration
+ tax_config_country = tax_config.country_exceptions.get(country=country)
+
# when
response = staff_api_client.post_graphql(
QUERY_PRICING_ON_PRODUCT_CHANNEL_LISTING,
@@ -71,6 +83,9 @@ def test_product_channel_listing_pricing_field(
product_data = content["data"]["product"]
product_channel_listing_data = product_data["channelListings"][0]
assert product_data["pricing"] == product_channel_listing_data["pricing"]
+ assert product_data["pricing"]["displayGrossPrices"] == get_display_gross_prices(
+ tax_config, tax_config_country
+ )
QUERY_PRICING_ON_PRODUCT_CHANNEL_LISTING_NO_ADDRESS = """
@@ -100,12 +115,9 @@ query FetchProduct($id: ID, $channel: String) {
"""
- "saleor.graphql.product.types.products.get_product_availability",
- wraps=get_product_availability,
-)
[email protected]("saleor.graphql.product.types.products.get_tax_rate_for_tax_class")
def test_product_channel_listing_pricing_field_no_address(
- mock_get_product_availability,
+ mock_get_tax_rate_for_tax_class,
staff_api_client,
permission_manage_products,
channel_USD,
@@ -130,6 +142,331 @@ def test_product_channel_listing_pricing_field_no_address(
# then
assert (
- mock_get_product_availability.call_args[1]["country"]
- == channel_USD.default_country
+ mock_get_tax_rate_for_tax_class.call_args[0][3] == channel_USD.default_country
+ )
+
+
+FRAGMENT_PRICE = """
+ fragment Price on TaxedMoney {
+ gross {
+ amount
+ }
+ net {
+ amount
+ }
+ tax {
+ amount
+ }
+ }
+"""
+
+
+FRAGMENT_PRICING = (
+ """
+ fragment Pricing on ProductPricingInfo {
+ priceRange {
+ start {
+ ...Price
+ }
+ stop {
+ ...Price
+ }
+ }
+ priceRangeUndiscounted {
+ start {
+ ...Price
+ }
+ stop {
+ ...Price
+ }
+ }
+ }
+"""
+ + FRAGMENT_PRICE
+)
+
+
+QUERY_PRODUCT_PRICING = (
+ """
+ query Product($id: ID!, $channel: String!) {
+ product(id: $id, channel: $channel) {
+ channelListings {
+ channel {
+ slug
+ }
+ pricingPL: pricing(address: { country: PL }) {
+ ...Pricing
+ }
+ pricingDE: pricing(address: { country: DE }) {
+ ...Pricing
+ }
+ pricing: pricing {
+ ...Pricing
+ }
+ }
+ }
+ }
+"""
+ + FRAGMENT_PRICING
+)
+
+
+def _enable_flat_rates(channel, prices_entered_with_tax):
+ tc = channel.tax_configuration
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.prices_entered_with_tax = prices_entered_with_tax
+ tc.charge_taxes = True
+ tc.country_exceptions.all().delete()
+ tc.country_exceptions.create(
+ country="PL",
+ charge_taxes=True,
+ tax_calculation_strategy=TaxCalculationStrategy.FLAT_RATES,
+ )
+ tc.country_exceptions.create(
+ country="DE",
+ charge_taxes=True,
+ tax_calculation_strategy=TaxCalculationStrategy.FLAT_RATES,
+ )
+ tc.save()
+
+
+def _configure_tax_rates(product):
+ product.tax_class.country_rates.all().delete()
+ product.tax_class.country_rates.create(country="PL", rate=TAX_RATE_PL)
+ product.tax_class.country_rates.create(country="DE", rate=TAX_RATE_DE)
+
+
+ "net_PL, gross_PL, net_DE, gross_DE, prices_entered_with_tax",
+ [
+ (40.65, 50.00, 42.02, 50.00, True),
+ (50.00, 61.50, 50.00, 59.50, False),
+ ],
+)
+def test_product_pricing(
+ product_available_in_many_channels,
+ channel_PLN,
+ staff_api_client,
+ net_PL,
+ gross_PL,
+ net_DE,
+ gross_DE,
+ prices_entered_with_tax,
+ permission_manage_products,
+):
+ # given
+ product = product_available_in_many_channels
+ _enable_flat_rates(channel_PLN, prices_entered_with_tax)
+ _configure_tax_rates(product)
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Product", product.id),
+ "channel": channel_PLN.slug,
+ }
+ response = staff_api_client.post_graphql(
+ QUERY_PRODUCT_PRICING,
+ variables,
+ permissions=(permission_manage_products,),
+ check_no_permissions=False,
+ )
+ content = get_graphql_content(response)
+
+ # then
+ data = None
+ for channel_data in content["data"]["product"]["channelListings"]:
+ if channel_data["channel"]["slug"] == channel_PLN.slug:
+ data = channel_data
+
+ price_range_PL = data["pricingPL"]["priceRange"]
+ price_range_undiscounted_PL = data["pricingPL"]["priceRangeUndiscounted"]
+ assert price_range_PL["start"]["net"]["amount"] == net_PL
+ assert price_range_PL["start"]["gross"]["amount"] == gross_PL
+ assert price_range_PL["stop"]["net"]["amount"] == net_PL
+ assert price_range_PL["stop"]["gross"]["amount"] == gross_PL
+ assert price_range_undiscounted_PL["start"]["net"]["amount"] == net_PL
+ assert price_range_undiscounted_PL["start"]["gross"]["amount"] == gross_PL
+ assert price_range_undiscounted_PL["stop"]["net"]["amount"] == net_PL
+ assert price_range_undiscounted_PL["stop"]["gross"]["amount"] == gross_PL
+
+ price_range_DE = data["pricingDE"]["priceRange"]
+ price_range_undiscounted_DE = data["pricingDE"]["priceRangeUndiscounted"]
+ assert price_range_DE["start"]["net"]["amount"] == net_DE
+ assert price_range_DE["start"]["gross"]["amount"] == gross_DE
+ assert price_range_DE["stop"]["net"]["amount"] == net_DE
+ assert price_range_DE["stop"]["gross"]["amount"] == gross_DE
+ assert price_range_undiscounted_DE["start"]["net"]["amount"] == net_DE
+ assert price_range_undiscounted_DE["start"]["gross"]["amount"] == gross_DE
+ assert price_range_undiscounted_DE["stop"]["net"]["amount"] == net_DE
+ assert price_range_undiscounted_DE["stop"]["gross"]["amount"] == gross_DE
+
+
+def test_product_pricing_default_country_default_rate(
+ product_available_in_many_channels,
+ channel_PLN,
+ staff_api_client,
+ permission_manage_products,
+):
+ # given
+ product = product_available_in_many_channels
+ _enable_flat_rates(channel_PLN, True)
+ TaxClassCountryRate.objects.all().delete()
+ TaxClassCountryRate.objects.create(
+ country=channel_PLN.default_country, rate=TAX_RATE_PL
+ )
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Product", product.id),
+ "channel": channel_PLN.slug,
+ }
+ response = staff_api_client.post_graphql(
+ QUERY_PRODUCT_PRICING,
+ variables,
+ permissions=(permission_manage_products,),
+ check_no_permissions=False,
+ )
+ content = get_graphql_content(response)
+
+ # then
+ data = None
+ for channel_data in content["data"]["product"]["channelListings"]:
+ if channel_data["channel"]["slug"] == channel_PLN.slug:
+ data = channel_data
+
+ variant = product.variants.first()
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ gross = channel_listing.price_amount.quantize(Decimal(".01"))
+ net = (gross / Decimal(1 + TAX_RATE_PL / 100)).quantize(Decimal(".01"))
+ gross = float(gross)
+ net = float(net)
+
+ price_range = data["pricing"]["priceRange"]
+ price_range_undiscounted = data["pricing"]["priceRangeUndiscounted"]
+
+ assert price_range["start"]["net"]["amount"] == net
+ assert price_range["start"]["gross"]["amount"] == gross
+ assert price_range["stop"]["net"]["amount"] == net
+ assert price_range["stop"]["gross"]["amount"] == gross
+ assert price_range_undiscounted["start"]["net"]["amount"] == net
+ assert price_range_undiscounted["start"]["gross"]["amount"] == gross
+ assert price_range_undiscounted["stop"]["net"]["amount"] == net
+ assert price_range_undiscounted["stop"]["gross"]["amount"] == gross
+
+
+def test_product_pricing_use_tax_class_from_product_type(
+ product_available_in_many_channels,
+ channel_PLN,
+ staff_api_client,
+ permission_manage_products,
+):
+ # given
+ product = product_available_in_many_channels
+ _enable_flat_rates(channel_PLN, True)
+ TaxClassCountryRate.objects.all().delete()
+ product.tax_class = None
+ product.save(update_fields=["tax_class"])
+ product.product_type.tax_class.country_rates.create(
+ country=channel_PLN.default_country, rate=TAX_RATE_PL
+ )
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Product", product.id),
+ "channel": channel_PLN.slug,
+ }
+ response = staff_api_client.post_graphql(
+ QUERY_PRODUCT_PRICING,
+ variables,
+ permissions=(permission_manage_products,),
+ check_no_permissions=False,
+ )
+ content = get_graphql_content(response)
+
+ # then
+ variant = product.variants.first()
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ gross = channel_listing.price_amount.quantize(Decimal(".01"))
+ net = (gross / Decimal(1 + TAX_RATE_PL / 100)).quantize(Decimal(".01"))
+ gross = float(gross)
+ net = float(net)
+
+ data = None
+ for channel_data in content["data"]["product"]["channelListings"]:
+ if channel_data["channel"]["slug"] == channel_PLN.slug:
+ data = channel_data
+
+ price_range_PL = data["pricingPL"]["priceRange"]
+ price_range_undiscounted_PL = data["pricingPL"]["priceRangeUndiscounted"]
+ assert price_range_PL["start"]["net"]["amount"] == net
+ assert price_range_PL["start"]["gross"]["amount"] == gross
+ assert price_range_PL["stop"]["net"]["amount"] == net
+ assert price_range_PL["stop"]["gross"]["amount"] == gross
+ assert price_range_undiscounted_PL["start"]["net"]["amount"] == net
+ assert price_range_undiscounted_PL["start"]["gross"]["amount"] == gross
+ assert price_range_undiscounted_PL["stop"]["net"]["amount"] == net
+ assert price_range_undiscounted_PL["stop"]["gross"]["amount"] == gross
+
+
+def test_product_pricing_no_flat_rates_in_one_country(
+ product_available_in_many_channels,
+ channel_PLN,
+ staff_api_client,
+ permission_manage_products,
+):
+ # given
+ product = product_available_in_many_channels
+ _enable_flat_rates(channel_PLN, True)
+ _configure_tax_rates(product)
+ TaxConfigurationPerCountry.objects.filter(country="PL").update(
+ tax_calculation_strategy=None
)
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Product", product.id),
+ "channel": channel_PLN.slug,
+ }
+ response = staff_api_client.post_graphql(
+ QUERY_PRODUCT_PRICING,
+ variables,
+ permissions=(permission_manage_products,),
+ check_no_permissions=False,
+ )
+ content = get_graphql_content(response)
+
+ # then
+ variant = product.variants.first()
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ price_pl = float(channel_listing.price_amount.quantize(Decimal(".01")))
+ gross_de = channel_listing.price_amount.quantize(Decimal(".01"))
+ net_de = (gross_de / Decimal(1 + TAX_RATE_DE / 100)).quantize(Decimal(".01"))
+ gross_de = float(gross_de)
+ net_de = float(net_de)
+
+ data = None
+ for channel_data in content["data"]["product"]["channelListings"]:
+ if channel_data["channel"]["slug"] == channel_PLN.slug:
+ data = channel_data
+
+ price_range_PL = data["pricingPL"]["priceRange"]
+ price_range_undiscounted_PL = data["pricingPL"]["priceRangeUndiscounted"]
+ assert price_range_PL["start"]["net"]["amount"] == price_pl
+ assert price_range_PL["start"]["gross"]["amount"] == price_pl
+ assert price_range_PL["stop"]["net"]["amount"] == price_pl
+ assert price_range_PL["stop"]["gross"]["amount"] == price_pl
+ assert price_range_undiscounted_PL["start"]["net"]["amount"] == price_pl
+ assert price_range_undiscounted_PL["start"]["gross"]["amount"] == price_pl
+ assert price_range_undiscounted_PL["stop"]["net"]["amount"] == price_pl
+ assert price_range_undiscounted_PL["stop"]["gross"]["amount"] == price_pl
+
+ price_range_DE = data["pricingDE"]["priceRange"]
+ price_range_undiscounted_DE = data["pricingDE"]["priceRangeUndiscounted"]
+ assert price_range_DE["start"]["net"]["amount"] == net_de
+ assert price_range_DE["start"]["gross"]["amount"] == gross_de
+ assert price_range_DE["stop"]["net"]["amount"] == net_de
+ assert price_range_DE["stop"]["gross"]["amount"] == gross_de
+ assert price_range_undiscounted_DE["start"]["net"]["amount"] == net_de
+ assert price_range_undiscounted_DE["start"]["gross"]["amount"] == gross_de
+ assert price_range_undiscounted_DE["stop"]["net"]["amount"] == net_de
+ assert price_range_undiscounted_DE["stop"]["gross"]["amount"] == gross_de
diff --git a/saleor/graphql/product/tests/test_product_pricing.py b/saleor/graphql/product/tests/test_product_pricing.py
new file mode 100644
index 0000000000..bc09807b05
--- /dev/null
+++ b/saleor/graphql/product/tests/test_product_pricing.py
@@ -0,0 +1,290 @@
+from decimal import Decimal
+
+import graphene
+import pytest
+
+from ....tax import TaxCalculationStrategy
+from ....tax.models import TaxClassCountryRate, TaxConfigurationPerCountry
+from ...tests.utils import get_graphql_content
+
+TAX_RATE_DE = 19
+TAX_RATE_PL = 23
+
+FRAGMENT_PRICE = """
+ fragment Price on TaxedMoney {
+ gross {
+ amount
+ }
+ net {
+ amount
+ }
+ tax {
+ amount
+ }
+ }
+"""
+
+
+FRAGMENT_PRICING = (
+ """
+ fragment Pricing on ProductPricingInfo {
+ priceRange {
+ start {
+ ...Price
+ }
+ stop {
+ ...Price
+ }
+ }
+ priceRangeUndiscounted {
+ start {
+ ...Price
+ }
+ stop {
+ ...Price
+ }
+ }
+ }
+"""
+ + FRAGMENT_PRICE
+)
+
+
+QUERY_PRODUCT_PRICING = (
+ """
+ query Product($id: ID!, $channel: String!) {
+ product(id: $id, channel: $channel) {
+ pricingPL: pricing(address: { country: PL }) {
+ ...Pricing
+ }
+ pricingDE: pricing(address: { country: DE }) {
+ ...Pricing
+ }
+ pricing: pricing {
+ ...Pricing
+ }
+ }
+ }
+"""
+ + FRAGMENT_PRICING
+)
+
+
+def _enable_flat_rates(channel, prices_entered_with_tax):
+ tc = channel.tax_configuration
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.prices_entered_with_tax = prices_entered_with_tax
+ tc.charge_taxes = True
+ tc.country_exceptions.all().delete()
+ tc.country_exceptions.create(
+ country="PL",
+ charge_taxes=True,
+ tax_calculation_strategy=TaxCalculationStrategy.FLAT_RATES,
+ )
+ tc.country_exceptions.create(
+ country="DE",
+ charge_taxes=True,
+ tax_calculation_strategy=TaxCalculationStrategy.FLAT_RATES,
+ )
+ tc.save()
+
+
+def _configure_tax_rates(product):
+ product.tax_class.country_rates.all().delete()
+ product.tax_class.country_rates.create(country="PL", rate=TAX_RATE_PL)
+ product.tax_class.country_rates.create(country="DE", rate=TAX_RATE_DE)
+
+
+ "net_PL, gross_PL, net_DE, gross_DE, prices_entered_with_tax",
+ [
+ (40.65, 50.00, 42.02, 50.00, True),
+ (50.00, 61.50, 50.00, 59.50, False),
+ ],
+)
+def test_product_pricing(
+ product_available_in_many_channels,
+ channel_PLN,
+ user_api_client,
+ net_PL,
+ gross_PL,
+ net_DE,
+ gross_DE,
+ prices_entered_with_tax,
+):
+ # given
+ product = product_available_in_many_channels
+ _enable_flat_rates(channel_PLN, prices_entered_with_tax)
+ _configure_tax_rates(product)
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Product", product.id),
+ "channel": channel_PLN.slug,
+ }
+ response = user_api_client.post_graphql(QUERY_PRODUCT_PRICING, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["product"]
+
+ # then
+ price_range_PL = data["pricingPL"]["priceRange"]
+ price_range_undiscounted_PL = data["pricingPL"]["priceRangeUndiscounted"]
+ assert price_range_PL["start"]["net"]["amount"] == net_PL
+ assert price_range_PL["start"]["gross"]["amount"] == gross_PL
+ assert price_range_PL["stop"]["net"]["amount"] == net_PL
+ assert price_range_PL["stop"]["gross"]["amount"] == gross_PL
+ assert price_range_undiscounted_PL["start"]["net"]["amount"] == net_PL
+ assert price_range_undiscounted_PL["start"]["gross"]["amount"] == gross_PL
+ assert price_range_undiscounted_PL["stop"]["net"]["amount"] == net_PL
+ assert price_range_undiscounted_PL["stop"]["gross"]["amount"] == gross_PL
+
+ price_range_DE = data["pricingDE"]["priceRange"]
+ price_range_undiscounted_DE = data["pricingDE"]["priceRangeUndiscounted"]
+ assert price_range_DE["start"]["net"]["amount"] == net_DE
+ assert price_range_DE["start"]["gross"]["amount"] == gross_DE
+ assert price_range_DE["stop"]["net"]["amount"] == net_DE
+ assert price_range_DE["stop"]["gross"]["amount"] == gross_DE
+ assert price_range_undiscounted_DE["start"]["net"]["amount"] == net_DE
+ assert price_range_undiscounted_DE["start"]["gross"]["amount"] == gross_DE
+ assert price_range_undiscounted_DE["stop"]["net"]["amount"] == net_DE
+ assert price_range_undiscounted_DE["stop"]["gross"]["amount"] == gross_DE
+
+
+def test_product_pricing_default_country_default_rate(
+ product_available_in_many_channels,
+ channel_PLN,
+ user_api_client,
+):
+ # given
+ product = product_available_in_many_channels
+ _enable_flat_rates(channel_PLN, True)
+ TaxClassCountryRate.objects.all().delete()
+ TaxClassCountryRate.objects.create(
+ country=channel_PLN.default_country, rate=TAX_RATE_PL
+ )
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Product", product.id),
+ "channel": channel_PLN.slug,
+ }
+ response = user_api_client.post_graphql(QUERY_PRODUCT_PRICING, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["product"]
+
+ # then
+ variant = product.variants.first()
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ gross = channel_listing.price_amount.quantize(Decimal(".01"))
+ net = (gross / Decimal(1 + TAX_RATE_PL / 100)).quantize(Decimal(".01"))
+ gross = float(gross)
+ net = float(net)
+
+ price_range = data["pricing"]["priceRange"]
+ price_range_undiscounted = data["pricing"]["priceRangeUndiscounted"]
+ assert price_range["start"]["net"]["amount"] == net
+ assert price_range["start"]["gross"]["amount"] == gross
+ assert price_range["stop"]["net"]["amount"] == net
+ assert price_range["stop"]["gross"]["amount"] == gross
+ assert price_range_undiscounted["start"]["net"]["amount"] == net
+ assert price_range_undiscounted["start"]["gross"]["amount"] == gross
+ assert price_range_undiscounted["stop"]["net"]["amount"] == net
+ assert price_range_undiscounted["stop"]["gross"]["amount"] == gross
+
+
+def test_product_pricing_use_tax_class_from_product_type(
+ product_available_in_many_channels,
+ channel_PLN,
+ user_api_client,
+):
+ # given
+ product = product_available_in_many_channels
+ _enable_flat_rates(channel_PLN, True)
+ TaxClassCountryRate.objects.all().delete()
+ product.tax_class = None
+ product.save(update_fields=["tax_class"])
+ product.product_type.tax_class.country_rates.create(
+ country=channel_PLN.default_country, rate=TAX_RATE_PL
+ )
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Product", product.id),
+ "channel": channel_PLN.slug,
+ }
+ response = user_api_client.post_graphql(QUERY_PRODUCT_PRICING, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["product"]
+
+ # then
+ variant = product.variants.first()
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ gross = channel_listing.price_amount.quantize(Decimal(".01"))
+ net = (gross / Decimal(1 + TAX_RATE_PL / 100)).quantize(Decimal(".01"))
+ gross = float(gross)
+ net = float(net)
+
+ price_range_PL = data["pricingPL"]["priceRange"]
+ price_range_undiscounted_PL = data["pricingPL"]["priceRangeUndiscounted"]
+ assert price_range_PL["start"]["net"]["amount"] == net
+ assert price_range_PL["start"]["gross"]["amount"] == gross
+ assert price_range_PL["stop"]["net"]["amount"] == net
+ assert price_range_PL["stop"]["gross"]["amount"] == gross
+ assert price_range_undiscounted_PL["start"]["net"]["amount"] == net
+ assert price_range_undiscounted_PL["start"]["gross"]["amount"] == gross
+ assert price_range_undiscounted_PL["stop"]["net"]["amount"] == net
+ assert price_range_undiscounted_PL["stop"]["gross"]["amount"] == gross
+
+
+def test_product_pricing_no_flat_rates_in_one_country(
+ product_available_in_many_channels,
+ channel_PLN,
+ user_api_client,
+):
+ # given
+ product = product_available_in_many_channels
+ _enable_flat_rates(channel_PLN, True)
+ _configure_tax_rates(product)
+ TaxConfigurationPerCountry.objects.filter(country="PL").update(
+ tax_calculation_strategy=None
+ )
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("Product", product.id),
+ "channel": channel_PLN.slug,
+ }
+ response = user_api_client.post_graphql(QUERY_PRODUCT_PRICING, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["product"]
+
+ # then
+ variant = product.variants.first()
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ price_pl = float(channel_listing.price_amount.quantize(Decimal(".01")))
+ gross_de = channel_listing.price_amount.quantize(Decimal(".01"))
+ net_de = (gross_de / Decimal(1 + TAX_RATE_DE / 100)).quantize(Decimal(".01"))
+ gross_de = float(gross_de)
+ net_de = float(net_de)
+
+ price_range_PL = data["pricingPL"]["priceRange"]
+ price_range_undiscounted_PL = data["pricingPL"]["priceRangeUndiscounted"]
+ assert price_range_PL["start"]["net"]["amount"] == price_pl
+ assert price_range_PL["start"]["gross"]["amount"] == price_pl
+ assert price_range_PL["stop"]["net"]["amount"] == price_pl
+ assert price_range_PL["stop"]["gross"]["amount"] == price_pl
+ assert price_range_undiscounted_PL["start"]["net"]["amount"] == price_pl
+ assert price_range_undiscounted_PL["start"]["gross"]["amount"] == price_pl
+ assert price_range_undiscounted_PL["stop"]["net"]["amount"] == price_pl
+ assert price_range_undiscounted_PL["stop"]["gross"]["amount"] == price_pl
+
+ price_range_DE = data["pricingDE"]["priceRange"]
+ price_range_undiscounted_DE = data["pricingDE"]["priceRangeUndiscounted"]
+ assert price_range_DE["start"]["net"]["amount"] == net_de
+ assert price_range_DE["start"]["gross"]["amount"] == gross_de
+ assert price_range_DE["stop"]["net"]["amount"] == net_de
+ assert price_range_DE["stop"]["gross"]["amount"] == gross_de
+ assert price_range_undiscounted_DE["start"]["net"]["amount"] == net_de
+ assert price_range_undiscounted_DE["start"]["gross"]["amount"] == gross_de
+ assert price_range_undiscounted_DE["stop"]["net"]["amount"] == net_de
+ assert price_range_undiscounted_DE["stop"]["gross"]["amount"] == gross_de
diff --git a/saleor/graphql/product/tests/test_variant_pricing.py b/saleor/graphql/product/tests/test_variant_pricing.py
index b16b191236..95239d2d0d 100644
--- a/saleor/graphql/product/tests/test_variant_pricing.py
+++ b/saleor/graphql/product/tests/test_variant_pricing.py
@@ -1,13 +1,19 @@
-from unittest.mock import Mock
+from decimal import Decimal
+from unittest.mock import Mock, patch
-from django_countries.fields import Country
+import graphene
+import pytest
from prices import Money, TaxedMoney
-from ....plugins.manager import PluginsManager, get_plugins_manager
-from ....product.models import ProductVariant
+from ....product.models import ProductVariant, ProductVariantChannelListing
from ....product.utils.availability import get_variant_availability
+from ....tax import TaxCalculationStrategy
+from ....tax.models import TaxClassCountryRate, TaxConfigurationPerCountry
from ...tests.utils import get_graphql_content
+TAX_RATE_DE = 19
+TAX_RATE_PL = 23
+
QUERY_GET_VARIANT_PRICING = """
fragment VariantPricingInfo on VariantPricingInfo {
onSale
@@ -109,16 +115,23 @@ def test_get_variant_pricing_not_on_sale(api_client, product, channel_USD):
def test_variant_pricing(
variant: ProductVariant, monkeypatch, settings, stock, channel_USD
):
- taxed_price = TaxedMoney(Money("10.0", "USD"), Money("12.30", "USD"))
- monkeypatch.setattr(
- PluginsManager, "apply_taxes_to_product", Mock(return_value=taxed_price)
- )
-
product = variant.product
+ tax_class = product.tax_class or product.product_type.tax_class
+
+ tc = channel_USD.tax_configuration
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.charge_taxes = True
+ tc.prices_entered_with_tax = False
+ tc.save()
+
+ tax_rate = Decimal(TAX_RATE_PL)
+ country = "PL"
+ tax_class.country_rates.update_or_create(rate=tax_rate, country=country)
+
+ taxed_price = TaxedMoney(Money("10.0", "USD"), Money("12.30", "USD"))
product_channel_listing = product.channel_listings.get()
variant_channel_listing = variant.channel_listings.get()
- manager = get_plugins_manager()
pricing = get_variant_availability(
variant=variant,
variant_channel_listing=variant_channel_listing,
@@ -127,8 +140,9 @@ def test_variant_pricing(
collections=[],
discounts=[],
channel=channel_USD,
- plugins=manager,
- country=Country("US"),
+ tax_rate=tax_rate,
+ tax_calculation_strategy=tc.tax_calculation_strategy,
+ prices_entered_with_tax=tc.prices_entered_with_tax,
)
assert pricing.price == taxed_price
assert pricing.price_local_currency is None
@@ -148,9 +162,10 @@ def test_variant_pricing(
collections=[],
discounts=[],
channel=channel_USD,
- plugins=manager,
local_currency="PLN",
- country=Country("US"),
+ tax_rate=tax_rate,
+ tax_calculation_strategy=tc.tax_calculation_strategy,
+ prices_entered_with_tax=tc.prices_entered_with_tax,
)
assert pricing.price_local_currency.currency == "PLN" # type: ignore
@@ -162,9 +177,452 @@ def test_variant_pricing(
collections=[],
discounts=[],
channel=channel_USD,
- plugins=manager,
- country=Country("PL"),
+ tax_rate=tax_rate,
+ tax_calculation_strategy=tc.tax_calculation_strategy,
+ prices_entered_with_tax=tc.prices_entered_with_tax,
)
assert pricing.price.tax.amount
assert pricing.price_undiscounted.tax.amount
assert pricing.price_undiscounted.tax.amount
+
+
+QUERY_GET_PRODUCT_VARIANTS_PRICING = """
+ query getProductVariants($id: ID!, $channel: String, $address: AddressInput) {
+ product(id: $id, channel: $channel) {
+ variants {
+ id
+ pricingNoAddress: pricing {
+ priceUndiscounted {
+ gross {
+ amount
+ }
+ }
+ }
+ pricing(address: $address) {
+ priceUndiscounted {
+ gross {
+ amount
+ }
+ }
+ }
+ }
+ }
+ }
+"""
+
+
+ "variant_price_amount, api_variant_price",
+ [(200, 200), (0, 0)],
+)
+def test_product_variant_price(
+ variant_price_amount,
+ api_variant_price,
+ user_api_client,
+ variant,
+ stock,
+ channel_USD,
+):
+ product = variant.product
+ ProductVariantChannelListing.objects.filter(
+ channel=channel_USD, variant__product_id=product.pk
+ ).update(price_amount=variant_price_amount)
+
+ product_id = graphene.Node.to_global_id("Product", variant.product.id)
+ variables = {
+ "id": product_id,
+ "channel": channel_USD.slug,
+ "address": {"country": "US"},
+ }
+ response = user_api_client.post_graphql(
+ QUERY_GET_PRODUCT_VARIANTS_PRICING, variables
+ )
+ content = get_graphql_content(response)
+ data = content["data"]["product"]
+ variant_price = data["variants"][0]["pricing"]["priceUndiscounted"]["gross"]
+ assert variant_price["amount"] == api_variant_price
+
+
+def test_product_variant_without_price_as_user(
+ user_api_client,
+ variant,
+ stock,
+ channel_USD,
+):
+ variant.channel_listings.filter(channel=channel_USD).update(price_amount=None)
+ product_id = graphene.Node.to_global_id("Product", variant.product.id)
+ variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
+ variables = {
+ "id": product_id,
+ "channel": channel_USD.slug,
+ "address": {"country": "US"},
+ }
+
+ response = user_api_client.post_graphql(
+ QUERY_GET_PRODUCT_VARIANTS_PRICING, variables
+ )
+ content = get_graphql_content(response)
+
+ variants_data = content["data"]["product"]["variants"]
+ assert not variants_data[0]["id"] == variant_id
+ assert len(variants_data) == 1
+
+
+def test_product_variant_without_price_as_staff_without_permission(
+ staff_api_client,
+ variant,
+ stock,
+ channel_USD,
+):
+
+ variant_channel_listing = variant.channel_listings.first()
+ variant_channel_listing.price_amount = None
+ variant_channel_listing.save()
+
+ product_id = graphene.Node.to_global_id("Product", variant.product.id)
+ variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
+ variables = {
+ "id": product_id,
+ "channel": channel_USD.slug,
+ "address": {"country": "US"},
+ }
+ response = staff_api_client.post_graphql(
+ QUERY_GET_PRODUCT_VARIANTS_PRICING, variables
+ )
+ content = get_graphql_content(response)
+ variants_data = content["data"]["product"]["variants"]
+
+ assert len(variants_data) == 1
+
+ assert variants_data[0]["pricing"] is not None
+ assert variants_data[0]["id"] != variant_id
+
+
+def test_product_variant_without_price_as_staff_with_permission(
+ staff_api_client, variant, stock, channel_USD, permission_manage_products
+):
+ product = variant.product
+ variant_1, variant_2 = product.variants.all()
+
+ variant_channel_listing = variant_1.channel_listings.first()
+ variant_channel_listing.price_amount = None
+ variant_channel_listing.save()
+
+ product_id = graphene.Node.to_global_id("Product", product.id)
+ variant_1_id = graphene.Node.to_global_id("ProductVariant", variant_1.id)
+ variant_2_id = graphene.Node.to_global_id("ProductVariant", variant_2.id)
+ variant_2_price = (
+ variant_2.channel_listings.filter(channel_id=channel_USD.pk)
+ .first()
+ .price_amount
+ )
+
+ variables = {
+ "id": product_id,
+ "channel": channel_USD.slug,
+ "address": {"country": "US"},
+ }
+ response = staff_api_client.post_graphql(
+ QUERY_GET_PRODUCT_VARIANTS_PRICING,
+ variables,
+ permissions=[permission_manage_products],
+ check_no_permissions=False,
+ )
+ content = get_graphql_content(response)
+ variants_data = content["data"]["product"]["variants"]
+
+ assert len(variants_data) == 2
+
+ item_without_price = {"id": variant_1_id, "pricingNoAddress": None, "pricing": None}
+ assert item_without_price in variants_data
+
+ item_with_price = {
+ "id": variant_2_id,
+ "pricingNoAddress": {
+ "priceUndiscounted": {"gross": {"amount": variant_2_price}}
+ },
+ "pricing": {"priceUndiscounted": {"gross": {"amount": variant_2_price}}},
+ }
+ assert item_with_price in variants_data
+
+
+QUERY_GET_PRODUCT_VARIANTS_PRICING_NO_ADDRESS = """
+ query getProductVariants($id: ID!, $channel: String) {
+ product(id: $id, channel: $channel) {
+ variants {
+ id
+ pricing {
+ priceUndiscounted {
+ gross {
+ amount
+ }
+ }
+ }
+ }
+ }
+ }
+"""
+
+
+@patch(
+ "saleor.graphql.product.types.products.get_tax_rate_for_tax_class",
+)
+def test_product_variant_price_no_address(
+ mock_get_tax_rate_for_tax_class, user_api_client, variant, stock, channel_USD
+):
+ channel_USD.default_country = "FR"
+ channel_USD.save()
+ product_id = graphene.Node.to_global_id("Product", variant.product.id)
+ variables = {"id": product_id, "channel": channel_USD.slug}
+ user_api_client.post_graphql(
+ QUERY_GET_PRODUCT_VARIANTS_PRICING_NO_ADDRESS, variables
+ )
+ assert (
+ mock_get_tax_rate_for_tax_class.call_args[0][3] == channel_USD.default_country
+ )
+
+
+FRAGMENT_PRICE = """
+ fragment Price on TaxedMoney {
+ gross {
+ amount
+ }
+ net {
+ amount
+ }
+ tax {
+ amount
+ }
+ }
+"""
+
+FRAGMENT_PRICING = (
+ """
+ fragment Pricing on VariantPricingInfo {
+ price {
+ ...Price
+ }
+ priceUndiscounted {
+ ...Price
+ }
+ }
+"""
+ + FRAGMENT_PRICE
+)
+
+
+QUERY_PRODUCT_VARIANT_PRICING = (
+ """
+ query Variant($id:ID!, $channel: String!) {
+ productVariant(id: $id, channel: $channel) {
+ pricingPL: pricing(address: { country: PL }) {
+ ...Pricing
+ }
+ pricingDE: pricing(address: { country: DE }) {
+ ...Pricing
+ }
+ pricing: pricing {
+ ...Pricing
+ }
+ }
+ }
+"""
+ + FRAGMENT_PRICING
+)
+
+
+def _enable_flat_rates(channel, prices_entered_with_tax):
+ tc = channel.tax_configuration
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.prices_entered_with_tax = prices_entered_with_tax
+ tc.charge_taxes = True
+ tc.country_exceptions.all().delete()
+ tc.country_exceptions.create(
+ country="PL",
+ charge_taxes=True,
+ tax_calculation_strategy=TaxCalculationStrategy.FLAT_RATES,
+ )
+ tc.country_exceptions.create(
+ country="DE",
+ charge_taxes=True,
+ tax_calculation_strategy=TaxCalculationStrategy.FLAT_RATES,
+ )
+ tc.save()
+
+
+def _configure_tax_rates(product):
+ product.tax_class.country_rates.all().delete()
+ product.tax_class.country_rates.create(country="PL", rate=TAX_RATE_PL)
+ product.tax_class.country_rates.create(country="DE", rate=TAX_RATE_DE)
+
+
+ "net_PL, gross_PL, net_DE, gross_DE, prices_entered_with_tax",
+ [
+ (40.65, 50.00, 42.02, 50.00, True),
+ (50.00, 61.50, 50.00, 59.50, False),
+ ],
+)
+def test_product_variant_pricing(
+ product_available_in_many_channels,
+ channel_PLN,
+ user_api_client,
+ net_PL,
+ gross_PL,
+ net_DE,
+ gross_DE,
+ prices_entered_with_tax,
+):
+ # given
+ product = product_available_in_many_channels
+ variant = product.variants.first()
+ _enable_flat_rates(channel_PLN, prices_entered_with_tax)
+ _configure_tax_rates(product)
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("ProductVariant", variant.id),
+ "channel": channel_PLN.slug,
+ }
+ response = user_api_client.post_graphql(QUERY_PRODUCT_VARIANT_PRICING, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["productVariant"]
+
+ # then
+ price_PL = data["pricingPL"]["price"]
+ price_undiscounted_PL = data["pricingPL"]["priceUndiscounted"]
+ assert price_PL["net"]["amount"] == net_PL
+ assert price_PL["gross"]["amount"] == gross_PL
+ assert price_undiscounted_PL["net"]["amount"] == net_PL
+ assert price_undiscounted_PL["gross"]["amount"] == gross_PL
+
+ price_DE = data["pricingDE"]["price"]
+ price_undiscounted_DE = data["pricingDE"]["priceUndiscounted"]
+ assert price_DE["net"]["amount"] == net_DE
+ assert price_DE["gross"]["amount"] == gross_DE
+ assert price_undiscounted_DE["net"]["amount"] == net_DE
+ assert price_undiscounted_DE["gross"]["amount"] == gross_DE
+
+
+def test_product_variant_pricing_default_country_default_rate(
+ product_available_in_many_channels,
+ channel_PLN,
+ user_api_client,
+):
+ # given
+ product = product_available_in_many_channels
+ variant = product.variants.first()
+ _enable_flat_rates(channel_PLN, True)
+ TaxClassCountryRate.objects.all().delete()
+ TaxClassCountryRate.objects.create(
+ country=channel_PLN.default_country, rate=TAX_RATE_PL
+ )
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("ProductVariant", variant.id),
+ "channel": channel_PLN.slug,
+ }
+ response = user_api_client.post_graphql(QUERY_PRODUCT_VARIANT_PRICING, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["productVariant"]
+
+ # then
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ gross = channel_listing.price_amount.quantize(Decimal(".01"))
+ net = (gross / Decimal(1 + TAX_RATE_PL / 100)).quantize(Decimal(".01"))
+ gross = float(gross)
+ net = float(net)
+
+ price_PL = data["pricingPL"]["price"]
+ price_undiscounted_PL = data["pricingPL"]["priceUndiscounted"]
+ assert price_PL["net"]["amount"] == net
+ assert price_PL["gross"]["amount"] == gross
+ assert price_undiscounted_PL["net"]["amount"] == net
+ assert price_undiscounted_PL["gross"]["amount"] == gross
+
+
+def test_product_variant_pricing_use_tax_class_from_product_type(
+ product_available_in_many_channels,
+ channel_PLN,
+ user_api_client,
+):
+ # given
+ product = product_available_in_many_channels
+ variant = product.variants.first()
+ _enable_flat_rates(channel_PLN, True)
+ TaxClassCountryRate.objects.all().delete()
+ product.tax_class = None
+ product.save(update_fields=["tax_class"])
+ product.product_type.tax_class.country_rates.create(
+ country=channel_PLN.default_country, rate=TAX_RATE_PL
+ )
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("ProductVariant", variant.id),
+ "channel": channel_PLN.slug,
+ }
+ response = user_api_client.post_graphql(QUERY_PRODUCT_VARIANT_PRICING, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["productVariant"]
+
+ # then
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ gross = channel_listing.price_amount.quantize(Decimal(".01"))
+ net = (gross / Decimal(1 + TAX_RATE_PL / 100)).quantize(Decimal(".01"))
+ gross = float(gross)
+ net = float(net)
+
+ price_PL = data["pricingPL"]["price"]
+ price_undiscounted_PL = data["pricingPL"]["priceUndiscounted"]
+ assert price_PL["net"]["amount"] == net
+ assert price_PL["gross"]["amount"] == gross
+ assert price_undiscounted_PL["net"]["amount"] == net
+ assert price_undiscounted_PL["gross"]["amount"] == gross
+
+
+def test_product_variant_pricing_no_flat_rates_in_one_country(
+ product_available_in_many_channels,
+ channel_PLN,
+ user_api_client,
+):
+ # given
+ product = product_available_in_many_channels
+ variant = product.variants.first()
+ _enable_flat_rates(channel_PLN, True)
+ _configure_tax_rates(product)
+ TaxConfigurationPerCountry.objects.filter(country="PL").update(
+ tax_calculation_strategy=None
+ )
+
+ # when
+ variables = {
+ "id": graphene.Node.to_global_id("ProductVariant", variant.id),
+ "channel": channel_PLN.slug,
+ }
+ response = user_api_client.post_graphql(QUERY_PRODUCT_VARIANT_PRICING, variables)
+ content = get_graphql_content(response)
+ data = content["data"]["productVariant"]
+
+ # then
+ channel_listing = variant.channel_listings.filter(channel_id=channel_PLN.id).first()
+ price_pl = float(channel_listing.price_amount.quantize(Decimal(".01")))
+ gross_de = channel_listing.price_amount.quantize(Decimal(".01"))
+ net_de = (gross_de / Decimal(1 + TAX_RATE_DE / 100)).quantize(Decimal(".01"))
+ gross_de = float(gross_de)
+ net_de = float(net_de)
+
+ price_PL = data["pricingPL"]["price"]
+ price_undiscounted_PL = data["pricingPL"]["priceUndiscounted"]
+ assert price_PL["net"]["amount"] == price_pl
+ assert price_PL["gross"]["amount"] == price_pl
+ assert price_undiscounted_PL["net"]["amount"] == price_pl
+ assert price_undiscounted_PL["gross"]["amount"] == price_pl
+
+ price_DE = data["pricingDE"]["price"]
+ price_undiscounted_DE = data["pricingDE"]["priceUndiscounted"]
+ assert price_DE["net"]["amount"] == net_de
+ assert price_DE["gross"]["amount"] == gross_de
+ assert price_undiscounted_DE["net"]["amount"] == net_de
+ assert price_undiscounted_DE["gross"]["amount"] == gross_de
diff --git a/saleor/graphql/product/types/channels.py b/saleor/graphql/product/types/channels.py
index 7fc93ff7d3..750aa52948 100644
--- a/saleor/graphql/product/types/channels.py
+++ b/saleor/graphql/product/types/channels.py
@@ -1,7 +1,8 @@
from dataclasses import asdict
+from decimal import Decimal
import graphene
-from django_countries.fields import Country
+from promise import Promise
from ....core.permissions import ProductPermissions
from ....core.tracing import traced_resolver
@@ -13,6 +14,11 @@ from ....product.utils.costs import (
get_margin_for_variant_channel_listing,
get_product_costs_data,
)
+from ....tax.utils import (
+ get_display_gross_prices,
+ get_tax_calculation_strategy,
+ get_tax_rate_for_tax_class,
+)
from ...account import types as account_types
from ...channel.dataloaders import ChannelByIdLoader
from ...channel.types import Channel
@@ -25,7 +31,13 @@ from ...core.descriptions import (
from ...core.fields import PermissionsField
from ...core.types import ModelObjectType
from ...discount.dataloaders import DiscountsByDateTimeLoader
-from ...plugins.dataloaders import load_plugin_manager
+from ...tax.dataloaders import (
+ TaxClassByProductIdLoader,
+ TaxClassCountryRateByTaxClassIDLoader,
+ TaxClassDefaultRateByCountryLoader,
+ TaxConfigurationByChannelId,
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader,
+)
from ..dataloaders import (
CollectionsByProductIdLoader,
ProductByIdLoader,
@@ -195,79 +207,114 @@ class ProductChannelListing(ModelObjectType):
@staticmethod
def resolve_pricing(root: models.ProductChannelListing, info, *, address=None):
context = info.context
-
address_country = address.country if address is not None else None
- manager = load_plugin_manager(info.context)
-
- def calculate_pricing_info(discounts):
- def calculate_pricing_with_channel(channel):
- def calculate_pricing_with_product(product):
- def calculate_pricing_with_variants(variants):
- def calculate_pricing_with_variants_channel_listings(
- variants_channel_listing,
- ):
- def calculate_pricing_with_collections(collections):
- if not variants_channel_listing:
- return None
-
- country_code = (
- address_country or channel.default_country.code
- )
- local_currency = None
- local_currency = get_currency_for_country(country_code)
-
- availability = get_product_availability(
- product=product,
- product_channel_listing=root,
- variants=variants,
- variants_channel_listing=variants_channel_listing,
- collections=collections,
- discounts=discounts,
- channel=channel,
- manager=manager,
- country=Country(country_code),
- local_currency=local_currency,
- )
- from .products import ProductPricingInfo
-
- return ProductPricingInfo(**asdict(availability))
-
- return (
- CollectionsByProductIdLoader(context)
- .load(root.product_id)
- .then(calculate_pricing_with_collections)
+
+ channel = ChannelByIdLoader(context).load(root.channel_id)
+ product = ProductByIdLoader(context).load(root.product_id)
+ variants = ProductVariantsByProductIdLoader(context).load(root.product_id)
+ collections = CollectionsByProductIdLoader(context).load(root.product_id)
+ discounts = DiscountsByDateTimeLoader(context).load(info.context.request_time)
+
+ def load_tax_configuration(data):
+ channel, product, variants, collections, discounts = data
+ country_code = address_country or channel.default_country.code
+
+ def load_tax_country_exceptions(tax_config):
+ tax_class = TaxClassByProductIdLoader(info.context).load(product.id)
+ tax_configs_per_country = (
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader(context).load(
+ tax_config.id
+ )
+ )
+
+ def load_variant_channel_listings(data):
+ tax_class, tax_configs_per_country = data
+
+ def load_default_tax_rate(variants_channel_listing):
+ if not variants_channel_listing:
+ return None
+
+ def calculate_pricing_info(data):
+ country_rates, default_country_rate_obj = data
+ local_currency = None
+ local_currency = get_currency_for_country(country_code)
+
+ tax_config_country = next(
+ (
+ tc
+ for tc in tax_configs_per_country
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ display_gross_prices = get_display_gross_prices(
+ tax_config,
+ tax_config_country,
)
+ tax_calculation_strategy = get_tax_calculation_strategy(
+ tax_config, tax_config_country
+ )
+ default_tax_rate = (
+ default_country_rate_obj.rate
+ if default_country_rate_obj
+ else Decimal(0)
+ )
+ tax_rate = get_tax_rate_for_tax_class(
+ tax_class, country_rates, default_tax_rate, country_code
+ )
+ prices_entered_with_tax = tax_config.prices_entered_with_tax
+
+ availability = get_product_availability(
+ product=product,
+ product_channel_listing=root,
+ variants=variants,
+ variants_channel_listing=variants_channel_listing,
+ collections=collections,
+ discounts=discounts,
+ channel=channel,
+ local_currency=local_currency,
+ prices_entered_with_tax=prices_entered_with_tax,
+ tax_calculation_strategy=tax_calculation_strategy,
+ tax_rate=tax_rate,
+ )
+ from .products import ProductPricingInfo
- return (
- VariantsChannelListingByProductIdAndChannelSlugLoader(
- context
+ pricing_info = asdict(availability)
+ pricing_info["display_gross_prices"] = display_gross_prices
+ return ProductPricingInfo(**pricing_info)
+
+ country_rates = (
+ TaxClassCountryRateByTaxClassIDLoader(context).load(
+ tax_class.pk
)
- .load((root.product_id, channel.slug))
- .then(calculate_pricing_with_variants_channel_listings)
+ if tax_class
+ else []
+ )
+ default_country_rate = TaxClassDefaultRateByCountryLoader(
+ context
+ ).load(country_code)
+ return Promise.all([country_rates, default_country_rate]).then(
+ calculate_pricing_info
)
return (
- ProductVariantsByProductIdLoader(context)
- .load(root.product_id)
- .then(calculate_pricing_with_variants)
+ VariantsChannelListingByProductIdAndChannelSlugLoader(context)
+ .load((root.product_id, channel.slug))
+ .then(load_default_tax_rate)
)
- return (
- ProductByIdLoader(context)
- .load(root.product_id)
- .then(calculate_pricing_with_product)
+ return Promise.all([tax_class, tax_configs_per_country]).then(
+ load_variant_channel_listings
)
return (
- ChannelByIdLoader(context)
- .load(root.channel_id)
- .then(calculate_pricing_with_channel)
+ TaxConfigurationByChannelId(context)
+ .load(channel.id)
+ .then(load_tax_country_exceptions)
)
- return (
- DiscountsByDateTimeLoader(context)
- .load(info.context.request_time)
- .then(calculate_pricing_info)
+ return Promise.all([channel, product, variants, collections, discounts]).then(
+ load_tax_configuration
)
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index ae092e5c6e..7b48ceec58 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -1,11 +1,12 @@
import sys
from collections import defaultdict
from dataclasses import asdict
+from decimal import Decimal
from typing import List, Optional
import graphene
-from django_countries.fields import Country
from graphene import relay
+from promise import Promise
from ....attribute import models as attribute_models
from ....core.permissions import (
@@ -25,6 +26,11 @@ from ....product.utils.availability import (
get_variant_availability,
)
from ....product.utils.variants import get_variant_selection_attributes
+from ....tax.utils import (
+ get_display_gross_prices,
+ get_tax_calculation_strategy,
+ get_tax_rate_for_tax_class,
+)
from ....thumbnail.utils import get_image_or_proxy_url, get_thumbnail_size
from ....warehouse.reservations import is_reservation_enabled
from ...account import types as account_types
@@ -48,6 +54,7 @@ from ...core.connection import (
)
from ...core.descriptions import (
ADDED_IN_31,
+ ADDED_IN_39,
DEPRECATED_IN_3X_FIELD,
DEPRECATED_IN_3X_INPUT,
PREVIEW_FEATURE,
@@ -84,6 +91,17 @@ from ...product.dataloaders.products import (
ProductVariantsByProductIdAndChannel,
)
from ...site.dataloaders import load_site_callback
+from ...tax.dataloaders import (
+ ProductChargeTaxesByTaxClassIdLoader,
+ TaxClassByIdLoader,
+ TaxClassByProductIdLoader,
+ TaxClassByVariantIdLoader,
+ TaxClassCountryRateByTaxClassIDLoader,
+ TaxClassDefaultRateByCountryLoader,
+ TaxConfigurationByChannelId,
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader,
+)
+from ...tax.types import TaxClass
from ...translations.fields import TranslationField
from ...translations.types import (
CategoryTranslation,
@@ -197,6 +215,13 @@ class ProductPricingInfo(BasePricingInfo):
"in the local currency."
),
)
+ display_gross_prices = graphene.Boolean(
+ description=(
+ "Determines whether this product's price displayed in a storefront "
+ "should include taxes." + ADDED_IN_39 + PREVIEW_FEATURE
+ ),
+ required=True,
+ )
class Meta:
description = "Represents availability of a product in the storefront."
@@ -556,66 +581,106 @@ class ProductVariant(ChannelContextTypeWithMetadata, ModelObjectType):
).load((root.node.id, channel_slug))
collections = CollectionsByProductIdLoader(context).load(root.node.product_id)
channel = ChannelBySlugLoader(context).load(channel_slug)
+ discounts = DiscountsByDateTimeLoader(context).load(info.context.request_time)
+ tax_class = TaxClassByVariantIdLoader(context).load(root.node.id)
address_country = address.country if address is not None else None
- manager = load_plugin_manager(info.context)
- def calculate_pricing_info(discounts):
- def calculate_pricing_with_channel(channel):
- def calculate_pricing_with_product_variant_channel_listings(
- variant_channel_listing,
- ):
- def calculate_pricing_with_product(product):
- def calculate_pricing_with_product_channel_listings(
- product_channel_listing,
- ):
- def calculate_pricing_with_collections(collections):
- if (
- not variant_channel_listing
- or not product_channel_listing
- ):
- return None
-
- country_code = (
- address_country or channel.default_country.code
- )
+ def load_tax_configuration(data):
+ (
+ product,
+ product_channel_listing,
+ variant_channel_listing,
+ collections,
+ channel,
+ tax_class,
+ discounts,
+ ) = data
+
+ if not variant_channel_listing or not product_channel_listing:
+ return None
- local_currency = None
- local_currency = get_currency_for_country(country_code)
-
- availability = get_variant_availability(
- variant=root.node,
- variant_channel_listing=variant_channel_listing,
- product=product,
- product_channel_listing=product_channel_listing,
- collections=collections,
- discounts=discounts,
- channel=channel,
- country=Country(country_code),
- local_currency=local_currency,
- plugins=manager,
- )
- return VariantPricingInfo(**asdict(availability))
+ country_code = address_country or channel.default_country.code
+
+ def load_tax_country_exceptions(tax_config):
+ def load_default_tax_rate(tax_configs_per_country):
+ def calculate_pricing_info(data):
+ country_rates, default_country_rate_obj = data
+ local_currency = get_currency_for_country(country_code)
+
+ tax_config_country = next(
+ (
+ tc
+ for tc in tax_configs_per_country
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ tax_calculation_strategy = get_tax_calculation_strategy(
+ tax_config, tax_config_country
+ )
- return collections.then(calculate_pricing_with_collections)
+ default_tax_rate = (
+ default_country_rate_obj.rate
+ if default_country_rate_obj
+ else Decimal(0)
+ )
+ tax_rate = get_tax_rate_for_tax_class(
+ tax_class, country_rates, default_tax_rate, country_code
+ )
- return product_channel_listing.then(
- calculate_pricing_with_product_channel_listings
+ availability = get_variant_availability(
+ variant=root.node,
+ variant_channel_listing=variant_channel_listing,
+ product=product,
+ product_channel_listing=product_channel_listing,
+ collections=collections,
+ discounts=discounts,
+ channel=channel,
+ local_currency=local_currency,
+ prices_entered_with_tax=tax_config.prices_entered_with_tax,
+ tax_calculation_strategy=tax_calculation_strategy,
+ tax_rate=tax_rate,
)
+ return VariantPricingInfo(**asdict(availability))
- return product.then(calculate_pricing_with_product)
+ country_rates = (
+ TaxClassCountryRateByTaxClassIDLoader(context).load(
+ tax_class.pk
+ )
+ if tax_class
+ else []
+ )
+ default_rate = TaxClassDefaultRateByCountryLoader(context).load(
+ country_code
+ )
+ return Promise.all([country_rates, default_rate]).then(
+ calculate_pricing_info
+ )
- return variant_channel_listing.then(
- calculate_pricing_with_product_variant_channel_listings
+ return (
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader(context)
+ .load(tax_config.id)
+ .then(load_default_tax_rate)
)
- return channel.then(calculate_pricing_with_channel)
+ return (
+ TaxConfigurationByChannelId(context)
+ .load(channel.id)
+ .then(load_tax_country_exceptions)
+ )
- return (
- DiscountsByDateTimeLoader(context)
- .load(info.context.request_time)
- .then(calculate_pricing_info)
- )
+ return Promise.all(
+ [
+ product,
+ product_channel_listing,
+ variant_channel_listing,
+ collections,
+ channel,
+ tax_class,
+ discounts,
+ ]
+ ).then(load_tax_configuration)
@staticmethod
def resolve_product(root: ChannelContext[models.ProductVariant], info):
@@ -757,7 +822,13 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):
category = graphene.Field(lambda: Category)
created = graphene.DateTime(required=True)
updated_at = graphene.DateTime(required=True)
- charge_taxes = graphene.Boolean(required=True)
+ charge_taxes = graphene.Boolean(
+ required=True,
+ deprecation_reason=(
+ f"{DEPRECATED_IN_3X_FIELD} Use `Channel.taxConfiguration` field to "
+ "determine whether tax collection is enabled."
+ ),
+ )
weight = graphene.Field(Weight)
default_variant = graphene.Field(ProductVariant)
rating = graphene.Float()
@@ -787,7 +858,9 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):
description="Whether the product is in stock and visible or not.",
)
tax_type = graphene.Field(
- TaxType, description="A type of tax. Assigned by enabled tax gateway"
+ TaxType,
+ description="A type of tax. Assigned by enabled tax gateway",
+ deprecation_reason=f"{DEPRECATED_IN_3X_FIELD} Use `taxClass` field instead.",
)
attributes = NonNullList(
SelectedAttribute,
@@ -856,6 +929,15 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):
is_available_for_purchase = graphene.Boolean(
description="Whether the product is available for purchase."
)
+ tax_class = PermissionsField(
+ TaxClass,
+ description=(
+ "Tax class assigned to this product type. All products of this product "
+ "type use this tax class, unless it's overridden in the `Product` type."
+ ),
+ required=False,
+ permissions=[AuthorizationFilters.AUTHENTICATED_STAFF_USER],
+ )
class Meta:
default_resolver = ChannelContextType.resolver_with_context
@@ -901,9 +983,19 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):
@staticmethod
def resolve_tax_type(root: ChannelContext[models.Product], info):
- manager = load_plugin_manager(info.context)
- tax_data = manager.get_tax_code_from_object_meta(root.node)
- return TaxType(tax_code=tax_data.code, description=tax_data.description)
+ def with_tax_class(tax_class):
+ manager = load_plugin_manager(info.context)
+ tax_data = manager.get_tax_code_from_object_meta(tax_class)
+ return TaxType(tax_code=tax_data.code, description=tax_data.description)
+
+ if root.node.tax_class_id:
+ return (
+ TaxClassByIdLoader(info.context)
+ .load(root.node.tax_class_id)
+ .then(with_tax_class)
+ )
+
+ return None
@staticmethod
def resolve_thumbnail(
@@ -951,7 +1043,9 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):
channel_slug = str(root.channel_slug)
context = info.context
+ address_country = address.country if address is not None else None
+ channel = ChannelBySlugLoader(context).load(channel_slug)
product_channel_listing = ProductChannelListingByProductIdAndChannelSlugLoader(
context
).load((root.node.id, channel_slug))
@@ -962,63 +1056,125 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):
)
)
collections = CollectionsByProductIdLoader(context).load(root.node.id)
- channel = ChannelBySlugLoader(context).load(channel_slug)
-
- address_country = address.country if address is not None else None
- manager = load_plugin_manager(info.context)
+ discounts = DiscountsByDateTimeLoader(context).load(context.request_time)
+ tax_class = TaxClassByProductIdLoader(context).load(root.node.id)
+
+ def load_tax_configuration(data):
+ (
+ channel,
+ product_channel_listing,
+ variants,
+ variants_channel_listing,
+ collections,
+ discounts,
+ tax_class,
+ ) = data
+
+ if not variants_channel_listing:
+ return None
- def calculate_pricing_info(discounts):
- def calculate_pricing_with_channel(channel):
- def calculate_pricing_with_product_channel_listings(
- product_channel_listing,
- ):
- def calculate_pricing_with_variants(variants):
- def calculate_pricing_with_variants_channel_listings(
- variants_channel_listing,
- ):
- def calculate_pricing_with_collections(collections):
- if not variants_channel_listing:
- return None
+ country_code = address_country or channel.default_country.code
+
+ def load_tax_country_exceptions(tax_config):
+ def load_default_tax_rate(tax_configs_per_country):
+ def calculate_pricing_info(data):
+ country_rates, default_country_rate_obj = data
+ local_currency = None
+ local_currency = get_currency_for_country(country_code)
+
+ tax_config_country = next(
+ (
+ tc
+ for tc in tax_configs_per_country
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ display_gross_prices = get_display_gross_prices(
+ tax_config,
+ tax_config_country,
+ )
- local_currency = None
- country_code = (
- address_country or channel.default_country.code
- )
- local_currency = get_currency_for_country(country_code)
-
- availability = get_product_availability(
- product=root.node,
- product_channel_listing=product_channel_listing,
- variants=variants,
- variants_channel_listing=variants_channel_listing,
- collections=collections,
- discounts=discounts,
- channel=channel,
- manager=manager,
- country=Country(country_code),
- local_currency=local_currency,
- )
- return ProductPricingInfo(**asdict(availability))
+ tax_config_country = next(
+ (
+ tc
+ for tc in tax_configs_per_country
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ display_gross_prices = get_display_gross_prices(
+ tax_config,
+ tax_config_country,
+ )
+ tax_calculation_strategy = get_tax_calculation_strategy(
+ tax_config, tax_config_country
+ )
- return collections.then(calculate_pricing_with_collections)
+ default_tax_rate = (
+ default_country_rate_obj.rate
+ if default_country_rate_obj
+ else Decimal(0)
+ )
+ tax_rate = get_tax_rate_for_tax_class(
+ tax_class, country_rates, default_tax_rate, country_code
+ )
- return variants_channel_listing.then(
- calculate_pricing_with_variants_channel_listings
+ availability = get_product_availability(
+ product=root.node,
+ product_channel_listing=product_channel_listing,
+ variants=variants,
+ variants_channel_listing=variants_channel_listing,
+ collections=collections,
+ discounts=discounts,
+ channel=channel,
+ local_currency=local_currency,
+ prices_entered_with_tax=tax_config.prices_entered_with_tax,
+ tax_calculation_strategy=tax_calculation_strategy,
+ tax_rate=tax_rate,
)
- return variants.then(calculate_pricing_with_variants)
+ pricing_info = asdict(availability)
+ pricing_info["display_gross_prices"] = display_gross_prices
+ return ProductPricingInfo(**pricing_info)
- return product_channel_listing.then(
- calculate_pricing_with_product_channel_listings
+ country_rates = (
+ TaxClassCountryRateByTaxClassIDLoader(context).load(
+ tax_class.pk
+ )
+ if tax_class
+ else []
+ )
+ default_rate = TaxClassDefaultRateByCountryLoader(context).load(
+ country_code
+ )
+ return Promise.all([country_rates, default_rate]).then(
+ calculate_pricing_info
+ )
+
+ return (
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader(context)
+ .load(tax_config.id)
+ .then(load_default_tax_rate)
)
- return channel.then(calculate_pricing_with_channel)
+ return (
+ TaxConfigurationByChannelId(context)
+ .load(channel.id)
+ .then(load_tax_country_exceptions)
+ )
- return (
- DiscountsByDateTimeLoader(context)
- .load(info.context.request_time)
- .then(calculate_pricing_info)
- )
+ return Promise.all(
+ [
+ channel,
+ product_channel_listing,
+ variants,
+ variants_channel_listing,
+ collections,
+ discounts,
+ tax_class,
+ ]
+ ).then(load_tax_configuration)
@staticmethod
@traced_resolver
@@ -1240,6 +1396,51 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):
def resolve_product_type(root: ChannelContext[models.Product], info):
return ProductTypeByIdLoader(info.context).load(root.node.product_type_id)
+ @staticmethod
+ def resolve_tax_class(root: ChannelContext[models.Product], info):
+ product_type = (
+ ProductTypeByIdLoader(info.context).load(root.node.product_type_id)
+ if not root.node.tax_class_id
+ else None
+ )
+
+ def resolve_tax_class(product_type):
+ tax_class_id = (
+ product_type.tax_class_id if product_type else root.node.tax_class_id
+ )
+ return (
+ TaxClassByIdLoader(info.context).load(tax_class_id)
+ if tax_class_id
+ else None
+ )
+
+ return Promise.resolve(product_type).then(resolve_tax_class)
+
+ def resolve_charge_taxes(root: ChannelContext[models.Product], info):
+ # Deprecated: this field is deprecated as it only checks whether there are any
+ # non-zero flat rates set for a product. Instead channel tax configuration
+ # should be used to check whether taxes are charged.
+
+ tax_class_id = root.node.tax_class_id
+ if not tax_class_id:
+ product_type = ProductTypeByIdLoader(info.context).load(
+ root.node.product_type_id
+ )
+
+ def with_product_type(product_type):
+ tax_class_id = product_type.tax_class_id
+ return (
+ ProductChargeTaxesByTaxClassIdLoader(info.context).load(
+ tax_class_id
+ )
+ if tax_class_id
+ else False
+ )
+
+ return product_type.then(with_product_type)
+
+ return ProductChargeTaxesByTaxClassIdLoader(info.context).load(tax_class_id)
+
@staticmethod
def __resolve_references(roots: List["Product"], info):
requestor = get_user_or_app_from_context(info.context)
@@ -1292,7 +1493,18 @@ class ProductType(ModelObjectType):
),
)
tax_type = graphene.Field(
- TaxType, description="A type of tax. Assigned by enabled tax gateway"
+ TaxType,
+ description="A type of tax. Assigned by enabled tax gateway",
+ deprecation_reason=f"{DEPRECATED_IN_3X_FIELD} Use `taxClass` field instead.",
+ )
+ tax_class = PermissionsField(
+ TaxClass,
+ description=(
+ "Tax class assigned to this product type. All products of this product "
+ "type use this tax class, unless it's overridden in the `Product` type."
+ ),
+ required=False,
+ permissions=[AuthorizationFilters.AUTHENTICATED_STAFF_USER],
)
variant_attributes = NonNullList(
Attribute,
@@ -1336,9 +1548,19 @@ class ProductType(ModelObjectType):
@staticmethod
def resolve_tax_type(root: models.ProductType, info):
- manager = load_plugin_manager(info.context)
- tax_data = manager.get_tax_code_from_object_meta(root)
- return TaxType(tax_code=tax_data.code, description=tax_data.description)
+ def with_tax_class(tax_class):
+ manager = load_plugin_manager(info.context)
+ tax_data = manager.get_tax_code_from_object_meta(tax_class)
+ return TaxType(tax_code=tax_data.code, description=tax_data.description)
+
+ if root.tax_class_id:
+ return (
+ TaxClassByIdLoader(info.context)
+ .load(root.tax_class_id)
+ .then(with_tax_class)
+ )
+
+ return None
@staticmethod
def resolve_product_attributes(root: models.ProductType, info):
@@ -1430,6 +1652,14 @@ class ProductType(ModelObjectType):
def resolve_weight(root: models.ProductType, _info):
return convert_weight_to_default_weight_unit(root.weight)
+ @staticmethod
+ def resolve_tax_class(root: models.ProductType, info):
+ return (
+ TaxClassByIdLoader(info.context).load(root.tax_class_id)
+ if root.tax_class_id
+ else None
+ )
+
@staticmethod
def __resolve_references(roots: List["ProductType"], _info):
return resolve_federation_references(
diff --git a/saleor/graphql/query_cost_map.py b/saleor/graphql/query_cost_map.py
index 92f1a34f9c..096f5d50cc 100644
--- a/saleor/graphql/query_cost_map.py
+++ b/saleor/graphql/query_cost_map.py
@@ -114,6 +114,12 @@ COST_MAP = {
"staffUsers": {"complexity": 1, "multipliers": ["first", "last"]},
"stock": {"complexity": 1},
"stocks": {"complexity": 1, "multipliers": ["first", "last"]},
+ "taxClass": {"complexity": 1},
+ "taxClasses": {"complexity": 1, "multipliers": ["first", "last"]},
+ "taxConfiguration": {"complexity": 1},
+ "taxConfigurations": {"complexity": 1, "multipliers": ["first", "last"]},
+ "taxCountryConfiguration": {"complexity": 1},
+ "taxCountryConfigurations": {"complexity": 1},
"taxTypes": {"complexity": 1},
"translation": {"complexity": 1},
"translations": {"complexity": 1, "multipliers": ["first", "last"]},
@@ -306,6 +312,19 @@ COST_MAP = {
"Stock": {
"productVariant": {"complexity": 1},
},
+ "TaxClass": {
+ "countries": {"complexity": 1},
+ },
+ "TaxClassCountryRate": {
+ "taxClass": {"complexity": 1},
+ },
+ "TaxCountryConfiguration": {
+ "taxClassCountryRates": {"complexity": 1},
+ },
+ "TaxConfiguration": {
+ "channel": {"complexity": 1},
+ "countries": {"complexity": 1},
+ },
"User": {
"avatar": {"complexity": 1},
"checkout": {"complexity": 1},
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 0f9ef19cd1..e95996d77d 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -95,6 +95,102 @@ type Query {
kind: TranslatableKinds!
): TranslatableItem
+ """
+ Look up a tax configuration.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
+ """
+ taxConfiguration(
+ """ID of a tax configuration."""
+ id: ID!
+ ): TaxConfiguration
+
+ """
+ List of tax configurations.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
+ """
+ taxConfigurations(
+ """Filtering options for tax configurations."""
+ filter: TaxConfigurationFilterInput
+
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
+
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
+
+ """Return the first n elements from the list."""
+ first: Int
+
+ """Return the last n elements from the list."""
+ last: Int
+ ): TaxConfigurationCountableConnection
+
+ """
+ Look up a tax class.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
+ """
+ taxClass(
+ """ID of a tax class."""
+ id: ID!
+ ): TaxClass
+
+ """
+ List of tax classes.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
+ """
+ taxClasses(
+ """Sort tax classes."""
+ sortBy: TaxClassSortingInput
+
+ """Filtering options for tax classes."""
+ filter: TaxClassFilterInput
+
+ """Return the elements in the list that come before the specified cursor."""
+ before: String
+
+ """Return the elements in the list that come after the specified cursor."""
+ after: String
+
+ """Return the first n elements from the list."""
+ first: Int
+
+ """Return the last n elements from the list."""
+ last: Int
+ ): TaxClassCountableConnection
+
+ """
+ Tax class rates grouped by country.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
+ """
+ taxCountryConfiguration(
+ """Country for which to return tax class rates."""
+ countryCode: CountryCode!
+ ): TaxCountryConfiguration
+
+ "\\n\\nRequires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP."
+ taxCountryConfigurations: [TaxCountryConfiguration!]
+
"""
Look up a stock by ID
@@ -2480,13 +2576,13 @@ enum PermissionEnum {
MANAGE_TAXES
MANAGE_CHANNELS
MANAGE_DISCOUNTS
- MANAGE_PLUGINS
MANAGE_GIFT_CARD
MANAGE_MENUS
MANAGE_ORDERS
MANAGE_PAGES
MANAGE_PAGE_TYPES_AND_ATTRIBUTES
HANDLE_PAYMENTS
+ MANAGE_PLUGINS
MANAGE_PRODUCTS
MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES
MANAGE_SHIPPING
@@ -2962,7 +3058,7 @@ type CountryDisplay {
country: String!
"""Country tax."""
- vat: VAT
+ vat: VAT @deprecated(reason: "This field will be removed in Saleor 4.0. Use `TaxClassCountryRate` type to manage tax rates per country.")
}
"""Represents a VAT rate for a country."""
@@ -3223,6 +3319,13 @@ type ShippingMethodType implements Node & ObjectWithMetadata {
"""Minimal number of days for delivery."""
minimumDeliveryDays: Int
+
+ """
+ Tax class assigned to this shipping method.
+
+ Requires one of the following permissions: MANAGE_TAXES, MANAGE_SHIPPING.
+ """
+ taxClass: TaxClass
}
"""An enumeration."""
@@ -4647,7 +4750,7 @@ type Product implements Node & ObjectWithMetadata {
category: Category
created: DateTime!
updatedAt: DateTime!
- chargeTaxes: Boolean!
+ chargeTaxes: Boolean! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `Channel.taxConfiguration` field to determine whether tax collection is enabled.")
weight: Weight
defaultVariant: ProductVariant
rating: Float
@@ -4698,7 +4801,7 @@ type Product implements Node & ObjectWithMetadata {
): Boolean
"""A type of tax. Assigned by enabled tax gateway"""
- taxType: TaxType
+ taxType: TaxType @deprecated(reason: "This field will be removed in Saleor 4.0. Use `taxClass` field instead.")
"""List of attributes assigned to this product."""
attributes: [SelectedAttribute!]!
@@ -4752,6 +4855,13 @@ type Product implements Node & ObjectWithMetadata {
"""Whether the product is available for purchase."""
isAvailableForPurchase: Boolean
+
+ """
+ Tax class assigned to this product type. All products of this product type use this tax class, unless it's overridden in the `Product` type.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER.
+ """
+ taxClass: TaxClass
}
"""
@@ -4834,7 +4944,14 @@ type ProductType implements Node & ObjectWithMetadata {
): ProductCountableConnection @deprecated(reason: "This field will be removed in Saleor 4.0. Use the top-level `products` query with the `productTypes` filter.")
"""A type of tax. Assigned by enabled tax gateway"""
- taxType: TaxType
+ taxType: TaxType @deprecated(reason: "This field will be removed in Saleor 4.0. Use `taxClass` field instead.")
+
+ """
+ Tax class assigned to this product type. All products of this product type use this tax class, unless it's overridden in the `Product` type.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER.
+ """
+ taxClass: TaxClass
"""Variant attributes of that product type."""
variantAttributes(
@@ -4892,6 +5009,88 @@ type TaxType {
taxCode: String
}
+"""
+Tax class is a named object used to define tax rates per country. Tax class can be assigned to product types, products and shipping methods to define their tax rates.
+
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+"""
+type TaxClass implements Node & ObjectWithMetadata {
+ """The ID of the object."""
+ id: ID!
+
+ """List of private metadata items. Requires staff permissions to access."""
+ privateMetadata: [MetadataItem!]!
+
+ """
+ A single key from private metadata. Requires staff permissions to access.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ privateMetafield(key: String!): String
+
+ """
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ privateMetafields(keys: [String!]): Metadata
+
+ """List of public metadata items. Can be accessed without permissions."""
+ metadata: [MetadataItem!]!
+
+ """
+ A single key from public metadata.
+
+ Tip: Use GraphQL aliases to fetch multiple keys.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ metafield(key: String!): String
+
+ """
+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ metafields(keys: [String!]): Metadata
+
+ """Name of the tax class."""
+ name: String!
+
+ """Country-specific tax rates for this tax class."""
+ countries: [TaxClassCountryRate!]!
+}
+
+"""
+Tax rate for a country. When tax class is null, it represents the default tax rate for that country; otherwise it's a country tax rate specific to the given tax class.
+
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+"""
+type TaxClassCountryRate {
+ """Country in which this tax rate applies."""
+ country: CountryDisplay!
+
+ """Tax rate value."""
+ rate: Float!
+
+ """Related tax class."""
+ taxClass: TaxClass
+}
+
"""
Custom attribute of a product. Attributes can be assigned to products and variants at the product type level.
"""
@@ -6029,6 +6228,15 @@ type ProductPricingInfo {
The discounted price range of the product variants in the local currency.
"""
priceRangeLocalCurrency: TaxedMoneyRange
+
+ """
+ Determines whether this product's price displayed in a storefront should include taxes.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ displayGrossPrices: Boolean!
}
"""Represents a range of monetary values."""
@@ -7592,93 +7800,276 @@ enum TranslatableKinds {
VOUCHER
}
-type StockCountableConnection {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [StockCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type StockCountableEdge {
- """The item at the end of the edge."""
- node: Stock!
-
- """A cursor for use in pagination."""
- cursor: String!
-}
-
-input StockFilterInput {
- quantity: Float
- search: String
-}
-
-"""
-Represents a shop resource containing general shop data and configuration.
"""
-type Shop {
- """List of available payment gateways."""
- availablePaymentGateways(
- """
- A currency for which gateways will be returned.
-
- DEPRECATED: this field will be removed in Saleor 4.0. Use `channel` argument instead.
- """
- currency: String
-
- """Slug of a channel for which the data should be returned."""
- channel: String
- ): [PaymentGateway!]!
+Channel-specific tax configuration.
- """List of available external authentications."""
- availableExternalAuthentications: [ExternalAuthentication!]!
+Added in Saleor 3.9.
- """Shipping methods that are available for the shop."""
- availableShippingMethods(
- """Slug of a channel for which the data should be returned."""
- channel: String!
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+"""
+type TaxConfiguration implements Node & ObjectWithMetadata {
+ """The ID of the object."""
+ id: ID!
- """Address for which available shipping methods should be returned."""
- address: AddressInput
- ): [ShippingMethod!]
+ """List of private metadata items. Requires staff permissions to access."""
+ privateMetadata: [MetadataItem!]!
"""
- List of all currencies supported by shop's channels.
+ A single key from private metadata. Requires staff permissions to access.
- Added in Saleor 3.1.
+ Tip: Use GraphQL aliases to fetch multiple keys.
- Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
- channelCurrencies: [String!]!
-
- """List of countries available in the shop."""
- countries(
- """
- A language code to return the translation for.
-
- DEPRECATED: this field will be removed in Saleor 4.0.
- """
- languageCode: LanguageCodeEnum
-
- """Filtering options for countries"""
- filter: CountryFilterInput
- ): [CountryDisplay!]!
-
- """Shop's default country."""
- defaultCountry: CountryDisplay
+ privateMetafield(key: String!): String
"""
- Default shop's email sender's name.
+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.
- Requires one of the following permissions: MANAGE_SETTINGS.
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
- defaultMailSenderName: String
+ privateMetafields(keys: [String!]): Metadata
+
+ """List of public metadata items. Can be accessed without permissions."""
+ metadata: [MetadataItem!]!
"""
- Default shop's email sender's address.
+ A single key from public metadata.
- Requires one of the following permissions: MANAGE_SETTINGS.
+ Tip: Use GraphQL aliases to fetch multiple keys.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ metafield(key: String!): String
+
+ """
+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.
+
+ Added in Saleor 3.3.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ metafields(keys: [String!]): Metadata
+
+ """A channel to which the tax configuration applies to."""
+ channel: Channel!
+
+ """Determines whether taxes are charged in the given channel."""
+ chargeTaxes: Boolean!
+
+ """
+ The default strategy to use for tax calculation in the given channel. Taxes can be calculated either using user-defined flat rates or with a tax app. Empty value means that no method is selected and taxes are not calculated.
+ """
+ taxCalculationStrategy: TaxCalculationStrategy
+
+ """
+ Determines whether prices displayed in a storefront should include taxes.
+ """
+ displayGrossPrices: Boolean!
+
+ """Determines whether prices are entered with the tax included."""
+ pricesEnteredWithTax: Boolean!
+
+ """List of country-specific exceptions in tax configuration."""
+ countries: [TaxConfigurationPerCountry!]!
+}
+
+enum TaxCalculationStrategy {
+ FLAT_RATES
+ TAX_APP
+}
+
+"""
+Country-specific exceptions of a channel's tax configuration.
+
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+"""
+type TaxConfigurationPerCountry {
+ """Country in which this configuration applies."""
+ country: CountryDisplay!
+
+ """Determines whether taxes are charged in this country."""
+ chargeTaxes: Boolean!
+
+ """
+ A country-specific strategy to use for tax calculation. Taxes can be calculated either using user-defined flat rates or with a tax app. If not provided, use the value from the channel's tax configuration.
+ """
+ taxCalculationStrategy: TaxCalculationStrategy
+
+ """
+ Determines whether prices displayed in a storefront should include taxes for this country.
+ """
+ displayGrossPrices: Boolean!
+}
+
+type TaxConfigurationCountableConnection {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [TaxConfigurationCountableEdge!]!
+
+ """A total count of items in the collection."""
+ totalCount: Int
+}
+
+type TaxConfigurationCountableEdge {
+ """The item at the end of the edge."""
+ node: TaxConfiguration!
+
+ """A cursor for use in pagination."""
+ cursor: String!
+}
+
+input TaxConfigurationFilterInput {
+ metadata: [MetadataFilter!]
+ ids: [ID!]
+}
+
+type TaxClassCountableConnection {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [TaxClassCountableEdge!]!
+
+ """A total count of items in the collection."""
+ totalCount: Int
+}
+
+type TaxClassCountableEdge {
+ """The item at the end of the edge."""
+ node: TaxClass!
+
+ """A cursor for use in pagination."""
+ cursor: String!
+}
+
+input TaxClassSortingInput {
+ """Specifies the direction in which to sort products."""
+ direction: OrderDirection!
+
+ """Sort tax classes by the selected field."""
+ field: TaxClassSortField!
+}
+
+enum TaxClassSortField {
+ """Sort tax classes by name."""
+ NAME
+}
+
+input TaxClassFilterInput {
+ metadata: [MetadataFilter!]
+ ids: [ID!]
+ countries: [CountryCode!]
+}
+
+"""
+Tax class rates grouped by country.
+
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+"""
+type TaxCountryConfiguration {
+ """A country for which tax class rates are grouped."""
+ country: CountryDisplay!
+
+ """List of tax class rates."""
+ taxClassCountryRates: [TaxClassCountryRate!]!
+}
+
+type StockCountableConnection {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [StockCountableEdge!]!
+
+ """A total count of items in the collection."""
+ totalCount: Int
+}
+
+type StockCountableEdge {
+ """The item at the end of the edge."""
+ node: Stock!
+
+ """A cursor for use in pagination."""
+ cursor: String!
+}
+
+input StockFilterInput {
+ quantity: Float
+ search: String
+}
+
+"""
+Represents a shop resource containing general shop data and configuration.
+"""
+type Shop {
+ """List of available payment gateways."""
+ availablePaymentGateways(
+ """
+ A currency for which gateways will be returned.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use `channel` argument instead.
+ """
+ currency: String
+
+ """Slug of a channel for which the data should be returned."""
+ channel: String
+ ): [PaymentGateway!]!
+
+ """List of available external authentications."""
+ availableExternalAuthentications: [ExternalAuthentication!]!
+
+ """Shipping methods that are available for the shop."""
+ availableShippingMethods(
+ """Slug of a channel for which the data should be returned."""
+ channel: String!
+
+ """Address for which available shipping methods should be returned."""
+ address: AddressInput
+ ): [ShippingMethod!]
+
+ """
+ List of all currencies supported by shop's channels.
+
+ Added in Saleor 3.1.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
+ """
+ channelCurrencies: [String!]!
+
+ """List of countries available in the shop."""
+ countries(
+ """
+ A language code to return the translation for.
+
+ DEPRECATED: this field will be removed in Saleor 4.0.
+ """
+ languageCode: LanguageCodeEnum
+
+ """Filtering options for countries"""
+ filter: CountryFilterInput
+ ): [CountryDisplay!]!
+
+ """Shop's default country."""
+ defaultCountry: CountryDisplay
+
+ """
+ Default shop's email sender's name.
+
+ Requires one of the following permissions: MANAGE_SETTINGS.
+ """
+ defaultMailSenderName: String
+
+ """
+ Default shop's email sender's address.
+
+ Requires one of the following permissions: MANAGE_SETTINGS.
"""
defaultMailSenderAddress: String
@@ -7703,9 +8094,6 @@ type Shop {
"""Header text."""
headerText: String
- """Include taxes in prices."""
- includeTaxesInPrices: Boolean!
-
"""
Automatically approve all new fulfillments.
@@ -7720,12 +8108,6 @@ type Shop {
"""
fulfillmentAllowUnpaid: Boolean!
- """Display prices with tax in store."""
- displayGrossPrices: Boolean!
-
- """Charge taxes on shipping."""
- chargeTaxesOnShipping: Boolean!
-
"""Enable inventory tracking."""
trackInventoryByDefault: Boolean
@@ -7814,6 +8196,15 @@ type Shop {
Requires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.
"""
version: String!
+
+ """Include taxes in prices."""
+ includeTaxesInPrices: Boolean! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `Channel.taxConfiguration.pricesEnteredWithTax` to determine whether prices are entered with tax.")
+
+ """Display prices with tax in store."""
+ displayGrossPrices: Boolean! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `Channel.taxConfiguration` to determine whether to display gross or net prices.")
+
+ """Charge taxes on shipping."""
+ chargeTaxesOnShipping: Boolean! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `ShippingMethodType.taxClass` to determine whether taxes are calculated for shipping methods; if a tax class is set, the taxes will be calculated, otherwise no tax rate will be applied.")
}
"""
@@ -8223,6 +8614,15 @@ type Checkout implements Node & ObjectWithMetadata {
Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
transactions: [TransactionItem!]
+
+ """
+ Determines whether checkout prices should include taxes when displayed in a storefront.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ displayGrossPrices: Boolean!
}
"""
@@ -8855,13 +9255,52 @@ type Order implements Node & ObjectWithMetadata {
"""Total price of shipping."""
shippingPrice: TaxedMoney!
+
+ """The shipping tax rate value."""
shippingTaxRate: Float!
+
+ """
+ Denormalized tax class assigned to the shipping method.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER.
+ """
+ shippingTaxClass: TaxClass
+
+ """
+ Denormalized name of the tax class assigned to the shipping method.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ shippingTaxClassName: String
+
+ """
+ Denormalized public metadata of the shipping method's tax class.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ shippingTaxClassMetadata: [MetadataItem!]!
+
+ """
+ Denormalized private metadata of the shipping method's tax class. Requires staff permissions to access.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ shippingTaxClassPrivateMetadata: [MetadataItem!]!
token: String! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `id` instead.")
voucher: Voucher
"""List of user gift cards."""
giftCards: [GiftCard!]!
- displayGrossPrices: Boolean!
customerNote: String!
weight: Weight!
redirectUrl: String
@@ -8928,6 +9367,15 @@ type Order implements Node & ObjectWithMetadata {
"""List of errors that occurred during order validation."""
errors: [OrderError!]!
+
+ """
+ Determines whether checkout prices should include taxes when displayed in a storefront.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ displayGrossPrices: Boolean!
}
"""An enumeration."""
@@ -9143,13 +9591,51 @@ type OrderLine implements Node & ObjectWithMetadata {
"""Type of the discount: fixed or percent"""
unitDiscountType: DiscountValueTypeEnum
-}
-
-"""
-Positive Decimal scalar implementation.
-Should be used in places where value must be positive.
-"""
+ """
+ Denormalized tax class of the product in this order line.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: AUTHENTICATED_STAFF_USER.
+ """
+ taxClass: TaxClass
+
+ """
+ Denormalized name of the tax class.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ taxClassName: String
+
+ """
+ Denormalized public metadata of the tax class.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ taxClassMetadata: [MetadataItem!]!
+
+ """
+ Denormalized private metadata of the tax class. Requires staff permissions to access.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ taxClassPrivateMetadata: [MetadataItem!]!
+}
+
+"""
+Positive Decimal scalar implementation.
+
+Should be used in places where value must be positive.
+"""
scalar PositiveDecimal
"""Represents allocation."""
@@ -11299,6 +11785,101 @@ type Mutation {
shippingZoneIds: [ID!]!
): WarehouseShippingZoneUnassign
+ """
+ Create a tax class.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: MANAGE_TAXES.
+ """
+ taxClassCreate(
+ """Fields required to create a tax class."""
+ input: TaxClassCreateInput!
+ ): TaxClassCreate
+
+ """
+ Delete a tax class. After deleting the tax class any products, product types or shipping methods using it are updated to use the default tax class.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: MANAGE_TAXES.
+ """
+ taxClassDelete(
+ """ID of a tax class to delete."""
+ id: ID!
+ ): TaxClassDelete
+
+ """
+ Update a tax class.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: MANAGE_TAXES.
+ """
+ taxClassUpdate(
+ """ID of the tax class."""
+ id: ID!
+
+ """Fields required to update a tax class."""
+ input: TaxClassUpdateInput!
+ ): TaxClassUpdate
+
+ """
+ Update tax configuration for a channel.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: MANAGE_TAXES.
+ """
+ taxConfigurationUpdate(
+ """ID of the tax configuration."""
+ id: ID!
+
+ """Fields required to update the tax configuration."""
+ input: TaxConfigurationUpdateInput!
+ ): TaxConfigurationUpdate
+
+ """
+ Update tax class rates for a specific country.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: MANAGE_TAXES.
+ """
+ taxCountryConfigurationUpdate(
+ """Country in which to update the tax class rates."""
+ countryCode: CountryCode!
+
+ """
+ List of tax rates per tax class to update. When `{taxClass: id, rate: null`} is passed, it deletes the rate object for given taxClass ID. When `{rate: Int}` is passed without a tax class, it updates the default tax class for this country.
+ """
+ updateTaxClassRates: [TaxClassRateInput!]!
+ ): TaxCountryConfigurationUpdate
+
+ """
+ Remove all tax class rates for a specific country.
+
+ Added in Saleor 3.9.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+ Requires one of the following permissions: MANAGE_TAXES.
+ """
+ taxCountryConfigurationDelete(
+ """Country in which to update the tax class rates."""
+ countryCode: CountryCode!
+ ): TaxCountryConfigurationDelete
+
"""
Exempt checkout or order from charging the taxes. When tax exemption is enabled, taxes won't be charged for the checkout or order. Taxes may still be calculated in cases when product prices are entered with the tax included and the net price needs to be known.
@@ -11374,7 +11955,7 @@ type Mutation {
Requires one of the following permissions: MANAGE_SETTINGS.
"""
- shopFetchTaxRates: ShopFetchTaxRates
+ shopFetchTaxRates: ShopFetchTaxRates @deprecated(reason: "\\n\\nDEPRECATED: this mutation will be removed in Saleor 4.0.")
"""
Creates/updates translations for shop settings.
@@ -14934,82 +15515,371 @@ type WebhookDelete {
}
"""
-Updates a webhook subscription.
+Updates a webhook subscription.
+
+Requires one of the following permissions: MANAGE_APPS.
+"""
+type WebhookUpdate {
+ webhookErrors: [WebhookError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
+ errors: [WebhookError!]!
+ webhook: Webhook
+}
+
+input WebhookUpdateInput {
+ """The new name of the webhook."""
+ name: String
+
+ """The url to receive the payload."""
+ targetUrl: String
+
+ """
+ The events that webhook wants to subscribe.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use `asyncEvents` or `syncEvents` instead.
+ """
+ events: [WebhookEventTypeEnum!]
+
+ """The asynchronous events that webhook wants to subscribe."""
+ asyncEvents: [WebhookEventTypeAsyncEnum!]
+
+ """The synchronous events that webhook wants to subscribe."""
+ syncEvents: [WebhookEventTypeSyncEnum!]
+
+ """ID of the app to which webhook belongs."""
+ app: ID
+
+ """Determine if webhook will be set active or not."""
+ isActive: Boolean
+
+ """
+ Use to create a hash signature with each payload.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS.
+ """
+ secretKey: String
+
+ """
+ Subscription query used to define a webhook payload.
+
+ Added in Saleor 3.2.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ query: String
+}
+
+"""
+Retries event delivery.
+
+Requires one of the following permissions: MANAGE_APPS.
+"""
+type EventDeliveryRetry {
+ """Event delivery."""
+ delivery: EventDelivery
+ errors: [WebhookError!]!
+}
+
+"""
+Creates new warehouse.
+
+Requires one of the following permissions: MANAGE_PRODUCTS.
+"""
+type WarehouseCreate {
+ warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
+ errors: [WarehouseError!]!
+ warehouse: Warehouse
+}
+
+type WarehouseError {
+ """
+ Name of a field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.
+ """
+ field: String
+
+ """The error message."""
+ message: String
+
+ """The error code."""
+ code: WarehouseErrorCode!
+
+ """List of shipping zones IDs which causes the error."""
+ shippingZones: [ID!]
+}
+
+"""An enumeration."""
+enum WarehouseErrorCode {
+ ALREADY_EXISTS
+ GRAPHQL_ERROR
+ INVALID
+ NOT_FOUND
+ REQUIRED
+ UNIQUE
+}
+
+input WarehouseCreateInput {
+ """Warehouse slug."""
+ slug: String
+
+ """The email address of the warehouse."""
+ email: String
+
+ """Warehouse name."""
+ name: String!
+
+ """Address of the warehouse."""
+ address: AddressInput!
+
+ """
+ Shipping zones supported by the warehouse.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Providing the zone ids will raise a ValidationError.
+ """
+ shippingZones: [ID!]
+}
+
+"""
+Updates given warehouse.
+
+Requires one of the following permissions: MANAGE_PRODUCTS.
+"""
+type WarehouseUpdate {
+ warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
+ errors: [WarehouseError!]!
+ warehouse: Warehouse
+}
+
+input WarehouseUpdateInput {
+ """Warehouse slug."""
+ slug: String
+
+ """The email address of the warehouse."""
+ email: String
+
+ """Warehouse name."""
+ name: String
+
+ """Address of the warehouse."""
+ address: AddressInput
+
+ """
+ Click and collect options: local, all or disabled.
+
+ Added in Saleor 3.1.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ clickAndCollectOption: WarehouseClickAndCollectOptionEnum
+
+ """
+ Visibility of warehouse stocks.
+
+ Added in Saleor 3.1.
+
+ Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ """
+ isPrivate: Boolean
+}
+
+"""
+Deletes selected warehouse.
+
+Requires one of the following permissions: MANAGE_PRODUCTS.
+"""
+type WarehouseDelete {
+ warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
+ errors: [WarehouseError!]!
+ warehouse: Warehouse
+}
+
+"""
+Add shipping zone to given warehouse.
+
+Requires one of the following permissions: MANAGE_PRODUCTS.
+"""
+type WarehouseShippingZoneAssign {
+ warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
+ errors: [WarehouseError!]!
+ warehouse: Warehouse
+}
+
+"""
+Remove shipping zone from given warehouse.
+
+Requires one of the following permissions: MANAGE_PRODUCTS.
+"""
+type WarehouseShippingZoneUnassign {
+ warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
+ errors: [WarehouseError!]!
+ warehouse: Warehouse
+}
+
+"""
+Create a tax class.
+
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+Requires one of the following permissions: MANAGE_TAXES.
+"""
+type TaxClassCreate {
+ errors: [TaxClassCreateError!]!
+ taxClass: TaxClass
+}
+
+type TaxClassCreateError {
+ """
+ Name of a field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.
+ """
+ field: String
+
+ """The error message."""
+ message: String
+
+ """The error code."""
+ code: TaxClassCreateErrorCode!
+
+ """List of country codes for which the configuration is invalid."""
+ countryCodes: [String!]!
+}
+
+"""An enumeration."""
+enum TaxClassCreateErrorCode {
+ GRAPHQL_ERROR
+ INVALID
+ NOT_FOUND
+}
+
+input TaxClassCreateInput {
+ """Name of the tax class."""
+ name: String!
+
+ """List of country-specific tax rates to create for this tax class."""
+ createCountryRates: [CountryRateInput!]
+}
+
+input CountryRateInput {
+ """Country in which this rate applies."""
+ countryCode: CountryCode!
+
+ """
+ Tax rate value provided as percentage. Example: provide `23` to represent `23%` tax rate.
+ """
+ rate: Float!
+}
+
+"""
+Delete a tax class. After deleting the tax class any products, product types or shipping methods using it are updated to use the default tax class.
+
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+Requires one of the following permissions: MANAGE_TAXES.
+"""
+type TaxClassDelete {
+ errors: [TaxClassDeleteError!]!
+ taxClass: TaxClass
+}
+
+type TaxClassDeleteError {
+ """
+ Name of a field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.
+ """
+ field: String
+
+ """The error message."""
+ message: String
+
+ """The error code."""
+ code: TaxClassDeleteErrorCode!
+}
+
+"""An enumeration."""
+enum TaxClassDeleteErrorCode {
+ GRAPHQL_ERROR
+ INVALID
+ NOT_FOUND
+}
+
+"""
+Update a tax class.
-Requires one of the following permissions: MANAGE_APPS.
-"""
-type WebhookUpdate {
- webhookErrors: [WebhookError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
- errors: [WebhookError!]!
- webhook: Webhook
-}
+Added in Saleor 3.9.
-input WebhookUpdateInput {
- """The new name of the webhook."""
- name: String
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
- """The url to receive the payload."""
- targetUrl: String
+Requires one of the following permissions: MANAGE_TAXES.
+"""
+type TaxClassUpdate {
+ errors: [TaxClassUpdateError!]!
+ taxClass: TaxClass
+}
+type TaxClassUpdateError {
"""
- The events that webhook wants to subscribe.
-
- DEPRECATED: this field will be removed in Saleor 4.0. Use `asyncEvents` or `syncEvents` instead.
+ Name of a field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.
"""
- events: [WebhookEventTypeEnum!]
+ field: String
- """The asynchronous events that webhook wants to subscribe."""
- asyncEvents: [WebhookEventTypeAsyncEnum!]
+ """The error message."""
+ message: String
- """The synchronous events that webhook wants to subscribe."""
- syncEvents: [WebhookEventTypeSyncEnum!]
+ """The error code."""
+ code: TaxClassUpdateErrorCode!
- """ID of the app to which webhook belongs."""
- app: ID
+ """List of country codes for which the configuration is invalid."""
+ countryCodes: [String!]!
+}
- """Determine if webhook will be set active or not."""
- isActive: Boolean
+"""An enumeration."""
+enum TaxClassUpdateErrorCode {
+ DUPLICATED_INPUT_ITEM
+ GRAPHQL_ERROR
+ INVALID
+ NOT_FOUND
+}
+
+input TaxClassUpdateInput {
+ """Name of the tax class."""
+ name: String
"""
- Use to create a hash signature with each payload.
-
- DEPRECATED: this field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS.
+ List of country-specific tax rates to create or update for this tax class.
"""
- secretKey: String
+ updateCountryRates: [CountryRateUpdateInput!]
"""
- Subscription query used to define a webhook payload.
-
- Added in Saleor 3.2.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ List of country codes for which to remove the tax class rates. Note: It removes all rates for given country code.
"""
- query: String
+ removeCountryRates: [CountryCode!]
}
-"""
-Retries event delivery.
+input CountryRateUpdateInput {
+ """Country in which this rate applies."""
+ countryCode: CountryCode!
-Requires one of the following permissions: MANAGE_APPS.
-"""
-type EventDeliveryRetry {
- """Event delivery."""
- delivery: EventDelivery
- errors: [WebhookError!]!
+ """
+ Tax rate value provided as percentage. Example: provide `23` to represent `23%` tax rate. Provide `null` to remove the particular rate.
+ """
+ rate: Float
}
"""
-Creates new warehouse.
+Update tax configuration for a channel.
-Requires one of the following permissions: MANAGE_PRODUCTS.
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+Requires one of the following permissions: MANAGE_TAXES.
"""
-type WarehouseCreate {
- warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
- errors: [WarehouseError!]!
- warehouse: Warehouse
+type TaxConfigurationUpdate {
+ errors: [TaxConfigurationUpdateError!]!
+ taxConfiguration: TaxConfiguration
}
-type WarehouseError {
+type TaxConfigurationUpdateError {
"""
Name of a field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.
"""
@@ -15019,117 +15889,145 @@ type WarehouseError {
message: String
"""The error code."""
- code: WarehouseErrorCode!
+ code: TaxConfigurationUpdateErrorCode!
- """List of shipping zones IDs which causes the error."""
- shippingZones: [ID!]
+ """List of country codes for which the configuration is invalid."""
+ countryCodes: [String!]!
}
"""An enumeration."""
-enum WarehouseErrorCode {
- ALREADY_EXISTS
+enum TaxConfigurationUpdateErrorCode {
+ DUPLICATED_INPUT_ITEM
GRAPHQL_ERROR
INVALID
NOT_FOUND
- REQUIRED
- UNIQUE
}
-input WarehouseCreateInput {
- """Warehouse slug."""
- slug: String
+input TaxConfigurationUpdateInput {
+ """Determines whether taxes are charged in the given channel."""
+ chargeTaxes: Boolean
- """The email address of the warehouse."""
- email: String
+ """
+ The default strategy to use for tax calculation in the given channel. Taxes can be calculated either using user-defined flat rates or with a tax app. Empty value means that no method is selected and taxes are not calculated.
+ """
+ taxCalculationStrategy: TaxCalculationStrategy
- """Warehouse name."""
- name: String!
+ """
+ Determines whether prices displayed in a storefront should include taxes.
+ """
+ displayGrossPrices: Boolean
- """Address of the warehouse."""
- address: AddressInput!
+ """Determines whether prices are entered with the tax included."""
+ pricesEnteredWithTax: Boolean
"""
- Shipping zones supported by the warehouse.
-
- DEPRECATED: this field will be removed in Saleor 4.0. Providing the zone ids will raise a ValidationError.
+ List of tax country configurations to create or update (identified by a country code).
"""
- shippingZones: [ID!]
-}
-
-"""
-Updates given warehouse.
+ updateCountriesConfiguration: [TaxConfigurationPerCountryInput!]
-Requires one of the following permissions: MANAGE_PRODUCTS.
-"""
-type WarehouseUpdate {
- warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
- errors: [WarehouseError!]!
- warehouse: Warehouse
+ """List of country codes for which to remove the tax configuration."""
+ removeCountriesConfiguration: [CountryCode!]
}
-input WarehouseUpdateInput {
- """Warehouse slug."""
- slug: String
-
- """The email address of the warehouse."""
- email: String
-
- """Warehouse name."""
- name: String
+input TaxConfigurationPerCountryInput {
+ """Country in which this configuration applies."""
+ countryCode: CountryCode!
- """Address of the warehouse."""
- address: AddressInput
+ """Determines whether taxes are charged in this country."""
+ chargeTaxes: Boolean!
"""
- Click and collect options: local, all or disabled.
-
- Added in Saleor 3.1.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ A country-specific strategy to use for tax calculation. Taxes can be calculated either using user-defined flat rates or with a tax app. If not provided, use the value from the channel's tax configuration.
"""
- clickAndCollectOption: WarehouseClickAndCollectOptionEnum
+ taxCalculationStrategy: TaxCalculationStrategy
"""
- Visibility of warehouse stocks.
-
- Added in Saleor 3.1.
-
- Note: this API is currently in Feature Preview and can be subject to changes at later point.
+ Determines whether prices displayed in a storefront should include taxes for this country.
"""
- isPrivate: Boolean
+ displayGrossPrices: Boolean!
}
"""
-Deletes selected warehouse.
+Update tax class rates for a specific country.
-Requires one of the following permissions: MANAGE_PRODUCTS.
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+Requires one of the following permissions: MANAGE_TAXES.
"""
-type WarehouseDelete {
- warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
- errors: [WarehouseError!]!
- warehouse: Warehouse
+type TaxCountryConfigurationUpdate {
+ """Updated tax class rates grouped by a country."""
+ taxCountryConfiguration: TaxCountryConfiguration
+ errors: [TaxCountryConfigurationUpdateError!]!
}
-"""
-Add shipping zone to given warehouse.
+type TaxCountryConfigurationUpdateError {
+ """
+ Name of a field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.
+ """
+ field: String
-Requires one of the following permissions: MANAGE_PRODUCTS.
-"""
-type WarehouseShippingZoneAssign {
- warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
- errors: [WarehouseError!]!
- warehouse: Warehouse
+ """The error message."""
+ message: String
+
+ """The error code."""
+ code: TaxCountryConfigurationUpdateErrorCode!
+
+ """List of tax class IDs for which the update failed."""
+ taxClassIds: [String!]!
+}
+
+"""An enumeration."""
+enum TaxCountryConfigurationUpdateErrorCode {
+ GRAPHQL_ERROR
+ INVALID
+ NOT_FOUND
+ ONLY_ONE_DEFAULT_COUNTRY_RATE_ALLOWED
+ CANNOT_CREATE_NEGATIVE_RATE
+}
+
+input TaxClassRateInput {
+ """ID of a tax class for which to update the tax rate"""
+ taxClassId: ID
+
+ """Tax rate value."""
+ rate: Float
}
"""
-Remove shipping zone from given warehouse.
+Remove all tax class rates for a specific country.
-Requires one of the following permissions: MANAGE_PRODUCTS.
+Added in Saleor 3.9.
+
+Note: this API is currently in Feature Preview and can be subject to changes at later point.
+
+Requires one of the following permissions: MANAGE_TAXES.
"""
-type WarehouseShippingZoneUnassign {
- warehouseErrors: [WarehouseError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
- errors: [WarehouseError!]!
- warehouse: Warehouse
+type TaxCountryConfigurationDelete {
+ """Updated tax class rates grouped by a country."""
+ taxCountryConfiguration: TaxCountryConfiguration
+ errors: [TaxCountryConfigurationDeleteError!]!
+}
+
+type TaxCountryConfigurationDeleteError {
+ """
+ Name of a field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.
+ """
+ field: String
+
+ """The error message."""
+ message: String
+
+ """The error code."""
+ code: TaxCountryConfigurationDeleteErrorCode!
+}
+
+"""An enumeration."""
+enum TaxCountryConfigurationDeleteErrorCode {
+ GRAPHQL_ERROR
+ INVALID
+ NOT_FOUND
}
"""
@@ -15276,15 +16174,6 @@ input ShopSettingsInput {
"""SEO description."""
description: String
- """Include taxes in prices."""
- includeTaxesInPrices: Boolean
-
- """Display prices with tax in store."""
- displayGrossPrices: Boolean
-
- """Charge taxes on shipping."""
- chargeTaxesOnShipping: Boolean
-
"""Enable inventory tracking."""
trackInventoryByDefault: Boolean
@@ -15345,6 +16234,27 @@ input ShopSettingsInput {
Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
limitQuantityPerCheckout: Int
+
+ """
+ Include taxes in prices.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use `taxConfigurationUpdate` mutation to configure this setting per channel or country.
+ """
+ includeTaxesInPrices: Boolean
+
+ """
+ Display prices with tax in store.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use `taxConfigurationUpdate` mutation to configure this setting per channel or country.
+ """
+ displayGrossPrices: Boolean
+
+ """
+ Charge taxes on shipping.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. To enable taxes for a shipping method, assign a tax class to the shipping method with `shippingPriceCreate` or `shippingPriceUpdate` mutations.
+ """
+ chargeTaxesOnShipping: Boolean
}
"""
@@ -15609,6 +16519,11 @@ input ShippingPriceInput {
"""Inclusion type for currently assigned postal code rules."""
inclusionType: PostalCodeRuleInclusionTypeEnum
+
+ """
+ ID of a tax class to assign to this shipping method. If not provided, the default tax class will be used.
+ """
+ taxClass: ID
}
scalar WeightScalar
@@ -16357,7 +17272,11 @@ input ProductCreateInput {
"""ID of the product's category."""
category: ID
- """Determine if taxes are being charged for the product."""
+ """
+ Determine if taxes are being charged for the product.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use `Channel.taxConfiguration` to configure whether tax collection is enabled.
+ """
chargeTaxes: Boolean
"""List of IDs of collections that the product belongs to."""
@@ -16376,7 +17295,16 @@ input ProductCreateInput {
"""Product slug."""
slug: String
- """Tax rate for enabled tax gateway."""
+ """
+ ID of a tax class to assign to this product. If not provided, product will use the tax class which is assigned to the product type.
+ """
+ taxClass: ID
+
+ """
+ Tax rate for enabled tax gateway.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use tax classes to control the tax calculation for a product.
+ """
taxCode: String
"""Search engine optimization fields."""
@@ -16481,7 +17409,11 @@ input ProductInput {
"""ID of the product's category."""
category: ID
- """Determine if taxes are being charged for the product."""
+ """
+ Determine if taxes are being charged for the product.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use `Channel.taxConfiguration` to configure whether tax collection is enabled.
+ """
chargeTaxes: Boolean
"""List of IDs of collections that the product belongs to."""
@@ -16500,7 +17432,16 @@ input ProductInput {
"""Product slug."""
slug: String
- """Tax rate for enabled tax gateway."""
+ """
+ ID of a tax class to assign to this product. If not provided, product will use the tax class which is assigned to the product type.
+ """
+ taxClass: ID
+
+ """
+ Tax rate for enabled tax gateway.
+
+ DEPRECATED: this field will be removed in Saleor 4.0. Use tax classes to control the tax calculation for a product.
+ """
taxCode: String
"""Search engine optimization fields."""
@@ -16776,8 +17717,17 @@ input ProductTypeInput {
"""Weight of the ProductType items."""
weight: WeightScalar
- """Tax rate for enabled tax gateway."""
+ """
+ Tax rate for enabled tax gateway.
+
+ DEPRECATED: this field will be removed in Saleor 4.0.. Use tax classes to control the tax calculation for a product type.
+ """
taxCode: String
+
+ """
+ ID of a tax class to assign to this product type. All products of this product type would use this tax class, unless it's overridden in the `Product` type.
+ """
+ taxClass: ID
}
"""
diff --git a/saleor/graphql/shipping/mutations/shippings.py b/saleor/graphql/shipping/mutations/shippings.py
index 60b8156fd7..72eb505d0f 100644
--- a/saleor/graphql/shipping/mutations/shippings.py
+++ b/saleor/graphql/shipping/mutations/shippings.py
@@ -69,6 +69,13 @@ class ShippingPriceInput(graphene.InputObjectType):
inclusion_type = PostalCodeRuleInclusionTypeEnum(
description="Inclusion type for currently assigned postal code rules.",
)
+ tax_class = graphene.ID(
+ description=(
+ "ID of a tax class to assign to this shipping method. If not provided, "
+ "the default tax class will be used."
+ ),
+ required=False,
+ )
class ShippingZoneCreateInput(graphene.InputObjectType):
@@ -480,7 +487,6 @@ class ShippingPriceMixin:
)
}
)
-
return cleaned_input
@classmethod
diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_price_create.py b/saleor/graphql/shipping/tests/mutations/test_shipping_price_create.py
index a7ddb4b7db..c795f6cd98 100644
--- a/saleor/graphql/shipping/tests/mutations/test_shipping_price_create.py
+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_price_create.py
@@ -27,45 +27,51 @@ PRICE_BASED_SHIPPING_MUTATION = """
$addPostalCodeRules: [ShippingPostalCodeRulesCreateInputRange!]
$deletePostalCodeRules: [ID!]
$inclusionType: PostalCodeRuleInclusionTypeEnum
+ $taxClass: ID
) {
- shippingPriceCreate(
- input: {
- name: $name, shippingZone: $shippingZone, type: $type,
- maximumDeliveryDays: $maximumDeliveryDays,
- minimumDeliveryDays: $minimumDeliveryDays,
- addPostalCodeRules: $addPostalCodeRules,
- deletePostalCodeRules: $deletePostalCodeRules,
- inclusionType: $inclusionType, description: $description
- }) {
- errors {
- field
- code
- }
- shippingZone {
- id
- }
- shippingMethod {
- id
- name
- description
- channelListings {
- price {
- amount
- }
- minimumOrderPrice {
- amount
- }
- maximumOrderPrice {
- amount
- }
+ shippingPriceCreate(
+ input: {
+ name: $name, shippingZone: $shippingZone, type: $type,
+ maximumDeliveryDays: $maximumDeliveryDays,
+ minimumDeliveryDays: $minimumDeliveryDays,
+ addPostalCodeRules: $addPostalCodeRules,
+ deletePostalCodeRules: $deletePostalCodeRules,
+ inclusionType: $inclusionType,
+ description: $description,
+ taxClass: $taxClass
+ }) {
+ errors {
+ field
+ code
}
- type
- minimumDeliveryDays
- maximumDeliveryDays
- postalCodeRules {
- start
- end
+ shippingZone {
+ id
}
+ shippingMethod {
+ id
+ name
+ description
+ channelListings {
+ price {
+ amount
+ }
+ minimumOrderPrice {
+ amount
+ }
+ maximumOrderPrice {
+ amount
+ }
+ }
+ taxClass {
+ id
+ }
+ type
+ minimumDeliveryDays
+ maximumDeliveryDays
+ postalCodeRules {
+ start
+ end
+ }
}
}
}
@@ -84,12 +90,14 @@ def test_create_shipping_method(
shipping_zone,
postal_code_rules,
permission_manage_shipping,
+ tax_classes,
):
name = "DHL"
shipping_zone_id = graphene.Node.to_global_id("ShippingZone", shipping_zone.pk)
max_del_days = 10
min_del_days = 3
description = dummy_editorjs("description", True)
+ tax_class_id = graphene.Node.to_global_id("TaxClass", tax_classes[0].pk)
variables = {
"shippingZone": shipping_zone_id,
"name": name,
@@ -100,6 +108,7 @@ def test_create_shipping_method(
"addPostalCodeRules": postal_code_rules,
"deletePostalCodeRules": [],
"inclusionType": PostalCodeRuleInclusionTypeEnum.EXCLUDE.name,
+ "taxClass": tax_class_id,
}
response = staff_api_client.post_graphql(
PRICE_BASED_SHIPPING_MUTATION,
@@ -117,6 +126,7 @@ def test_create_shipping_method(
assert data["shippingMethod"]["minimumDeliveryDays"] == min_del_days
assert data["shippingMethod"]["maximumDeliveryDays"] == max_del_days
assert data["shippingMethod"]["postalCodeRules"] == postal_code_rules
+ assert data["shippingMethod"]["taxClass"]["id"] == tax_class_id
@freeze_time("2022-05-12 12:00:00")
diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_price_update.py b/saleor/graphql/shipping/tests/mutations/test_shipping_price_update.py
index f38cd87fb7..e1ff30e3b2 100644
--- a/saleor/graphql/shipping/tests/mutations/test_shipping_price_update.py
+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_price_update.py
@@ -28,6 +28,7 @@ UPDATE_SHIPPING_PRICE_MUTATION = """
$addPostalCodeRules: [ShippingPostalCodeRulesCreateInputRange!],
$deletePostalCodeRules: [ID!],
$inclusionType: PostalCodeRuleInclusionTypeEnum,
+ $taxClass: ID
) {
shippingPriceUpdate(
id: $id, input: {
@@ -41,6 +42,7 @@ UPDATE_SHIPPING_PRICE_MUTATION = """
addPostalCodeRules: $addPostalCodeRules,
deletePostalCodeRules: $deletePostalCodeRules,
inclusionType: $inclusionType,
+ taxClass: $taxClass
}) {
errors {
field
@@ -58,6 +60,9 @@ UPDATE_SHIPPING_PRICE_MUTATION = """
start
end
}
+ taxClass {
+ id
+ }
}
}
}
@@ -65,7 +70,7 @@ UPDATE_SHIPPING_PRICE_MUTATION = """
def test_update_shipping_method(
- staff_api_client, shipping_zone, permission_manage_shipping
+ staff_api_client, shipping_zone, permission_manage_shipping, tax_classes
):
query = UPDATE_SHIPPING_PRICE_MUTATION
shipping_method = shipping_zone.shipping_methods.first()
@@ -76,6 +81,7 @@ def test_update_shipping_method(
max_del_days = 8
min_del_days = 2
description = dummy_editorjs("description", True)
+ tax_class_id = graphene.Node.to_global_id("TaxClass", tax_classes[0].pk)
variables = {
"shippingZone": shipping_zone_id,
"id": shipping_method_id,
@@ -83,6 +89,7 @@ def test_update_shipping_method(
"type": ShippingMethodTypeEnum.PRICE.name,
"maximumDeliveryDays": max_del_days,
"minimumDeliveryDays": min_del_days,
+ "taxClass": tax_class_id,
}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_shipping]
@@ -93,6 +100,7 @@ def test_update_shipping_method(
assert data["shippingMethod"]["description"] == description
assert data["shippingMethod"]["minimumDeliveryDays"] == min_del_days
assert data["shippingMethod"]["maximumDeliveryDays"] == max_del_days
+ assert data["shippingMethod"]["taxClass"]["id"] == tax_class_id
@freeze_time("2022-05-12 12:00:00")
diff --git a/saleor/graphql/shipping/types.py b/saleor/graphql/shipping/types.py
index 8468479812..a164248bea 100644
--- a/saleor/graphql/shipping/types.py
+++ b/saleor/graphql/shipping/types.py
@@ -1,7 +1,7 @@
import graphene
from graphene import relay
-from ...core.permissions import ShippingPermissions
+from ...core.permissions import CheckoutPermissions, ShippingPermissions
from ...core.tracing import traced_resolver
from ...core.weight import convert_weight_to_default_weight_unit
from ...product import models as product_models
@@ -35,6 +35,8 @@ from ..core.types import (
)
from ..meta.types import ObjectWithMetadata
from ..shipping.resolvers import resolve_price_range, resolve_shipping_translation
+from ..tax.dataloaders import TaxClassByIdLoader
+from ..tax.types import TaxClass
from ..translations.fields import TranslationField
from ..translations.types import ShippingMethodTranslation
from ..warehouse.types import Warehouse
@@ -138,6 +140,15 @@ class ShippingMethodType(ChannelContextTypeWithMetadataForObjectType):
minimum_delivery_days = graphene.Int(
description="Minimal number of days for delivery."
)
+ tax_class = PermissionsField(
+ TaxClass,
+ description="Tax class assigned to this shipping method.",
+ required=False,
+ permissions=[
+ CheckoutPermissions.MANAGE_TAXES,
+ ShippingPermissions.MANAGE_SHIPPING,
+ ],
+ )
class Meta:
default_resolver = ChannelContextType.resolver_with_context
@@ -223,6 +234,14 @@ class ShippingMethodType(ChannelContextTypeWithMetadataForObjectType):
return create_connection_slice(qs, info, kwargs, ProductCountableConnection)
+ @staticmethod
+ def resolve_tax_class(root: ChannelContext[models.ShippingMethod], info):
+ return (
+ TaxClassByIdLoader(info.context).load(root.node.tax_class_id)
+ if root.node.tax_class_id
+ else None
+ )
+
class ShippingZone(ChannelContextTypeWithMetadata, ModelObjectType):
id = graphene.GlobalID(required=True)
diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.py
index 10212b2a79..d5c5a646fb 100644
--- a/saleor/graphql/shop/mutations.py
+++ b/saleor/graphql/shop/mutations.py
@@ -10,7 +10,7 @@ from ...site.error_codes import GiftCardSettingsErrorCode
from ...site.models import DEFAULT_LIMIT_QUANTITY_PER_CHECKOUT
from ..account.i18n import I18nMixin
from ..account.types import AddressInput, StaffNotificationRecipient
-from ..core.descriptions import ADDED_IN_31, PREVIEW_FEATURE
+from ..core.descriptions import ADDED_IN_31, DEPRECATED_IN_3X_INPUT, PREVIEW_FEATURE
from ..core.enums import WeightUnitsEnum
from ..core.mutations import BaseMutation, ModelDeleteMutation, ModelMutation
from ..core.types import (
@@ -19,7 +19,6 @@ from ..core.types import (
ShopError,
TimePeriodInputType,
)
-from ..plugins.dataloaders import load_plugin_manager
from ..site.dataloaders import get_site_promise
from .enums import GiftCardSettingsExpiryTypeEnum
from .types import GiftCardSettings, OrderSettings, Shop
@@ -28,11 +27,6 @@ from .types import GiftCardSettings, OrderSettings, Shop
class ShopSettingsInput(graphene.InputObjectType):
header_text = graphene.String(description="Header text.")
description = graphene.String(description="SEO description.")
- include_taxes_in_prices = graphene.Boolean(description="Include taxes in prices.")
- display_gross_prices = graphene.Boolean(
- description="Display prices with tax in store."
- )
- charge_taxes_on_shipping = graphene.Boolean(description="Charge taxes on shipping.")
track_inventory_by_default = graphene.Boolean(
description="Enable inventory tracking."
)
@@ -85,6 +79,29 @@ class ShopSettingsInput(graphene.InputObjectType):
)
)
+ # deprecated
+ include_taxes_in_prices = graphene.Boolean(
+ description=(
+ f"Include taxes in prices. {DEPRECATED_IN_3X_INPUT} Use "
+ "`taxConfigurationUpdate` mutation to configure this setting per channel "
+ "or country."
+ )
+ )
+ display_gross_prices = graphene.Boolean(
+ description=(
+ f"Display prices with tax in store. {DEPRECATED_IN_3X_INPUT} Use "
+ "`taxConfigurationUpdate` mutation to configure this setting per channel "
+ "or country."
+ )
+ )
+ charge_taxes_on_shipping = graphene.Boolean(
+ description=(
+ f"Charge taxes on shipping. {DEPRECATED_IN_3X_INPUT} To enable taxes for "
+ "a shipping method, assign a tax class to the shipping method with "
+ "`shippingPriceCreate` or `shippingPriceUpdate` mutations."
+ ),
+ )
+
class SiteDomainInput(graphene.InputObjectType):
domain = graphene.String(description="Domain name for shop.")
@@ -234,13 +251,7 @@ class ShopFetchTaxRates(BaseMutation):
@classmethod
def perform_mutation(cls, _root, info):
- manager = load_plugin_manager(info.context)
- if not manager.fetch_taxes_data():
- raise ValidationError(
- "Could not fetch tax rates. Make sure you have supplied a "
- "valid credential for your tax plugin.",
- code=ShopErrorCode.CANNOT_FETCH_TAX_RATES.value,
- )
+ # This mutation is deprecated and will be removed in Saleor 4.0.
return ShopFetchTaxRates(shop=Shop())
diff --git a/saleor/graphql/shop/schema.py b/saleor/graphql/shop/schema.py
index 66ac27b9c1..84911e8038 100644
--- a/saleor/graphql/shop/schema.py
+++ b/saleor/graphql/shop/schema.py
@@ -1,6 +1,7 @@
import graphene
from ...core.permissions import GiftcardPermissions, OrderPermissions
+from ..core.descriptions import DEPRECATED_IN_3X_MUTATION
from ..core.fields import PermissionsField
from ..site.dataloaders import load_site_callback
from ..translations.mutations import ShopSettingsTranslate
@@ -55,7 +56,9 @@ class ShopMutations(graphene.ObjectType):
shop_domain_update = ShopDomainUpdate.Field()
shop_settings_update = ShopSettingsUpdate.Field()
- shop_fetch_tax_rates = ShopFetchTaxRates.Field()
+ shop_fetch_tax_rates = ShopFetchTaxRates.Field(
+ deprecation_reason=DEPRECATED_IN_3X_MUTATION
+ )
shop_settings_translate = ShopSettingsTranslate.Field()
shop_address_update = ShopAddressUpdate.Field()
diff --git a/saleor/graphql/shop/tests/test_shop.py b/saleor/graphql/shop/tests/test_shop.py
index 13a88caee0..5efcad2ea7 100644
--- a/saleor/graphql/shop/tests/test_shop.py
+++ b/saleor/graphql/shop/tests/test_shop.py
@@ -903,58 +903,6 @@ def test_query_available_shipping_methods_for_given_address(
) not in {ship_meth["id"] for ship_meth in data}
-def test_query_available_shipping_methods_no_address_vatlayer_set(
- staff_api_client,
- shipping_method,
- shipping_method_channel_PLN,
- channel_USD,
- setup_vatlayer,
-):
- # given
- query = AVAILABLE_SHIPPING_METHODS_QUERY
-
- # when
- response = staff_api_client.post_graphql(query, {"channel": channel_USD.slug})
-
- # then
- content = get_graphql_content(response)
- data = content["data"]["shop"]["availableShippingMethods"]
- assert {ship_meth["id"] for ship_meth in data} == {
- graphene.Node.to_global_id("ShippingMethod", ship_meth.pk)
- for ship_meth in ShippingMethod.objects.filter(
- channel_listings__channel__slug=channel_USD.slug
- )
- }
-
-
-def test_query_available_shipping_methods_for_given_address_vatlayer_set(
- staff_api_client,
- channel_USD,
- shipping_method,
- shipping_zone_without_countries,
- address,
- setup_vatlayer,
-):
- # given
- query = AVAILABLE_SHIPPING_METHODS_QUERY
- shipping_method_count = ShippingMethod.objects.count()
- variables = {
- "channel": channel_USD.slug,
- "address": {"country": CountryCodeEnum.US.name},
- }
-
- # when
- response = staff_api_client.post_graphql(query, variables)
-
- # then
- content = get_graphql_content(response)
- data = content["data"]["shop"]["availableShippingMethods"]
- assert len(data) == shipping_method_count - 1
- assert graphene.Node.to_global_id(
- "ShippingMethodType", shipping_zone_without_countries.pk
- ) not in {ship_meth["id"] for ship_meth in data}
-
-
def test_query_available_shipping_methods_for_excluded_postal_code(
staff_api_client, channel_USD, shipping_method
):
diff --git a/saleor/graphql/shop/tests/test_shop_taxes.py b/saleor/graphql/shop/tests/test_shop_taxes.py
index d17d4752f3..0aee5dbe4e 100644
--- a/saleor/graphql/shop/tests/test_shop_taxes.py
+++ b/saleor/graphql/shop/tests/test_shop_taxes.py
@@ -1,5 +1,3 @@
-from unittest.mock import Mock
-
import pytest
from django_prices_vatlayer.models import VAT
from django_prices_vatlayer.utils import get_tax_for_rate
@@ -52,7 +50,7 @@ def taxes(tax_rates):
@pytest.fixture
-def vatlayer(db, tax_rates, taxes, setup_vatlayer):
+def vatlayer(db, tax_rates, taxes):
VAT.objects.create(country_code="PL", data=tax_rates)
tax_rates_2 = {
@@ -129,40 +127,3 @@ def test_query_default_country_with_tax(user_api_client, settings, vatlayer, tax
data = content["data"]["shop"]["defaultCountry"]
assert data["code"] == settings.DEFAULT_COUNTRY
assert data["vat"]["standardRate"] == tax_rates["standard_rate"]
-
-
-MUTATION_SHOP_FETCH_TAX_RATES = """
- mutation FetchTaxRates {
- shopFetchTaxRates {
- errors {
- field
- message
- }
- }
- }
- """
-
-
-def test_shop_fetch_tax_rates_no_api_access_key(
- staff_api_client, permission_manage_settings
-):
- staff_api_client.user.user_permissions.add(permission_manage_settings)
- response = staff_api_client.post_graphql(MUTATION_SHOP_FETCH_TAX_RATES)
- content = get_graphql_content(response)
- data = content["data"]["shopFetchTaxRates"]
- error_message = (
- "Could not fetch tax rates. "
- "Make sure you have supplied a valid credential for your tax plugin."
- )
- assert data["errors"][0]["message"] == error_message
-
-
-def test_shop_fetch_tax_rates(
- monkeypatch, staff_api_client, permission_manage_settings, setup_vatlayer
-):
- mocked_fetch = Mock()
- monkeypatch.setattr("saleor.plugins.vatlayer.plugin.fetch_rates", mocked_fetch)
- staff_api_client.user.user_permissions.add(permission_manage_settings)
- response = staff_api_client.post_graphql(MUTATION_SHOP_FETCH_TAX_RATES)
- get_graphql_content(response)
- mocked_fetch.assert_called_once_with("vatlayer_access_key")
diff --git a/saleor/graphql/shop/types.py b/saleor/graphql/shop/types.py
index 280e7e49f2..bd1988c21f 100644
--- a/saleor/graphql/shop/types.py
+++ b/saleor/graphql/shop/types.py
@@ -15,7 +15,12 @@ from ...core.utils import build_absolute_uri
from ...site import models as site_models
from ..account.types import Address, AddressInput, StaffNotificationRecipient
from ..checkout.types import PaymentGateway
-from ..core.descriptions import ADDED_IN_31, DEPRECATED_IN_3X_INPUT, PREVIEW_FEATURE
+from ..core.descriptions import (
+ ADDED_IN_31,
+ DEPRECATED_IN_3X_FIELD,
+ DEPRECATED_IN_3X_INPUT,
+ PREVIEW_FEATURE,
+)
from ..core.enums import LanguageCodeEnum, WeightUnitsEnum
from ..core.fields import PermissionsField
from ..core.types import (
@@ -206,9 +211,6 @@ class Shop(graphene.ObjectType):
graphene.String, description="List of possible phone prefixes.", required=True
)
header_text = graphene.String(description="Header text.")
- include_taxes_in_prices = graphene.Boolean(
- description="Include taxes in prices.", required=True
- )
fulfillment_auto_approve = graphene.Boolean(
description="Automatically approve all new fulfillments." + ADDED_IN_31,
required=True,
@@ -217,12 +219,6 @@ class Shop(graphene.ObjectType):
description="Allow to approve fulfillments which are unpaid." + ADDED_IN_31,
required=True,
)
- display_gross_prices = graphene.Boolean(
- description="Display prices with tax in store.", required=True
- )
- charge_taxes_on_shipping = graphene.Boolean(
- description="Charge taxes on shipping.", required=True
- )
track_inventory_by_default = graphene.Boolean(
description="Enable inventory tracking."
)
@@ -298,6 +294,34 @@ class Shop(graphene.ObjectType):
],
)
+ # deprecated
+ include_taxes_in_prices = graphene.Boolean(
+ description="Include taxes in prices.",
+ deprecation_reason=(
+ f"{DEPRECATED_IN_3X_FIELD} Use "
+ "`Channel.taxConfiguration.pricesEnteredWithTax` to determine whether "
+ "prices are entered with tax."
+ ),
+ required=True,
+ )
+ display_gross_prices = graphene.Boolean(
+ description="Display prices with tax in store.",
+ deprecation_reason=(
+ f"{DEPRECATED_IN_3X_FIELD} Use `Channel.taxConfiguration` to determine "
+ "whether to display gross or net prices."
+ ),
+ required=True,
+ )
+ charge_taxes_on_shipping = graphene.Boolean(
+ description="Charge taxes on shipping.",
+ deprecation_reason=(
+ f"{DEPRECATED_IN_3X_FIELD} Use `ShippingMethodType.taxClass` to determine "
+ "whether taxes are calculated for shipping methods; if a tax class is set, "
+ "the taxes will be calculated, otherwise no tax rate will be applied."
+ ),
+ required=True,
+ )
+
class Meta:
description = (
"Represents a shop resource containing general shop data and configuration."
@@ -376,11 +400,6 @@ class Shop(graphene.ObjectType):
def resolve_header_text(_, _info, site):
return site.settings.header_text
- @staticmethod
- @load_site_callback
- def resolve_include_taxes_in_prices(_, _info, site):
- return site.settings.include_taxes_in_prices
-
@staticmethod
@load_site_callback
def resolve_fulfillment_auto_approve(_, _info, site):
@@ -391,11 +410,6 @@ class Shop(graphene.ObjectType):
def resolve_fulfillment_allow_unpaid(_, info, site):
return site.settings.fulfillment_allow_unpaid
- @staticmethod
- @load_site_callback
- def resolve_display_gross_prices(_, _info, site):
- return site.settings.display_gross_prices
-
@staticmethod
@load_site_callback
def resolve_charge_taxes_on_shipping(_, _info, site):
@@ -491,3 +505,15 @@ class Shop(graphene.ObjectType):
@staticmethod
def resolve_version(_, _info):
return __version__
+
+ # deprecated
+
+ @staticmethod
+ @load_site_callback
+ def resolve_include_taxes_in_prices(_, _info, site):
+ return site.settings.include_taxes_in_prices
+
+ @staticmethod
+ @load_site_callback
+ def resolve_display_gross_prices(_, _info, site):
+ return site.settings.display_gross_prices
diff --git a/saleor/graphql/tax/dataloaders.py b/saleor/graphql/tax/dataloaders.py
new file mode 100644
index 0000000000..9cd71b823b
--- /dev/null
+++ b/saleor/graphql/tax/dataloaders.py
@@ -0,0 +1,164 @@
+from collections import defaultdict
+from decimal import Decimal
+
+from django.db.models import Exists, OuterRef
+from promise import Promise
+
+from ...tax.models import (
+ TaxClass,
+ TaxClassCountryRate,
+ TaxConfiguration,
+ TaxConfigurationPerCountry,
+)
+from ..core.dataloaders import DataLoader
+from ..product.dataloaders import (
+ ProductByIdLoader,
+ ProductByVariantIdLoader,
+ ProductTypeByProductIdLoader,
+ ProductTypeByVariantIdLoader,
+)
+
+
+class TaxConfigurationPerCountryByTaxConfigurationIDLoader(DataLoader):
+ context_key = "tax_configuration_per_country_by_tax_configuration_id"
+
+ def batch_load(self, keys):
+ tax_configs_per_country = TaxConfigurationPerCountry.objects.using(
+ self.database_connection_name
+ ).filter(tax_configuration_id__in=keys)
+
+ one_to_many = defaultdict(list)
+ for obj in tax_configs_per_country:
+ one_to_many[obj.tax_configuration_id].append(obj)
+
+ return [one_to_many[key] for key in keys]
+
+
+class TaxConfigurationByChannelId(DataLoader):
+ context_key = "tax_configuration_by_channel_id"
+
+ def batch_load(self, keys):
+ tax_configs = TaxConfiguration.objects.using(
+ self.database_connection_name
+ ).in_bulk(keys, field_name="channel_id")
+ return [tax_configs[key] for key in keys]
+
+
+class TaxClassCountryRateByTaxClassIDLoader(DataLoader):
+ context_key = "tax_class_country_rate_by_tax_class_id"
+
+ def batch_load(self, keys):
+ tax_rates = TaxClassCountryRate.objects.using(
+ self.database_connection_name
+ ).filter(tax_class_id__in=keys)
+
+ one_to_many = defaultdict(list)
+ for obj in tax_rates:
+ one_to_many[obj.tax_class_id].append(obj)
+
+ return [one_to_many[key] for key in keys]
+
+
+class TaxClassDefaultRateByCountryLoader(DataLoader):
+ context_key = "tax_class_default_rate_by_country"
+
+ def batch_load(self, keys):
+ tax_rates = TaxClassCountryRate.objects.using(
+ self.database_connection_name
+ ).filter(tax_class=None, country__in=keys)
+ tax_rates_map = {rate.country: rate for rate in tax_rates}
+ return [tax_rates_map.get(key) for key in keys]
+
+
+class TaxClassByIdLoader(DataLoader):
+ context_key = "tax_class_by_id"
+
+ def batch_load(self, keys):
+ tax_class_map = TaxClass.objects.using(self.database_connection_name).in_bulk(
+ keys
+ )
+ return [tax_class_map.get(obj_id) for obj_id in keys]
+
+
+class TaxClassByProductIdLoader(DataLoader):
+ context_key = "tax_class_by_product_id"
+
+ def batch_load(self, keys):
+ products = ProductByIdLoader(self.context).load_many(keys)
+ product_types = ProductTypeByProductIdLoader(self.context).load_many(keys)
+
+ def load_tax_classes(results):
+ (products, product_types) = results
+ products_map = dict(zip(keys, products))
+ product_types_map = dict(zip(keys, product_types))
+
+ tax_class_ids_map = {}
+ for product_id in keys:
+ product = products_map[product_id]
+ product_type = product_types_map[product_id]
+ tax_class_id = product.tax_class_id or product_type.tax_class_id
+ tax_class_ids_map[product_id] = tax_class_id
+
+ return [
+ TaxClassByIdLoader(self.context).load(tax_class_ids_map[product_id])
+ if tax_class_ids_map[product_id]
+ else None
+ for product_id in keys
+ ]
+
+ return Promise.all([products, product_types]).then(load_tax_classes)
+
+
+class TaxClassByVariantIdLoader(DataLoader):
+ context_key = "tax_class_by_variant_id"
+
+ def batch_load(self, keys):
+ products = ProductByVariantIdLoader(self.context).load_many(keys)
+ product_types = ProductTypeByVariantIdLoader(self.context).load_many(keys)
+
+ def load_tax_classes(results):
+ (products, product_types) = results
+ products_map = dict(zip(keys, products))
+ product_types_map = dict(zip(keys, product_types))
+
+ tax_class_ids_map = {}
+ for variant_pk in keys:
+ product = products_map[variant_pk]
+ product_type = product_types_map[variant_pk]
+ tax_class_id = product.tax_class_id or product_type.tax_class_id
+ tax_class_ids_map[variant_pk] = tax_class_id
+
+ return [
+ TaxClassByIdLoader(self.context).load(tax_class_ids_map[variant_id])
+ if tax_class_ids_map[variant_id]
+ else None
+ for variant_id in keys
+ ]
+
+ return Promise.all([products, product_types]).then(load_tax_classes)
+
+
+class ProductChargeTaxesByTaxClassIdLoader(DataLoader):
+ # Deprecated: this dataloader is used only for deprecated `Product.chargeTaxes`
+ # and `ProductType.chargeTaxes` fields and it only reflects flat tax rates, while it
+ # ignores any tax apps. To determine whether to charge taxes, one should look into
+ # TaxConfiguration of a channel.
+
+ context_key = "product_charge_taxes_by_tax_class_id"
+
+ def batch_load(self, keys):
+ non_zero_rates = TaxClassCountryRate.objects.filter(
+ tax_class=OuterRef("pk")
+ ).exclude(rate=Decimal(0))
+ tax_class_map = (
+ TaxClass.objects.using(self.database_connection_name)
+ .filter(pk__in=keys)
+ .annotate(charge_taxes=Exists(non_zero_rates))
+ .in_bulk(keys)
+ )
+ return [
+ tax_class_map[tax_class_id].charge_taxes
+ if tax_class_map.get(tax_class_id)
+ else False
+ for tax_class_id in keys
+ ]
diff --git a/saleor/graphql/tax/enums.py b/saleor/graphql/tax/enums.py
new file mode 100644
index 0000000000..be94540bc3
--- /dev/null
+++ b/saleor/graphql/tax/enums.py
@@ -0,0 +1,17 @@
+from ...tax import TaxCalculationStrategy as InternalTaxCalculationStrategy
+from ..core.enums import to_enum
+
+
+def description(enum):
+ if enum == InternalTaxCalculationStrategy.FLAT_RATES:
+ return "Use flat rates to calculate taxes."
+ if enum == InternalTaxCalculationStrategy.TAX_APP:
+ return "Use tax app or plugin to calculate taxes."
+ return None
+
+
+TaxCalculationStrategy = to_enum(
+ InternalTaxCalculationStrategy,
+ description=description,
+ type_name="TaxCalculationStrategy",
+)
diff --git a/saleor/graphql/tax/filters.py b/saleor/graphql/tax/filters.py
new file mode 100644
index 0000000000..b0b0f1a853
--- /dev/null
+++ b/saleor/graphql/tax/filters.py
@@ -0,0 +1,48 @@
+from django.db.models import Exists, OuterRef
+
+from ...tax import models
+from ..account.enums import CountryCodeEnum
+from ..core.filters import (
+ GlobalIDMultipleChoiceFilter,
+ ListObjectTypeFilter,
+ MetadataFilterBase,
+)
+from ..core.types import FilterInputObjectType
+from ..utils.filters import filter_by_id
+from .types import TaxClass, TaxConfiguration
+
+
+def filter_tax_classes_by_country(qs, _, values):
+ if values:
+ rates = models.TaxClassCountryRate.objects.filter(country__in=values)
+ qs = qs.filter(Exists(rates.filter(tax_class_id=OuterRef("id"))))
+ return qs
+
+
+class TaxConfigurationFilter(MetadataFilterBase):
+ ids = GlobalIDMultipleChoiceFilter(method=filter_by_id(TaxConfiguration))
+
+ class Meta:
+ model = models.TaxConfiguration
+ fields = []
+
+
+class TaxConfigurationFilterInput(FilterInputObjectType):
+ class Meta:
+ filterset_class = TaxConfigurationFilter
+
+
+class TaxClassFilter(MetadataFilterBase):
+ ids = GlobalIDMultipleChoiceFilter(method=filter_by_id(TaxClass))
+ countries = ListObjectTypeFilter(
+ input_class=CountryCodeEnum, method=filter_tax_classes_by_country
+ )
+
+ class Meta:
+ model = models.TaxClass
+ fields = []
+
+
+class TaxClassFilterInput(FilterInputObjectType):
+ class Meta:
+ filterset_class = TaxClassFilter
diff --git a/saleor/graphql/tax/mutations/__init__.py b/saleor/graphql/tax/mutations/__init__.py
index 792f96cce1..211a147cc6 100644
--- a/saleor/graphql/tax/mutations/__init__.py
+++ b/saleor/graphql/tax/mutations/__init__.py
@@ -1,3 +1,17 @@
+from .tax_class_create import TaxClassCreate
+from .tax_class_delete import TaxClassDelete
+from .tax_class_update import TaxClassUpdate
+from .tax_configuration_update import TaxConfigurationUpdate
+from .tax_country_configuration_delete import TaxCountryConfigurationDelete
+from .tax_country_configuration_update import TaxCountryConfigurationUpdate
from .tax_exemption_manage import TaxExemptionManage
-__all__ = ["TaxExemptionManage"]
+__all__ = [
+ "TaxClassCreate",
+ "TaxClassDelete",
+ "TaxClassUpdate",
+ "TaxConfigurationUpdate",
+ "TaxCountryConfigurationDelete",
+ "TaxCountryConfigurationUpdate",
+ "TaxExemptionManage",
+]
diff --git a/saleor/graphql/tax/mutations/tax_class_create.py b/saleor/graphql/tax/mutations/tax_class_create.py
new file mode 100644
index 0000000000..733a73f85a
--- /dev/null
+++ b/saleor/graphql/tax/mutations/tax_class_create.py
@@ -0,0 +1,71 @@
+import graphene
+
+from ....core.permissions import CheckoutPermissions
+from ....tax import error_codes, models
+from ...account.enums import CountryCodeEnum
+from ...core.descriptions import ADDED_IN_39, PREVIEW_FEATURE
+from ...core.mutations import ModelMutation
+from ...core.types import Error, NonNullList
+from ..types import TaxClass
+
+TaxClassCreateErrorCode = graphene.Enum.from_enum(error_codes.TaxClassCreateErrorCode)
+
+
+class TaxClassCreateError(Error):
+ code = TaxClassCreateErrorCode(description="The error code.", required=True)
+ country_codes = NonNullList(
+ graphene.String,
+ description="List of country codes for which the configuration is invalid.",
+ required=True,
+ )
+
+
+class CountryRateInput(graphene.InputObjectType):
+ country_code = CountryCodeEnum(
+ description="Country in which this rate applies.", required=True
+ )
+ rate = graphene.Float(
+ description=(
+ "Tax rate value provided as percentage. Example: provide `23` to "
+ "represent `23%` tax rate."
+ ),
+ required=True,
+ )
+
+
+class TaxClassCreateInput(graphene.InputObjectType):
+ name = graphene.String(description="Name of the tax class.", required=True)
+ create_country_rates = NonNullList(
+ CountryRateInput,
+ description="List of country-specific tax rates to create for this tax class.",
+ )
+
+
+class TaxClassCreate(ModelMutation):
+ class Arguments:
+ input = TaxClassCreateInput(
+ description="Fields required to create a tax class.", required=True
+ )
+
+ class Meta:
+ description = "Create a tax class." + ADDED_IN_39 + PREVIEW_FEATURE
+ error_type_class = TaxClassCreateError
+ model = models.TaxClass
+ object_type = TaxClass
+ permissions = (CheckoutPermissions.MANAGE_TAXES,)
+
+ @classmethod
+ def create_country_rates(cls, instance, country_rates):
+ to_create = [
+ models.TaxClassCountryRate(
+ tax_class=instance, country=item["country_code"], rate=item["rate"]
+ )
+ for item in country_rates
+ ]
+ models.TaxClassCountryRate.objects.bulk_create(to_create)
+
+ @classmethod
+ def save(cls, _info, instance, cleaned_input):
+ instance.save()
+ create_country_rates = cleaned_input.get("create_country_rates", [])
+ cls.create_country_rates(instance, create_country_rates)
diff --git a/saleor/graphql/tax/mutations/tax_class_delete.py b/saleor/graphql/tax/mutations/tax_class_delete.py
new file mode 100644
index 0000000000..8fc0faaed1
--- /dev/null
+++ b/saleor/graphql/tax/mutations/tax_class_delete.py
@@ -0,0 +1,34 @@
+import graphene
+
+from ....core.permissions import CheckoutPermissions
+from ....tax import error_codes, models
+from ...core.descriptions import ADDED_IN_39, PREVIEW_FEATURE
+from ...core.mutations import ModelDeleteMutation
+from ...core.types import Error
+from ..types import TaxClass
+
+TaxClassDeleteErrorCode = graphene.Enum.from_enum(error_codes.TaxClassDeleteErrorCode)
+
+
+class TaxClassDeleteError(Error):
+ code = TaxClassDeleteErrorCode(description="The error code.", required=True)
+
+
+class TaxClassDelete(ModelDeleteMutation):
+ class Arguments:
+ id = graphene.ID(required=True, description="ID of a tax class to delete.")
+
+ class Meta:
+ description = (
+ (
+ "Delete a tax class. After deleting the tax class any products, "
+ "product types or shipping methods using it are updated to use the "
+ "default tax class."
+ )
+ + ADDED_IN_39
+ + PREVIEW_FEATURE
+ )
+ error_type_class = TaxClassDeleteError
+ model = models.TaxClass
+ object_type = TaxClass
+ permissions = (CheckoutPermissions.MANAGE_TAXES,)
diff --git a/saleor/graphql/tax/mutations/tax_class_update.py b/saleor/graphql/tax/mutations/tax_class_update.py
new file mode 100644
index 0000000000..2aece0ef77
--- /dev/null
+++ b/saleor/graphql/tax/mutations/tax_class_update.py
@@ -0,0 +1,135 @@
+import graphene
+from django.core.exceptions import ValidationError
+
+from ....core.permissions import CheckoutPermissions
+from ....tax import error_codes, models
+from ...account.enums import CountryCodeEnum
+from ...core.descriptions import ADDED_IN_39, PREVIEW_FEATURE
+from ...core.mutations import ModelMutation
+from ...core.types import Error, NonNullList
+from ...core.utils import get_duplicates_items
+from ..types import TaxClass
+
+TaxClassUpdateErrorCode = graphene.Enum.from_enum(error_codes.TaxClassUpdateErrorCode)
+
+
+class CountryRateUpdateInput(graphene.InputObjectType):
+ country_code = CountryCodeEnum(
+ description="Country in which this rate applies.", required=True
+ )
+ rate = graphene.Float(
+ description=(
+ "Tax rate value provided as percentage. Example: provide `23` to "
+ "represent `23%` tax rate. Provide `null` to remove the particular rate."
+ ),
+ required=False,
+ )
+
+
+class TaxClassUpdateError(Error):
+ code = TaxClassUpdateErrorCode(description="The error code.", required=True)
+ country_codes = NonNullList(
+ graphene.String,
+ description="List of country codes for which the configuration is invalid.",
+ required=True,
+ )
+
+
+class TaxClassUpdateInput(graphene.InputObjectType):
+ name = graphene.String(description="Name of the tax class.")
+ update_country_rates = NonNullList(
+ CountryRateUpdateInput,
+ description=(
+ "List of country-specific tax rates to create or update for this tax class."
+ ),
+ )
+ remove_country_rates = NonNullList(
+ CountryCodeEnum,
+ description=(
+ "List of country codes for which to remove the tax class rates. Note: It "
+ "removes all rates for given country code."
+ ),
+ )
+
+
+class TaxClassUpdate(ModelMutation):
+ class Arguments:
+ id = graphene.ID(description="ID of the tax class.", required=True)
+ input = TaxClassUpdateInput(
+ description="Fields required to update a tax class.", required=True
+ )
+
+ class Meta:
+ description = "Update a tax class." + ADDED_IN_39 + PREVIEW_FEATURE
+ error_type_class = TaxClassUpdateError
+ model = models.TaxClass
+ object_type = TaxClass
+ permissions = (CheckoutPermissions.MANAGE_TAXES,)
+
+ @classmethod
+ def clean_input(cls, info, instance, data, input_cls=None):
+ update_country_rates = data.get("update_country_rates", [])
+ update_country_codes = [item["country_code"] for item in update_country_rates]
+ remove_country_rates = data.get("remove_country_rates", [])
+
+ if duplicated_country_codes := list(
+ get_duplicates_items(update_country_codes, remove_country_rates)
+ ):
+ message = (
+ "The same country code cannot be in both lists for updating and "
+ "removing items: "
+ ) + ", ".join(duplicated_country_codes)
+ params = {"country_codes": duplicated_country_codes}
+ code = error_codes.TaxClassUpdateErrorCode.DUPLICATED_INPUT_ITEM
+ raise ValidationError(message=message, code=code, params=params)
+
+ return super().clean_input(info, instance, data, input_cls)
+
+ @classmethod
+ def update_country_rates(cls, instance, country_rates):
+ input_data_by_country = {item["country_code"]: item for item in country_rates}
+
+ # Update existing instances.
+ to_update = instance.country_rates.filter(
+ country__in=input_data_by_country.keys()
+ )
+ updated_countries = []
+ for obj in to_update:
+ data = input_data_by_country[obj.country]
+ rate = data.get("rate")
+ if rate:
+ obj.rate = rate
+ updated_countries.append(obj.country.code)
+ models.TaxClassCountryRate.objects.bulk_update(to_update, fields=("rate",))
+
+ # Create new instances.
+ to_create = [
+ models.TaxClassCountryRate(
+ tax_class=instance, country=item["country_code"], rate=item["rate"]
+ )
+ for item in country_rates
+ if item["country_code"] not in updated_countries
+ and item.get("rate") is not None
+ ]
+ models.TaxClassCountryRate.objects.bulk_create(to_create)
+
+ # Delete instances where null rates were provided.
+ to_delete = [
+ item["country_code"] for item in country_rates if item.get("rate") is None
+ ]
+ models.TaxClassCountryRate.objects.filter(
+ country__in=to_delete,
+ tax_class=instance,
+ ).delete()
+
+ @classmethod
+ def remove_country_rates(cls, country_codes):
+ models.TaxClassCountryRate.objects.filter(country__in=country_codes).delete()
+
+ @classmethod
+ def save(cls, _info, instance, cleaned_input):
+ instance.save()
+ update_country_rates = cleaned_input.get("update_country_rates", [])
+ remove_country_rates = cleaned_input.get("remove_country_rates", [])
+ cls.update_country_rates(instance, update_country_rates)
+ cls.remove_country_rates(remove_country_rates)
diff --git a/saleor/graphql/tax/mutations/tax_configuration_update.py b/saleor/graphql/tax/mutations/tax_configuration_update.py
new file mode 100644
index 0000000000..84ac4d0ad2
--- /dev/null
+++ b/saleor/graphql/tax/mutations/tax_configuration_update.py
@@ -0,0 +1,183 @@
+import graphene
+from django.core.exceptions import ValidationError
+
+from ....core.permissions import CheckoutPermissions
+from ....tax import error_codes, models
+from ...account.enums import CountryCodeEnum
+from ...core.descriptions import ADDED_IN_39, PREVIEW_FEATURE
+from ...core.mutations import ModelMutation
+from ...core.types import Error, NonNullList
+from ...core.utils import get_duplicates_items
+from ..enums import TaxCalculationStrategy
+from ..types import TaxConfiguration
+
+TaxConfigurationUpdateErrorCode = graphene.Enum.from_enum(
+ error_codes.TaxConfigurationUpdateErrorCode
+)
+
+
+class TaxConfigurationPerCountryInput(graphene.InputObjectType):
+ country_code = CountryCodeEnum(
+ description="Country in which this configuration applies.", required=True
+ )
+ charge_taxes = graphene.Boolean(
+ description="Determines whether taxes are charged in this country.",
+ required=True,
+ )
+ tax_calculation_strategy = graphene.Field(
+ TaxCalculationStrategy,
+ required=False,
+ description=(
+ "A country-specific strategy to use for tax calculation. Taxes can be "
+ "calculated either using user-defined flat rates or with a tax app. If "
+ "not provided, use the value from the channel's tax configuration."
+ ),
+ )
+ display_gross_prices = graphene.Boolean(
+ description=(
+ "Determines whether prices displayed in a storefront should include taxes "
+ "for this country."
+ ),
+ required=True,
+ )
+
+
+class TaxConfigurationUpdateInput(graphene.InputObjectType):
+ charge_taxes = graphene.Boolean(
+ description="Determines whether taxes are charged in the given channel."
+ )
+ tax_calculation_strategy = graphene.Field(
+ TaxCalculationStrategy,
+ required=False,
+ description=(
+ "The default strategy to use for tax calculation in the given channel. "
+ "Taxes can be calculated either using user-defined flat rates or with "
+ "a tax app. Empty value means that no method is selected and taxes are "
+ "not calculated."
+ ),
+ )
+ display_gross_prices = graphene.Boolean(
+ description=(
+ "Determines whether prices displayed in a storefront should include taxes."
+ )
+ )
+ prices_entered_with_tax = graphene.Boolean(
+ description="Determines whether prices are entered with the tax included."
+ )
+ update_countries_configuration = NonNullList(
+ TaxConfigurationPerCountryInput,
+ description=(
+ "List of tax country configurations to create or update (identified by a "
+ "country code)."
+ ),
+ )
+ remove_countries_configuration = NonNullList(
+ CountryCodeEnum,
+ description="List of country codes for which to remove the tax configuration.",
+ )
+
+
+class TaxConfigurationUpdateError(Error):
+ code = TaxConfigurationUpdateErrorCode(description="The error code.", required=True)
+ country_codes = NonNullList(
+ graphene.String,
+ description="List of country codes for which the configuration is invalid.",
+ required=True,
+ )
+
+
+class TaxConfigurationUpdate(ModelMutation):
+ class Arguments:
+ id = graphene.ID(description="ID of the tax configuration.", required=True)
+ input = TaxConfigurationUpdateInput(
+ description="Fields required to update the tax configuration.",
+ required=True,
+ )
+
+ class Meta:
+ description = (
+ "Update tax configuration for a channel." + ADDED_IN_39 + PREVIEW_FEATURE
+ )
+ error_type_class = TaxConfigurationUpdateError
+ model = models.TaxConfiguration
+ object_type = TaxConfiguration
+ permissions = (CheckoutPermissions.MANAGE_TAXES,)
+
+ @classmethod
+ def clean_input(cls, info, instance, data, input_cls=None):
+ update_countries_configuration = data.get("update_countries_configuration", [])
+ update_country_codes = [
+ item["country_code"] for item in update_countries_configuration
+ ]
+ remove_country_codes = data.get("remove_countries_configuration", [])
+
+ if duplicated_country_codes := list(
+ get_duplicates_items(update_country_codes, remove_country_codes)
+ ):
+ message = (
+ "The same country code cannot be in both lists for updating and "
+ "removing items: "
+ ) + ", ".join(duplicated_country_codes)
+ params = {"country_codes": duplicated_country_codes}
+ code = error_codes.TaxConfigurationUpdateErrorCode.DUPLICATED_INPUT_ITEM
+ raise ValidationError(message=message, code=code, params=params)
+
+ return super().clean_input(info, instance, data, input_cls)
+
+ @classmethod
+ def update_countries_configuration(cls, instance, countries_configuration):
+ input_data_by_country = {
+ item["country_code"]: item for item in countries_configuration
+ }
+
+ # update existing instances
+ to_update = instance.country_exceptions.filter(
+ country__in=input_data_by_country.keys()
+ )
+ updated_countries = []
+ for obj in to_update:
+ data = input_data_by_country[obj.country]
+ obj.charge_taxes = data["charge_taxes"]
+ obj.display_gross_prices = data["display_gross_prices"]
+ obj.tax_calculation_strategy = data.get("tax_calculation_strategy")
+ updated_countries.append(obj.country.code)
+ models.TaxConfigurationPerCountry.objects.bulk_update(
+ to_update,
+ fields=(
+ "charge_taxes",
+ "display_gross_prices",
+ "tax_calculation_strategy",
+ ),
+ )
+
+ # create new instances
+ to_create = [
+ models.TaxConfigurationPerCountry(
+ tax_configuration=instance,
+ country=item["country_code"],
+ charge_taxes=item["charge_taxes"],
+ tax_calculation_strategy=item.get("tax_calculation_strategy"),
+ display_gross_prices=item["display_gross_prices"],
+ )
+ for item in countries_configuration
+ if item["country_code"] not in updated_countries
+ ]
+ models.TaxConfigurationPerCountry.objects.bulk_create(to_create)
+
+ @classmethod
+ def remove_countries_configuration(cls, country_codes):
+ models.TaxConfigurationPerCountry.objects.filter(
+ country__in=country_codes
+ ).delete()
+
+ @classmethod
+ def save(cls, _info, instance, cleaned_input):
+ instance.save()
+ update_countries_configuration = cleaned_input.get(
+ "update_countries_configuration", []
+ )
+ remove_countries_configuration = cleaned_input.get(
+ "remove_countries_configuration", []
+ )
+ cls.update_countries_configuration(instance, update_countries_configuration)
+ cls.remove_countries_configuration(remove_countries_configuration)
diff --git a/saleor/graphql/tax/mutations/tax_country_configuration_delete.py b/saleor/graphql/tax/mutations/tax_country_configuration_delete.py
new file mode 100644
index 0000000000..c803eda996
--- /dev/null
+++ b/saleor/graphql/tax/mutations/tax_country_configuration_delete.py
@@ -0,0 +1,51 @@
+import graphene
+from django_countries.fields import Country
+
+from ....core.permissions import CheckoutPermissions
+from ....tax import error_codes, models
+from ...account.enums import CountryCodeEnum
+from ...core.descriptions import ADDED_IN_39, PREVIEW_FEATURE
+from ...core.mutations import BaseMutation
+from ...core.types import Error
+from ..types import TaxCountryConfiguration
+
+TaxCountryConfigurationDeleteErrorCode = graphene.Enum.from_enum(
+ error_codes.TaxCountryConfigurationDeleteErrorCode
+)
+
+
+class TaxCountryConfigurationDeleteError(Error):
+ code = TaxCountryConfigurationDeleteErrorCode(
+ description="The error code.", required=True
+ )
+
+
+class TaxCountryConfigurationDelete(BaseMutation):
+ tax_country_configuration = graphene.Field(
+ TaxCountryConfiguration,
+ description="Updated tax class rates grouped by a country.",
+ )
+
+ class Arguments:
+ country_code = CountryCodeEnum(
+ description="Country in which to update the tax class rates.", required=True
+ )
+
+ class Meta:
+ description = (
+ "Remove all tax class rates for a specific country."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE
+ )
+ error_type_class = TaxCountryConfigurationDeleteError
+ permissions = (CheckoutPermissions.MANAGE_TAXES,)
+
+ @classmethod
+ def perform_mutation(cls, _root, _info, **data):
+ country_code = data["country_code"]
+ rates = models.TaxClassCountryRate.objects.filter(country=country_code)
+ rates.delete()
+ country_config = TaxCountryConfiguration(
+ country=Country(country_code), tax_class_country_rates=[]
+ )
+ return TaxCountryConfigurationDelete(tax_country_configuration=country_config)
diff --git a/saleor/graphql/tax/mutations/tax_country_configuration_update.py b/saleor/graphql/tax/mutations/tax_country_configuration_update.py
new file mode 100644
index 0000000000..78a22c4956
--- /dev/null
+++ b/saleor/graphql/tax/mutations/tax_country_configuration_update.py
@@ -0,0 +1,234 @@
+import graphene
+from django.core.exceptions import ValidationError
+from django.db.models import Q
+from django_countries.fields import Country
+from graphql import GraphQLError
+
+from ....core.permissions import CheckoutPermissions
+from ....tax import error_codes, models
+from ...account.enums import CountryCodeEnum
+from ...core.descriptions import ADDED_IN_39, PREVIEW_FEATURE
+from ...core.mutations import BaseMutation
+from ...core.types import Error, NonNullList
+from ...core.utils import from_global_id_or_error
+from ..types import TaxCountryConfiguration
+
+TaxCountryConfigurationUpdateErrorCode = graphene.Enum.from_enum(
+ error_codes.TaxCountryConfigurationUpdateErrorCode
+)
+
+
+class TaxCountryConfigurationUpdateError(Error):
+ code = TaxCountryConfigurationUpdateErrorCode(
+ description="The error code.", required=True
+ )
+ tax_class_ids = NonNullList(
+ graphene.String,
+ description="List of tax class IDs for which the update failed.",
+ required=True,
+ )
+
+
+class TaxClassRateInput(graphene.InputObjectType):
+ tax_class_id = graphene.ID(
+ description="ID of a tax class for which to update the tax rate", required=False
+ )
+ rate = graphene.Float(description="Tax rate value.", required=False)
+
+
+class TaxCountryConfigurationUpdate(BaseMutation):
+ tax_country_configuration = graphene.Field(
+ TaxCountryConfiguration,
+ description="Updated tax class rates grouped by a country.",
+ )
+
+ class Arguments:
+ country_code = CountryCodeEnum(
+ description="Country in which to update the tax class rates.", required=True
+ )
+ update_tax_class_rates = NonNullList(
+ TaxClassRateInput,
+ description=(
+ "List of tax rates per tax class to update. When "
+ "`{taxClass: id, rate: null`} is passed, it deletes the rate object "
+ "for given taxClass ID. When `{rate: Int}` is passed without a tax "
+ "class, it updates the default tax class for this country."
+ ),
+ required=True,
+ )
+
+ class Meta:
+ description = (
+ "Update tax class rates for a specific country."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE
+ )
+ error_type_class = TaxCountryConfigurationUpdateError
+ permissions = (CheckoutPermissions.MANAGE_TAXES,)
+
+ def _clean_default_rates(tax_rate_items):
+ # Check if only one default rate is provided (only one item without the tax
+ # class).
+ default_rate_items = [
+ item for item in tax_rate_items if item.get("tax_class_id") is None
+ ]
+ if len(default_rate_items) > 1:
+ code = (
+ error_codes.TaxCountryConfigurationUpdateErrorCode.ONLY_ONE_DEFAULT_COUNTRY_RATE_ALLOWED # noqa: E501
+ )
+ params = {"tax_class_ids": []}
+ raise ValidationError(
+ {
+ "update_tax_class_rates": ValidationError(
+ code=code,
+ message=(
+ "Only one default country rate can be created for "
+ "a country (a rate without a tax class)."
+ ),
+ params=params,
+ )
+ }
+ )
+
+ def _clean_tax_class_ids(tax_rate_items):
+ cleaned_data = {}
+ failed_ids = []
+ for item in tax_rate_items:
+ global_id = item.get("tax_class_id")
+ pk = None
+ if global_id:
+ try:
+ _, pk = from_global_id_or_error(
+ global_id, "TaxClass", raise_error=True
+ )
+ except GraphQLError:
+ failed_ids.append(global_id)
+ continue
+ pk = int(pk)
+
+ cleaned_data[pk] = item
+
+ if failed_ids:
+ params = {"tax_class_ids": failed_ids}
+ code = error_codes.TaxCountryConfigurationUpdateErrorCode.NOT_FOUND
+ message = "Failed to resolve some of the provided tax class IDs."
+ raise ValidationError(
+ {
+ "update_tax_class_rates": ValidationError(
+ code=code, message=message, params=params
+ )
+ }
+ )
+
+ return cleaned_data
+
+ @classmethod
+ def _clean_rate_values(cls, tax_rate_items):
+ invalid_rates = []
+ for item in tax_rate_items:
+ rate = item.get("rate")
+ if rate is not None and rate < 0:
+ invalid_rates.append(item)
+
+ if invalid_rates:
+ code = (
+ error_codes.TaxCountryConfigurationUpdateErrorCode.CANNOT_CREATE_NEGATIVE_RATE # noqa: E501
+ )
+ message = "Cannot create rates with negative values."
+ params = {
+ "tax_class_ids": [
+ item["tax_class_id"]
+ for item in invalid_rates
+ if item.get("tax_class_id")
+ ]
+ }
+ raise ValidationError(
+ {
+ "update_tax_class_rates": ValidationError(
+ code=code, message=message, params=params
+ )
+ }
+ )
+
+ @classmethod
+ def clean_input(cls, **data):
+ update_tax_class_rates = data.get("update_tax_class_rates", [])
+ cls._clean_rate_values(update_tax_class_rates)
+ cls._clean_default_rates(update_tax_class_rates)
+ return cls._clean_tax_class_ids(update_tax_class_rates)
+
+ @classmethod
+ def update_default_rate(cls, country_code, cleaned_data):
+ # Handle the default country rate first (the one without a tax class).
+ default_rate = cleaned_data.get(None)
+ if default_rate:
+ rate = default_rate.get("rate")
+ if rate is not None:
+ models.TaxClassCountryRate.objects.update_or_create(
+ country=country_code,
+ tax_class=None,
+ defaults={"rate": default_rate["rate"]},
+ )
+ else:
+ default_rate_obj = models.TaxClassCountryRate.objects.filter(
+ country=country_code,
+ tax_class=None,
+ ).first()
+ if default_rate_obj:
+ default_rate_obj.delete()
+
+ @classmethod
+ def update_and_create_country_rates(cls, country_code, cleaned_data):
+ # Prepare IDs to create and update.
+ input_ids = [key for key in cleaned_data.keys() if key is not None]
+ update_qs = models.TaxClassCountryRate.objects.filter(
+ country=country_code, tax_class_id__in=input_ids
+ )
+ update_ids = [item.tax_class_id for item in update_qs]
+ create_ids = set(input_ids) - set(update_ids)
+ delete_ids = []
+
+ # Update existing instances.
+ for obj in update_qs:
+ rate = cleaned_data[obj.tax_class_id].get("rate")
+ if rate is None:
+ delete_ids.append(obj.tax_class_id)
+ else:
+ obj.rate = rate
+ models.TaxClassCountryRate.objects.bulk_update(update_qs, fields=("rate",))
+
+ # Create new instances.
+ to_create = []
+ for tax_class_id in create_ids:
+ input_item = cleaned_data[tax_class_id]
+ rate = input_item.get("rate")
+ if rate is not None:
+ obj = models.TaxClassCountryRate(
+ country=country_code, tax_class_id=tax_class_id, rate=rate
+ )
+ to_create.append(obj)
+ models.TaxClassCountryRate.objects.bulk_create(to_create)
+
+ # Delete instances where null rates were provided.
+ models.TaxClassCountryRate.objects.filter(
+ country=country_code,
+ tax_class_id__in=delete_ids,
+ ).delete()
+
+ @classmethod
+ def perform_mutation(cls, _root, _info, **data):
+ country_code = data["country_code"]
+ cleaned_data = cls.clean_input(**data)
+ cls.update_default_rate(country_code, cleaned_data)
+ cls.update_and_create_country_rates(country_code, cleaned_data)
+
+ tax_classes_lookup = Q(tax_class_id__in=cleaned_data.keys())
+ if None in cleaned_data:
+ tax_classes_lookup |= Q(tax_class=None)
+ all_rates = models.TaxClassCountryRate.objects.filter(
+ tax_classes_lookup, country=country_code
+ )
+ country_config = TaxCountryConfiguration(
+ country=Country(country_code), tax_class_country_rates=all_rates
+ )
+ return TaxCountryConfigurationUpdate(tax_country_configuration=country_config)
diff --git a/saleor/graphql/tax/schema.py b/saleor/graphql/tax/schema.py
index 4f56cf5f7c..7548542270 100644
--- a/saleor/graphql/tax/schema.py
+++ b/saleor/graphql/tax/schema.py
@@ -1,7 +1,156 @@
+from collections import defaultdict
+
import graphene
+from django_countries.fields import Country
+
+from ...core.permissions import AuthorizationFilters
+from ...tax import models
+from ..account.enums import CountryCodeEnum
+from ..core.connection import create_connection_slice, filter_connection_queryset
+from ..core.descriptions import ADDED_IN_39, PREVIEW_FEATURE
+from ..core.fields import FilterConnectionField, PermissionsField
+from ..core.types import NonNullList
+from ..core.utils import from_global_id_or_error
+from .filters import TaxClassFilterInput, TaxConfigurationFilterInput
+from .mutations import (
+ TaxClassCreate,
+ TaxClassDelete,
+ TaxClassUpdate,
+ TaxConfigurationUpdate,
+ TaxCountryConfigurationDelete,
+ TaxCountryConfigurationUpdate,
+ TaxExemptionManage,
+)
+from .sorters import TaxClassSortingInput
+from .types import (
+ TaxClass,
+ TaxClassCountableConnection,
+ TaxConfiguration,
+ TaxConfigurationCountableConnection,
+ TaxCountryConfiguration,
+)
+
+
+class TaxQueries(graphene.ObjectType):
+ tax_configuration = PermissionsField(
+ TaxConfiguration,
+ description="Look up a tax configuration." + ADDED_IN_39 + PREVIEW_FEATURE,
+ id=graphene.Argument(
+ graphene.ID, description="ID of a tax configuration.", required=True
+ ),
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ AuthorizationFilters.AUTHENTICATED_APP,
+ ],
+ )
+ tax_configurations = FilterConnectionField(
+ TaxConfigurationCountableConnection,
+ description="List of tax configurations." + ADDED_IN_39 + PREVIEW_FEATURE,
+ filter=TaxConfigurationFilterInput(
+ description="Filtering options for tax configurations."
+ ),
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ AuthorizationFilters.AUTHENTICATED_APP,
+ ],
+ )
+ tax_class = PermissionsField(
+ TaxClass,
+ description="Look up a tax class." + ADDED_IN_39 + PREVIEW_FEATURE,
+ id=graphene.Argument(
+ graphene.ID, description="ID of a tax class.", required=True
+ ),
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ AuthorizationFilters.AUTHENTICATED_APP,
+ ],
+ )
+ tax_classes = FilterConnectionField(
+ TaxClassCountableConnection,
+ description="List of tax classes." + ADDED_IN_39 + PREVIEW_FEATURE,
+ sort_by=TaxClassSortingInput(description="Sort tax classes."),
+ filter=TaxClassFilterInput(description="Filtering options for tax classes."),
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ AuthorizationFilters.AUTHENTICATED_APP,
+ ],
+ )
+ tax_country_configuration = PermissionsField(
+ TaxCountryConfiguration,
+ country_code=graphene.Argument(
+ CountryCodeEnum,
+ description="Country for which to return tax class rates.",
+ required=True,
+ ),
+ description="Tax class rates grouped by country.",
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ AuthorizationFilters.AUTHENTICATED_APP,
+ ],
+ )
+ tax_country_configurations = PermissionsField(
+ NonNullList(
+ TaxCountryConfiguration,
+ description="A list of countries with grouped tax class rates.",
+ required=True,
+ ),
+ permissions=[
+ AuthorizationFilters.AUTHENTICATED_STAFF_USER,
+ AuthorizationFilters.AUTHENTICATED_APP,
+ ],
+ )
+
+ @staticmethod
+ def resolve_tax_configuration(_root, _info, id):
+ _, id = from_global_id_or_error(id, TaxConfiguration)
+ return models.TaxConfiguration.objects.filter(id=id).first()
+
+ @staticmethod
+ def resolve_tax_configurations(_root, info, **kwargs):
+ qs = models.TaxConfiguration.objects.all()
+ qs = filter_connection_queryset(qs, kwargs)
+ return create_connection_slice(
+ qs, info, kwargs, TaxConfigurationCountableConnection
+ )
+
+ @staticmethod
+ def resolve_tax_class(_root, _info, id):
+ _, id = from_global_id_or_error(id, TaxClass)
+ return models.TaxClass.objects.filter(id=id).first()
+
+ @staticmethod
+ def resolve_tax_classes(_root, info, **kwargs):
+ qs = models.TaxClass.objects.all()
+ qs = filter_connection_queryset(qs, kwargs)
+ return create_connection_slice(qs, info, kwargs, TaxClassCountableConnection)
+
+ @staticmethod
+ def resolve_tax_country_configuration(_root, _info, country_code):
+ country_rates = models.TaxClassCountryRate.objects.filter(country=country_code)
+ return TaxCountryConfiguration(
+ country=Country(country_code),
+ tax_class_country_rates=country_rates,
+ )
-from .mutations import TaxExemptionManage
+ @staticmethod
+ def resolve_tax_country_configurations(_root, _info, **kwargs):
+ country_rates = models.TaxClassCountryRate.objects.all()
+ rates_per_country = defaultdict(list)
+ for country_rate in country_rates:
+ rates_per_country[country_rate.country].append(country_rate)
+ return [
+ TaxCountryConfiguration(
+ country=country, tax_class_country_rates=rates_per_country[country]
+ )
+ for country in rates_per_country
+ ]
class TaxMutations(graphene.ObjectType):
+ tax_class_create = TaxClassCreate.Field()
+ tax_class_delete = TaxClassDelete.Field()
+ tax_class_update = TaxClassUpdate.Field()
+ tax_configuration_update = TaxConfigurationUpdate.Field()
+ tax_country_configuration_update = TaxCountryConfigurationUpdate.Field()
+ tax_country_configuration_delete = TaxCountryConfigurationDelete.Field()
tax_exemption_manage = TaxExemptionManage.Field()
diff --git a/saleor/graphql/tax/sorters.py b/saleor/graphql/tax/sorters.py
new file mode 100644
index 0000000000..4fa3d1abd2
--- /dev/null
+++ b/saleor/graphql/tax/sorters.py
@@ -0,0 +1,20 @@
+import graphene
+
+from ..core.types import SortInputObjectType
+
+
+class TaxClassSortField(graphene.Enum):
+ NAME = ["name", "pk"]
+
+ @property
+ def description(self):
+ if self.name in TaxClassSortField.__enum__._member_names_:
+ sort_name = self.name.lower().replace("_", " ")
+ return f"Sort tax classes by {sort_name}."
+ raise ValueError(f"Unsupported enum value: {self.value}")
+
+
+class TaxClassSortingInput(SortInputObjectType):
+ class Meta:
+ sort_enum = TaxClassSortField
+ type_name = "tax classes"
diff --git a/saleor/graphql/tax/tests/fragments.py b/saleor/graphql/tax/tests/fragments.py
new file mode 100644
index 0000000000..9dbc50e4ba
--- /dev/null
+++ b/saleor/graphql/tax/tests/fragments.py
@@ -0,0 +1,60 @@
+TAX_CONFIGURATION_FRAGMENT = """
+ fragment TaxConfiguration on TaxConfiguration {
+ id
+ channel {
+ id
+ name
+ }
+ chargeTaxes
+ taxCalculationStrategy
+ displayGrossPrices
+ pricesEnteredWithTax
+ countries {
+ country {
+ code
+ country
+ }
+ chargeTaxes
+ taxCalculationStrategy
+ displayGrossPrices
+ }
+ metadata {
+ key
+ value
+ }
+ }
+"""
+
+
+TAX_CLASS_FRAGMENT = """
+ fragment TaxClass on TaxClass {
+ id
+ name
+ countries {
+ country {
+ code
+ country
+ }
+ rate
+ }
+ metadata {
+ key
+ value
+ }
+ }
+"""
+
+TAX_COUNTRY_CONFIGURATION_FRAGMENT = """
+ fragment TaxCountryConfiguration on TaxCountryConfiguration {
+ country {
+ code
+ }
+ taxClassCountryRates {
+ rate
+ taxClass {
+ id
+ name
+ }
+ }
+ }
+"""
diff --git a/saleor/graphql/tax/tests/mutations/test_tax_class_create.py b/saleor/graphql/tax/tests/mutations/test_tax_class_create.py
new file mode 100644
index 0000000000..8b02b3679b
--- /dev/null
+++ b/saleor/graphql/tax/tests/mutations/test_tax_class_create.py
@@ -0,0 +1,77 @@
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_CLASS_FRAGMENT
+
+MUTATION = (
+ """
+ mutation TaxClassCreate($input: TaxClassCreateInput!) {
+ taxClassCreate(input: $input) {
+ errors {
+ field
+ message
+ code
+ countryCodes
+ }
+ taxClass {
+ ...TaxClass
+ }
+ }
+ }
+"""
+ + TAX_CLASS_FRAGMENT
+)
+
+
+def _test_no_permissions(api_client):
+ # given
+ variables = {"input": {"name": "Test"}}
+
+ # when
+ response = api_client.post_graphql(MUTATION, variables, permissions=[])
+
+ # then
+ assert_no_permission(response)
+
+
+def test_no_permission_staff(staff_api_client):
+ _test_no_permissions(staff_api_client)
+
+
+def test_no_permission_app(app_api_client):
+ _test_no_permissions(app_api_client)
+
+
+def _test_tax_class_create(api_client, permission_manage_taxes):
+ # given
+ name = "New tax class"
+ rate = 23
+ country_code = "PL"
+ variables = {
+ "input": {
+ "name": name,
+ "createCountryRates": [
+ {"countryCode": country_code, "rate": rate},
+ ],
+ },
+ }
+
+ # when
+ response = api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClassCreate"]
+ assert not data["errors"]
+ assert data["taxClass"]["name"] == name
+ assert len(data["taxClass"]["countries"]) == 1
+ assert data["taxClass"]["countries"][0]["rate"] == rate
+ assert data["taxClass"]["countries"][0]["country"]["code"] == country_code
+
+
+def test_create_as_staff(staff_api_client, permission_manage_taxes):
+ _test_tax_class_create(staff_api_client, permission_manage_taxes)
+
+
+def test_create_as_app(app_api_client, permission_manage_taxes):
+ _test_tax_class_create(app_api_client, permission_manage_taxes)
diff --git a/saleor/graphql/tax/tests/mutations/test_tax_class_delete.py b/saleor/graphql/tax/tests/mutations/test_tax_class_delete.py
new file mode 100644
index 0000000000..6304d75c86
--- /dev/null
+++ b/saleor/graphql/tax/tests/mutations/test_tax_class_delete.py
@@ -0,0 +1,69 @@
+import graphene
+
+from .....tax.models import TaxClass
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_CLASS_FRAGMENT
+
+MUTATION = (
+ """
+ mutation TaxClassDelete($id: ID!) {
+ taxClassDelete(id: $id) {
+ errors {
+ field
+ message
+ code
+ }
+ taxClass {
+ ...TaxClass
+ }
+ }
+ }
+"""
+ + TAX_CLASS_FRAGMENT
+)
+
+
+def _test_no_permissions(api_client):
+ # given
+ tax_class = TaxClass.objects.first()
+ variables = {"id": graphene.Node.to_global_id("TaxClass", tax_class.pk)}
+
+ # when
+ response = api_client.post_graphql(MUTATION, variables, permissions=[])
+
+ # then
+ assert_no_permission(response)
+
+
+def test_no_permission_staff(staff_api_client):
+ _test_no_permissions(staff_api_client)
+
+
+def test_no_permission_app(app_api_client):
+ _test_no_permissions(app_api_client)
+
+
+def _test_tax_class_delete(api_client, permission_manage_taxes):
+ # given
+ tax_class = TaxClass.objects.create(name="Test")
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {"id": id}
+
+ # when
+ response = api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClassDelete"]
+ assert not data["errors"]
+ assert data["taxClass"]["id"] == id
+
+
+def test_delete_as_staff(staff_api_client, permission_manage_taxes):
+ _test_tax_class_delete(staff_api_client, permission_manage_taxes)
+
+
+def test_delete_as_app(app_api_client, permission_manage_taxes):
+ _test_tax_class_delete(app_api_client, permission_manage_taxes)
diff --git a/saleor/graphql/tax/tests/mutations/test_tax_class_update.py b/saleor/graphql/tax/tests/mutations/test_tax_class_update.py
new file mode 100644
index 0000000000..ca628ce4c0
--- /dev/null
+++ b/saleor/graphql/tax/tests/mutations/test_tax_class_update.py
@@ -0,0 +1,217 @@
+import graphene
+
+from .....tax.error_codes import TaxClassUpdateErrorCode
+from .....tax.models import TaxClass, TaxClassCountryRate
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_CLASS_FRAGMENT
+
+MUTATION = (
+ """
+ mutation TaxClassUpdate($id: ID!, $input: TaxClassUpdateInput!) {
+ taxClassUpdate(id: $id, input: $input) {
+ errors {
+ field
+ message
+ code
+ countryCodes
+ }
+ taxClass {
+ ...TaxClass
+ }
+ }
+ }
+ """
+ + TAX_CLASS_FRAGMENT
+)
+
+
+def _test_no_permissions(api_client):
+ # given
+ tax_class = TaxClass.objects.first()
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {"id": id, "input": {"name": "Test"}}
+
+ # when
+ response = api_client.post_graphql(MUTATION, variables, permissions=[])
+
+ # then
+ assert_no_permission(response)
+
+
+def test_no_permission_staff(staff_api_client):
+ _test_no_permissions(staff_api_client)
+
+
+def test_no_permission_app(app_api_client):
+ _test_no_permissions(app_api_client)
+
+
+def _test_tax_class_update(api_client, permission_manage_taxes):
+ # given
+ tax_class = TaxClass.objects.create(name="Tax Class")
+ tax_class.country_rates.create(country="PL", rate=21)
+
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+
+ new_name = "New tax class name"
+ update_PL_rate = {"countryCode": "PL", "rate": 23}
+ create_DE_rate = {"countryCode": "DE", "rate": 19}
+
+ variables = {
+ "id": id,
+ "input": {
+ "name": new_name,
+ "updateCountryRates": [update_PL_rate, create_DE_rate],
+ },
+ }
+
+ # when
+ response = api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClassUpdate"]
+ assert not data["errors"]
+ assert data["taxClass"]["name"] == new_name
+ assert len(data["taxClass"]["countries"]) == 2
+
+ response_data = []
+ for item in data["taxClass"]["countries"]:
+ new_item = {**item, "countryCode": item["country"]["code"]}
+ new_item.pop("country")
+ response_data.append(new_item)
+
+ assert update_PL_rate in response_data
+ assert create_DE_rate in response_data
+
+
+def test_create_as_staff(staff_api_client, permission_manage_taxes):
+ _test_tax_class_update(staff_api_client, permission_manage_taxes)
+
+
+def test_create_as_app(app_api_client, permission_manage_taxes):
+ _test_tax_class_update(app_api_client, permission_manage_taxes)
+
+
+def test_raise_duplicated_item_error(staff_api_client, permission_manage_taxes):
+ # given
+ tax_class = TaxClass.objects.create(name="Tax Class")
+ tax_class.country_rates.create(country="PL", rate=21)
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {
+ "id": id,
+ "input": {
+ "updateCountryRates": [{"countryCode": "PL", "rate": 23}],
+ "removeCountryRates": ["PL"],
+ },
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ errors = content["data"]["taxClassUpdate"]["errors"]
+ assert errors
+ assert errors[0]["code"] == TaxClassUpdateErrorCode.DUPLICATED_INPUT_ITEM.name
+ assert errors[0]["countryCodes"] == ["PL"]
+
+
+def test_remove_all_country_rates(staff_api_client, permission_manage_taxes):
+ # given
+ tax_class = TaxClass.objects.create(name="Tax Class")
+ tax_class.country_rates.create(country="PL", rate=21)
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {
+ "id": id,
+ "input": {"removeCountryRates": ["PL"]},
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClassUpdate"]
+ assert not data["errors"]
+ assert len(data["taxClass"]["countries"]) == 0
+
+
+def test_remove_individual_country_rates(staff_api_client, permission_manage_taxes):
+ # given
+ default_rate_de, _ = TaxClassCountryRate.objects.get_or_create(
+ country="DE", tax_class=None, rate=19
+ )
+ tax_class = TaxClass.objects.create(name="Tax Class")
+ tax_class.country_rates.create(country="PL", rate=21)
+ tax_class.country_rates.create(country="DE", rate=19)
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ new_rate_pl = 23
+ variables = {
+ "id": id,
+ "input": {
+ "updateCountryRates": [
+ {"countryCode": "PL", "rate": new_rate_pl},
+ {"countryCode": "DE"}, # null rate; should remove this item from DB
+ ],
+ },
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClassUpdate"]
+ assert not data["errors"]
+ assert len(data["taxClass"]["countries"]) == 1
+ assert data["taxClass"]["countries"][0]["country"]["code"] == "PL"
+ assert data["taxClass"]["countries"][0]["rate"] == new_rate_pl
+
+ default_rate_de.refresh_from_db()
+ assert default_rate_de.pk is not None
+
+
+def test_remove_individual_country_rates_non_existing_rate(
+ staff_api_client, permission_manage_taxes
+):
+ # given
+ default_rate_de, _ = TaxClassCountryRate.objects.get_or_create(
+ country="DE", tax_class=None, rate=19
+ )
+ tax_class = TaxClass.objects.create(name="Tax Class")
+ tax_class.country_rates.create(country="PL", rate=21)
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ new_rate_pl = 23
+ variables = {
+ "id": id,
+ "input": {
+ "updateCountryRates": [
+ {"countryCode": "PL", "rate": new_rate_pl},
+ {"countryCode": "DE"},
+ ],
+ },
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClassUpdate"]
+ assert not data["errors"]
+ assert len(data["taxClass"]["countries"]) == 1
+ assert data["taxClass"]["countries"][0]["country"]["code"] == "PL"
+
+ default_rate_de.refresh_from_db()
+ assert default_rate_de.pk is not None
diff --git a/saleor/graphql/tax/tests/mutations/test_tax_configuration_update.py b/saleor/graphql/tax/tests/mutations/test_tax_configuration_update.py
new file mode 100644
index 0000000000..f5544382b4
--- /dev/null
+++ b/saleor/graphql/tax/tests/mutations/test_tax_configuration_update.py
@@ -0,0 +1,284 @@
+import graphene
+import pytest
+
+from .....tax.error_codes import TaxConfigurationUpdateErrorCode
+from .....tax.models import TaxConfiguration
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ...enums import TaxCalculationStrategy
+from ..fragments import TAX_CONFIGURATION_FRAGMENT
+
+MUTATION = (
+ """
+ mutation TaxConfigurationUpdate(
+ $id: ID!
+ $input: TaxConfigurationUpdateInput!
+ ) {
+ taxConfigurationUpdate(id: $id, input: $input) {
+ errors {
+ field
+ message
+ code
+ countryCodes
+ }
+ taxConfiguration {
+ ...TaxConfiguration
+ }
+ }
+ }
+"""
+ + TAX_CONFIGURATION_FRAGMENT
+)
+
+
+def _test_no_permissions(api_client):
+ # given
+ tax_configuration = TaxConfiguration.objects.first()
+ id = graphene.Node.to_global_id("TaxConfiguration", tax_configuration.pk)
+ variables = {"id": id, "input": {}}
+
+ # when
+ response = api_client.post_graphql(MUTATION, variables, permissions=[])
+
+ # then
+ assert_no_permission(response)
+
+
+def test_no_permission_staff(channel_USD, staff_api_client):
+ _test_no_permissions(staff_api_client)
+
+
+def test_no_permission_app(channel_USD, app_api_client):
+ _test_no_permissions(app_api_client)
+
+
+def example_tax_configuration(channel_USD):
+ channel_USD.tax_configuration.delete()
+ tax_configuration = TaxConfiguration.objects.create(
+ channel=channel_USD,
+ charge_taxes=True,
+ display_gross_prices=True,
+ prices_entered_with_tax=True,
+ )
+ tax_configuration.country_exceptions.create(
+ country="PL", charge_taxes=True, display_gross_prices=True
+ )
+ return tax_configuration
+
+
+def _test_tax_configuration_update(
+ example_tax_configuration, api_client, permission_manage_taxes
+):
+ # given
+ id = graphene.Node.to_global_id("TaxConfiguration", example_tax_configuration.pk)
+ variables = {
+ "id": id,
+ "input": {
+ "chargeTaxes": False,
+ "taxCalculationStrategy": TaxCalculationStrategy.FLAT_RATES.value,
+ "displayGrossPrices": False,
+ "pricesEnteredWithTax": False,
+ "updateCountriesConfiguration": [
+ {
+ "countryCode": "PL",
+ "chargeTaxes": False,
+ "displayGrossPrices": False,
+ "taxCalculationStrategy": TaxCalculationStrategy.FLAT_RATES.value,
+ }
+ ],
+ "removeCountriesConfiguration": [],
+ },
+ }
+
+ # when
+ response = api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxConfigurationUpdate"]
+ assert not data["errors"]
+ assert data["taxConfiguration"]["id"] == id
+ assert data["taxConfiguration"]["chargeTaxes"] is False
+ assert (
+ data["taxConfiguration"]["taxCalculationStrategy"]
+ == TaxCalculationStrategy.FLAT_RATES.name
+ )
+ assert data["taxConfiguration"]["displayGrossPrices"] is False
+ assert data["taxConfiguration"]["pricesEnteredWithTax"] is False
+ assert data["taxConfiguration"]["countries"][0]["chargeTaxes"] is False
+ assert (
+ data["taxConfiguration"]["countries"][0]["taxCalculationStrategy"]
+ == TaxCalculationStrategy.FLAT_RATES.name
+ )
+ assert data["taxConfiguration"]["countries"][0]["displayGrossPrices"] is False
+
+
+def test_update_as_staff(
+ example_tax_configuration, staff_api_client, permission_manage_taxes
+):
+ _test_tax_configuration_update(
+ example_tax_configuration, staff_api_client, permission_manage_taxes
+ )
+
+
+def test_update_as_app(
+ example_tax_configuration, app_api_client, permission_manage_taxes
+):
+ _test_tax_configuration_update(
+ example_tax_configuration, app_api_client, permission_manage_taxes
+ )
+
+
+def test_raise_duplicate_input_item(
+ example_tax_configuration, staff_api_client, permission_manage_taxes
+):
+ id = graphene.Node.to_global_id("TaxConfiguration", example_tax_configuration.pk)
+ variables = {
+ "id": id,
+ "input": {
+ "updateCountriesConfiguration": [
+ {"countryCode": "PL", "chargeTaxes": False, "displayGrossPrices": False}
+ ],
+ "removeCountriesConfiguration": ["PL"],
+ },
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ errors = content["data"]["taxConfigurationUpdate"]["errors"]
+ assert errors
+ assert (
+ errors[0]["code"] == TaxConfigurationUpdateErrorCode.DUPLICATED_INPUT_ITEM.name
+ )
+ assert errors[0]["countryCodes"] == ["PL"]
+
+
+def test_create_and_update_country_configurations(
+ example_tax_configuration, staff_api_client, permission_manage_taxes
+):
+ # given
+ id = graphene.Node.to_global_id("TaxConfiguration", example_tax_configuration.pk)
+
+ # update PL configuration and create DE configuration
+ update_PL_data = {
+ "countryCode": "PL",
+ "chargeTaxes": False,
+ "taxCalculationStrategy": TaxCalculationStrategy.FLAT_RATES.value,
+ "displayGrossPrices": False,
+ }
+ create_DE_data = {
+ "countryCode": "DE",
+ "chargeTaxes": False,
+ "taxCalculationStrategy": TaxCalculationStrategy.FLAT_RATES.value,
+ "displayGrossPrices": False,
+ }
+
+ variables = {
+ "id": id,
+ "input": {
+ "updateCountriesConfiguration": [
+ update_PL_data,
+ create_DE_data,
+ ],
+ },
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxConfigurationUpdate"]["taxConfiguration"]
+ assert len(data["countries"]) == 2
+
+ response_data = []
+ for item in data["countries"]:
+ new_item = {**item, "countryCode": item["country"]["code"]}
+ new_item.pop("country")
+ response_data.append(new_item)
+
+ assert update_PL_data in response_data
+ assert create_DE_data in response_data
+
+
+def test_create_and_update_country_configurations_no_tax_calculation_strategy(
+ example_tax_configuration, staff_api_client, permission_manage_taxes
+):
+ # given
+ id = graphene.Node.to_global_id("TaxConfiguration", example_tax_configuration.pk)
+
+ # update PL configuration and create PT configuration with omitting the
+ # `taxCalculationStrategy` in both inputs
+ update_PL_data = {
+ "countryCode": "PL",
+ "chargeTaxes": False,
+ "displayGrossPrices": False,
+ }
+ create_PT_data = {
+ "countryCode": "PT",
+ "chargeTaxes": False,
+ "displayGrossPrices": False,
+ }
+
+ variables = {
+ "id": id,
+ "input": {
+ "updateCountriesConfiguration": [
+ update_PL_data,
+ create_PT_data,
+ ],
+ },
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxConfigurationUpdate"]["taxConfiguration"]
+ assert len(data["countries"]) == 2
+
+ response_data = []
+ for item in data["countries"]:
+ new_item = {**item, "countryCode": item["country"]["code"]}
+ new_item.pop("country")
+ response_data.append(new_item)
+
+ update_PL_data["taxCalculationStrategy"] = None
+ create_PT_data["taxCalculationStrategy"] = None
+
+ assert update_PL_data in response_data
+ assert create_PT_data in response_data
+
+
+def test_remove_country_configurations(
+ example_tax_configuration, staff_api_client, permission_manage_taxes
+):
+ id = graphene.Node.to_global_id("TaxConfiguration", example_tax_configuration.pk)
+ variables = {
+ "id": id,
+ "input": {
+ "removeCountriesConfiguration": ["PL"],
+ },
+ }
+
+ # when
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxConfigurationUpdate"]["taxConfiguration"]
+ assert data["countries"] == []
diff --git a/saleor/graphql/tax/tests/mutations/test_tax_country_configuration_delete.py b/saleor/graphql/tax/tests/mutations/test_tax_country_configuration_delete.py
new file mode 100644
index 0000000000..9f8365b235
--- /dev/null
+++ b/saleor/graphql/tax/tests/mutations/test_tax_country_configuration_delete.py
@@ -0,0 +1,72 @@
+from .....tax.models import TaxClass
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_COUNTRY_CONFIGURATION_FRAGMENT
+
+MUTATION = (
+ """
+ mutation TaxCountryConfigurationDelete($countryCode: CountryCode!) {
+ taxCountryConfigurationDelete(countryCode: $countryCode) {
+ errors {
+ field
+ message
+ code
+ }
+ taxCountryConfiguration {
+ ...TaxCountryConfiguration
+ }
+ }
+ }
+ """
+ + TAX_COUNTRY_CONFIGURATION_FRAGMENT
+)
+
+
+def _test_no_permissions(api_client):
+ # given
+ country_code = "PL"
+
+ # when
+ response = api_client.post_graphql(
+ MUTATION, {"countryCode": country_code}, permissions=[]
+ )
+
+ # then
+ assert_no_permission(response)
+
+
+def test_no_permission_staff(staff_api_client):
+ _test_no_permissions(staff_api_client)
+
+
+def test_no_permission_app(app_api_client):
+ _test_no_permissions(app_api_client)
+
+
+def _test_delete_tax_rates_for_country(api_client, permission_manage_taxes):
+ # given
+ country_code = "PL"
+ tax_class_1 = TaxClass.objects.create(name="Books")
+ tax_class_2 = TaxClass.objects.create(name="Accessories")
+ tax_class_1.country_rates.create(country=country_code, rate=23)
+ tax_class_2.country_rates.create(country=country_code, rate=23)
+
+ # when
+ response = api_client.post_graphql(
+ MUTATION, {"countryCode": country_code}, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxCountryConfigurationDelete"]
+ assert not data["errors"]
+ assert len(data["taxCountryConfiguration"]["taxClassCountryRates"]) == 0
+
+
+def test_delete_tax_rates_for_country_by_staff(
+ staff_api_client, permission_manage_taxes
+):
+ _test_delete_tax_rates_for_country(staff_api_client, permission_manage_taxes)
+
+
+def test_delete_tax_rates_for_country_by_app(app_api_client, permission_manage_taxes):
+ _test_delete_tax_rates_for_country(app_api_client, permission_manage_taxes)
diff --git a/saleor/graphql/tax/tests/mutations/test_tax_country_configuration_update.py b/saleor/graphql/tax/tests/mutations/test_tax_country_configuration_update.py
new file mode 100644
index 0000000000..f3f4a07801
--- /dev/null
+++ b/saleor/graphql/tax/tests/mutations/test_tax_country_configuration_update.py
@@ -0,0 +1,284 @@
+import graphene
+import pytest
+
+from .....tax.error_codes import TaxCountryConfigurationUpdateErrorCode
+from .....tax.models import TaxClass, TaxClassCountryRate
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_COUNTRY_CONFIGURATION_FRAGMENT
+
+MUTATION = (
+ """
+ mutation TaxCountryConfigurationUpdate(
+ $countryCode: CountryCode!
+ $updateTaxClassRates: [TaxClassRateInput!]!
+ ) {
+ taxCountryConfigurationUpdate(
+ countryCode: $countryCode
+ updateTaxClassRates: $updateTaxClassRates
+ ) {
+ errors {
+ field
+ message
+ code
+ taxClassIds
+ }
+ taxCountryConfiguration {
+ ...TaxCountryConfiguration
+ }
+ }
+ }
+ """
+ + TAX_COUNTRY_CONFIGURATION_FRAGMENT
+)
+
+
+def _test_no_permissions(api_client):
+ # given
+ country_code = "PL"
+
+ # when
+ response = api_client.post_graphql(
+ MUTATION,
+ {"countryCode": country_code, "updateTaxClassRates": []},
+ permissions=[],
+ )
+
+ # then
+ assert_no_permission(response)
+
+
+def test_no_permission_staff(staff_api_client):
+ _test_no_permissions(staff_api_client)
+
+
+def test_no_permission_app(app_api_client):
+ _test_no_permissions(app_api_client)
+
+
+def _test_country_rates_update(api_client, permission_manage_taxes):
+ # given
+ tax_class_1 = TaxClass.objects.create(name="Books")
+ tax_class_2 = TaxClass.objects.create(name="Accessories")
+ tax_class_1.country_rates.create(country="PL", rate=23)
+
+ id_1 = graphene.Node.to_global_id("TaxClass", tax_class_1.pk)
+ id_2 = graphene.Node.to_global_id("TaxClass", tax_class_2.pk)
+
+ # when
+ variables = {
+ "countryCode": "PL",
+ "updateTaxClassRates": [
+ {"taxClassId": id_1, "rate": 0}, # should update existing rate
+ {"taxClassId": id_2, "rate": 20}, # should create new rate
+ ],
+ }
+ response = api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxCountryConfigurationUpdate"]
+ assert not data["errors"]
+ assert len(data["taxCountryConfiguration"]["taxClassCountryRates"]) == 2
+
+ response_data = []
+ for item in data["taxCountryConfiguration"]["taxClassCountryRates"]:
+ response_data.append({"rate": item["rate"], "id": item["taxClass"]["id"]})
+
+ assert {"rate": 0, "id": id_1} in response_data
+ assert {"rate": 20, "id": id_2} in response_data
+
+
+def test_update_rates_as_staff(staff_api_client, permission_manage_taxes):
+ _test_country_rates_update(staff_api_client, permission_manage_taxes)
+
+
+def test_update_rates_as_app(app_api_client, permission_manage_taxes):
+ _test_country_rates_update(app_api_client, permission_manage_taxes)
+
+
+def test_create_country_rate_ignore_input_item_when_rate_is_none(
+ staff_api_client, permission_manage_taxes
+):
+ # given
+ tax_class_1 = TaxClass.objects.create(name="Books")
+ tax_class_2 = TaxClass.objects.create(name="Accessories")
+ tax_class_1.country_rates.create(country="PL", rate=23)
+
+ id_1 = graphene.Node.to_global_id("TaxClass", tax_class_1.pk)
+ id_2 = graphene.Node.to_global_id("TaxClass", tax_class_2.pk)
+
+ rate_1 = 20
+
+ # when
+ variables = {
+ "countryCode": "PL",
+ "updateTaxClassRates": [
+ {"taxClassId": id_1, "rate": rate_1}, # should update existing rate
+ {"taxClassId": id_2}, # the rate is missing, ignore this item
+ ],
+ }
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxCountryConfigurationUpdate"]
+ assert not data["errors"]
+ assert len(data["taxCountryConfiguration"]["taxClassCountryRates"]) == 1
+
+ assert (
+ data["taxCountryConfiguration"]["taxClassCountryRates"][0]["taxClass"]["id"]
+ == id_1
+ )
+ assert data["taxCountryConfiguration"]["taxClassCountryRates"][0]["rate"] == rate_1
+
+
+def test_delete_country_rate(staff_api_client, permission_manage_taxes):
+ # given
+ tax_class_1 = TaxClass.objects.create(name="Books")
+ tax_class_1.country_rates.create(country="PL", rate=23)
+ id_1 = graphene.Node.to_global_id("TaxClass", tax_class_1.pk)
+
+ # when
+ variables = {
+ "countryCode": "PL",
+ "updateTaxClassRates": [
+ {"taxClassId": id_1}, # should delete this rate item
+ ],
+ }
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxCountryConfigurationUpdate"]
+ assert not data["errors"]
+ assert len(data["taxCountryConfiguration"]["taxClassCountryRates"]) == 0
+
+
+def test_tax_class_id_not_found(staff_api_client, permission_manage_taxes):
+ # given
+ TaxClass.objects.create(name="Books")
+
+ # when
+ id = "spanishinquisition"
+ variables = {
+ "countryCode": "PL",
+ "updateTaxClassRates": [
+ {"taxClassId": id, "rate": 20},
+ ],
+ }
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxCountryConfigurationUpdate"]
+ assert data["errors"]
+ assert (
+ data["errors"][0]["code"]
+ == TaxCountryConfigurationUpdateErrorCode.NOT_FOUND.name
+ )
+ assert data["errors"][0]["taxClassIds"] == [id]
+
+
[email protected]("rate", [0, 23])
+def test_update_default_country_rate(staff_api_client, permission_manage_taxes, rate):
+ # when
+ variables = {
+ "countryCode": "PL",
+ "updateTaxClassRates": [
+ {"rate": rate},
+ ],
+ }
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxCountryConfigurationUpdate"]
+ assert not data["errors"]
+ assert len(data["taxCountryConfiguration"]["taxClassCountryRates"]) == 1
+
+ response_data = []
+ for item in data["taxCountryConfiguration"]["taxClassCountryRates"]:
+ response_data.append({"rate": item["rate"], "id": None})
+
+ assert {"rate": rate, "id": None} in response_data
+
+
+def test_delete_default_country_rate(staff_api_client, permission_manage_taxes):
+ # given
+ default_rate = TaxClassCountryRate.objects.create(country="PL", rate=0)
+
+ # when
+ variables = {
+ "countryCode": "PL",
+ "updateTaxClassRates": [
+ {"rate": None},
+ ],
+ }
+ staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ with pytest.raises(TaxClassCountryRate.DoesNotExist):
+ default_rate.refresh_from_db()
+
+
+def test_update_default_country_rate_throws_error_with_multiple_rates(
+ staff_api_client, permission_manage_taxes
+):
+ # when
+ variables = {
+ "countryCode": "PL",
+ "updateTaxClassRates": [{"rate": 23}, {"rate": 25}],
+ }
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxCountryConfigurationUpdate"]
+ assert data["errors"]
+ code = TaxCountryConfigurationUpdateErrorCode.ONLY_ONE_DEFAULT_COUNTRY_RATE_ALLOWED
+ assert data["errors"][0]["code"] == code.name
+
+
+def test_validate_negative_rates(staff_api_client, permission_manage_taxes):
+ # given
+ tax_class_1 = TaxClass.objects.create(name="Books")
+ tax_class_2 = TaxClass.objects.create(name="Accessories")
+
+ id_1 = graphene.Node.to_global_id("TaxClass", tax_class_1.pk)
+ id_2 = graphene.Node.to_global_id("TaxClass", tax_class_2.pk)
+
+ # when
+ variables = {
+ "countryCode": "PL",
+ "updateTaxClassRates": [
+ {"rate": -1},
+ {"taxClassId": id_1, "rate": -1},
+ {"taxClassId": id_2, "rate": 0},
+ ],
+ }
+ response = staff_api_client.post_graphql(
+ MUTATION, variables, permissions=[permission_manage_taxes]
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxCountryConfigurationUpdate"]
+ assert data["errors"]
+ code = TaxCountryConfigurationUpdateErrorCode.CANNOT_CREATE_NEGATIVE_RATE
+ assert data["errors"][0]["code"] == code.name
+ assert len(data["errors"][0]["taxClassIds"]) == 1
+ assert id_1 in data["errors"][0]["taxClassIds"]
diff --git a/saleor/plugins/vatlayer/tests/__init__.py b/saleor/graphql/tax/tests/queries/__init__.py
similarity index 100%
rename from saleor/plugins/vatlayer/tests/__init__.py
rename to saleor/graphql/tax/tests/queries/__init__.py
diff --git a/saleor/graphql/tax/tests/queries/test_tax_class.py b/saleor/graphql/tax/tests/queries/test_tax_class.py
new file mode 100644
index 0000000000..c4490703bd
--- /dev/null
+++ b/saleor/graphql/tax/tests/queries/test_tax_class.py
@@ -0,0 +1,127 @@
+import graphene
+
+from .....tax.models import TaxClass
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_CLASS_FRAGMENT
+
+QUERY = (
+ """
+ query TaxClass($id: ID!) {
+ taxClass(id: $id) {
+ ...TaxClass
+ }
+ }
+ """
+ + TAX_CLASS_FRAGMENT
+)
+
+
+def _test_field_resolvers(tax_class: TaxClass, data: dict):
+ country_rates = tax_class.country_rates.all()
+ country_rate = country_rates[0]
+ assert data["id"] == graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ assert data["name"] == tax_class.name
+ assert len(data["countries"]) == len(country_rates)
+ assert country_rate
+ assert data["countries"][0]["country"]["code"] == country_rate.country.code
+ assert data["countries"][0]["rate"] == country_rate.rate
+
+
+def test_tax_class_query_no_permissions(user_api_client):
+ # given
+ tax_class = TaxClass.objects.first()
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {"id": id}
+
+ # when
+ response = user_api_client.post_graphql(QUERY, variables)
+
+ # then
+ assert_no_permission(response)
+
+
+def test_tax_class_query_staff_user(staff_api_client, default_tax_class):
+ # given
+ tax_class = default_tax_class
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {"id": id}
+
+ # when
+ response = staff_api_client.post_graphql(QUERY, variables)
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClass"]
+ _test_field_resolvers(tax_class, data)
+
+
+def test_tax_class_query_app(app_api_client, default_tax_class):
+ # given
+ tax_class = default_tax_class
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {"id": id}
+
+ # when
+ response = app_api_client.post_graphql(QUERY, variables)
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClass"]
+ _test_field_resolvers(tax_class, data)
+
+
+TAX_CLASS_PRIVATE_METADATA_QUERY = """
+ query TaxClass($id: ID!) {
+ taxClass(id: $id) {
+ id
+ privateMetadata {
+ key
+ value
+ }
+ }
+ }
+"""
+
+
+def test_tax_class_private_metadata_requires_manage_taxes_app(
+ app_api_client, default_tax_class, permission_manage_taxes
+):
+ # given
+ tax_class = default_tax_class
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {"id": id}
+
+ # when
+ response = app_api_client.post_graphql(
+ TAX_CLASS_PRIVATE_METADATA_QUERY,
+ variables,
+ permissions=[permission_manage_taxes],
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClass"]
+ assert data["id"] == graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ assert data["privateMetadata"]
+
+
+def test_tax_class_private_metadata_requires_manage_taxes_staff_user(
+ staff_api_client, default_tax_class, permission_manage_taxes
+):
+ # given
+ tax_class = default_tax_class
+ id = graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ variables = {"id": id}
+
+ # when
+ response = staff_api_client.post_graphql(
+ TAX_CLASS_PRIVATE_METADATA_QUERY,
+ variables,
+ permissions=[permission_manage_taxes],
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxClass"]
+ assert data["id"] == graphene.Node.to_global_id("TaxClass", tax_class.pk)
+ assert data["privateMetadata"]
diff --git a/saleor/graphql/tax/tests/queries/test_tax_classes.py b/saleor/graphql/tax/tests/queries/test_tax_classes.py
new file mode 100644
index 0000000000..fa057c07ef
--- /dev/null
+++ b/saleor/graphql/tax/tests/queries/test_tax_classes.py
@@ -0,0 +1,89 @@
+import graphene
+import pytest
+
+from .....tax.models import TaxClass
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_CLASS_FRAGMENT
+
+QUERY = (
+ """
+ query TaxClasses($sortBy: TaxClassSortingInput, $filter: TaxClassFilterInput) {
+ taxClasses(first: 100, sortBy: $sortBy, filter: $filter) {
+ totalCount
+ edges {
+ node {
+ ...TaxClass
+ }
+ }
+ }
+ }
+ """
+ + TAX_CLASS_FRAGMENT
+)
+
+
+def test_tax_classes_query_no_permissions(user_api_client):
+ # when
+ response = user_api_client.post_graphql(QUERY, {}, permissions=[])
+
+ # then
+ assert_no_permission(response)
+
+
+def test_tax_classes_query_staff_user(staff_api_client):
+ # given
+ total_count = TaxClass.objects.count()
+
+ # when
+ response = staff_api_client.post_graphql(QUERY, {})
+
+ # then
+ content = get_graphql_content(response)
+ edges = content["data"]["taxClasses"]["edges"]
+ assert content["data"]["taxClasses"]["totalCount"] == total_count
+ assert len(edges) == total_count
+ assert edges[0]["node"]
+
+
+def test_tax_classes_query_app(app_api_client):
+ # given
+ total_count = TaxClass.objects.count()
+
+ # when
+ response = app_api_client.post_graphql(QUERY, {})
+
+ # then
+ content = get_graphql_content(response)
+ edges = content["data"]["taxClasses"]["edges"]
+ assert content["data"]["taxClasses"]["totalCount"] == total_count
+ assert len(edges) == total_count
+ assert edges[0]["node"]
+
+
+def test_tax_classes_filter_by_ids(staff_api_client):
+ # given
+ id = graphene.Node.to_global_id("TaxClass", TaxClass.objects.first().pk)
+ ids = [id]
+
+ # when
+ response = staff_api_client.post_graphql(QUERY, {"filter": {"ids": ids}})
+
+ # then
+ content = get_graphql_content(response)
+ edges = content["data"]["taxClasses"]["edges"]
+ assert len(edges) == 1
+ assert edges[0]["node"]["id"] == id
+
+
[email protected]("country, count", [("PL", 1), ("US", 0)])
+def test_tax_classes_filter_by_countries(country, count, staff_api_client):
+ # given
+ filter = {"filter": {"countries": [country]}}
+
+ # when
+ response = staff_api_client.post_graphql(QUERY, filter)
+
+ # then
+ content = get_graphql_content(response)
+ edges = content["data"]["taxClasses"]["edges"]
+ assert len(edges) == count
diff --git a/saleor/graphql/tax/tests/queries/test_tax_configuration.py b/saleor/graphql/tax/tests/queries/test_tax_configuration.py
new file mode 100644
index 0000000000..73297b2699
--- /dev/null
+++ b/saleor/graphql/tax/tests/queries/test_tax_configuration.py
@@ -0,0 +1,121 @@
+import graphene
+
+from saleor.tax.models import TaxConfiguration
+
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_CONFIGURATION_FRAGMENT
+
+QUERY = (
+ """
+ query TaxConfiguration($id: ID!) {
+ taxConfiguration(id: $id) {
+ ...TaxConfiguration
+ }
+ }
+ """
+ + TAX_CONFIGURATION_FRAGMENT
+)
+
+
+def _test_field_resolvers(tax_configuration: TaxConfiguration, data: dict):
+ country_exceptions = tax_configuration.country_exceptions.all()
+ country_exception = country_exceptions[0]
+ assert data["id"] == graphene.Node.to_global_id(
+ "TaxConfiguration", tax_configuration.pk
+ )
+ assert data["chargeTaxes"] == tax_configuration.charge_taxes
+ assert data["displayGrossPrices"] == tax_configuration.display_gross_prices
+ assert data["pricesEnteredWithTax"] == tax_configuration.prices_entered_with_tax
+ assert len(data["countries"]) == len(country_exceptions)
+ assert data["countries"][0]["country"]["code"] == country_exception.country.code
+ assert data["countries"][0]["chargeTaxes"] == country_exception.charge_taxes
+ assert (
+ data["countries"][0]["displayGrossPrices"]
+ == country_exception.display_gross_prices
+ )
+
+
+def test_tax_configuration_query_no_permissions(channel_USD, user_api_client):
+ # given
+ id = graphene.Node.to_global_id(
+ "TaxConfiguration", channel_USD.tax_configuration.pk
+ )
+ variables = {"id": id}
+
+ # when
+ response = user_api_client.post_graphql(QUERY, variables, permissions=[])
+
+ # then
+ assert_no_permission(response)
+
+
+def test_tax_configuration_query_staff_user(channel_USD, staff_api_client):
+ # given
+ id = graphene.Node.to_global_id(
+ "TaxConfiguration", channel_USD.tax_configuration.pk
+ )
+ variables = {"id": id}
+
+ # when
+ response = staff_api_client.post_graphql(QUERY, variables)
+
+ # then
+ content = get_graphql_content(response)
+ _test_field_resolvers(
+ channel_USD.tax_configuration, content["data"]["taxConfiguration"]
+ )
+
+
+def test_tax_configuration_query_app(channel_USD, app_api_client):
+ # given
+ id = graphene.Node.to_global_id(
+ "TaxConfiguration", channel_USD.tax_configuration.pk
+ )
+ variables = {"id": id}
+
+ # when
+ response = app_api_client.post_graphql(QUERY, variables)
+
+ # then
+ content = get_graphql_content(response)
+ _test_field_resolvers(
+ channel_USD.tax_configuration, content["data"]["taxConfiguration"]
+ )
+
+
+TAX_CONFIGURATION_PRIVATE_METADATA_QUERY = """
+ query TaxConfiguration($id: ID!) {
+ taxConfiguration(id: $id) {
+ id
+ privateMetadata {
+ key
+ value
+ }
+ }
+ }
+"""
+
+
+def test_tax_class_private_metadata_requires_manage_taxes_app(
+ app_api_client, channel_USD, permission_manage_taxes
+):
+ # given
+ id = graphene.Node.to_global_id(
+ "TaxConfiguration", channel_USD.tax_configuration.pk
+ )
+ variables = {"id": id}
+
+ # when
+ response = app_api_client.post_graphql(
+ TAX_CONFIGURATION_PRIVATE_METADATA_QUERY,
+ variables,
+ permissions=[permission_manage_taxes],
+ )
+
+ # then
+ content = get_graphql_content(response)
+ data = content["data"]["taxConfiguration"]
+ assert data["id"] == graphene.Node.to_global_id(
+ "TaxConfiguration", channel_USD.tax_configuration.pk
+ )
+ assert data["privateMetadata"]
diff --git a/saleor/graphql/tax/tests/queries/test_tax_configurations.py b/saleor/graphql/tax/tests/queries/test_tax_configurations.py
new file mode 100644
index 0000000000..6ae1810863
--- /dev/null
+++ b/saleor/graphql/tax/tests/queries/test_tax_configurations.py
@@ -0,0 +1,76 @@
+import graphene
+
+from .....tax.models import TaxConfiguration
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_CONFIGURATION_FRAGMENT
+
+QUERY = (
+ """
+ query TaxConfiguration($filter: TaxConfigurationFilterInput) {
+ taxConfigurations(first: 100, filter: $filter) {
+ totalCount
+ edges {
+ node {
+ ...TaxConfiguration
+ }
+ }
+ }
+ }
+ """
+ + TAX_CONFIGURATION_FRAGMENT
+)
+
+
+def test_tax_configurations_query_no_permissions(channel_USD, user_api_client):
+ # when
+ response = user_api_client.post_graphql(QUERY, {}, permissions=[])
+
+ # then
+ assert_no_permission(response)
+
+
+def test_tax_configurations_query_staff_user(channel_USD, staff_api_client):
+ # given
+ total_count = TaxConfiguration.objects.count()
+
+ # when
+ response = staff_api_client.post_graphql(QUERY, {})
+
+ # then
+ content = get_graphql_content(response)
+ edges = content["data"]["taxConfigurations"]["edges"]
+ assert content["data"]["taxConfigurations"]["totalCount"] == total_count
+ assert len(edges) == total_count
+ assert edges[0]["node"]
+
+
+def test_tax_configurations_query_app(channel_USD, app_api_client):
+ # given
+ total_count = TaxConfiguration.objects.count()
+
+ # when
+ response = app_api_client.post_graphql(QUERY, {})
+
+ # then
+ content = get_graphql_content(response)
+ edges = content["data"]["taxConfigurations"]["edges"]
+ assert content["data"]["taxConfigurations"]["totalCount"] == total_count
+ assert len(edges) == total_count
+ assert edges[0]["node"]
+
+
+def test_tax_configurations_filter(channel_USD, staff_api_client):
+ # given
+ id = graphene.Node.to_global_id(
+ "TaxConfiguration", TaxConfiguration.objects.first().pk
+ )
+ ids = [id]
+
+ # when
+ response = staff_api_client.post_graphql(QUERY, {"ids": ids})
+
+ # then
+ content = get_graphql_content(response)
+ edges = content["data"]["taxConfigurations"]["edges"]
+ assert len(edges) == 1
+ assert edges[0]["node"]["id"] == id
diff --git a/saleor/graphql/tax/tests/queries/test_tax_country_configuration.py b/saleor/graphql/tax/tests/queries/test_tax_country_configuration.py
new file mode 100644
index 0000000000..ba6841e3aa
--- /dev/null
+++ b/saleor/graphql/tax/tests/queries/test_tax_country_configuration.py
@@ -0,0 +1,84 @@
+from typing import TYPE_CHECKING
+
+import graphene
+
+from saleor.tax.models import TaxClassCountryRate
+
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_COUNTRY_CONFIGURATION_FRAGMENT
+
+if TYPE_CHECKING:
+ from django.db.models import QuerySet
+
+
+QUERY = (
+ """
+ query TaxCountryConfiguration($countryCode: CountryCode!) {
+ taxCountryConfiguration(countryCode: $countryCode) {
+ ...TaxCountryConfiguration
+ }
+ }
+ """
+ + TAX_COUNTRY_CONFIGURATION_FRAGMENT
+)
+
+
+def _test_field_resolvers(
+ country_code, country_rates: "QuerySet[TaxClassCountryRate]", data: dict
+):
+ assert data["country"]["code"] == country_code
+ assert data["taxClassCountryRates"]
+ assert len(data["taxClassCountryRates"]) == len(country_rates)
+
+ for country_rate in country_rates:
+ expected_rate_data = {
+ "rate": country_rate.rate,
+ "taxClass": {
+ "id": graphene.Node.to_global_id("TaxClass", country_rate.tax_class.pk),
+ "name": country_rate.tax_class.name,
+ },
+ }
+ assert expected_rate_data in data["taxClassCountryRates"]
+
+
+def test_tax_country_configuration_query_no_permissions(user_api_client):
+ # given
+ country_code = "PL"
+
+ # when
+ response = user_api_client.post_graphql(
+ QUERY, {"countryCode": country_code}, permissions=[]
+ )
+
+ # then
+ assert_no_permission(response)
+
+
+def test_tax_country_configuration_query_staff_user(staff_api_client):
+ # given
+ country_code = "PL"
+ country_rates = TaxClassCountryRate.objects.filter(country="PL")
+
+ # when
+ response = staff_api_client.post_graphql(QUERY, {"countryCode": country_code})
+
+ # then
+ content = get_graphql_content(response)
+ _test_field_resolvers(
+ country_code, country_rates, content["data"]["taxCountryConfiguration"]
+ )
+
+
+def test_tax_country_configuration_query_app(app_api_client):
+ # given
+ country_code = "PL"
+ country_rates = TaxClassCountryRate.objects.filter(country="PL")
+
+ # when
+ response = app_api_client.post_graphql(QUERY, {"countryCode": country_code})
+
+ # then
+ content = get_graphql_content(response)
+ _test_field_resolvers(
+ country_code, country_rates, content["data"]["taxCountryConfiguration"]
+ )
diff --git a/saleor/graphql/tax/tests/queries/test_tax_country_configurations.py b/saleor/graphql/tax/tests/queries/test_tax_country_configurations.py
new file mode 100644
index 0000000000..46ac4fc1d9
--- /dev/null
+++ b/saleor/graphql/tax/tests/queries/test_tax_country_configurations.py
@@ -0,0 +1,46 @@
+from saleor.tax.models import TaxClassCountryRate
+
+from ....tests.utils import assert_no_permission, get_graphql_content
+from ..fragments import TAX_COUNTRY_CONFIGURATION_FRAGMENT
+
+QUERY = (
+ """
+ query TaxCountryConfigurations {
+ taxCountryConfigurations {
+ ...TaxCountryConfiguration
+ }
+ }
+ """
+ + TAX_COUNTRY_CONFIGURATION_FRAGMENT
+)
+
+
+def _test_field_resolvers(data: dict):
+ configured_countries = set(TaxClassCountryRate.objects.values_list("country"))
+ assert len(data["taxCountryConfigurations"]) == len(configured_countries)
+
+
+def test_tax_country_configurations_query_no_permissions(user_api_client):
+ # when
+ response = user_api_client.post_graphql(QUERY, {}, permissions=[])
+
+ # then
+ assert_no_permission(response)
+
+
+def test_tax_country_configurations_query_staff_user(staff_api_client):
+ # when
+ response = staff_api_client.post_graphql(QUERY, {})
+
+ # then
+ content = get_graphql_content(response)
+ _test_field_resolvers(content["data"])
+
+
+def test_tax_country_configurations_query_app(app_api_client):
+ # when
+ response = app_api_client.post_graphql(QUERY, {})
+
+ # then
+ content = get_graphql_content(response)
+ _test_field_resolvers(content["data"])
diff --git a/saleor/graphql/tax/types.py b/saleor/graphql/tax/types.py
new file mode 100644
index 0000000000..a30d7d9c96
--- /dev/null
+++ b/saleor/graphql/tax/types.py
@@ -0,0 +1,194 @@
+import graphene
+
+from ...tax import models
+from ..channel.dataloaders import ChannelByIdLoader
+from ..channel.types import Channel
+from ..core.connection import CountableConnection
+from ..core.descriptions import ADDED_IN_39, PREVIEW_FEATURE
+from ..core.types import CountryDisplay, ModelObjectType, NonNullList
+from ..meta.types import ObjectWithMetadata
+from .dataloaders import (
+ TaxClassByIdLoader,
+ TaxClassCountryRateByTaxClassIDLoader,
+ TaxConfigurationPerCountryByTaxConfigurationIDLoader,
+)
+from .enums import TaxCalculationStrategy
+
+
+class TaxConfiguration(ModelObjectType):
+ channel = graphene.Field(
+ Channel,
+ description="A channel to which the tax configuration applies to.",
+ required=True,
+ )
+ charge_taxes = graphene.Boolean(
+ description="Determines whether taxes are charged in the given channel.",
+ required=True,
+ )
+ tax_calculation_strategy = graphene.Field(
+ TaxCalculationStrategy,
+ required=False,
+ description=(
+ "The default strategy to use for tax calculation in the given channel. "
+ "Taxes can be calculated either using user-defined flat rates or with "
+ "a tax app. Empty value means that no method is selected and taxes are "
+ "not calculated."
+ ),
+ )
+ display_gross_prices = graphene.Boolean(
+ description=(
+ "Determines whether prices displayed in a storefront should include taxes."
+ ),
+ required=True,
+ )
+ prices_entered_with_tax = graphene.Boolean(
+ description="Determines whether prices are entered with the tax included.",
+ required=True,
+ )
+ countries = NonNullList(
+ "saleor.graphql.tax.types.TaxConfigurationPerCountry",
+ required=True,
+ description="List of country-specific exceptions in tax configuration.",
+ )
+
+ class Meta:
+ description = (
+ "Channel-specific tax configuration." + ADDED_IN_39 + PREVIEW_FEATURE
+ )
+ interfaces = [graphene.relay.Node, ObjectWithMetadata]
+ model = models.TaxConfiguration
+
+ @staticmethod
+ def resolve_channel(root: models.TaxConfiguration, info):
+ return ChannelByIdLoader(info.context).load(root.channel_id)
+
+ @staticmethod
+ def resolve_countries(root: models.TaxConfiguration, info):
+ return TaxConfigurationPerCountryByTaxConfigurationIDLoader(info.context).load(
+ root.pk
+ )
+
+
+class TaxConfigurationCountableConnection(CountableConnection):
+ class Meta:
+ node = TaxConfiguration
+
+
+class TaxConfigurationPerCountry(ModelObjectType):
+ country = graphene.Field(
+ CountryDisplay,
+ required=True,
+ description="Country in which this configuration applies.",
+ )
+ charge_taxes = graphene.Boolean(
+ description="Determines whether taxes are charged in this country.",
+ required=True,
+ )
+ tax_calculation_strategy = graphene.Field(
+ TaxCalculationStrategy,
+ required=False,
+ description=(
+ "A country-specific strategy to use for tax calculation. Taxes can be "
+ "calculated either using user-defined flat rates or with a tax app. If "
+ "not provided, use the value from the channel's tax configuration."
+ ),
+ )
+ display_gross_prices = graphene.Boolean(
+ description=(
+ "Determines whether prices displayed in a storefront should include taxes "
+ "for this country."
+ ),
+ required=True,
+ )
+
+ class Meta:
+ description = (
+ "Country-specific exceptions of a channel's tax configuration."
+ + ADDED_IN_39
+ + PREVIEW_FEATURE
+ )
+ interface = [graphene.relay.Node]
+ model = models.TaxConfigurationPerCountry
+
+ @staticmethod
+ def resolve_country(root: models.TaxConfigurationPerCountry, _info):
+ return CountryDisplay(code=root.country.code, country=root.country.name)
+
+
+class TaxClass(ModelObjectType):
+ name = graphene.String(description="Name of the tax class.", required=True)
+ countries = NonNullList(
+ "saleor.graphql.tax.types.TaxClassCountryRate",
+ required=True,
+ description="Country-specific tax rates for this tax class.",
+ )
+
+ class Meta:
+ description = (
+ "Tax class is a named object used to define tax rates per country. Tax "
+ "class can be assigned to product types, products and shipping methods to "
+ "define their tax rates." + ADDED_IN_39 + PREVIEW_FEATURE
+ )
+ interfaces = [graphene.relay.Node, ObjectWithMetadata]
+ model = models.TaxClass
+
+ @staticmethod
+ def resolve_countries(root: models.TaxConfiguration, info):
+ return TaxClassCountryRateByTaxClassIDLoader(info.context).load(root.pk)
+
+
+class TaxClassCountableConnection(CountableConnection):
+ class Meta:
+ node = TaxClass
+
+
+class TaxClassCountryRate(ModelObjectType):
+ country = graphene.Field(
+ CountryDisplay,
+ required=True,
+ description="Country in which this tax rate applies.",
+ )
+ rate = graphene.Float(required=True, description="Tax rate value.")
+ tax_class = graphene.Field(
+ TaxClass, description="Related tax class.", required=False
+ )
+
+ class Meta:
+ description = (
+ "Tax rate for a country. When tax class is null, it represents the default "
+ "tax rate for that country; otherwise it's a country tax rate specific to "
+ "the given tax class." + ADDED_IN_39 + PREVIEW_FEATURE
+ )
+ model = models.TaxClassCountryRate
+
+ @staticmethod
+ def resolve_country(root: models.TaxConfigurationPerCountry, _info):
+ return CountryDisplay(code=root.country.code, country=root.country.name)
+
+ @staticmethod
+ def resolve_tax_class(root, info):
+ return (
+ TaxClassByIdLoader(info.context).load(root.tax_class_id)
+ if root.tax_class_id
+ else None
+ )
+
+
+class TaxCountryConfiguration(graphene.ObjectType):
+ country = graphene.Field(
+ CountryDisplay,
+ required=True,
+ description="A country for which tax class rates are grouped.",
+ )
+ tax_class_country_rates = NonNullList(
+ TaxClassCountryRate, description="List of tax class rates.", required=True
+ )
+
+ class Meta:
+ description = (
+ "Tax class rates grouped by country." + ADDED_IN_39 + PREVIEW_FEATURE
+ )
+
+ @staticmethod
+ def resolve_country(root, info, **kwargs):
+ return CountryDisplay(code=root.country.code, country=root.country.name)
diff --git a/saleor/order/calculations.py b/saleor/order/calculations.py
index ae997b54bb..da196ebd60 100644
--- a/saleor/order/calculations.py
+++ b/saleor/order/calculations.py
@@ -1,24 +1,27 @@
from decimal import Decimal
-from typing import TYPE_CHECKING, Iterable, Optional, Tuple, cast
+from typing import Iterable, Optional, Tuple, cast
from django.db import transaction
from django.db.models import prefetch_related_objects
from prices import Money, TaxedMoney
-from ..checkout import base_calculations
from ..core.prices import quantize_price
from ..core.taxes import TaxData, TaxError, zero_taxed_money
-from ..order import base_calculations as base_order_calculations
+from ..order import base_calculations
from ..payment.model_helpers import get_subtotal
from ..plugins.manager import PluginsManager
-from ..site.models import Site
+from ..tax import TaxCalculationStrategy
+from ..tax.calculations.order import update_order_prices_with_flat_rates
+from ..tax.utils import (
+ calculate_tax_rate,
+ get_charge_taxes_for_order,
+ get_tax_calculation_strategy_for_order,
+ normalize_tax_rate_for_db,
+)
from . import ORDER_EDITABLE_STATUS
from .interface import OrderTaxedPricesData
from .models import Order, OrderLine
-if TYPE_CHECKING:
- from ..site.models import SiteSettings
-
def _recalculate_order_prices(
manager: PluginsManager, order: Order, lines: Iterable[OrderLine]
@@ -53,10 +56,6 @@ def _recalculate_order_prices(
except TaxError:
pass
- # Plugins like Vatlayer don't implement Order line calculation instead of implement
- # `update_taxes_for_order_lines`
- manager.update_taxes_for_order_lines(order, list(lines))
-
try:
order.shipping_price = manager.calculate_order_shipping(order)
order.shipping_tax_rate = manager.get_order_shipping_tax_rate(
@@ -72,66 +71,67 @@ def _get_order_base_prices(order, lines):
currency = order.currency
undiscounted_subtotal = zero_taxed_money(currency)
+ # Calculate order lines prices.
for line in lines:
variant = line.variant
- if variant:
- try:
- line_unit_default = OrderTaxedPricesData(
- undiscounted_price=TaxedMoney(
- line.undiscounted_base_unit_price,
- line.undiscounted_base_unit_price,
- ),
- price_with_discounts=TaxedMoney(
- line.base_unit_price,
- line.base_unit_price,
- ),
- )
- line_unit_default.price_with_discounts = quantize_price(
- line_unit_default.price_with_discounts, currency
- )
- line_unit_default.undiscounted_price = quantize_price(
- line_unit_default.undiscounted_price, currency
- )
+ if not variant:
+ continue
+
+ line_unit_default = OrderTaxedPricesData(
+ undiscounted_price=TaxedMoney(
+ line.undiscounted_base_unit_price,
+ line.undiscounted_base_unit_price,
+ ),
+ price_with_discounts=TaxedMoney(
+ line.base_unit_price,
+ line.base_unit_price,
+ ),
+ )
+ line_unit_default.price_with_discounts = quantize_price(
+ line_unit_default.price_with_discounts, currency
+ )
+ line_unit_default.undiscounted_price = quantize_price(
+ line_unit_default.undiscounted_price, currency
+ )
- line.undiscounted_unit_price = line_unit_default.undiscounted_price
- line.unit_price = line_unit_default.price_with_discounts
+ line.undiscounted_unit_price = line_unit_default.undiscounted_price
+ line.unit_price = line_unit_default.price_with_discounts
- line_total = base_order_calculations.base_order_line_total(line)
- line_total.price_with_discounts = quantize_price(
- line_total.price_with_discounts, currency
- )
- line_total.undiscounted_price = quantize_price(
- line_total.undiscounted_price, currency
- )
+ line_total = base_calculations.base_order_line_total(line)
+ line_total.price_with_discounts = quantize_price(
+ line_total.price_with_discounts, currency
+ )
+ line_total.undiscounted_price = quantize_price(
+ line_total.undiscounted_price, currency
+ )
- line.undiscounted_total_price = line_total.undiscounted_price
- undiscounted_subtotal += line_total.undiscounted_price
- line.total_price = line_total.price_with_discounts
+ line.undiscounted_total_price = line_total.undiscounted_price
+ undiscounted_subtotal += line_total.undiscounted_price
+ line.total_price = line_total.price_with_discounts
- line.tax_rate = base_calculations.base_tax_rate(line.unit_price)
- except TaxError:
- pass
+ line.tax_rate = calculate_tax_rate(line.unit_price)
- try:
- shipping_price = order.base_shipping_price
- order.shipping_price = quantize_price(
- TaxedMoney(net=shipping_price, gross=shipping_price),
- shipping_price.currency,
- )
- order.shipping_tax_rate = base_calculations.base_tax_rate(order.shipping_price)
- except TaxError:
- pass
+ # Calculate shipping price.
+ shipping_price = order.base_shipping_price
+ order.shipping_price = quantize_price(
+ TaxedMoney(net=shipping_price, gross=shipping_price),
+ shipping_price.currency,
+ )
+ order.shipping_tax_rate = calculate_tax_rate(order.shipping_price)
+ # Calculate order total.
order.undiscounted_total = undiscounted_subtotal + order.shipping_price
-
- total = base_order_calculations.base_order_total(order, lines)
+ total = base_calculations.base_order_total(order, lines)
order.total = quantize_price(TaxedMoney(total, total), currency)
def _apply_tax_data(
- order: Order, lines: Iterable[OrderLine], tax_data: TaxData
+ order: Order, lines: Iterable[OrderLine], tax_data: Optional[TaxData]
) -> None:
"""Apply all prices from tax data to order and order lines."""
+ if not tax_data:
+ return
+
currency = order.currency
shipping_price = TaxedMoney(
net=Money(tax_data.shipping_price_net_amount, currency),
@@ -139,10 +139,7 @@ def _apply_tax_data(
)
order.shipping_price = shipping_price
- # We use % value in tax app input but on database we store
- # it as a fractional value.
- # e.g Tax app sends `10%` as `10` but in database it's stored as `0.1`
- order.shipping_tax_rate = tax_data.shipping_tax_rate / 100
+ order.shipping_tax_rate = normalize_tax_rate_for_db(tax_data.shipping_tax_rate)
subtotal = zero_taxed_money(order.currency)
for (order_line, tax_line) in zip(lines, tax_data.lines):
@@ -152,10 +149,7 @@ def _apply_tax_data(
)
order_line.total_price = line_total_price
order_line.unit_price = line_total_price / order_line.quantity
- # We use % value in tax app input but on database we store
- # it as a fractional value.
- # e.g Tax app sends `10%` as `10` but in database it's stored as `0.1`
- order_line.tax_rate = tax_line.tax_rate / 100
+ order_line.tax_rate = normalize_tax_rate_for_db(tax_line.tax_rate)
subtotal += line_total_price
order.total = shipping_price + subtotal
@@ -166,7 +160,6 @@ def fetch_order_prices_if_expired(
manager: PluginsManager,
lines: Optional[Iterable[OrderLine]] = None,
force_update: bool = False,
- site_settings: "SiteSettings" = None,
) -> Tuple[Order, Optional[Iterable[OrderLine]]]:
"""Fetch order prices with taxes.
@@ -182,8 +175,11 @@ def fetch_order_prices_if_expired(
if not force_update and not order.should_refresh_prices:
return order, lines
- if site_settings is None:
- site_settings = Site.objects.get_current().settings
+ tax_configuration = order.channel.tax_configuration
+ tax_calculation_strategy = get_tax_calculation_strategy_for_order(order)
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
+ charge_taxes = get_charge_taxes_for_order(order)
+ should_charge_tax = charge_taxes and not order.tax_exemption
if lines is None:
lines = list(order.lines.select_related("variant__product__product_type"))
@@ -192,18 +188,29 @@ def fetch_order_prices_if_expired(
order.should_refresh_prices = False
- if order.tax_exemption and not site_settings.include_taxes_in_prices:
- _get_order_base_prices(order, lines)
- else:
- _recalculate_order_prices(manager, order, lines)
-
- tax_data = manager.get_taxes_for_order(order)
+ if prices_entered_with_tax:
+ # If prices are entered with tax, we need to always calculate it anyway, to
+ # display the tax rate to the user.
+ _calculate_and_add_tax(
+ tax_calculation_strategy, order, lines, manager, prices_entered_with_tax
+ )
- if tax_data:
- _apply_tax_data(order, lines, tax_data)
+ if not should_charge_tax:
+ # If charge_taxes is disabled or order is exempt from taxes, remove the
+ # tax from the original gross prices.
+ _remove_tax(order, lines)
- if order.tax_exemption and site_settings.include_taxes_in_prices:
- _exempt_taxes_in_order(order, lines)
+ else:
+ # Prices are entered without taxes.
+ if should_charge_tax:
+ # Calculate taxes if charge_taxes is enabled and order is not exempt
+ # from taxes.
+ _calculate_and_add_tax(
+ tax_calculation_strategy, order, lines, manager, prices_entered_with_tax
+ )
+ else:
+ # Calculate net prices without taxes.
+ _get_order_base_prices(order, lines)
with transaction.atomic(savepoint=False):
order.save(
@@ -235,7 +242,22 @@ def fetch_order_prices_if_expired(
return order, lines
-def _exempt_taxes_in_order(order, lines):
+def _calculate_and_add_tax(
+ tax_calculation_strategy: str,
+ order: "Order",
+ lines: Iterable["OrderLine"],
+ manager: "PluginsManager",
+ prices_entered_with_tax: bool,
+):
+ if tax_calculation_strategy == TaxCalculationStrategy.TAX_APP:
+ _recalculate_order_prices(manager, order, lines)
+ tax_data = manager.get_taxes_for_order(order)
+ _apply_tax_data(order, lines, tax_data)
+ elif tax_calculation_strategy == TaxCalculationStrategy.FLAT_RATES:
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+
+def _remove_tax(order, lines):
order.total_gross_amount = order.total_net_amount
order.undiscounted_total_gross_amount = order.undiscounted_total_net_amount
order.shipping_price_gross_amount = order.shipping_price_net_amount
@@ -318,7 +340,7 @@ def order_line_tax_rate(
manager: PluginsManager,
lines: Optional[Iterable[OrderLine]] = None,
force_update: bool = False,
-) -> Decimal:
+) -> Optional[Decimal]:
"""Return the tax rate of provided line.
It takes into account all plugins.
@@ -352,7 +374,7 @@ def order_shipping_tax_rate(
manager: PluginsManager,
lines: Optional[Iterable[OrderLine]] = None,
force_update: bool = False,
-) -> Decimal:
+) -> Optional[Decimal]:
"""Return the shipping tax rate of the order.
It takes into account all plugins.
diff --git a/saleor/order/migrations/0159_order_shipping_tax_class_and_more.py b/saleor/order/migrations/0159_order_shipping_tax_class_and_more.py
new file mode 100644
index 0000000000..3e7d4fb8e0
--- /dev/null
+++ b/saleor/order/migrations/0159_order_shipping_tax_class_and_more.py
@@ -0,0 +1,100 @@
+# Generated by Django 4.0.7 on 2022-10-20 11:55
+
+from django.db import migrations, models
+import django.db.models.deletion
+import saleor.core.utils.json_serializer
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("tax", "0005_migrate_vatlayer"),
+ ("order", "0158_migrate_base_shipping_price_amount"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="order",
+ name="shipping_tax_class",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="tax.taxclass",
+ ),
+ ),
+ migrations.AddField(
+ model_name="order",
+ name="shipping_tax_class_metadata",
+ field=models.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ migrations.AddField(
+ model_name="order",
+ name="shipping_tax_class_name",
+ field=models.CharField(blank=True, max_length=255, null=True),
+ ),
+ migrations.AddField(
+ model_name="order",
+ name="shipping_tax_class_private_metadata",
+ field=models.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ migrations.AddField(
+ model_name="orderline",
+ name="tax_class",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="tax.taxclass",
+ ),
+ ),
+ migrations.AddField(
+ model_name="orderline",
+ name="tax_class_metadata",
+ field=models.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ migrations.AddField(
+ model_name="orderline",
+ name="tax_class_name",
+ field=models.CharField(blank=True, max_length=255, null=True),
+ ),
+ migrations.AddField(
+ model_name="orderline",
+ name="tax_class_private_metadata",
+ field=models.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="order",
+ name="shipping_tax_rate",
+ field=models.DecimalField(
+ blank=True, decimal_places=4, max_digits=5, null=True
+ ),
+ ),
+ migrations.AlterField(
+ model_name="orderline",
+ name="tax_rate",
+ field=models.DecimalField(
+ blank=True, decimal_places=4, max_digits=5, null=True
+ ),
+ ),
+ ]
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 14cee02cf2..6658626d7d 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -214,7 +214,20 @@ class Order(ModelWithMetadata):
amount_field="base_shipping_price_amount", currency_field="currency"
)
shipping_tax_rate = models.DecimalField(
- max_digits=5, decimal_places=4, default=Decimal("0.0")
+ max_digits=5, decimal_places=4, blank=True, null=True
+ )
+ shipping_tax_class = models.ForeignKey(
+ "tax.TaxClass",
+ on_delete=models.SET_NULL,
+ blank=True,
+ null=True,
+ )
+ shipping_tax_class_name = models.CharField(max_length=255, blank=True, null=True)
+ shipping_tax_class_private_metadata = JSONField(
+ blank=True, null=True, default=dict, encoder=CustomJsonEncoder
+ )
+ shipping_tax_class_metadata = JSONField(
+ blank=True, null=True, default=dict, encoder=CustomJsonEncoder
)
# Token of a checkout instance that this order was created from
@@ -286,7 +299,6 @@ class Order(ModelWithMetadata):
Voucher, blank=True, null=True, related_name="+", on_delete=models.SET_NULL
)
gift_cards = models.ManyToManyField(GiftCard, blank=True, related_name="orders")
-
display_gross_prices = models.BooleanField(default=True)
customer_note = models.TextField(blank=True, default="")
weight = MeasurementField(
@@ -612,7 +624,20 @@ class OrderLine(ModelWithMetadata):
)
tax_rate = models.DecimalField(
- max_digits=5, decimal_places=4, default=Decimal("0.0")
+ max_digits=5, decimal_places=4, blank=True, null=True
+ )
+ tax_class = models.ForeignKey(
+ "tax.TaxClass",
+ on_delete=models.SET_NULL,
+ blank=True,
+ null=True,
+ )
+ tax_class_name = models.CharField(max_length=255, blank=True, null=True)
+ tax_class_private_metadata = JSONField(
+ blank=True, null=True, default=dict, encoder=CustomJsonEncoder
+ )
+ tax_class_metadata = JSONField(
+ blank=True, null=True, default=dict, encoder=CustomJsonEncoder
)
# Fulfilled when voucher code was used for product in the line
diff --git a/saleor/order/tests/test_calculations.py b/saleor/order/tests/test_calculations.py
index aacf992e8f..cec68bb229 100644
--- a/saleor/order/tests/test_calculations.py
+++ b/saleor/order/tests/test_calculations.py
@@ -7,7 +7,8 @@ from prices import Money, TaxedMoney
from ...core.prices import quantize_price
from ...core.taxes import TaxData, TaxError, TaxLineData, zero_taxed_money
-from ...plugins.manager import get_plugins_manager
+from ...tax import TaxCalculationStrategy
+from ...tax.calculations.order import update_order_prices_with_flat_rates
from .. import OrderStatus, calculations
from ..interface import OrderTaxedPricesData
@@ -125,22 +126,6 @@ def test_recalculate_order_prices(order_with_lines, order_lines, tax_data):
assert tax_rate == line.tax_rate
-@patch("saleor.plugins.manager.PluginsManager.update_taxes_for_order_lines")
-def test_recalculate_order_prices_calls_update_taxes_for_order_lines(
- mocked_update_taxes_for_order_lines, order_with_lines, order_lines
-):
- # given
- order = order_with_lines
- manager = get_plugins_manager()
- lines = list(order_lines)
-
- # when
- calculations._recalculate_order_prices(manager, order, lines)
-
- # then
- mocked_update_taxes_for_order_lines.assert_called_once_with(order, lines)
-
-
@pytest.mark.parametrize(
"mocked_method_name",
[
@@ -482,6 +467,38 @@ def test_fetch_order_prices_if_expired_plugins(
assert order_line.tax_rate == tax_line.tax_rate
+@patch(
+ "saleor.order.calculations.update_order_prices_with_flat_rates",
+ wraps=update_order_prices_with_flat_rates,
+)
[email protected]("prices_entered_with_tax", [True, False])
+def test_fetch_order_prices_if_expired_flat_rates(
+ mocked_update_order_prices_with_flat_rates,
+ order_with_lines,
+ fetch_kwargs,
+ prices_entered_with_tax,
+):
+ # given
+ order = order_with_lines
+ tc = order.channel.tax_configuration
+ tc.country_exceptions.all().delete()
+ tc.prices_entered_with_tax = prices_entered_with_tax
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.save()
+
+ # when
+ calculations.fetch_order_prices_if_expired(**fetch_kwargs)
+ order.refresh_from_db()
+ line = order.lines.first()
+
+ # then
+ mocked_update_order_prices_with_flat_rates.assert_called_once_with(
+ order, list(order.lines.all()), prices_entered_with_tax
+ )
+ assert line.tax_rate == Decimal("0.2300")
+ assert order.shipping_tax_rate == Decimal("0.2300")
+
+
def test_fetch_order_prices_if_expired_webhooks_success(
plugins_manager,
fetch_kwargs,
@@ -611,7 +628,7 @@ def test_fetch_order_prices_when_tax_exemption_and_include_taxes_in_prices(
def test_fetch_order_prices_when_tax_exemption_and_not_include_taxes_in_prices(
- plugins_manager, fetch_kwargs, order_with_lines, tax_data, site_settings
+ plugins_manager, fetch_kwargs, order_with_lines, tax_data
):
"""Test tax exemption when taxes are not included in prices.
@@ -619,6 +636,12 @@ def test_fetch_order_prices_when_tax_exemption_and_not_include_taxes_in_prices(
tax plugins should be ignored and only net prices should be calculated and returned.
"""
# given
+
+ tc = order_with_lines.channel.tax_configuration
+ tc.prices_entered_with_tax = False
+ tc.save(update_fields=["prices_entered_with_tax"])
+ tc.country_exceptions.all().delete()
+
currency = order_with_lines.currency
discount_amount = Decimal("3.00")
discount_as_money = Money(discount_amount, currency)
@@ -634,9 +657,6 @@ def test_fetch_order_prices_when_tax_exemption_and_not_include_taxes_in_prices(
order_with_lines.tax_exemption = True
order_with_lines.save()
- site_settings.include_taxes_in_prices = False
- site_settings.save(update_fields=["include_taxes_in_prices"])
-
plugins_manager.get_taxes_for_order = Mock(return_value=tax_data)
# when
diff --git a/saleor/order/tests/test_notifications.py b/saleor/order/tests/test_notifications.py
index b25b809abf..d3c977cead 100644
--- a/saleor/order/tests/test_notifications.py
+++ b/saleor/order/tests/test_notifications.py
@@ -399,7 +399,6 @@ def test_send_confirmation_emails_without_addresses_for_payment(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
DigitalContentUrl.objects.create(content=digital_content, line=line)
@@ -453,7 +452,6 @@ def test_send_confirmation_emails_without_addresses_for_order(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
DigitalContentUrl.objects.create(content=digital_content, line=line)
diff --git a/saleor/order/tests/test_order.py b/saleor/order/tests/test_order.py
index 96ee119f3e..51a0df9c46 100644
--- a/saleor/order/tests/test_order.py
+++ b/saleor/order/tests/test_order.py
@@ -95,7 +95,6 @@ def test_add_variant_to_order_adds_line_for_new_variant(
product_translation_fr,
settings,
anonymous_plugins,
- site_settings,
):
order = order_with_lines
variant = product.variants.get()
@@ -109,7 +108,6 @@ def test_add_variant_to_order_adds_line_for_new_variant(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
line = order.lines.last()
@@ -134,7 +132,6 @@ def test_add_variant_to_order_adds_line_for_new_variant_on_sale(
discount_info,
settings,
anonymous_plugins,
- site_settings,
):
order = order_with_lines
variant = product.variants.first()
@@ -150,7 +147,6 @@ def test_add_variant_to_order_adds_line_for_new_variant_on_sale(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
discounts=[discount_info],
)
@@ -181,7 +177,6 @@ def test_add_variant_to_draft_order_adds_line_for_variant_with_price_0(
product_translation_fr,
settings,
anonymous_plugins,
- site_settings,
):
order = order_with_lines
variant = product.variants.get()
@@ -199,7 +194,6 @@ def test_add_variant_to_draft_order_adds_line_for_variant_with_price_0(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
line = order.lines.last()
@@ -216,7 +210,6 @@ def test_add_variant_to_order_not_allocates_stock_for_new_variant(
order_with_lines,
product,
anonymous_plugins,
- site_settings,
):
variant = product.variants.get()
stock = Stock.objects.get(product_variant=variant)
@@ -230,7 +223,6 @@ def test_add_variant_to_order_not_allocates_stock_for_new_variant(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
stock.refresh_from_db()
@@ -238,7 +230,7 @@ def test_add_variant_to_order_not_allocates_stock_for_new_variant(
def test_add_variant_to_order_edits_line_for_existing_variant(
- order_with_lines, anonymous_plugins, site_settings
+ order_with_lines, anonymous_plugins
):
existing_line = order_with_lines.lines.first()
variant = existing_line.variant
@@ -254,7 +246,6 @@ def test_add_variant_to_order_edits_line_for_existing_variant(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
existing_line.refresh_from_db()
@@ -265,7 +256,7 @@ def test_add_variant_to_order_edits_line_for_existing_variant(
def test_add_variant_to_order_not_allocates_stock_for_existing_variant(
- order_with_lines, anonymous_plugins, site_settings
+ order_with_lines, anonymous_plugins
):
existing_line = order_with_lines.lines.first()
variant = existing_line.variant
@@ -283,7 +274,6 @@ def test_add_variant_to_order_not_allocates_stock_for_existing_variant(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
stock.refresh_from_db()
@@ -555,9 +545,7 @@ def test_calculate_order_weight(order_with_lines):
assert calculated_weight == order_weight
-def test_order_weight_add_more_variant(
- order_with_lines, anonymous_plugins, site_settings
-):
+def test_order_weight_add_more_variant(order_with_lines, anonymous_plugins):
variant = order_with_lines.lines.first().variant
line_data = OrderLineData(variant_id=str(variant.id), variant=variant, quantity=2)
@@ -567,7 +555,6 @@ def test_order_weight_add_more_variant(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
order_with_lines.refresh_from_db()
@@ -580,7 +567,6 @@ def test_order_weight_add_new_variant(
order_with_lines,
product,
anonymous_plugins,
- site_settings,
):
variant = product.variants.first()
line_data = OrderLineData(variant_id=str(variant.id), variant=variant, quantity=2)
@@ -591,7 +577,6 @@ def test_order_weight_add_new_variant(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
order_with_lines.refresh_from_db()
@@ -628,7 +613,6 @@ def test_get_order_weight_non_existing_product(
order_with_lines,
product,
anonymous_plugins,
- site_settings,
):
# Removing product should not affect order's weight
order = order_with_lines
@@ -641,7 +625,6 @@ def test_get_order_weight_non_existing_product(
user=None,
app=None,
manager=anonymous_plugins,
- site_settings=site_settings,
)
old_weight = order.get_total_weight()
@@ -702,6 +685,7 @@ def test_value_voucher_order_discount(
min_spent_amount,
expected_value,
channel_USD,
+ address_usa,
):
voucher = Voucher.objects.create(
code="unique",
@@ -717,7 +701,11 @@ def test_value_voucher_order_discount(
subtotal = Money(subtotal, "USD")
subtotal = TaxedMoney(net=subtotal, gross=subtotal)
order = Mock(
- get_subtotal=Mock(return_value=subtotal), voucher=voucher, channel=channel_USD
+ get_subtotal=Mock(return_value=subtotal),
+ voucher=voucher,
+ shipping_address=address_usa,
+ billing_address=address_usa,
+ channel=channel_USD,
)
discount = get_voucher_discount_for_order(order)
assert discount == Money(expected_value, "USD")
@@ -728,7 +716,12 @@ def test_value_voucher_order_discount(
[(10, 50, DiscountValueType.PERCENTAGE, 5), (10, 20, DiscountValueType.FIXED, 10)],
)
def test_shipping_voucher_order_discount(
- shipping_cost, discount_value, discount_type, expected_value, channel_USD
+ shipping_cost,
+ discount_value,
+ discount_type,
+ expected_value,
+ channel_USD,
+ address_usa,
):
voucher = Voucher.objects.create(
code="unique",
@@ -748,6 +741,8 @@ def test_shipping_voucher_order_discount(
order = Mock(
get_subtotal=Mock(return_value=subtotal),
shipping_price=shipping_total,
+ shipping_address=address_usa,
+ billing_address=address_usa,
voucher=voucher,
channel=channel_USD,
)
@@ -777,6 +772,7 @@ def test_shipping_voucher_checkout_discount_not_applicable_returns_zero(
min_checkout_items_quantity,
voucher_type,
channel_USD,
+ address_usa,
):
voucher = Voucher.objects.create(
code="unique",
@@ -795,6 +791,8 @@ def test_shipping_voucher_checkout_discount_not_applicable_returns_zero(
order = Mock(
get_subtotal=Mock(return_value=price),
get_total_quantity=Mock(return_value=total_quantity),
+ shipping_address=address_usa,
+ billing_address=address_usa,
shipping_price=price,
voucher=voucher,
channel=channel_USD,
diff --git a/saleor/order/tests/test_order_utils.py b/saleor/order/tests/test_order_utils.py
index 837343bc85..fbb74d7a44 100644
--- a/saleor/order/tests/test_order_utils.py
+++ b/saleor/order/tests/test_order_utils.py
@@ -17,9 +17,11 @@ from ..utils import (
add_gift_cards_to_order,
add_variant_to_order,
change_order_line_quantity,
+ get_order_country,
get_total_order_discount_excluding_shipping,
get_valid_shipping_methods_for_order,
match_orders_with_new_user,
+ update_order_display_gross_prices,
)
@@ -279,7 +281,6 @@ def test_add_variant_to_order(
customer_user,
None,
manager,
- site_settings,
[discount_info],
)
@@ -471,9 +472,60 @@ def test_get_total_order_discount_excluding_shipping_no_shipping_discounts(
)
+def test_update_order_display_gross_prices_use_default_tax_settings(order):
+ # given
+ tax_config = order.channel.tax_configuration
+ tax_config.display_gross_prices = True
+ tax_config.save()
+ tax_config.country_exceptions.all().delete()
+
+ order.display_gross_prices = False
+ order.save(update_fields=["display_gross_prices"])
+
+ # when
+ update_order_display_gross_prices(order)
+
+ # then
+ assert order.display_gross_prices
+
+
+def test_update_order_display_gross_prices_use_country_specific_tax_settings(order):
+ # given
+ country_code = "PT"
+ tax_config = order.channel.tax_configuration
+ tax_config.display_gross_prices = False
+ tax_config.save()
+ tax_config.country_exceptions.create(
+ country=country_code, display_gross_prices=True
+ )
+
+ order.display_gross_prices = False
+ order.save(update_fields=["display_gross_prices"])
+ order.shipping_address.country = country_code
+ order.shipping_address.save()
+
+ # when
+ update_order_display_gross_prices(order)
+
+ # then
+ assert order.display_gross_prices
+
+
def test_get_total_order_discount_excluding_shipping_no_discounts(order):
# when
discount_amount = get_total_order_discount_excluding_shipping(order)
# then
assert discount_amount == Money("0", order.currency)
+
+
+def test_get_order_country_use_channel_country(order):
+ # given
+ order.shipping_address = order.billing_address = None
+ order.save(update_fields=["shipping_address", "billing_address"])
+
+ # when
+ country = get_order_country(order)
+
+ # then
+ assert country == order.channel.default_country
diff --git a/saleor/order/utils.py b/saleor/order/utils.py
index a56fa7de92..dd704b47c7 100644
--- a/saleor/order/utils.py
+++ b/saleor/order/utils.py
@@ -3,7 +3,6 @@ from functools import wraps
from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, cast
import graphene
-from django.conf import settings
from django.utils import timezone
from prices import Money, TaxedMoney
@@ -30,6 +29,11 @@ from ..shipping.utils import (
convert_to_shipping_method_data,
initialize_shipping_method_active_status,
)
+from ..tax.utils import (
+ get_display_gross_prices,
+ get_tax_class_kwargs_for_order_line,
+ get_tax_country,
+)
from ..warehouse.management import (
decrease_allocations,
get_order_lines_with_track_inventory,
@@ -61,7 +65,7 @@ def get_order_country(order: Order) -> str:
if order.is_shipping_required():
address = order.shipping_address
if address is None:
- return settings.DEFAULT_COUNTRY
+ return order.channel.default_country.code
return address.country.code
@@ -203,7 +207,6 @@ def create_order_line(
order,
line_data,
manager,
- site_settings,
discounts=None,
allocate_stock=False,
):
@@ -232,6 +235,12 @@ def create_order_line(
total_price = unit_price * quantity
undiscounted_total_price = undiscounted_unit_price * quantity
+ tax_class = None
+ if product.tax_class_id:
+ tax_class = product.tax_class
+ else:
+ tax_class = product.product_type.tax_class
+
product_name = str(product)
variant_name = str(variant)
translated_product_name = str(product.translated)
@@ -257,10 +266,9 @@ def create_order_line(
total_price=total_price,
undiscounted_total_price=undiscounted_total_price,
variant=variant,
+ **get_tax_class_kwargs_for_order_line(tax_class),
)
- manager.update_taxes_for_order_lines(order, list(order.lines.all()))
-
unit_discount = line.undiscounted_unit_price - line.unit_price
if unit_discount.gross:
sale_id = get_sale_id_applied_as_a_discount(
@@ -271,8 +279,11 @@ def create_order_line(
channel=channel,
variant_id=variant.id,
)
- taxes_included_in_prices = site_settings.include_taxes_in_prices
- if taxes_included_in_prices:
+
+ tax_configuration = channel.tax_configuration
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
+
+ if prices_entered_with_tax:
discount_amount = unit_discount.gross
else:
discount_amount = unit_discount.net
@@ -316,7 +327,6 @@ def add_variant_to_order(
user,
app,
manager,
- site_settings,
discounts=None,
allocate_stock=False,
):
@@ -363,7 +373,6 @@ def add_variant_to_order(
order,
line_data,
manager,
- site_settings,
discounts,
allocate_stock,
)
@@ -768,8 +777,6 @@ def update_discount_for_order_line(
reason: Optional[str],
value_type: Optional[str],
value: Optional[Decimal],
- manager,
- tax_included,
):
"""Update discount fields for order line. Apply discount to the price."""
current_value = order_line.unit_discount_value
@@ -825,9 +832,7 @@ def update_discount_for_order_line(
order_line.save(update_fields=fields_to_update)
-def remove_discount_from_order_line(
- order_line: OrderLine, order: "Order", manager, tax_included
-):
+def remove_discount_from_order_line(order_line: OrderLine, order: "Order"):
"""Drop discount applied to order line. Restore undiscounted price."""
order_line.unit_price = TaxedMoney(
net=order_line.undiscounted_base_unit_price,
@@ -949,3 +954,27 @@ def update_order_authorize_data(order: Order, with_save=True):
order.save(
update_fields=["total_authorized_amount", "authorize_status", "updated_at"]
)
+
+
+def update_order_display_gross_prices(order: "Order"):
+ """Update Order's `display_gross_prices` DB field.
+
+ It gets the appropriate country code based on the current order lines and addresses.
+ Having the country code get the proper tax configuration for this channel and
+ country and determine whether gross prices should be displayed for this order.
+ Doesn't save the value in the database.
+ """
+ channel = order.channel
+ tax_configuration = channel.tax_configuration
+ country_code = get_tax_country(
+ channel,
+ order.is_shipping_required(),
+ order.shipping_address,
+ order.billing_address,
+ )
+ country_tax_configuration = tax_configuration.country_exceptions.filter(
+ country=country_code
+ ).first()
+ order.display_gross_prices = get_display_gross_prices(
+ tax_configuration, country_tax_configuration
+ )
diff --git a/saleor/plugins/avatax/__init__.py b/saleor/plugins/avatax/__init__.py
index 6312b280dd..f995b81af4 100644
--- a/saleor/plugins/avatax/__init__.py
+++ b/saleor/plugins/avatax/__init__.py
@@ -9,7 +9,6 @@ from urllib.parse import urljoin
import opentracing
import opentracing.tags
import requests
-from django.contrib.sites.models import Site
from django.core.cache import cache
from requests.auth import HTTPBasicAuth
@@ -21,12 +20,15 @@ from ...discount import OrderDiscountType, VoucherType
from ...order import base_calculations as base_order_calculations
from ...order.utils import get_total_order_discount_excluding_shipping
from ...shipping.models import ShippingMethod
+from ...tax.utils import get_charge_taxes_for_checkout
from ...warehouse.models import Warehouse
if TYPE_CHECKING:
from ...checkout.fetch import CheckoutInfo, CheckoutLineInfo
from ...order.models import Order
- from ...product.models import Product, ProductType, ProductVariant
+ from ...product.models import Product, ProductType
+ from ...tax.models import TaxClass
+
logger = logging.getLogger(__name__)
@@ -45,6 +47,8 @@ COMMON_DISCOUNT_VOUCHER_CODE = "OD010000"
DEFAULT_TAX_CODE = "O9999999"
DEFAULT_TAX_DESCRIPTION = "Unmapped Other SKU - taxable default"
+TAX_CODE_NON_TAXABLE_PRODUCT = "NT"
+
@dataclass
class AvataxConfiguration:
@@ -59,16 +63,6 @@ class AvataxConfiguration:
company_name: str = "DEFAULT"
autocommit: bool = False
shipping_tax_code: str = ""
- override_global_tax: bool = False
- include_taxes_in_prices: bool = True
-
- @property
- def tax_included(self) -> bool:
- return (
- self.include_taxes_in_prices
- if self.override_global_tax
- else Site.objects.get_current().settings.include_taxes_in_prices
- )
class TransactionType:
@@ -223,7 +217,7 @@ def append_line_to_data(
amount: Decimal,
tax_code: str,
item_code: str,
- tax_included: bool,
+ prices_entered_with_tax: bool,
name: str = None,
discounted: Optional[bool] = False,
tax_override_data: Optional[dict] = None,
@@ -234,7 +228,7 @@ def append_line_to_data(
"quantity": quantity,
"amount": str(amount),
"taxCode": tax_code,
- "taxIncluded": tax_included,
+ "taxIncluded": prices_entered_with_tax,
"itemCode": item_code,
"discounted": discounted,
"description": name,
@@ -253,42 +247,48 @@ def append_shipping_to_data(
data: List[Dict],
shipping_price_amount: Optional[Decimal],
shipping_tax_code: str,
- tax_included: bool,
+ prices_entered_with_tax: bool,
discounted: Optional[bool] = False,
):
- charge_taxes_on_shipping = (
- Site.objects.get_current().settings.charge_taxes_on_shipping
- )
- if charge_taxes_on_shipping and shipping_price_amount is not None:
+ if shipping_price_amount is not None:
append_line_to_data(
data,
quantity=1,
amount=shipping_price_amount,
tax_code=shipping_tax_code,
item_code="Shipping",
- tax_included=tax_included,
+ prices_entered_with_tax=prices_entered_with_tax,
discounted=discounted,
)
-def get_checkout_lines_data(
+def generate_request_data_from_checkout_lines(
checkout_info: "CheckoutInfo",
lines_info: Iterable["CheckoutLineInfo"],
config: AvataxConfiguration,
- tax_included: bool,
discounts=None,
) -> List[Dict[str, Union[str, int, bool, None]]]:
data: List[Dict[str, Union[str, int, bool, None]]] = []
channel = checkout_info.channel
+
+ charge_taxes = get_charge_taxes_for_checkout(checkout_info, lines_info)
+ prices_entered_with_tax = checkout_info.tax_configuration.prices_entered_with_tax
+
voucher = checkout_info.voucher
is_entire_order_discount = (
voucher.type == VoucherType.ENTIRE_ORDER
if voucher and not voucher.apply_once_per_order
else False
)
+
for line_info in lines_info:
+ product = line_info.product
+ product_type = line_info.product_type
+ tax_code = _get_product_tax_code(product, product_type)
+ is_non_taxable_product = tax_code == TAX_CODE_NON_TAXABLE_PRODUCT
+
tax_override_data = {}
- if not line_info.product.charge_taxes:
+ if not charge_taxes or is_non_taxable_product:
if not is_entire_order_discount:
continue
# if there is a voucher for the entire order we need to attach this line
@@ -299,12 +299,6 @@ def get_checkout_lines_data(
"reason": "Charge taxes for this product are turned off.",
}
- product = line_info.product
- name = product.name
- product_type = line_info.product_type
- item_code = line_info.variant.sku or line_info.variant.get_global_id()
- tax_code = retrieve_tax_code_from_meta(product, default=None)
- tax_code = tax_code or retrieve_tax_code_from_meta(product_type)
checkout_line_total = base_calculations.calculate_base_line_total_price(
line_info,
channel,
@@ -324,13 +318,15 @@ def get_checkout_lines_data(
if checkout_line_total.amount and not tax_override_data
else DEFAULT_TAX_CODE
)
+ name = product.name
+ item_code = line_info.variant.sku or line_info.variant.get_global_id()
append_line_to_data_kwargs = {
"data": data,
"quantity": line_info.line.quantity,
"tax_code": tax_code,
"item_code": item_code,
"name": name,
- "tax_included": tax_included,
+ "prices_entered_with_tax": prices_entered_with_tax,
"discounted": is_entire_order_discount,
"tax_override_data": tax_override_data,
}
@@ -347,19 +343,22 @@ def get_checkout_lines_data(
is_shipping_discount = (
voucher.type == VoucherType.SHIPPING if voucher else False
)
- append_shipping_to_data(
- data,
- price.amount if price else None,
- config.shipping_tax_code,
- tax_included,
- is_shipping_discount,
- )
+
+ tax_class = getattr(delivery_method, "tax_class", None)
+ if tax_class:
+ append_shipping_to_data(
+ data=data,
+ shipping_price_amount=price.amount if price else None,
+ shipping_tax_code=config.shipping_tax_code,
+ prices_entered_with_tax=prices_entered_with_tax,
+ discounted=is_shipping_discount,
+ )
return data
def get_order_lines_data(
- order: "Order", config: AvataxConfiguration, tax_included: bool, discounted: bool
+ order: "Order", config: AvataxConfiguration, discounted: bool
) -> List[Dict[str, Union[str, int, bool, None]]]:
data: List[Dict[str, Union[str, int, bool, None]]] = []
lines = order.lines.prefetch_related(
@@ -367,16 +366,27 @@ def get_order_lines_data(
"variant__product__collections",
"variant__product__product_type",
).filter(variant__product__charge_taxes=True)
+
+ tax_configuration = order.channel.tax_configuration
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
+
for line in lines:
if not line.variant:
continue
- product = line.variant.product
- product_type = line.variant.product.product_type
- tax_code = retrieve_tax_code_from_meta(product, default=None)
- tax_code = tax_code or retrieve_tax_code_from_meta(product_type)
+
+ tax_code = None
+ tax_class = line.tax_class
+
+ if tax_class:
+ tax_code = retrieve_tax_code_from_meta(tax_class, default=None)
+ elif line.tax_class_metadata:
+ tax_code = line.tax_class_metadata.get(META_CODE_KEY, DEFAULT_TAX_CODE)
+ else:
+ tax_code = DEFAULT_TAX_CODE
+
prices_data = base_order_calculations.base_order_line_total(line)
- if tax_included:
+ if prices_entered_with_tax:
undiscounted_amount = prices_data.undiscounted_price.gross.amount
price_with_discounts_amount = prices_data.price_with_discounts.gross.amount
else:
@@ -394,7 +404,7 @@ def get_order_lines_data(
"tax_code": tax_code if undiscounted_amount else DEFAULT_TAX_CODE,
"item_code": line.variant.sku or line.variant.get_global_id(),
"name": line.variant.product.name,
- "tax_included": tax_included,
+ "prices_entered_with_tax": prices_entered_with_tax,
"discounted": discounted,
}
append_line_to_data(
@@ -406,13 +416,18 @@ def get_order_lines_data(
shipping_discounted = order.discounts.filter(
type=OrderDiscountType.MANUAL
).exists()
- append_shipping_to_data(
- data,
- shipping_price,
- config.shipping_tax_code,
- tax_included,
- shipping_discounted,
- )
+
+ # Calculate shipping tax if there is a shipping_tax_class assigned to the order,
+ # or if there is at least tax_class name set (this might be the case when tax
+ # class was assigned but it was removed from DB).
+ if order.shipping_tax_class_id or order.shipping_tax_class_name:
+ append_shipping_to_data(
+ data=data,
+ shipping_price_amount=shipping_price if shipping_price else None,
+ shipping_tax_code=config.shipping_tax_code,
+ prices_entered_with_tax=prices_entered_with_tax,
+ discounted=shipping_discounted,
+ )
return data
@@ -483,15 +498,14 @@ def generate_request_data_from_checkout(
checkout_info: "CheckoutInfo",
lines_info: Iterable["CheckoutLineInfo"],
config: AvataxConfiguration,
- tax_included: bool,
transaction_token=None,
transaction_type=TransactionType.ORDER,
discounts=None,
):
shipping_address = checkout_info.delivery_method_info.shipping_address
address = shipping_address or checkout_info.billing_address
- lines = get_checkout_lines_data(
- checkout_info, lines_info, config, tax_included, discounts
+ lines = generate_request_data_from_checkout_lines(
+ checkout_info, lines_info, config, discounts
)
if not lines:
return {}
@@ -566,19 +580,16 @@ def get_cached_response_or_fetch(
def get_checkout_tax_data(
checkout_info: "CheckoutInfo",
lines_info: Iterable["CheckoutLineInfo"],
- tax_included: bool,
discounts,
config: AvataxConfiguration,
) -> Dict[str, Any]:
data = generate_request_data_from_checkout(
- checkout_info, lines_info, config, tax_included, discounts=discounts
+ checkout_info, lines_info, config, discounts=discounts
)
return get_cached_response_or_fetch(data, str(checkout_info.checkout.token), config)
-def get_order_request_data(
- order: "Order", config: AvataxConfiguration, tax_included: bool
-):
+def get_order_request_data(order: "Order", config: AvataxConfiguration):
if order.collection_point_id:
address: Address = order.collection_point.address # type: ignore
else:
@@ -591,9 +602,7 @@ def get_order_request_data(
)
discount_amount = get_total_order_discount_excluding_shipping(order).amount
discounted_lines = discount_amount != Decimal("0")
- lines = get_order_lines_data(
- order, config, tax_included, discounted=discounted_lines
- )
+ lines = get_order_lines_data(order, config, discounted=discounted_lines)
# if there is no lines to sent we do not want to send the request to avalara
if not lines:
return {}
@@ -611,9 +620,9 @@ def get_order_request_data(
def get_order_tax_data(
- order: "Order", config: AvataxConfiguration, tax_included: bool, force_refresh=False
+ order: "Order", config: AvataxConfiguration, force_refresh=False
) -> Dict[str, Any]:
- data = get_order_request_data(order, config, tax_included)
+ data = get_order_request_data(order, config)
response = get_cached_response_or_fetch(
data, f"order_{order.id}", config, force_refresh
)
@@ -655,9 +664,19 @@ def get_cached_tax_codes_or_fetch(
return tax_codes
+def _get_product_tax_code(product: "Product", product_type: "ProductType"):
+ tax_code = None
+ if product.tax_class:
+ tax_code = retrieve_tax_code_from_meta(product.tax_class, default=None)
+ elif product_type.tax_class:
+ tax_code = retrieve_tax_code_from_meta(product_type.tax_class)
+ else:
+ tax_code = DEFAULT_TAX_CODE
+ return tax_code
+
+
def retrieve_tax_code_from_meta(
- obj: Union["Product", "ProductVariant", "ProductType"],
- default: Optional[str] = DEFAULT_TAX_CODE,
+ obj: "TaxClass", default: Optional[str] = DEFAULT_TAX_CODE
):
tax_code = obj.get_value_from_metadata(META_CODE_KEY, default)
return tax_code
diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.py
index 1972dd46a1..9abdc07eae 100644
--- a/saleor/plugins/avatax/plugin.py
+++ b/saleor/plugins/avatax/plugin.py
@@ -1,7 +1,8 @@
import logging
from dataclasses import asdict
from decimal import Decimal
-from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Union
+from functools import partial
+from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Union
from urllib.parse import urljoin
import opentracing
@@ -13,10 +14,11 @@ from prices import Money, TaxedMoney, TaxedMoneyRange
from ...checkout import base_calculations
from ...checkout.fetch import fetch_checkout_lines
-from ...core.taxes import TaxError, TaxType, charge_taxes_on_shipping, zero_taxed_money
+from ...core.taxes import TaxError, TaxType, zero_taxed_money
from ...discount import DiscountInfo
from ...order.interface import OrderTaxedPricesData
from ...product.models import ProductType
+from ...tax.utils import get_charge_taxes_for_checkout, get_charge_taxes_for_order
from ..base_plugin import BasePlugin, ConfigurationTypeField
from ..error_codes import PluginErrorCode
from . import (
@@ -45,12 +47,23 @@ if TYPE_CHECKING:
from ...checkout.fetch import CheckoutInfo, CheckoutLineInfo
from ...order.models import Order, OrderLine
from ...product.models import Product, ProductVariant
+ from ...tax.models import TaxClass
from ..models import PluginConfiguration
logger = logging.getLogger(__name__)
+def _get_prices_entered_with_tax_for_checkout(checkout_info: "CheckoutInfo"):
+ tax_configuration = checkout_info.tax_configuration
+ return tax_configuration.prices_entered_with_tax
+
+
+def _get_prices_entered_with_tax_for_order(order: "Order"):
+ tax_configuration = order.channel.tax_configuration
+ return tax_configuration.prices_entered_with_tax
+
+
class AvataxPlugin(BasePlugin):
PLUGIN_NAME = "Avalara"
PLUGIN_ID = "mirumee.taxes.avalara"
@@ -67,8 +80,6 @@ class AvataxPlugin(BasePlugin):
{"name": "from_country_area", "value": None},
{"name": "from_postal_code", "value": None},
{"name": "shipping_tax_code", "value": "FR000000"},
- {"name": "override_global_tax", "value": False},
- {"name": "include_taxes_in_prices", "value": True},
]
CONFIG_STRUCTURE = {
"Username or account": {
@@ -134,16 +145,6 @@ class AvataxPlugin(BasePlugin):
),
"label": "Shipping tax code",
},
- "override_global_tax": {
- "type": ConfigurationTypeField.BOOLEAN,
- "help_text": "Used when setting per channel is needed.",
- "label": "Override global tax settings.",
- },
- "include_taxes_in_prices": {
- "type": ConfigurationTypeField.BOOLEAN,
- "help_text": 'Applied only if "Override global tax settings" is on.',
- "label": "All products prices are entered with tax included.",
- },
}
def __init__(self, *args, **kwargs):
@@ -166,8 +167,6 @@ class AvataxPlugin(BasePlugin):
from_country_area=configuration["from_country_area"],
from_postal_code=configuration["from_postal_code"],
shipping_tax_code=configuration["shipping_tax_code"],
- override_global_tax=configuration["override_global_tax"],
- include_taxes_in_prices=configuration["include_taxes_in_prices"],
)
def _skip_plugin(
@@ -204,6 +203,10 @@ class AvataxPlugin(BasePlugin):
if response is None:
return previous_value
+ prices_entered_with_tax = partial(
+ _get_prices_entered_with_tax_for_checkout, checkout_info
+ )
+
currency = checkout_info.checkout.currency
taxed_total = zero_taxed_money(currency)
@@ -211,7 +214,7 @@ class AvataxPlugin(BasePlugin):
taxed_line_total_data = self._calculate_checkout_line_total_price(
taxes_data=response,
item_code=line.variant.sku or line.variant.get_global_id(),
- tax_included=self.config.tax_included,
+ prices_entered_with_tax=prices_entered_with_tax,
# for some cases we will need a base_value but no need to call it for
# each line
base_value=SimpleLazyObject( # type:ignore
@@ -226,7 +229,7 @@ class AvataxPlugin(BasePlugin):
checkout_info, lines
)
shipping_price = self._calculate_checkout_shipping(
- currency, response.get("lines", []), base_shipping_price
+ checkout_info, currency, response.get("lines", []), base_shipping_price
)
taxed_total += shipping_price
@@ -237,7 +240,11 @@ class AvataxPlugin(BasePlugin):
)
def _calculate_checkout_shipping(
- self, currency: str, lines: List[Dict], shipping_price: Money
+ self,
+ checkout_info: "CheckoutInfo",
+ currency: str,
+ lines: List[Dict],
+ shipping_price: Money,
) -> TaxedMoney:
discount_amount = Decimal(0.0)
shipping_tax = Decimal(0.0)
@@ -252,7 +259,10 @@ class AvataxPlugin(BasePlugin):
shipping_tax = Decimal(line["tax"])
break
- if currency == "JPY" and self.config.tax_included:
+ prices_entered_with_tax = partial(
+ _get_prices_entered_with_tax_for_checkout, checkout_info
+ )
+ if currency == "JPY" and prices_entered_with_tax():
shipping_gross = Money(amount=shipping_price.amount, currency=currency)
shipping_net = Money(
amount=shipping_gross.amount - shipping_tax, currency=currency
@@ -275,18 +285,15 @@ class AvataxPlugin(BasePlugin):
) -> TaxedMoney:
base_shipping_price = previous_value
- if not charge_taxes_on_shipping():
- return base_shipping_price
-
response = self._get_checkout_tax_data(
- checkout_info, lines, discounts, base_shipping_price
+ checkout_info, lines, discounts, self.config
)
if response is None:
return previous_value
currency = str(response.get("currencyCode"))
return self._calculate_checkout_shipping(
- currency, response.get("lines", []), base_shipping_price.net
+ checkout_info, currency, response.get("lines", []), base_shipping_price.net
)
def preprocess_order_creation(
@@ -315,7 +322,6 @@ class AvataxPlugin(BasePlugin):
checkout_info,
lines,
self.config,
- self.config.tax_included,
transaction_token=str(checkout_info.checkout.token),
transaction_type=TransactionType.ORDER,
discounts=discounts,
@@ -349,9 +355,7 @@ class AvataxPlugin(BasePlugin):
def order_created(self, order: "Order", previous_value: Any) -> Any:
if not self.active or order.is_unconfirmed():
return previous_value
- request_data = get_order_request_data(
- order, self.config, self.config.tax_included
- )
+ request_data = get_order_request_data(order, self.config)
if not request_data:
return previous_value
@@ -376,18 +380,24 @@ class AvataxPlugin(BasePlugin):
previous_value: TaxedMoney,
) -> TaxedMoney:
base_total = previous_value
- if not checkout_line_info.product.charge_taxes:
+
+ charge_taxes = get_charge_taxes_for_checkout(checkout_info, lines)
+ if not charge_taxes:
return base_total
+ prices_entered_with_tax = partial(
+ _get_prices_entered_with_tax_for_checkout, checkout_info
+ )
+
taxes_data = self._get_checkout_tax_data(
- checkout_info, lines, discounts, base_total
+ checkout_info, lines, discounts, self.config
)
variant = checkout_line_info.variant
return self._calculate_checkout_line_total_price(
taxes_data,
variant.sku or variant.get_global_id(),
- self.config.tax_included,
+ prices_entered_with_tax,
previous_value,
)
@@ -395,7 +405,7 @@ class AvataxPlugin(BasePlugin):
def _calculate_checkout_line_total_price(
taxes_data: Dict[str, Any],
item_code: str,
- tax_included: bool,
+ prices_entered_with_tax: Callable[[], bool],
base_value: TaxedMoney,
) -> TaxedMoney:
if not taxes_data or "error" in taxes_data:
@@ -413,7 +423,7 @@ class AvataxPlugin(BasePlugin):
discount_amount = Decimal(line.get("discountAmount", 0.0))
net = Decimal(line["lineAmount"])
- if currency == "JPY" and tax_included:
+ if currency == "JPY" and prices_entered_with_tax():
line_gross = base_value.gross
line_net = Money(amount=line_gross.amount - tax, currency=currency)
else:
@@ -432,13 +442,19 @@ class AvataxPlugin(BasePlugin):
product: "Product",
previous_value: OrderTaxedPricesData,
) -> OrderTaxedPricesData:
- if not product.charge_taxes:
+ if self._skip_plugin(previous_value):
return previous_value
+
+ charge_taxes = get_charge_taxes_for_order(order)
+ if not charge_taxes:
+ return previous_value
+
+ prices_entered_with_tax = partial(_get_prices_entered_with_tax_for_order, order)
taxes_data = self._get_order_tax_data(order, previous_value)
return self._calculate_order_line_total_price(
taxes_data,
variant.sku or variant.get_global_id(),
- self.config.tax_included,
+ prices_entered_with_tax,
previous_value,
)
@@ -446,7 +462,7 @@ class AvataxPlugin(BasePlugin):
def _calculate_order_line_total_price(
taxes_data: Dict[str, Any],
item_code: str,
- tax_included: bool,
+ prices_entered_with_tax: Callable[[], bool],
base_value: OrderTaxedPricesData,
) -> OrderTaxedPricesData:
if not taxes_data or "error" in taxes_data:
@@ -465,7 +481,7 @@ class AvataxPlugin(BasePlugin):
discount_amount = Decimal(line.get("discountAmount", 0.0))
net = Decimal(line["lineAmount"])
- if currency == "JPY" and tax_included:
+ if currency == "JPY" and prices_entered_with_tax():
line_gross = Money(
base_value.price_with_discounts.gross.amount - discount_amount,
currency,
@@ -496,20 +512,25 @@ class AvataxPlugin(BasePlugin):
previous_value: TaxedMoney,
) -> TaxedMoney:
base_total = previous_value
- if not checkout_line_info.product.charge_taxes:
+ charge_taxes = get_charge_taxes_for_checkout(checkout_info, lines)
+
+ if not charge_taxes:
return base_total
- taxes_data = self._get_checkout_tax_data(
- checkout_info, lines, discounts, base_total
+ prices_entered_with_tax = partial(
+ _get_prices_entered_with_tax_for_checkout, checkout_info
)
variant = checkout_line_info.variant
quantity = checkout_line_info.line.quantity
+ taxes_data = self._get_checkout_tax_data(
+ checkout_info, lines, discounts, self.config
+ )
default_total = previous_value * quantity
taxed_total_price = self._calculate_checkout_line_total_price(
taxes_data,
variant.sku or variant.get_global_id(),
- self.config.tax_included,
+ prices_entered_with_tax,
default_total,
)
return taxed_total_price / quantity
@@ -522,9 +543,12 @@ class AvataxPlugin(BasePlugin):
product: "Product",
previous_value: OrderTaxedPricesData,
) -> OrderTaxedPricesData:
- if not variant or (variant and not product.charge_taxes):
+ charge_taxes = get_charge_taxes_for_order(order)
+ if not variant or (variant and not charge_taxes):
return previous_value
+ prices_entered_with_tax = partial(_get_prices_entered_with_tax_for_order, order)
+
quantity = order_line.quantity
taxes_data = self._get_order_tax_data(order, previous_value)
default_total = OrderTaxedPricesData(
@@ -534,7 +558,7 @@ class AvataxPlugin(BasePlugin):
taxed_total_prices_data = self._calculate_order_line_total_price(
taxes_data,
variant.sku or variant.get_global_id(),
- self.config.tax_included,
+ prices_entered_with_tax,
default_total,
)
return OrderTaxedPricesData(
@@ -549,13 +573,14 @@ class AvataxPlugin(BasePlugin):
if taxes_data is None:
return previous_value
+ prices_entered_with_tax = partial(_get_prices_entered_with_tax_for_order, order)
currency = taxes_data.get("currencyCode")
for line in taxes_data.get("lines", []):
if line["itemCode"] == "Shipping":
tax = Decimal(line.get("tax", 0.0))
discount_amount = Decimal(line.get("discountAmount", 0.0))
net = Decimal(line.get("lineAmount", 0.0)) - discount_amount
- if currency == "JPY" and self.config.tax_included:
+ if currency == "JPY" and prices_entered_with_tax():
gross = previous_value.gross
net = Money(amount=gross.amount - tax, currency=currency)
else:
@@ -572,8 +597,6 @@ class AvataxPlugin(BasePlugin):
def calculate_order_shipping(
self, order: "Order", previous_value: TaxedMoney
) -> TaxedMoney:
- if not charge_taxes_on_shipping():
- return previous_value
taxes_data = self._get_order_tax_data(order, previous_value)
return self._calculate_order_shipping(order, taxes_data, previous_value)
@@ -584,6 +607,7 @@ class AvataxPlugin(BasePlugin):
previous_value: TaxedMoney,
) -> TaxedMoney:
taxes_data = self._get_order_tax_data(order, previous_value)
+ prices_entered_with_tax = partial(_get_prices_entered_with_tax_for_order, order)
currency = order.currency
taxed_subtotal = zero_taxed_money(currency)
@@ -599,7 +623,7 @@ class AvataxPlugin(BasePlugin):
taxed_line_total_data = self._calculate_order_line_total_price(
taxes_data,
line.product_sku or line.variant_name,
- self.config.tax_included,
+ prices_entered_with_tax,
base_line_price,
).price_with_discounts
taxed_subtotal += taxed_line_total_data
@@ -633,8 +657,10 @@ class AvataxPlugin(BasePlugin):
discounts: Iterable[DiscountInfo],
previous_value: Decimal,
) -> Decimal:
- if not checkout_line_info.product.charge_taxes:
+ charge_taxes = get_charge_taxes_for_checkout(checkout_info, lines)
+ if not charge_taxes:
return previous_value
+
response = self._get_checkout_tax_data(
checkout_info, lines, discounts, previous_value
)
@@ -653,8 +679,10 @@ class AvataxPlugin(BasePlugin):
address: Optional["Address"],
previous_value: Decimal,
) -> Decimal:
- if not product.charge_taxes:
+ charge_taxes = get_charge_taxes_for_order(order)
+ if not charge_taxes:
return previous_value
+
response = self._get_order_tax_data(order, previous_value)
return self._get_unit_tax_rate(
response,
@@ -694,7 +722,7 @@ class AvataxPlugin(BasePlugin):
return None
response = get_checkout_tax_data(
- checkout_info, lines_info, self.config.tax_included, discounts, self.config
+ checkout_info, lines_info, discounts, self.config
)
if not response or "error" in response:
@@ -712,9 +740,7 @@ class AvataxPlugin(BasePlugin):
if not valid:
return None
- response = get_order_tax_data(
- order, self.config, self.config.tax_included, False
- )
+ response = get_order_tax_data(order, self.config, False)
if not response or "error" in response:
return None
@@ -761,7 +787,7 @@ class AvataxPlugin(BasePlugin):
def assign_tax_code_to_object_meta(
self,
- obj: Union["Product", "ProductType"],
+ obj: "TaxClass",
tax_code: Optional[str],
previous_value: Any,
):
@@ -783,7 +809,7 @@ class AvataxPlugin(BasePlugin):
return previous_value
def get_tax_code_from_object_meta(
- self, obj: Union["Product", "ProductType"], previous_value: Any
+ self, obj: Union["Product", "ProductType", "TaxClass"], previous_value: Any
) -> TaxType:
if not self.active:
return previous_value
@@ -809,12 +835,6 @@ class AvataxPlugin(BasePlugin):
return previous_value
return False
- def fetch_taxes_data(self, previous_value):
- if not self.active:
- return previous_value
- get_cached_tax_codes_or_fetch(self.config)
- return True
-
@classmethod
def validate_authentication(cls, plugin_configuration: "PluginConfiguration"):
conf = {
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[False-24.39-30.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[False-24.39-30.00-True].yaml
index b9ba188954..5f19f41788 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[False-24.39-30.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[False-24.39-30.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "ecc08a3d-3d49-424d-9396-96a7fe74dacf", "date": "2022-09-08", "customerCode":
+ "16303d29-c98f-4c01-8a1a-6377f60359f9", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"ecc08a3d-3d49-424d-9396-96a7fe74dacf","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:13.5412996Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"16303d29-c98f-4c01-8a1a-6377f60359f9","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:18.5666886Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:13 GMT
+ - Fri, 09 Sep 2022 08:58:18 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0169248'
+ - '00:00:00.0168880'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - a3e862eb-2ce8-4535-81d7-d989f7a1d6af
+ - 5d45f7a3-1466-41de-8105-85619681d113
x-correlation-id:
- - a3e862eb-2ce8-4535-81d7-d989f7a1d6af
+ - 5d45f7a3-1466-41de-8105-85619681d113
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[False-30.00-36.90-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[False-30.00-36.90-False].yaml
index de4a05154a..9710104563 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[False-30.00-36.90-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[False-30.00-36.90-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "5fa6d885-5944-4056-bd70-fedad6e7f9d0", "date": "2022-09-08", "customerCode":
+ "cc4331c1-cf11-4e96-9fc0-19b74d5de335", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"5fa6d885-5944-4056-bd70-fedad6e7f9d0","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.2,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:15.6669216Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"cc4331c1-cf11-4e96-9fc0-19b74d5de335","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.2,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:20.9396014Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:15 GMT
+ - Fri, 09 Sep 2022 08:58:20 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0166574'
+ - '00:00:00.0170860'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 50e24e4d-a2e3-4c18-8ac1-b2697af03b99
+ - 2702a606-a252-4c6b-af61-3957eb6c63ad
x-correlation-id:
- - 50e24e4d-a2e3-4c18-8ac1-b2697af03b99
+ - 2702a606-a252-4c6b-af61-3957eb6c63ad
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[True-12.20-15.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[True-12.20-15.00-True].yaml
index 4dce88bed5..88301ffdfa 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[True-12.20-15.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[True-12.20-15.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "078f9472-a99d-484e-8bd1-688cf1613671", "date": "2022-09-08", "customerCode":
+ "a75ffeba-3d0f-4881-9b2f-6b08a438dc9f", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"078f9472-a99d-484e-8bd1-688cf1613671","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:14.4058162Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"a75ffeba-3d0f-4881-9b2f-6b08a438dc9f","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:17.3174407Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:14 GMT
+ - Fri, 09 Sep 2022 08:58:17 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0146730'
+ - '00:00:00.0172389'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - da2daad4-4f38-4697-ba74-dd02469e50d9
+ - 06ded7da-4ce6-4a50-82e4-8d30a81a2c04
x-correlation-id:
- - da2daad4-4f38-4697-ba74-dd02469e50d9
+ - 06ded7da-4ce6-4a50-82e4-8d30a81a2c04
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[True-15.00-18.45-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[True-15.00-18.45-False].yaml
index 0b1ba48a52..c9a17a030f 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[True-15.00-18.45-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total[True-15.00-18.45-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "e15e467f-f59d-4a46-85ee-7a8850b8dbf6", "date": "2022-09-08", "customerCode":
+ "8aed2996-325d-462b-8c47-d5c638ce4751", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"e15e467f-f59d-4a46-85ee-7a8850b8dbf6","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":25.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.75,"totalTaxable":25.0,"totalTaxCalculated":5.75,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:14.6108124Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":3.45,"taxableAmount":15.0,"taxCalculated":3.45,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.45,"taxableAmount":15.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":3.45,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":15.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.45,"reportingTaxCalculated":3.45,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"8aed2996-325d-462b-8c47-d5c638ce4751","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":25.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.75,"totalTaxable":25.0,"totalTaxCalculated":5.75,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:19.7286186Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":3.45,"taxableAmount":15.0,"taxCalculated":3.45,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.45,"taxableAmount":15.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":3.45,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":15.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.45,"reportingTaxCalculated":3.45,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:14 GMT
+ - Fri, 09 Sep 2022 08:58:19 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0174630'
+ - '00:00:00.0178824'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 8d3aa193-ba00-4882-9de0-bf3fd0ae821f
+ - 30a0fcb0-e29b-4d81-8702-9e328cbeebc4
x-correlation-id:
- - 8d3aa193-ba00-4882-9de0-bf3fd0ae821f
+ - 30a0fcb0-e29b-4d81-8702-9e328cbeebc4
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale.yaml
index 8048b5a506..8c7ca0354e 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "b3433237-367a-42ad-bb0f-c3a9be3fe69f", "date": "2022-09-08", "customerCode":
+ "4d0dfb6e-18c5-4e9a-8024-2b9ef5b92a40", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"b3433237-367a-42ad-bb0f-c3a9be3fe69f","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:14.4502622Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"4d0dfb6e-18c5-4e9a-8024-2b9ef5b92a40","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:22.2691995Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:14 GMT
+ - Fri, 09 Sep 2022 08:58:22 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0167609'
+ - '00:00:00.0150650'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 97a0a44f-a2c8-4cba-9b60-369d6ccb4176
+ - 39931aa8-2ddb-4762-bfdb-6c3917380bf5
x-correlation-id:
- - 97a0a44f-a2c8-4cba-9b60-369d6ccb4176
+ - 39931aa8-2ddb-4762-bfdb-6c3917380bf5
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale_and_voucher.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale_and_voucher.yaml
index 61f19fc0e5..4bdde635f3 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale_and_voucher.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale_and_voucher.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "3f25fd1c-2c18-4ba5-98ad-3a5e250a2998", "date": "2022-09-08", "customerCode":
+ "28db3467-8076-48f4-af8b-5878cbc48662", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"3f25fd1c-2c18-4ba5-98ad-3a5e250a2998","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":13.01,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":2.99,"totalTaxable":13.01,"totalTaxCalculated":2.99,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:15.8713084Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":4.8800,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":1.12,"taxableAmount":4.88,"taxCalculated":1.12,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.12,"taxableAmount":4.88,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":1.12,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":4.88,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.12,"reportingTaxCalculated":1.12,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"28db3467-8076-48f4-af8b-5878cbc48662","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":13.01,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":2.99,"totalTaxable":13.01,"totalTaxCalculated":2.99,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:26.5504188Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":4.8800,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":1.12,"taxableAmount":4.88,"taxCalculated":1.12,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.12,"taxableAmount":4.88,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":1.12,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":4.88,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.12,"reportingTaxCalculated":1.12,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:15 GMT
+ - Fri, 09 Sep 2022 08:58:26 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0168777'
+ - '00:00:00.0173981'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - e55eeba7-7bc8-4f52-8609-faad6ffa4d8e
+ - 7b486f83-4cca-4134-a8d1-769ab6c8e3a4
x-correlation-id:
- - e55eeba7-7bc8-4f52-8609-faad6ffa4d8e
+ - 7b486f83-4cca-4134-a8d1-769ab6c8e3a4
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale_and_voucher_only_once.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale_and_voucher_only_once.yaml
index b99b5f899a..d813ea7eb1 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale_and_voucher_only_once.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_variant_on_sale_and_voucher_only_once.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "32dfebca-a6ee-4636-9f3d-203e5fb04c24", "date": "2022-09-08", "customerCode":
+ "d37bf8f2-762d-4abd-bead-2f886108646a", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"32dfebca-a6ee-4636-9f3d-203e5fb04c24","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":17.89,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.11,"totalTaxable":17.89,"totalTaxCalculated":4.11,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:16.3003616Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":9.7600,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.24,"taxableAmount":9.76,"taxCalculated":2.24,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.24,"taxableAmount":9.76,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.24,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":9.76,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.24,"reportingTaxCalculated":2.24,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"d37bf8f2-762d-4abd-bead-2f886108646a","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":17.89,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.11,"totalTaxable":17.89,"totalTaxCalculated":4.11,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:27.9417211Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":9.7600,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.24,"taxableAmount":9.76,"taxCalculated":2.24,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.24,"taxableAmount":9.76,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.24,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":9.76,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.24,"reportingTaxCalculated":2.24,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:16 GMT
+ - Fri, 09 Sep 2022 08:58:27 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0181952'
+ - '00:00:00.0153156'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - f2cf6f65-3e8f-4380-bc77-5242b10a5c3d
+ - 7c6b310c-b2e2-41a7-be3d-1e1c74cfe1a3
x-correlation-id:
- - f2cf6f65-3e8f-4380-bc77-5242b10a5c3d
+ - 7c6b310c-b2e2-41a7-be3d-1e1c74cfe1a3
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_voucher.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_voucher.yaml
index 0311142849..9a62070104 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_voucher.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_voucher.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "ef8b117d-3887-4557-9ee9-52c2decf0e2d", "date": "2022-09-08", "customerCode":
+ "f85b7376-1e96-49e6-a180-8e7746275742", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"ef8b117d-3887-4557-9ee9-52c2decf0e2d","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":25.2,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.8,"totalTaxable":25.2,"totalTaxCalculated":5.8,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:16.5456467Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":17.0700,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":3.93,"taxableAmount":17.07,"taxCalculated":3.93,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.93,"taxableAmount":17.07,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":3.93,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":17.07,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.93,"reportingTaxCalculated":3.93,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"f85b7376-1e96-49e6-a180-8e7746275742","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":25.2,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.8,"totalTaxable":25.2,"totalTaxCalculated":5.8,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:23.700112Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":17.0700,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":3.93,"taxableAmount":17.07,"taxCalculated":3.93,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.93,"taxableAmount":17.07,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":3.93,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":17.07,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.93,"reportingTaxCalculated":3.93,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:16 GMT
+ - Fri, 09 Sep 2022 08:58:23 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0155204'
+ - '00:00:00.0223596'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - acc0b9f9-17d3-4507-9dd5-3e8c14d6592d
+ - e13eedc6-30db-464b-b1b2-6ad2d7a76456
x-correlation-id:
- - acc0b9f9-17d3-4507-9dd5-3e8c14d6592d
+ - e13eedc6-30db-464b-b1b2-6ad2d7a76456
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_voucher_once_per_order.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_voucher_once_per_order.yaml
index 6f6030ee1d..7264aaeffb 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_voucher_once_per_order.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_total_with_voucher_once_per_order.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "f05c9e77-607d-4242-8164-fff56f87546c", "date": "2022-09-08", "customerCode":
+ "cf221276-d095-4a63-a14f-bde0a41fb397", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"f05c9e77-607d-4242-8164-fff56f87546c","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":30.08,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.92,"totalTaxable":30.08,"totalTaxCalculated":6.92,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:15.0198696Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":21.9500,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.05,"taxableAmount":21.95,"taxCalculated":5.05,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.05,"taxableAmount":21.95,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.05,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":21.95,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.05,"reportingTaxCalculated":5.05,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"cf221276-d095-4a63-a14f-bde0a41fb397","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":30.08,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.92,"totalTaxable":30.08,"totalTaxCalculated":6.92,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:25.034472Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":21.9500,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.05,"taxableAmount":21.95,"taxCalculated":5.05,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.05,"taxableAmount":21.95,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.05,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":21.95,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.05,"reportingTaxCalculated":5.05,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:15 GMT
+ - Fri, 09 Sep 2022 08:58:25 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0167736'
+ - '00:00:00.0151693'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - ff94be7e-ef28-4b6d-add7-733022ad15f8
+ - 33d002ee-294a-44df-9bfd-5e4f01fde00c
x-correlation-id:
- - ff94be7e-ef28-4b6d-add7-733022ad15f8
+ - 33d002ee-294a-44df-9bfd-5e4f01fde00c
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price[True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price[True].yaml
index 9e651628eb..27649cc9c6 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price[True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price[True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "1e5a0e0f-656f-42db-bdcb-17ae703d89e2", "date": "2022-09-08", "customerCode":
+ "5b9b3e76-efa5-430c-a77a-d0a2a784729d", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"1e5a0e0f-656f-42db-bdcb-17ae703d89e2","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:30.217869Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"5b9b3e76-efa5-430c-a77a-d0a2a784729d","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:33.6574826Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:30 GMT
+ - Fri, 09 Sep 2022 08:59:33 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0156364'
+ - '00:00:00.0214087'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - b5fb8d42-9f42-42ea-b293-a94d1df7a32d
+ - 09fbc52b-2083-4b48-959b-4910ff685954
x-correlation-id:
- - b5fb8d42-9f42-42ea-b293-a94d1df7a32d
+ - 09fbc52b-2083-4b48-959b-4910ff685954
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_in_JPY.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_in_JPY.yaml
index 0c37f6fb5c..ffdbb40a16 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_in_JPY.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_in_JPY.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "700.000", "taxCode": "FR000000",
"taxIncluded": true, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "0853b7bf-61f2-4ce0-b5a2-1ebda00dcb5a", "date": "2022-09-08",
+ null}], "code": "d07d9447-da5c-44c1-8166-a5ac8d33cbb0", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"0853b7bf-61f2-4ce0-b5a2-1ebda00dcb5a","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"JPY","exchangeRateCurrencyCode":"JPY","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":3496.11,"totalExempt":0.17,"totalDiscount":0.0,"totalTax":803.0,"totalTaxable":3495.94,"totalTaxCalculated":803.0,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"modifiedDate":"2022-09-08T10:53:25.3785395Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.17,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":2927.0000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":673.0,"taxableAmount":2926.83,"taxCalculated":673.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":673.17,"taxableAmount":2926.83,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":673.17,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":2926.83,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":673.17,"reportingTaxCalculated":673.17,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":569.1100,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":130.0,"taxableAmount":569.11,"taxCalculated":130.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":130.89,"taxableAmount":569.11,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"d07d9447-da5c-44c1-8166-a5ac8d33cbb0","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"JPY","exchangeRateCurrencyCode":"JPY","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":3496.11,"totalExempt":0.17,"totalDiscount":0.0,"totalTax":803.0,"totalTaxable":3495.94,"totalTaxCalculated":803.0,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"modifiedDate":"2022-09-09T08:59:35.5093418Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.17,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":2927.0000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":673.0,"taxableAmount":2926.83,"taxCalculated":673.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":673.17,"taxableAmount":2926.83,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":673.17,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":2926.83,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":673.17,"reportingTaxCalculated":673.17,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":569.1100,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":130.0,"taxableAmount":569.11,"taxCalculated":130.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":130.89,"taxableAmount":569.11,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":130.89,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":569.11,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":130.89,"reportingTaxCalculated":130.89,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:25 GMT
+ - Fri, 09 Sep 2022 08:59:35 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0168012'
+ - '00:00:00.0181433'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - c283e1db-7249-4c8f-89f3-29672fbb5621
+ - cd4c4daf-00b0-4991-a111-4e6ecf48c059
x-correlation-id:
- - c283e1db-7249-4c8f-89f3-29672fbb5621
+ - cd4c4daf-00b0-4991-a111-4e6ecf48c059
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale.yaml
index 5c48bb2d38..580300f3ce 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "99eec789-37b5-4e96-a1b9-71bf59cba7b5", "date": "2022-09-08", "customerCode":
+ "2605a121-674c-47c0-a4e9-52f2a261c21a", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"99eec789-37b5-4e96-a1b9-71bf59cba7b5","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:26.8694489Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"2605a121-674c-47c0-a4e9-52f2a261c21a","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:36.7846848Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:26 GMT
+ - Fri, 09 Sep 2022 08:59:36 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0151410'
+ - '00:00:00.0177211'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - bb5bbc27-bcfb-4bc5-8de4-e62d84c6e8f6
+ - 018561e2-523d-4dbb-b7ac-d75f3b83a51f
x-correlation-id:
- - bb5bbc27-bcfb-4bc5-8de4-e62d84c6e8f6
+ - 018561e2-523d-4dbb-b7ac-d75f3b83a51f
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher.yaml
index 3731ec3e69..9ff3c4106f 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "28593f5f-4cf0-4a1f-a094-2a86470e3494", "date": "2022-09-08", "customerCode":
+ "8936fd3c-2837-49d2-9dba-d363e1020b0b", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"28593f5f-4cf0-4a1f-a094-2a86470e3494","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":13.01,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":2.99,"totalTaxable":13.01,"totalTaxCalculated":2.99,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:26.8047461Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":4.8800,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":1.12,"taxableAmount":4.88,"taxCalculated":1.12,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.12,"taxableAmount":4.88,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":1.12,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":4.88,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.12,"reportingTaxCalculated":1.12,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"8936fd3c-2837-49d2-9dba-d363e1020b0b","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":13.01,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":2.99,"totalTaxable":13.01,"totalTaxCalculated":2.99,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:40.8716639Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":4.8800,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":1.12,"taxableAmount":4.88,"taxCalculated":1.12,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.12,"taxableAmount":4.88,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":1.12,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":4.88,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.12,"reportingTaxCalculated":1.12,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:26 GMT
+ - Fri, 09 Sep 2022 08:59:40 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0155704'
+ - '00:00:00.0167764'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 075d98bd-7bf1-4764-a22e-e791ce0863fc
+ - fe446858-ef6b-4c92-8ec2-3b2bce6a039d
x-correlation-id:
- - 075d98bd-7bf1-4764-a22e-e791ce0863fc
+ - fe446858-ef6b-4c92-8ec2-3b2bce6a039d
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher_only_once.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher_only_once.yaml
index 9ef3e902d2..6bff4e971b 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher_only_once.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher_only_once.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "9377f88b-76f9-40d7-ba70-e44ec5e32e5a", "date": "2022-09-08", "customerCode":
+ "c87e27eb-69bf-42c4-a0ba-94ff5b369d29", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"9377f88b-76f9-40d7-ba70-e44ec5e32e5a","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":17.89,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.11,"totalTaxable":17.89,"totalTaxCalculated":4.11,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:28.6402615Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":9.7600,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.24,"taxableAmount":9.76,"taxCalculated":2.24,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.24,"taxableAmount":9.76,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.24,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":9.76,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.24,"reportingTaxCalculated":2.24,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"c87e27eb-69bf-42c4-a0ba-94ff5b369d29","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":17.89,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.11,"totalTaxable":17.89,"totalTaxCalculated":4.11,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:42.3020977Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":9.7600,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.24,"taxableAmount":9.76,"taxCalculated":2.24,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.24,"taxableAmount":9.76,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.24,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":9.76,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.24,"reportingTaxCalculated":2.24,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:28 GMT
+ - Fri, 09 Sep 2022 08:59:42 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0167424'
+ - '00:00:00.0177122'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 2186bbbd-136f-43ea-b35b-7726f08803f4
+ - 8dd58671-2523-42c7-9d20-3ae681f2d431
x-correlation-id:
- - 2186bbbd-136f-43ea-b35b-7726f08803f4
+ - 8dd58671-2523-42c7-9d20-3ae681f2d431
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_voucher.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_voucher.yaml
index fe0fb71171..88685a3d05 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_voucher.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_voucher.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "4d5176b4-1cbe-4c59-a27f-2d7e3358de36", "date": "2022-09-08", "customerCode":
+ "a7360b48-14fb-442f-866a-7dcbd4749226", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"4d5176b4-1cbe-4c59-a27f-2d7e3358de36","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":25.2,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.8,"totalTaxable":25.2,"totalTaxCalculated":5.8,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:28.550575Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":17.0700,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":3.93,"taxableAmount":17.07,"taxCalculated":3.93,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.93,"taxableAmount":17.07,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":3.93,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":17.07,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.93,"reportingTaxCalculated":3.93,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"a7360b48-14fb-442f-866a-7dcbd4749226","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":25.2,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.8,"totalTaxable":25.2,"totalTaxCalculated":5.8,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:38.1240226Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":17.0700,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":3.93,"taxableAmount":17.07,"taxCalculated":3.93,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.93,"taxableAmount":17.07,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":3.93,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":17.07,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.93,"reportingTaxCalculated":3.93,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:28 GMT
+ - Fri, 09 Sep 2022 08:59:38 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0151847'
+ - '00:00:00.0169088'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 996e51f7-4664-4e96-a322-a1f98f218337
+ - 06ebf8be-70bb-4443-b87d-d388c47b9bd2
x-correlation-id:
- - 996e51f7-4664-4e96-a322-a1f98f218337
+ - 06ebf8be-70bb-4443-b87d-d388c47b9bd2
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_voucher_once_per_order.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_voucher_once_per_order.yaml
index 70b95475ac..505b4291f2 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_voucher_once_per_order.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_unit_price_with_voucher_once_per_order.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "dcd8a0ee-7023-414c-b60d-41d3470fe479", "date": "2022-09-08", "customerCode":
+ "5caa05b9-5013-4cbb-8951-0ec19d4f1d7c", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"dcd8a0ee-7023-414c-b60d-41d3470fe479","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":30.08,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.92,"totalTaxable":30.08,"totalTaxCalculated":6.92,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:25.1503612Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":21.9500,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.05,"taxableAmount":21.95,"taxCalculated":5.05,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.05,"taxableAmount":21.95,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.05,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":21.95,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.05,"reportingTaxCalculated":5.05,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"5caa05b9-5013-4cbb-8951-0ec19d4f1d7c","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":30.08,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.92,"totalTaxable":30.08,"totalTaxCalculated":6.92,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:39.4724402Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":21.9500,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.05,"taxableAmount":21.95,"taxCalculated":5.05,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.05,"taxableAmount":21.95,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.05,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":21.95,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.05,"reportingTaxCalculated":5.05,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:25 GMT
+ - Fri, 09 Sep 2022 08:59:39 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0166016'
+ - '00:00:00.0170209'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 4be06d20-c2da-4513-a0d7-97211c34153c
+ - 5deacfd9-5bdd-41d5-a7b5-6e69f0665ff8
x-correlation-id:
- - 4be06d20-c2da-4513-a0d7-97211c34153c
+ - 5deacfd9-5bdd-41d5-a7b5-6e69f0665ff8
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[False-24.39-30.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[False-24.39-30.00-True].yaml
index 0305de77d0..e45ef288aa 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[False-24.39-30.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[False-24.39-30.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "UHJvZHVjdFZhcmlhbnQ6Mg", "discounted": false, "description":
"Test product"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": true, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "083b1be3-89ac-4f28-98ad-9b04949ca08d", "date": "2022-09-08",
+ null}], "code": "c70c5f6a-ae49-4e7b-bd20-290f37439d0a", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"083b1be3-89ac-4f28-98ad-9b04949ca08d","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:16.2469807Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"c70c5f6a-ae49-4e7b-bd20-290f37439d0a","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:30.5210195Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:16 GMT
+ - Fri, 09 Sep 2022 08:58:30 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0149273'
+ - '00:00:00.0150674'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - d5130858-d1d5-44c9-9f20-7c1f87c5dfe1
+ - 50def57c-7bbe-402c-b62c-6a7819f7805f
x-correlation-id:
- - d5130858-d1d5-44c9-9f20-7c1f87c5dfe1
+ - 50def57c-7bbe-402c-b62c-6a7819f7805f
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[False-30.00-36.90-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[False-30.00-36.90-False].yaml
index 9cc5528f92..175c080006 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[False-30.00-36.90-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[False-30.00-36.90-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "UHJvZHVjdFZhcmlhbnQ6Mg", "discounted": false, "description":
"Test product"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": false, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "e708a76b-18b6-4d40-83ae-922cfc20f676", "date": "2022-09-08",
+ null}], "code": "1e53b39c-b9c1-445c-8e50-a6496db476a8", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"e708a76b-18b6-4d40-83ae-922cfc20f676","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.2,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:16.0675903Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":30.0,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"1e53b39c-b9c1-445c-8e50-a6496db476a8","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.2,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:33.3559579Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":30.0,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:16 GMT
+ - Fri, 09 Sep 2022 08:58:33 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0150274'
+ - '00:00:00.0174940'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 9ae234a5-409f-46af-a3ef-ecd186a7c07c
+ - 677442c8-851f-46f1-9e94-18b8dab16707
x-correlation-id:
- - 9ae234a5-409f-46af-a3ef-ecd186a7c07c
+ - 677442c8-851f-46f1-9e94-18b8dab16707
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[True-12.20-15.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[True-12.20-15.00-True].yaml
index 4371c572eb..5827cee970 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[True-12.20-15.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[True-12.20-15.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "UHJvZHVjdFZhcmlhbnQ6Mg", "discounted": false, "description":
"Test product"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": true, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "b12bf3ce-b209-4f9e-8216-30ebb11aab65", "date": "2022-09-08",
+ null}], "code": "85eb319b-71f6-45af-8f77-438b15e62709", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"b12bf3ce-b209-4f9e-8216-30ebb11aab65","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:14.9889423Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":12.2000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"85eb319b-71f6-45af-8f77-438b15e62709","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:29.2504092Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":12.2000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:14 GMT
+ - Fri, 09 Sep 2022 08:58:29 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0176142'
+ - '00:00:00.0168936'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - ff31adfd-9b02-4627-aee6-ca62ba879f6e
+ - 4bd04d9d-10f0-442c-9cee-55de382678d5
x-correlation-id:
- - ff31adfd-9b02-4627-aee6-ca62ba879f6e
+ - 4bd04d9d-10f0-442c-9cee-55de382678d5
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[True-15.00-18.45-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[True-15.00-18.45-False].yaml
index 9f283e3c3e..c81169382c 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[True-15.00-18.45-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_line_without_sku_total[True-15.00-18.45-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "UHJvZHVjdFZhcmlhbnQ6Mg", "discounted": false, "description":
"Test product"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": false, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "81798039-b7bb-4086-b05e-74421bd0c9d3", "date": "2022-09-08",
+ null}], "code": "dcb8ed52-a395-41a8-b6ae-82f87d038b92", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"81798039-b7bb-4086-b05e-74421bd0c9d3","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":25.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.75,"totalTaxable":25.0,"totalTaxCalculated":5.75,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:18.1098558Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":15.0,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":3.45,"taxableAmount":15.0,"taxCalculated":3.45,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.45,"taxableAmount":15.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":3.45,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":15.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.45,"reportingTaxCalculated":3.45,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"dcb8ed52-a395-41a8-b6ae-82f87d038b92","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":25.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.75,"totalTaxable":25.0,"totalTaxCalculated":5.75,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:31.8530124Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":15.0,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":3.45,"taxableAmount":15.0,"taxCalculated":3.45,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.45,"taxableAmount":15.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":3.45,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":15.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.45,"reportingTaxCalculated":3.45,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:18 GMT
+ - Fri, 09 Sep 2022 08:58:31 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0175231'
+ - '00:00:00.0171752'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 4929df3e-bca0-4e0c-ab13-fce1f0ffbffd
+ - 6bd2957e-b517-4a44-92f2-a5f26337d53d
x-correlation-id:
- - 4929df3e-bca0-4e0c-ab13-fce1f0ffbffd
+ - 6bd2957e-b517-4a44-92f2-a5f26337d53d
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_shipping.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_shipping.yaml
index 50e08172c8..5382b33462 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_shipping.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_shipping.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "de52b845-e0f5-4b48-b2c8-2a4a19b332df", "date": "2022-09-08", "customerCode":
+ "29dc52b4-d661-4f33-9705-ff1051b1a7a8", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"de52b845-e0f5-4b48-b2c8-2a4a19b332df","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:22.1496047Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"29dc52b4-d661-4f33-9705-ff1051b1a7a8","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:06.6865697Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:22 GMT
+ - Fri, 09 Sep 2022 08:59:06 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0160305'
+ - '00:00:00.0172018'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 3920161f-430e-49f5-a98d-04471dc71676
+ - e1d2d867-da8c-48cf-aa97-bbdeb6755ea1
x-correlation-id:
- - 3920161f-430e-49f5-a98d-04471dc71676
+ - e1d2d867-da8c-48cf-aa97-bbdeb6755ea1
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[False-40.65-50.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[False-40.65-50.00-True].yaml
index 6a0a32e93d..573b97360a 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[False-40.65-50.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[False-40.65-50.00-True].yaml
@@ -7,7 +7,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product",
"ref1": "SKU_A"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": true, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "19bdb37f-ec68-4581-a24d-0bbab3d75197", "date": "2022-09-08",
+ null}], "code": "3f4a65a4-ddad-425a-b0e3-4bdb93afcac7", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -30,11 +30,11 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"19bdb37f-ec68-4581-a24d-0bbab3d75197","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":48.78,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":11.22,"totalTaxable":48.78,"totalTaxCalculated":11.22,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:23.6475756Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"3f4a65a4-ddad-425a-b0e3-4bdb93afcac7","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":48.78,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":11.22,"totalTaxable":48.78,"totalTaxCalculated":11.22,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T09:24:44.0254981Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"SKU_A","lineAmount":16.2600,"quantity":2.0,"ref1":"SKU_A","ref2":"","reportingDate":"2022-09-08","tax":3.74,"taxableAmount":16.26,"taxCalculated":3.74,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.74,"taxableAmount":16.26,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":3.74,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":16.26,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.74,"reportingTaxCalculated":3.74,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"SKU_A","lineAmount":16.2600,"quantity":2.0,"ref1":"SKU_A","ref2":"","reportingDate":"2022-09-09","tax":3.74,"taxableAmount":16.26,"taxCalculated":3.74,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.74,"taxableAmount":16.26,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":3.74,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":16.26,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.74,"reportingTaxCalculated":3.74,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -45,11 +45,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:23 GMT
+ - Fri, 09 Sep 2022 09:24:44 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0253987'
+ - '00:00:00.0208767'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -63,9 +63,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - e26e9353-2465-4c3b-a148-cd0cacc15e7c
+ - 1add8bc4-6cd0-4cea-83d5-912261c94d84
x-correlation-id:
- - e26e9353-2465-4c3b-a148-cd0cacc15e7c
+ - 1add8bc4-6cd0-4cea-83d5-912261c94d84
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[False-50.00-61.50-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[False-50.00-61.50-False].yaml
index 4526e47901..01317e7eff 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[False-50.00-61.50-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[False-50.00-61.50-False].yaml
@@ -7,7 +7,7 @@ interactions:
false, "itemCode": "SKU_A", "discounted": false, "description": "Test product",
"ref1": "SKU_A"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": false, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "2d3104d8-c9c4-485f-a85a-20e584c102a6", "date": "2022-09-08",
+ null}], "code": "2915c721-374a-45cf-8c03-51d17a468583", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -30,11 +30,11 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"2d3104d8-c9c4-485f-a85a-20e584c102a6","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":60.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":13.8,"totalTaxable":60.0,"totalTaxCalculated":13.8,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:25.3425933Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"2915c721-374a-45cf-8c03-51d17a468583","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":60.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":13.8,"totalTaxable":60.0,"totalTaxCalculated":13.8,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T09:24:44.573579Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"SKU_A","lineAmount":20.0,"quantity":2.0,"ref1":"SKU_A","ref2":"","reportingDate":"2022-09-08","tax":4.6,"taxableAmount":20.0,"taxCalculated":4.6,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":4.6,"taxableAmount":20.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":4.6,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":20.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":4.6,"reportingTaxCalculated":4.6,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"SKU_A","lineAmount":20.0,"quantity":2.0,"ref1":"SKU_A","ref2":"","reportingDate":"2022-09-09","tax":4.6,"taxableAmount":20.0,"taxCalculated":4.6,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":4.6,"taxableAmount":20.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":4.6,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":20.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":4.6,"reportingTaxCalculated":4.6,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -45,11 +45,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:25 GMT
+ - Fri, 09 Sep 2022 09:24:44 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0209366'
+ - '00:00:00.0212712'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -63,9 +63,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 2b49ad7c-3237-42fd-9845-77b7b4c9f86c
+ - f60dbb1c-0004-4116-8b86-e17dfbd20e7f
x-correlation-id:
- - 2b49ad7c-3237-42fd-9845-77b7b4c9f86c
+ - f60dbb1c-0004-4116-8b86-e17dfbd20e7f
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[True-20.33-25.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[True-20.33-25.00-True].yaml
index 2b29fa0d3b..544f7f603e 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[True-20.33-25.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[True-20.33-25.00-True].yaml
@@ -7,7 +7,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product",
"ref1": "SKU_A"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": true, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "7de5009b-7b73-4468-b355-c043affcc90d", "date": "2022-09-08",
+ null}], "code": "5b0b2c6b-0d48-4254-b61e-b24a16d1af53", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -30,11 +30,11 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"7de5009b-7b73-4468-b355-c043affcc90d","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":28.46,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.54,"totalTaxable":28.46,"totalTaxCalculated":6.54,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:26.9266066Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"5b0b2c6b-0d48-4254-b61e-b24a16d1af53","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":28.46,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.54,"totalTaxable":28.46,"totalTaxCalculated":6.54,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T09:24:44.5741508Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"SKU_A","lineAmount":8.1300,"quantity":2.0,"ref1":"SKU_A","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"SKU_A","lineAmount":8.1300,"quantity":2.0,"ref1":"SKU_A","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -45,11 +45,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:26 GMT
+ - Fri, 09 Sep 2022 09:24:44 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0206965'
+ - '00:00:00.0219526'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -63,9 +63,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 714fad19-5889-46b6-a723-dd0fa564b67f
+ - 57bb67cb-bb4c-4062-80b9-72882fa42ef0
x-correlation-id:
- - 714fad19-5889-46b6-a723-dd0fa564b67f
+ - 57bb67cb-bb4c-4062-80b9-72882fa42ef0
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[True-25.00-30.75-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[True-25.00-30.75-False].yaml
index 5f9ffab60f..5a3bb7a23c 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[True-25.00-30.75-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal[True-25.00-30.75-False].yaml
@@ -7,7 +7,7 @@ interactions:
false, "itemCode": "SKU_A", "discounted": false, "description": "Test product",
"ref1": "SKU_A"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": false, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "5d51f4d1-4033-4814-9429-c981962f5174", "date": "2022-09-08",
+ null}], "code": "e5dfab63-00be-433b-a113-d38587976fce", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -30,11 +30,11 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"5d51f4d1-4033-4814-9429-c981962f5174","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":35.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.05,"totalTaxable":35.0,"totalTaxCalculated":8.05,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:21.7299477Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":3.45,"taxableAmount":15.0,"taxCalculated":3.45,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.45,"taxableAmount":15.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"e5dfab63-00be-433b-a113-d38587976fce","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":35.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.05,"totalTaxable":35.0,"totalTaxCalculated":8.05,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T09:24:44.0293731Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":3.45,"taxableAmount":15.0,"taxCalculated":3.45,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":3.45,"taxableAmount":15.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":3.45,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":15.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.45,"reportingTaxCalculated":3.45,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"SKU_A","lineAmount":10.0,"quantity":2.0,"ref1":"SKU_A","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"SKU_A","lineAmount":10.0,"quantity":2.0,"ref1":"SKU_A","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -45,11 +45,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:21 GMT
+ - Fri, 09 Sep 2022 09:24:44 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0197905'
+ - '00:00:00.0207737'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -63,9 +63,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 930cba11-c923-49d4-9d3f-06f6557b0601
+ - c51f907a-d441-41d7-853d-4c3fb954874b
x-correlation-id:
- - 930cba11-c923-49d4-9d3f-06f6557b0601
+ - c51f907a-d441-41d7-853d-4c3fb954874b
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[False].yaml
index a4dbdf9701..f3fa1c8643 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[False].yaml
@@ -2,10 +2,10 @@ interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
- false, "itemCode": "123", "discounted": true, "description": "Test product",
+ true, "itemCode": "123", "discounted": true, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
- false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "5880ec70-5a40-42ab-88cd-683f29dadd31", "date": "2022-09-08", "customerCode":
+ true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
+ "24a3a4f0-a85f-4601-a0f3-4afeaf23b40f", "date": "2022-09-09", "customerCode":
0, "discount": "30.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -21,31 +21,31 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '851'
+ - '849'
User-Agent:
- python-requests/2.28.1
method: POST
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"5880ec70-5a40-42ab-88cd-683f29dadd31","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":30.0,"totalTax":2.3,"totalTaxable":10.0,"totalTaxCalculated":2.3,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:21.9260242Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":30.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
+ string: '{"id":0,"code":"24a3a4f0-a85f-4601-a0f3-4afeaf23b40f","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":30.0,"totalTax":1.87,"totalTaxable":8.13,"totalTaxCalculated":1.87,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:15.6148574Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":30.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
- Rate","rateType":"Standard","taxable":10.0,"rate":0.230000,"tax":2.3,"taxCalculated":2.3,"nonTaxable":0.0,"exemption":0.0}]}'
+ Rate","rateType":"Standard","taxable":8.13,"rate":0.230000,"tax":1.87,"taxCalculated":1.87,"nonTaxable":0.0,"exemption":0.0}]}'
headers:
Connection:
- keep-alive
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:21 GMT
+ - Fri, 09 Sep 2022 08:59:15 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0152795'
+ - '00:00:00.0159475'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 581c91fd-1996-4be3-9160-8bfabcc8744d
+ - bf9d9631-6371-491d-bffe-788b7c844f58
x-correlation-id:
- - 581c91fd-1996-4be3-9160-8bfabcc8744d
+ - bf9d9631-6371-491d-bffe-788b7c844f58
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[True].yaml
index e220e4f4ad..fc717441bf 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": true, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "70b1e4c2-6f64-4bb6-8f29-a2572faba96b", "date": "2022-09-08", "customerCode":
+ "4ac5d15f-a586-4133-a486-68b0f2d0c640", "date": "2022-09-09", "customerCode":
0, "discount": "30.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"70b1e4c2-6f64-4bb6-8f29-a2572faba96b","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":30.0,"totalTax":1.87,"totalTaxable":8.13,"totalTaxCalculated":1.87,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:28.8620727Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":30.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"4ac5d15f-a586-4133-a486-68b0f2d0c640","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":30.0,"totalTax":1.87,"totalTaxable":8.13,"totalTaxCalculated":1.87,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:14.1687417Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":30.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:28 GMT
+ - Fri, 09 Sep 2022 08:59:14 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0153931'
+ - '00:00:00.0159325'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 487ce187-51e8-4a7b-aa0e-e6aee54f464a
+ - 61b8f710-c9fe-4426-8c6b-54cfc684edc7
x-correlation-id:
- - 487ce187-51e8-4a7b-aa0e-e6aee54f464a
+ - 61b8f710-c9fe-4426-8c6b-54cfc684edc7
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[24.39-30.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[24.39-30.00-True].yaml
index d7a4076178..e4424111f6 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[24.39-30.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[24.39-30.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": true, "description": null}], "code":
- "863bde0d-75fb-4a43-8318-51ef50eebff2", "date": "2022-09-08", "customerCode":
+ "97eec62c-77e9-4c1f-9bd4-2f305739630b", "date": "2022-09-09", "customerCode":
0, "discount": "10.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"863bde0d-75fb-4a43-8318-51ef50eebff2","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":34.39,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:23.6373684Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":10.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"97eec62c-77e9-4c1f-9bd4-2f305739630b","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":34.39,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T10:13:02.7476628Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":10.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:23 GMT
+ - Fri, 09 Sep 2022 10:13:02 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0154032'
+ - '00:00:00.0233471'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 12811c44-7793-48c6-9b1f-1550c57b3b2e
+ - a180bd8e-15e5-482b-a585-d072adb5025f
x-correlation-id:
- - 12811c44-7793-48c6-9b1f-1550c57b3b2e
+ - a180bd8e-15e5-482b-a585-d072adb5025f
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[30.00-36.90-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[30.00-36.90-False].yaml
index c03479a8d8..b8b421edfd 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[30.00-36.90-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[30.00-36.90-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
false, "itemCode": "Shipping", "discounted": true, "description": null}], "code":
- "54aa844c-6598-472e-abf7-a515a5a9708b", "date": "2022-09-08", "customerCode":
+ "686b9ab8-ee2e-43dc-8d32-35f047781175", "date": "2022-09-09", "customerCode":
0, "discount": "10.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"54aa844c-6598-472e-abf7-a515a5a9708b","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:25.3017054Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":10.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"686b9ab8-ee2e-43dc-8d32-35f047781175","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T10:13:02.7095925Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":10.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:25 GMT
+ - Fri, 09 Sep 2022 10:13:02 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0151400'
+ - '00:00:00.0152280'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 774e1fb9-8b47-4201-82bb-601f15e4d7fd
+ - a37426a1-e1f1-4983-bce8-fb670fe82de5
x-correlation-id:
- - 774e1fb9-8b47-4201-82bb-601f15e4d7fd
+ - a37426a1-e1f1-4983-bce8-fb670fe82de5
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-32.04-38.99-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-32.04-38.99-3.0-True].yaml
index 4cdcce67a4..db84bccca0 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-32.04-38.99-3.0-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-32.04-38.99-3.0-True].yaml
@@ -9,7 +9,7 @@ interactions:
0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "9342458a-8d87-4208-8fc7-a643f855d756", "date": "2022-09-08", "customerCode":
+ "535c98ab-c71d-45a2-b9f6-67b3813cfecd", "date": "2022-09-09", "customerCode":
0, "discount": "3.0", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -32,12 +32,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"9342458a-8d87-4208-8fc7-a643f855d756","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":35.04,"totalExempt":1.8,"totalDiscount":3.0,"totalTax":6.95,"totalTaxable":30.24,"totalTaxCalculated":7.36,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:20.9404802Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":2.81,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.9200,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.08,"taxableAmount":22.11,"taxCalculated":5.08,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.08,"taxableAmount":22.11,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"535c98ab-c71d-45a2-b9f6-67b3813cfecd","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":35.04,"totalExempt":1.8,"totalDiscount":3.0,"totalTax":6.95,"totalTaxable":30.24,"totalTaxCalculated":7.36,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:56.3708705Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":2.81,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.9200,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.08,"taxableAmount":22.11,"taxCalculated":5.08,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.08,"taxableAmount":22.11,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":5.08,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":22.11,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.08,"reportingTaxCalculated":5.08,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.19,"exemptAmount":1.8,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.41,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ product with single variant","discountAmount":0.19,"exemptAmount":1.8,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.41,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.8,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.41,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.8,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.41,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.41,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.8,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.41,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -48,11 +48,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:20 GMT
+ - Fri, 09 Sep 2022 08:58:56 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0214658'
+ - '00:00:00.0188253'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -66,9 +66,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - c39b3f7d-8729-4ab0-85ca-17e27d39d40e
+ - 21443542-ba37-400e-a04d-139344a993a0
x-correlation-id:
- - c39b3f7d-8729-4ab0-85ca-17e27d39d40e
+ - 21443542-ba37-400e-a04d-139344a993a0
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-41.99-51.05-0.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-41.99-51.05-0.0-False].yaml
deleted file mode 100644
index c0e7ee41bd..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-41.99-51.05-0.0-False].yaml
+++ /dev/null
@@ -1,81 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PS081282", "taxIncluded":
- false, "itemCode": "123", "discounted": true, "description": "Test product",
- "ref1": "123"}, {"quantity": 1, "amount": "1.99", "taxCode": "O9999999", "taxIncluded":
- false, "itemCode": "SKU_SINGLE_VARIANT", "discounted": true, "description":
- "Test product with single variant", "taxOverride": {"type": "taxAmount", "taxAmount":
- 0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
- {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false,
- "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "35e78b2a-195b-4fc8-b6d7-66d201449c5e", "date": "2022-09-08", "customerCode":
- 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
- null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
- "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
- "region": "", "country": "PL", "postalCode": "53-105"}}, "commit": false, "currencyCode":
- "USD", "email": "[email protected]"}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate, br
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '1175'
- User-Agent:
- - python-requests/2.28.1
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: '{"id":0,"code":"35e78b2a-195b-4fc8-b6d7-66d201449c5e","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":41.99,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.66,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:19.0505943Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
- taxes for this product are turned off.","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.99,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
- Rate","rateType":"Standard","taxable":40.0,"rate":0.230000,"tax":9.2,"taxCalculated":9.66,"nonTaxable":1.99,"exemption":0.0}]}'
- headers:
- Connection:
- - keep-alive
- Content-Type:
- - application/json; charset=utf-8
- Date:
- - Thu, 08 Sep 2022 10:53:19 GMT
- Location:
- - /api/v2/companies/7799660/transactions/0
- ServerDuration:
- - '00:00:00.0204176'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- api-supported-versions:
- - '2.0'
- cache-control:
- - private, no-cache, no-store
- referrer-policy:
- - same-origin
- strict-transport-security:
- - max-age=31536000; includeSubdomains
- x-avalara-uid:
- - 2ee4ccb3-d0a5-4705-8d09-a466522ddefd
- x-correlation-id:
- - 2ee4ccb3-d0a5-4705-8d09-a466522ddefd
- x-frame-options:
- - sameorigin
- x-permitted-cross-domain-policies:
- - none
- x-xss-protection:
- - 1; mode=block
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-41.99-51.19-0.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-41.99-51.19-0.0-False].yaml
index cd6398fd26..273e1c43b6 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-41.99-51.19-0.0-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-41.99-51.19-0.0-False].yaml
@@ -9,7 +9,7 @@ interactions:
0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "1706ca1e-d71e-4ed4-84c7-a88e2d718a51", "date": "2022-09-08", "customerCode":
+ "e00a37fa-18d0-4c2e-8359-b898da16ab2f", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -32,12 +32,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"1706ca1e-d71e-4ed4-84c7-a88e2d718a51","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":41.99,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.66,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T11:13:48.3998537Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"e00a37fa-18d0-4c2e-8359-b898da16ab2f","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":41.99,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.66,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:54.8804898Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.99,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -48,11 +48,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 11:13:48 GMT
+ - Fri, 09 Sep 2022 08:58:54 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0214735'
+ - '00:00:00.0190391'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -66,9 +66,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 15c7f56a-f3f1-4f69-95bf-636eded5ca72
+ - 5fb6b12e-d632-4c1d-940e-fcfb9e7e103c
x-correlation-id:
- - 15c7f56a-f3f1-4f69-95bf-636eded5ca72
+ - 5fb6b12e-d632-4c1d-940e-fcfb9e7e103c
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.46-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.46-5.0-False].yaml
deleted file mode 100644
index 1fe1d8c28c..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.46-5.0-False].yaml
+++ /dev/null
@@ -1,81 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PS081282", "taxIncluded":
- false, "itemCode": "123", "discounted": true, "description": "Test product",
- "ref1": "123"}, {"quantity": 1, "amount": "1.99", "taxCode": "O9999999", "taxIncluded":
- false, "itemCode": "SKU_SINGLE_VARIANT", "discounted": true, "description":
- "Test product with single variant", "taxOverride": {"type": "taxAmount", "taxAmount":
- 0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
- {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false,
- "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "e965b9dc-e782-49df-8ed2-955b2755125e", "date": "2022-09-08", "customerCode":
- 0, "discount": "5.0", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
- null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
- "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
- "region": "", "country": "PL", "postalCode": "53-105"}}, "commit": false, "currencyCode":
- "USD", "email": "[email protected]"}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate, br
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '1176'
- User-Agent:
- - python-requests/2.28.1
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: '{"id":0,"code":"e965b9dc-e782-49df-8ed2-955b2755125e","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":26.99,"totalExempt":1.4,"totalDiscount":5.0,"totalTax":4.74,"totalTaxable":20.59,"totalTaxCalculated":5.06,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:21.1317221Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":4.41,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.44,"taxableAmount":10.59,"taxCalculated":2.44,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.44,"taxableAmount":10.59,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.44,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.59,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.44,"reportingTaxCalculated":2.44,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.59,"exemptAmount":1.4,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.32,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
- taxes for this product are turned off.","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.4,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.32,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.4,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.32,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
- Rate","rateType":"Standard","taxable":20.59,"rate":0.230000,"tax":4.74,"taxCalculated":5.06,"nonTaxable":1.4,"exemption":0.0}]}'
- headers:
- Connection:
- - keep-alive
- Content-Type:
- - application/json; charset=utf-8
- Date:
- - Thu, 08 Sep 2022 10:53:21 GMT
- Location:
- - /api/v2/companies/7799660/transactions/0
- ServerDuration:
- - '00:00:00.0212530'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- api-supported-versions:
- - '2.0'
- cache-control:
- - private, no-cache, no-store
- referrer-policy:
- - same-origin
- strict-transport-security:
- - max-age=31536000; includeSubdomains
- x-avalara-uid:
- - efbfae98-b089-4c90-b5ce-9691e56cd958
- x-correlation-id:
- - efbfae98-b089-4c90-b5ce-9691e56cd958
- x-frame-options:
- - sameorigin
- x-permitted-cross-domain-policies:
- - none
- x-xss-protection:
- - 1; mode=block
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.73-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.73-5.0-False].yaml
index 2df7bbe6d3..4573a30f22 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.73-5.0-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.73-5.0-False].yaml
@@ -9,7 +9,7 @@ interactions:
0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "616f650e-7fe2-4ac9-9e57-f8cbd8f3f296", "date": "2022-09-08", "customerCode":
+ "3350f034-bb3f-46a2-b0db-1242bdfd967b", "date": "2022-09-09", "customerCode":
0, "discount": "5.0", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -32,12 +32,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"616f650e-7fe2-4ac9-9e57-f8cbd8f3f296","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":26.99,"totalExempt":1.4,"totalDiscount":5.0,"totalTax":4.74,"totalTaxable":20.59,"totalTaxCalculated":5.06,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T11:13:48.5492145Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":4.41,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.44,"taxableAmount":10.59,"taxCalculated":2.44,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.44,"taxableAmount":10.59,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"3350f034-bb3f-46a2-b0db-1242bdfd967b","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":26.99,"totalExempt":1.4,"totalDiscount":5.0,"totalTax":4.74,"totalTaxable":20.59,"totalTaxCalculated":5.06,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:53.2123215Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":4.41,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.44,"taxableAmount":10.59,"taxCalculated":2.44,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.44,"taxableAmount":10.59,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.44,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.59,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.44,"reportingTaxCalculated":2.44,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.59,"exemptAmount":1.4,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.32,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ product with single variant","discountAmount":0.59,"exemptAmount":1.4,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.32,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.4,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.32,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.4,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.32,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.32,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.4,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.32,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -48,11 +48,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 11:13:48 GMT
+ - Fri, 09 Sep 2022 08:58:53 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0194582'
+ - '00:00:00.0189100'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -66,9 +66,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - c2a22334-865e-44f1-9aaf-8047abf5e8f6
+ - 86f19af4-3411-49e8-af6d-7315c7ec9eab
x-correlation-id:
- - c2a22334-865e-44f1-9aaf-8047abf5e8f6
+ - 86f19af4-3411-49e8-af6d-7315c7ec9eab
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-22.32-26.99-0.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-22.32-26.99-0.0-True].yaml
index 02c8342a2a..41131ae056 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-22.32-26.99-0.0-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-22.32-26.99-0.0-True].yaml
@@ -9,7 +9,7 @@ interactions:
0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "e4b4c4a5-22e9-4552-958f-b22e97ff99aa", "date": "2022-09-08", "customerCode":
+ "9676a205-d2a8-4a8b-b85e-d58b71171aff", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -32,12 +32,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"e4b4c4a5-22e9-4552-958f-b22e97ff99aa","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":22.32,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":5.13,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:20.3300687Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"9676a205-d2a8-4a8b-b85e-d58b71171aff","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":22.32,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":5.13,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:51.7435986Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"PS081282","taxCodeId":38007,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.99,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -48,11 +48,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:20 GMT
+ - Fri, 09 Sep 2022 08:58:51 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0185081'
+ - '00:00:00.0250610'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -66,9 +66,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - e0705a8d-30b3-4db1-aa1e-1073555d8eb9
+ - f91349b8-4b84-4bea-b288-27de01904867
x-correlation-id:
- - e0705a8d-30b3-4db1-aa1e-1073555d8eb9
+ - f91349b8-4b84-4bea-b288-27de01904867
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_not_charged_product_and_shipping_with_0_price.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_not_charged_product_and_shipping_with_0_price.yaml
index 597d6aa536..84b8d8c75c 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_not_charged_product_and_shipping_with_0_price.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_not_charged_product_and_shipping_with_0_price.yaml
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [], "code": "b47700e7-dab7-4be8-8374-4f77de101efe", "date": "2022-09-08",
+ "lines": [], "code": "715e26e3-7f29-4ed6-926e-1894cc4117f2", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -34,9 +34,9 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:23 GMT
+ - Fri, 09 Sep 2022 08:59:05 GMT
ServerDuration:
- - '00:00:00.0001835'
+ - '00:00:00.0001832'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -50,9 +50,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - eab8e0b4-d5bd-4db4-afef-d20ae720183a
+ - 69c8484e-2153-44a3-a0fa-137eba02ab1c
x-correlation-id:
- - eab8e0b4-d5bd-4db4-afef-d20ae720183a
+ - 69c8484e-2153-44a3-a0fa-137eba02ab1c
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-32.04-38.99-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-32.04-38.99-3.0-True].yaml
index 9faf31a4e0..6a91504afc 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-32.04-38.99-3.0-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-32.04-38.99-3.0-True].yaml
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
true, "itemCode": "123", "discounted": true, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "1.99", "taxCode": "O9999999", "taxIncluded":
true, "itemCode": "SKU_SINGLE_VARIANT", "discounted": true, "description": "Test
@@ -9,7 +9,7 @@ interactions:
0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "68481770-aa80-4ca4-b92d-23ff0ef6de79", "date": "2022-09-08", "customerCode":
+ "c833cd80-75e0-43b1-b0b5-7c3f4f5ee260", "date": "2022-09-09", "customerCode":
0, "discount": "3.0", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -32,12 +32,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"68481770-aa80-4ca4-b92d-23ff0ef6de79","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":35.04,"totalExempt":1.8,"totalDiscount":3.0,"totalTax":6.95,"totalTaxable":30.24,"totalTaxCalculated":7.36,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T11:13:12.5566266Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":2.81,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.9200,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.08,"taxableAmount":22.11,"taxCalculated":5.08,"taxCode":"PC040156","taxCodeId":10393,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.08,"taxableAmount":22.11,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.08,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":22.11,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.08,"reportingTaxCalculated":5.08,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.19,"exemptAmount":1.8,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.41,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ string: '{"id":0,"code":"c833cd80-75e0-43b1-b0b5-7c3f4f5ee260","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":35.04,"totalExempt":1.8,"totalDiscount":3.0,"totalTax":6.95,"totalTaxable":30.24,"totalTaxCalculated":7.36,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:50.2450937Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":2.81,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.9200,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.08,"taxableAmount":22.11,"taxCalculated":5.08,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.08,"taxableAmount":22.11,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.08,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":22.11,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.08,"reportingTaxCalculated":5.08,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
+ product with single variant","discountAmount":0.19,"exemptAmount":1.8,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.41,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.8,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.41,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.8,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.41,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.41,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.8,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.41,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -48,11 +48,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 11:13:12 GMT
+ - Fri, 09 Sep 2022 08:58:50 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0217009'
+ - '00:00:00.0208995'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -66,9 +66,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 12a8057c-ac70-4a40-9123-0c2df67e3527
+ - 2660be48-a317-4c81-bcf8-907a796d89f1
x-correlation-id:
- - 12a8057c-ac70-4a40-9123-0c2df67e3527
+ - 2660be48-a317-4c81-bcf8-907a796d89f1
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-41.99-51.19-0.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-41.99-51.19-0.0-False].yaml
index 682d99a895..29ce44def7 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-41.99-51.19-0.0-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-41.99-51.19-0.0-False].yaml
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
false, "itemCode": "123", "discounted": true, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "1.99", "taxCode": "O9999999", "taxIncluded":
false, "itemCode": "SKU_SINGLE_VARIANT", "discounted": true, "description":
@@ -9,7 +9,7 @@ interactions:
0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "45abd6f0-4a2b-4405-96c8-8c549328cb75", "date": "2022-09-08", "customerCode":
+ "14684008-c892-461c-9411-03f2891f3fa7", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -32,12 +32,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"45abd6f0-4a2b-4405-96c8-8c549328cb75","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":41.99,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.66,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T11:13:12.5767303Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"PC040156","taxCodeId":10393,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ string: '{"id":0,"code":"14684008-c892-461c-9411-03f2891f3fa7","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":41.99,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":9.2,"totalTaxable":40.0,"totalTaxCalculated":9.66,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:48.7280823Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
+ product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.99,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -48,11 +48,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 11:13:12 GMT
+ - Fri, 09 Sep 2022 08:58:48 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0203907'
+ - '00:00:00.0205413'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -66,9 +66,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 83fa6c23-f8f0-41a5-939f-d6099298f76b
+ - 8ddca86c-47c6-4246-b731-a02d582d7a2e
x-correlation-id:
- - 83fa6c23-f8f0-41a5-939f-d6099298f76b
+ - 8ddca86c-47c6-4246-b731-a02d582d7a2e
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-26.73-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-26.73-5.0-False].yaml
index 1c0a0b74d2..80c8130015 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-26.73-5.0-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-26.73-5.0-False].yaml
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
+ "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "O9999999", "taxIncluded":
false, "itemCode": "123", "discounted": true, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "1.99", "taxCode": "O9999999", "taxIncluded":
false, "itemCode": "SKU_SINGLE_VARIANT", "discounted": true, "description":
@@ -9,7 +9,7 @@ interactions:
0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "61586e38-de53-4cfb-b23f-d6bf03d577cd", "date": "2022-09-08", "customerCode":
+ "8e397871-1e70-489f-ae1e-6308deffffbc", "date": "2022-09-09", "customerCode":
0, "discount": "5.0", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -32,12 +32,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"61586e38-de53-4cfb-b23f-d6bf03d577cd","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":26.99,"totalExempt":1.4,"totalDiscount":5.0,"totalTax":4.74,"totalTaxable":20.59,"totalTaxCalculated":5.06,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T11:13:12.557424Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":4.41,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.44,"taxableAmount":10.59,"taxCalculated":2.44,"taxCode":"PC040156","taxCodeId":10393,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.44,"taxableAmount":10.59,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.44,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.59,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.44,"reportingTaxCalculated":2.44,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.59,"exemptAmount":1.4,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.32,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ string: '{"id":0,"code":"8e397871-1e70-489f-ae1e-6308deffffbc","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":26.99,"totalExempt":1.4,"totalDiscount":5.0,"totalTax":4.74,"totalTaxable":20.59,"totalTaxCalculated":5.06,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:47.210947Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":4.41,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.44,"taxableAmount":10.59,"taxCalculated":2.44,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.44,"taxableAmount":10.59,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.44,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.59,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.44,"reportingTaxCalculated":2.44,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
+ product with single variant","discountAmount":0.59,"exemptAmount":1.4,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.32,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.4,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.32,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.4,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.32,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.32,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.4,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.32,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -48,11 +48,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 11:13:12 GMT
+ - Fri, 09 Sep 2022 08:58:47 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0248365'
+ - '00:00:00.0200599'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -66,9 +66,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - d688206a-edda-49b3-ad97-6b96a17d09f8
+ - 68b1587c-c1d1-4f7d-bbe8-79920fe108c8
x-correlation-id:
- - d688206a-edda-49b3-ad97-6b96a17d09f8
+ - 68b1587c-c1d1-4f7d-bbe8-79920fe108c8
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-22.32-26.99-0.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-22.32-26.99-0.0-True].yaml
index 62dde2dd2d..f8a70ecd83 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-22.32-26.99-0.0-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-22.32-26.99-0.0-True].yaml
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
+ "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "O9999999", "taxIncluded":
true, "itemCode": "123", "discounted": true, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "1.99", "taxCode": "O9999999", "taxIncluded":
true, "itemCode": "SKU_SINGLE_VARIANT", "discounted": true, "description": "Test
@@ -9,7 +9,7 @@ interactions:
0, "reason": "Charge taxes for this product are turned off."}, "ref1": "SKU_SINGLE_VARIANT"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "507390d1-db1d-49aa-8db7-cdd4289bc12d", "date": "2022-09-08", "customerCode":
+ "1336d692-ea6e-49d5-aaed-14fcf3024b50", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -32,12 +32,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"507390d1-db1d-49aa-8db7-cdd4289bc12d","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":22.32,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":5.13,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T11:13:12.5552716Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"PC040156","taxCodeId":10393,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ string: '{"id":0,"code":"1336d692-ea6e-49d5-aaed-14fcf3024b50","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":22.32,"totalExempt":1.99,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":5.13,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:45.6998549Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
+ product with single variant","discountAmount":0.0,"exemptAmount":1.99,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"SKU_SINGLE_VARIANT","lineAmount":1.99,"quantity":1.0,"ref1":"SKU_SINGLE_VARIANT","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.46,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":1.99,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.46,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":1.99,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.46,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -48,11 +48,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 11:13:12 GMT
+ - Fri, 09 Sep 2022 08:58:45 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0215102'
+ - '00:00:00.0214758'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -66,9 +66,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - ea0d2d8b-5b43-4e9e-b5b3-b22d7144b97d
+ - d1fbec5c-884f-48bd-a67e-ecc6946fe80f
x-correlation-id:
- - ea0d2d8b-5b43-4e9e-b5b3-b22d7144b97d
+ - d1fbec5c-884f-48bd-a67e-ecc6946fe80f
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[10.00-12.30-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[10.00-12.30-False].yaml
index 43fa0d8148..172da0fc78 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[10.00-12.30-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[10.00-12.30-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "123", "discounted": true, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "7c38c06d-d1cb-4117-afdc-afd541a1ae6e", "date": "2022-09-08", "customerCode":
+ "6958d3c7-1eb9-4fa0-b662-a2fd393e0830", "date": "2022-09-09", "customerCode":
0, "discount": "30.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"7c38c06d-d1cb-4117-afdc-afd541a1ae6e","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":30.0,"totalTax":2.3,"totalTaxable":10.0,"totalTaxCalculated":2.3,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:23.4718612Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":30.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"6958d3c7-1eb9-4fa0-b662-a2fd393e0830","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":30.0,"totalTax":2.3,"totalTaxable":10.0,"totalTaxCalculated":2.3,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:58.9102129Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":30.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:23 GMT
+ - Fri, 09 Sep 2022 08:58:58 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0145798'
+ - '00:00:00.0169684'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - d114c868-8336-45e9-b212-4d23752c5fd1
+ - 2fc645e4-1fd3-4707-bd29-43968ce7ccb7
x-correlation-id:
- - d114c868-8336-45e9-b212-4d23752c5fd1
+ - 2fc645e4-1fd3-4707-bd29-43968ce7ccb7
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[8.13-10.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[8.13-10.00-True].yaml
index 141eea0791..370e10a299 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[8.13-10.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[8.13-10.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": true, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "f58b2910-e119-4d68-a6b2-9915a23d32df", "date": "2022-09-08", "customerCode":
+ "e409d539-553e-4910-a392-cfb0a8b1a358", "date": "2022-09-09", "customerCode":
0, "discount": "30.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"f58b2910-e119-4d68-a6b2-9915a23d32df","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":30.0,"totalTax":1.87,"totalTaxable":8.13,"totalTaxCalculated":1.87,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:20.5633079Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":30.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"e409d539-553e-4910-a392-cfb0a8b1a358","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":30.0,"totalTax":1.87,"totalTaxable":8.13,"totalTaxCalculated":1.87,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:58:57.6203131Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":30.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:20 GMT
+ - Fri, 09 Sep 2022 08:58:57 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0176626'
+ - '00:00:00.0169697'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 314a8f2a-5df6-4aad-b9ea-846dd01ebe29
+ - 5d4eb923-e079-454c-8b40-eb17f2000911
x-correlation-id:
- - 314a8f2a-5df6-4aad-b9ea-846dd01ebe29
+ - 5d4eb923-e079-454c-8b40-eb17f2000911
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_applied_once_per_order.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_applied_once_per_order.yaml
index c6e8775130..e70af8add4 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_applied_once_per_order.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_applied_once_per_order.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "c3fbbb98-478d-4d46-b45b-a605330c4e6a", "date": "2022-09-08", "customerCode":
+ "92f6efc2-b23c-4f8b-8426-989f1cf7cb82", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"c3fbbb98-478d-4d46-b45b-a605330c4e6a","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":31.71,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.29,"totalTaxable":31.71,"totalTaxCalculated":7.29,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:23.4704481Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":23.5800,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.42,"taxableAmount":23.58,"taxCalculated":5.42,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.42,"taxableAmount":23.58,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.42,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":23.58,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.42,"reportingTaxCalculated":5.42,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"92f6efc2-b23c-4f8b-8426-989f1cf7cb82","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":31.71,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.29,"totalTaxable":31.71,"totalTaxCalculated":7.29,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:00.226146Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":23.5800,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.42,"taxableAmount":23.58,"taxCalculated":5.42,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.42,"taxableAmount":23.58,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.42,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":23.58,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.42,"reportingTaxCalculated":5.42,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:23 GMT
+ - Fri, 09 Sep 2022 08:59:00 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0151805'
+ - '00:00:00.0168184'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 1ec0ff97-045d-4023-b9da-8cea7cce4c37
+ - 4f0e2b53-b577-43f3-a786-f0905dbd96af
x-correlation-id:
- - 1ec0ff97-045d-4023-b9da-8cea7cce4c37
+ - 4f0e2b53-b577-43f3-a786-f0905dbd96af
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes.yaml
index 02f8e9ec14..29ebdb17b3 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes.yaml
@@ -6,8 +6,8 @@ interactions:
"taxOverride": {"type": "taxAmount", "taxAmount": 0, "reason": "Charge taxes
for this product are turned off."}, "ref1": "123"}, {"quantity": 1, "amount":
"10.000", "taxCode": "FR000000", "taxIncluded": true, "itemCode": "Shipping",
- "discounted": false, "description": null}], "code": "39834d8a-b220-47eb-b346-eaa85427caa1",
- "date": "2022-09-08", "customerCode": 0, "discount": "2.0", "addresses": {"shipFrom":
+ "discounted": false, "description": null}], "code": "254e5ec6-d4af-4b84-9dd8-3b5d2254972d",
+ "date": "2022-09-09", "customerCode": 0, "discount": "2.0", "addresses": {"shipFrom":
{"line1": "Teczowa 7", "line2": null, "city": "Wroclaw", "region": "", "country":
"PL", "postalCode": "53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2":
"", "city": "WROC\u0141AW", "region": "", "country": "PL", "postalCode": "53-105"}},
@@ -29,10 +29,10 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"39834d8a-b220-47eb-b346-eaa85427caa1","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":38.13,"totalExempt":28.0,"totalDiscount":2.0,"totalTax":1.87,"totalTaxable":8.13,"totalTaxCalculated":8.31,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:20.2561232Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":2.0,"exemptAmount":28.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":6.44,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
+ string: '{"id":0,"code":"254e5ec6-d4af-4b84-9dd8-3b5d2254972d","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":38.13,"totalExempt":28.0,"totalDiscount":2.0,"totalTax":1.87,"totalTaxable":8.13,"totalTaxCalculated":8.31,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:01.5611744Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":2.0,"exemptAmount":28.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":6.44,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxOverrideType":"TaxAmount","taxOverrideAmount":0.0,"taxOverrideReason":"Charge
taxes for this product are turned off.","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":28.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":6.44,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":28.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":6.44,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":6.44,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":28.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":6.44,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -43,11 +43,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:20 GMT
+ - Fri, 09 Sep 2022 08:59:01 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0153001'
+ - '00:00:00.0227216'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -61,9 +61,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 18586c9d-af07-46d9-a8e6-ee1a4cd9d5a6
+ - 4722130d-4e0f-49aa-8565-84a81d79f72d
x-correlation-id:
- - 18586c9d-af07-46d9-a8e6-ee1a4cd9d5a6
+ - 4722130d-4e0f-49aa-8565-84a81d79f72d
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[24.39-30.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[24.39-30.00-True].yaml
index 207a00a0f6..e797b4ba88 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[24.39-30.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[24.39-30.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": true, "description": null}], "code":
- "7f22f397-42b8-4d83-8f31-13826622e16d", "date": "2022-09-08", "customerCode":
+ "00491b93-5481-453e-a042-16d25ba17ec4", "date": "2022-09-09", "customerCode":
0, "discount": "10.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"7f22f397-42b8-4d83-8f31-13826622e16d","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":34.39,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:21.7201288Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":10.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"00491b93-5481-453e-a042-16d25ba17ec4","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":34.39,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:02.8554612Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":10.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:21 GMT
+ - Fri, 09 Sep 2022 08:59:02 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0206311'
+ - '00:00:00.0171685'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 9b59f37d-505e-4540-842f-26989c549f3e
+ - 11966101-1eb0-4b9f-9989-f2c5bb4bdf25
x-correlation-id:
- - 9b59f37d-505e-4540-842f-26989c549f3e
+ - 11966101-1eb0-4b9f-9989-f2c5bb4bdf25
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[30.00-36.90-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[30.00-36.90-False].yaml
index 190372bf90..556a3644eb 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[30.00-36.90-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[30.00-36.90-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
false, "itemCode": "Shipping", "discounted": true, "description": null}], "code":
- "529cb63f-8eaa-4102-b0e8-9416cec38e67", "date": "2022-09-08", "customerCode":
+ "7c6e16ce-a3bb-4401-9687-8131889ba7aa", "date": "2022-09-09", "customerCode":
0, "discount": "10.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"529cb63f-8eaa-4102-b0e8-9416cec38e67","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:23.5382429Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":10.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"7c6e16ce-a3bb-4401-9687-8131889ba7aa","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:04.1447468Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":30.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":6.9,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":6.9,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":10.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:23 GMT
+ - Fri, 09 Sep 2022 08:59:04 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0168826'
+ - '00:00:00.0168738'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - c7123faf-00e3-40e4-bc15-aa39b8865dae
+ - a55f4ea0-d121-4442-81df-1b35b90800a3
x-correlation-id:
- - c7123faf-00e3-40e4-bc15-aa39b8865dae
+ - a55f4ea0-d121-4442-81df-1b35b90800a3
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total.yaml
index 4f75d97df8..3e3c7c1396 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "f53082df-3b79-40e3-bbc5-48d637a59280", "date": "2022-09-08", "customerCode":
+ "0066da6c-0161-43d6-8207-9b1a6e430559", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070687789,"code":"f53082df-3b79-40e3-bbc5-48d637a59280","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070687791,"destinationAddressId":85009070687790,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:18.5670893Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070687795,"transactionId":85009070687789,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070687790,"originAddressId":85009070687791,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070687816,"transactionLineId":85009070687795,"transactionId":85009070687789,"addressId":85009070687790,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070687798,"documentLineId":85009070687795,"documentAddressId":85009070687791,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070687799,"documentLineId":85009070687795,"documentAddressId":85009070687790,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070687796,"transactionId":85009070687789,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070687790,"originAddressId":85009070687791,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070687836,"transactionLineId":85009070687796,"transactionId":85009070687789,"addressId":85009070687790,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070687818,"documentLineId":85009070687796,"documentAddressId":85009070687791,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070687819,"documentLineId":85009070687796,"documentAddressId":85009070687790,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070687790,"transactionId":85009070687789,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009070687791,"transactionId":85009070687789,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070687793,"documentId":85009070687789,"documentAddressId":85009070687791,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070687794,"documentId":85009070687789,"documentAddressId":85009070687790,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141816769,"code":"0066da6c-0161-43d6-8207-9b1a6e430559","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141816771,"destinationAddressId":85009141816770,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:58:34.7395472Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141816775,"transactionId":85009141816769,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141816770,"originAddressId":85009141816771,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141816796,"transactionLineId":85009141816775,"transactionId":85009141816769,"addressId":85009141816770,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141816778,"documentLineId":85009141816775,"documentAddressId":85009141816771,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141816779,"documentLineId":85009141816775,"documentAddressId":85009141816770,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141816776,"transactionId":85009141816769,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141816770,"originAddressId":85009141816771,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141816816,"transactionLineId":85009141816776,"transactionId":85009141816769,"addressId":85009141816770,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141816798,"documentLineId":85009141816776,"documentAddressId":85009141816771,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141816799,"documentLineId":85009141816776,"documentAddressId":85009141816770,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141816770,"transactionId":85009141816769,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009141816771,"transactionId":85009141816769,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141816773,"documentId":85009141816769,"documentAddressId":85009141816771,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141816774,"documentId":85009141816769,"documentAddressId":85009141816770,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":32.52,"rate":0.230000,"tax":7.48,"taxCalculated":7.48,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:18 GMT
+ - Fri, 09 Sep 2022 08:58:34 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070687789
+ - /api/v2/companies/7799660/transactions/85009141816769
ServerDuration:
- - '00:00:00.0901421'
+ - '00:00:00.0934021'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - dae0a07a-9eae-4745-a787-7e7ab9b59b19
+ - 3cc563c7-616a-40d0-ad2e-63d3988b20fa
x-correlation-id:
- - dae0a07a-9eae-4745-a787-7e7ab9b59b19
+ - 3cc563c7-616a-40d0-ad2e-63d3988b20fa
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[16.26-20.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[16.26-20.00-True].yaml
index b9af05c4f6..fa94c654e5 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[16.26-20.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[16.26-20.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": true, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "4c11c33d-7ad7-4142-a28a-2a9bab2b560b", "date": "2022-09-08", "customerCode":
+ "1ac27325-4512-412f-99bf-180b86e72a26", "date": "2022-09-09", "customerCode":
0, "discount": "10.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070596706,"code":"4c11c33d-7ad7-4142-a28a-2a9bab2b560b","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":34.39,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070596708,"destinationAddressId":85009070596707,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:18.6148062Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070596712,"transactionId":85009070596706,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070596707,"originAddressId":85009070596708,"discountAmount":10.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":26.2600,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":3.74,"taxableAmount":16.26,"taxCalculated":3.74,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070596733,"transactionLineId":85009070596712,"transactionId":85009070596706,"addressId":85009070596707,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":3.7400,"taxableAmount":16.2600,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":3.7400,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":16.2600,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":16.26,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.74,"reportingTaxCalculated":3.74,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070596715,"documentLineId":85009070596712,"documentAddressId":85009070596708,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070596716,"documentLineId":85009070596712,"documentAddressId":85009070596707,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070596713,"transactionId":85009070596706,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070596707,"originAddressId":85009070596708,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070596753,"transactionLineId":85009070596713,"transactionId":85009070596706,"addressId":85009070596707,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070596735,"documentLineId":85009070596713,"documentAddressId":85009070596708,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070596736,"documentLineId":85009070596713,"documentAddressId":85009070596707,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070596707,"transactionId":85009070596706,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009070596708,"transactionId":85009070596706,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070596710,"documentId":85009070596706,"documentAddressId":85009070596708,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070596711,"documentId":85009070596706,"documentAddressId":85009070596707,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141651288,"code":"1ac27325-4512-412f-99bf-180b86e72a26","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":34.39,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141651290,"destinationAddressId":85009141651289,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:58:39.0193069Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141651294,"transactionId":85009141651288,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141651289,"originAddressId":85009141651290,"discountAmount":10.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":26.2600,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":3.74,"taxableAmount":16.26,"taxCalculated":3.74,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141651315,"transactionLineId":85009141651294,"transactionId":85009141651288,"addressId":85009141651289,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":3.7400,"taxableAmount":16.2600,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":3.7400,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":16.2600,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":16.26,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":3.74,"reportingTaxCalculated":3.74,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141651297,"documentLineId":85009141651294,"documentAddressId":85009141651290,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141651298,"documentLineId":85009141651294,"documentAddressId":85009141651289,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141651295,"transactionId":85009141651288,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141651289,"originAddressId":85009141651290,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141651335,"transactionLineId":85009141651295,"transactionId":85009141651288,"addressId":85009141651289,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141651317,"documentLineId":85009141651295,"documentAddressId":85009141651290,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141651318,"documentLineId":85009141651295,"documentAddressId":85009141651289,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141651289,"transactionId":85009141651288,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009141651290,"transactionId":85009141651288,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141651292,"documentId":85009141651288,"documentAddressId":85009141651290,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141651293,"documentId":85009141651288,"documentAddressId":85009141651289,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":24.39,"rate":0.230000,"tax":5.61,"taxCalculated":5.61,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:18 GMT
+ - Fri, 09 Sep 2022 08:58:39 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070596706
+ - /api/v2/companies/7799660/transactions/85009141651288
ServerDuration:
- - '00:00:00.0947839'
+ - '00:00:00.1016565'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - c0f67a89-c80a-4d16-8c68-a23831ae2aae
+ - a02f1620-3b76-41a3-8541-3d207d3671e6
x-correlation-id:
- - c0f67a89-c80a-4d16-8c68-a23831ae2aae
+ - a02f1620-3b76-41a3-8541-3d207d3671e6
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[20.00-24.60-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[20.00-24.60-False].yaml
index 9754c4ed0a..f9a5e0ead2 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[20.00-24.60-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[20.00-24.60-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "SKU_A", "discounted": true, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "2003ea6f-2d38-4710-ab96-2e6af754b05c", "date": "2022-09-08", "customerCode":
+ "d9be8a25-5248-4b6a-a2cb-207e52986c09", "date": "2022-09-09", "customerCode":
0, "discount": "10.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070496415,"code":"2003ea6f-2d38-4710-ab96-2e6af754b05c","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070496417,"destinationAddressId":85009070496416,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:16.7043899Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070496421,"transactionId":85009070496415,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070496416,"originAddressId":85009070496417,"discountAmount":10.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":4.6,"taxableAmount":20.0,"taxCalculated":4.6,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85009070496442,"transactionLineId":85009070496421,"transactionId":85009070496415,"addressId":85009070496416,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":4.6000,"taxableAmount":20.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":4.6000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":20.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":20.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":4.6,"reportingTaxCalculated":4.6,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070496424,"documentLineId":85009070496421,"documentAddressId":85009070496417,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070496425,"documentLineId":85009070496421,"documentAddressId":85009070496416,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070496422,"transactionId":85009070496415,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070496416,"originAddressId":85009070496417,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85009070496462,"transactionLineId":85009070496422,"transactionId":85009070496415,"addressId":85009070496416,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":2.3000,"taxableAmount":10.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":2.3000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":10.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070496444,"documentLineId":85009070496422,"documentAddressId":85009070496417,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070496445,"documentLineId":85009070496422,"documentAddressId":85009070496416,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070496416,"transactionId":85009070496415,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009070496417,"transactionId":85009070496415,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070496419,"documentId":85009070496415,"documentAddressId":85009070496417,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070496420,"documentId":85009070496415,"documentAddressId":85009070496416,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141817628,"code":"d9be8a25-5248-4b6a-a2cb-207e52986c09","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141817630,"destinationAddressId":85009141817629,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:58:40.5338867Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141817634,"transactionId":85009141817628,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141817629,"originAddressId":85009141817630,"discountAmount":10.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":4.6,"taxableAmount":20.0,"taxCalculated":4.6,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85009141817655,"transactionLineId":85009141817634,"transactionId":85009141817628,"addressId":85009141817629,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":4.6000,"taxableAmount":20.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":4.6000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":20.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":20.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":4.6,"reportingTaxCalculated":4.6,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141817637,"documentLineId":85009141817634,"documentAddressId":85009141817630,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141817638,"documentLineId":85009141817634,"documentAddressId":85009141817629,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141817635,"transactionId":85009141817628,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141817629,"originAddressId":85009141817630,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85009141817675,"transactionLineId":85009141817635,"transactionId":85009141817628,"addressId":85009141817629,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":2.3000,"taxableAmount":10.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":2.3000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":10.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141817657,"documentLineId":85009141817635,"documentAddressId":85009141817630,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141817658,"documentLineId":85009141817635,"documentAddressId":85009141817629,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141817629,"transactionId":85009141817628,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009141817630,"transactionId":85009141817628,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141817632,"documentId":85009141817628,"documentAddressId":85009141817630,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141817633,"documentId":85009141817628,"documentAddressId":85009141817629,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":30.00,"rate":0.230000,"tax":6.90,"taxCalculated":6.90,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:16 GMT
+ - Fri, 09 Sep 2022 08:58:40 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070496415
+ - /api/v2/companies/7799660/transactions/85009141817628
ServerDuration:
- - '00:00:00.0979791'
+ - '00:00:00.0955393'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - bdee2870-bb1d-4fef-80de-16cde4335493
+ - d4e150f0-ee6c-4f42-b493-520129616e30
x-correlation-id:
- - bdee2870-bb1d-4fef-80de-16cde4335493
+ - d4e150f0-ee6c-4f42-b493-520129616e30
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[24.39-30.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[24.39-30.00-True].yaml
index 52ef31026f..c81600df8c 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[24.39-30.00-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[24.39-30.00-True].yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "0.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "b062ea86-4f08-4bab-a4b5-797bbf16b862", "date": "2022-09-08", "customerCode":
+ "430020bb-e761-485f-8d02-46e233a64d2b", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070496658,"code":"b062ea86-4f08-4bab-a4b5-797bbf16b862","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":24.39,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070496660,"destinationAddressId":85009070496659,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:18.5341098Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070496664,"transactionId":85009070496658,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070496659,"originAddressId":85009070496660,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070496685,"transactionLineId":85009070496664,"transactionId":85009070496658,"addressId":85009070496659,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070496667,"documentLineId":85009070496664,"documentAddressId":85009070496660,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070496668,"documentLineId":85009070496664,"documentAddressId":85009070496659,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070496665,"transactionId":85009070496658,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070496659,"originAddressId":85009070496660,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"isSSTP":false,"itemCode":"Shipping","lineAmount":0.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070496705,"transactionLineId":85009070496665,"transactionId":85009070496658,"addressId":85009070496659,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.0000,"taxableAmount":0.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.0000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":0.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070496687,"documentLineId":85009070496665,"documentAddressId":85009070496660,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070496688,"documentLineId":85009070496665,"documentAddressId":85009070496659,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070496659,"transactionId":85009070496658,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009070496660,"transactionId":85009070496658,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070496662,"documentId":85009070496658,"documentAddressId":85009070496660,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070496663,"documentId":85009070496658,"documentAddressId":85009070496659,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141730211,"code":"430020bb-e761-485f-8d02-46e233a64d2b","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":24.39,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141730213,"destinationAddressId":85009141730212,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:58:41.9708127Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141730217,"transactionId":85009141730211,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141730212,"originAddressId":85009141730213,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141730238,"transactionLineId":85009141730217,"transactionId":85009141730211,"addressId":85009141730212,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141730220,"documentLineId":85009141730217,"documentAddressId":85009141730213,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141730221,"documentLineId":85009141730217,"documentAddressId":85009141730212,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141730218,"transactionId":85009141730211,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141730212,"originAddressId":85009141730213,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"isSSTP":false,"itemCode":"Shipping","lineAmount":0.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141730258,"transactionLineId":85009141730218,"transactionId":85009141730211,"addressId":85009141730212,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.0000,"taxableAmount":0.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.0000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":0.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141730240,"documentLineId":85009141730218,"documentAddressId":85009141730213,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141730241,"documentLineId":85009141730218,"documentAddressId":85009141730212,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141730212,"transactionId":85009141730211,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009141730213,"transactionId":85009141730211,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141730215,"documentId":85009141730211,"documentAddressId":85009141730213,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141730216,"documentId":85009141730211,"documentAddressId":85009141730212,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":24.39,"rate":0.230000,"tax":5.61,"taxCalculated":5.61,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:18 GMT
+ - Fri, 09 Sep 2022 08:58:42 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070496658
+ - /api/v2/companies/7799660/transactions/85009141730211
ServerDuration:
- - '00:00:00.0929843'
+ - '00:00:00.0974840'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - d4c45c45-be39-43c7-a303-0df7a8ce8132
+ - 9d088257-9508-492d-b179-4e2bbe12cc53
x-correlation-id:
- - d4c45c45-be39-43c7-a303-0df7a8ce8132
+ - 9d088257-9508-492d-b179-4e2bbe12cc53
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[30.00-36.90-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[30.00-36.90-False].yaml
index 4fbeebed18..e465f27815 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[30.00-36.90-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[30.00-36.90-False].yaml
@@ -5,7 +5,7 @@ interactions:
false, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "0.000", "taxCode": "FR000000", "taxIncluded": false,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "da2a2893-8cd7-4362-9281-4e199c4c8e9b", "date": "2022-09-08", "customerCode":
+ "ad2c1651-20c2-495d-937f-eda02391930e", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070780814,"code":"da2a2893-8cd7-4362-9281-4e199c4c8e9b","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":30.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070780816,"destinationAddressId":85009070780815,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:19.5658303Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070780820,"transactionId":85009070780814,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070780815,"originAddressId":85009070780816,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85009070780841,"transactionLineId":85009070780820,"transactionId":85009070780814,"addressId":85009070780815,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070780823,"documentLineId":85009070780820,"documentAddressId":85009070780816,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070780824,"documentLineId":85009070780820,"documentAddressId":85009070780815,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070780821,"transactionId":85009070780814,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070780815,"originAddressId":85009070780816,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"isSSTP":false,"itemCode":"Shipping","lineAmount":0.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85009070780861,"transactionLineId":85009070780821,"transactionId":85009070780814,"addressId":85009070780815,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.0000,"taxableAmount":0.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.0000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":0.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070780843,"documentLineId":85009070780821,"documentAddressId":85009070780816,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070780844,"documentLineId":85009070780821,"documentAddressId":85009070780815,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070780815,"transactionId":85009070780814,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009070780816,"transactionId":85009070780814,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070780818,"documentId":85009070780814,"documentAddressId":85009070780816,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070780819,"documentId":85009070780814,"documentAddressId":85009070780815,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141652111,"code":"ad2c1651-20c2-495d-937f-eda02391930e","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":30.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141652113,"destinationAddressId":85009141652112,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:58:43.3908584Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141652117,"transactionId":85009141652111,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141652112,"originAddressId":85009141652113,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85009141652138,"transactionLineId":85009141652117,"transactionId":85009141652111,"addressId":85009141652112,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141652120,"documentLineId":85009141652117,"documentAddressId":85009141652113,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141652121,"documentLineId":85009141652117,"documentAddressId":85009141652112,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141652118,"transactionId":85009141652111,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141652112,"originAddressId":85009141652113,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"isSSTP":false,"itemCode":"Shipping","lineAmount":0.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85009141652158,"transactionLineId":85009141652118,"transactionId":85009141652111,"addressId":85009141652112,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.0000,"taxableAmount":0.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.0000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":0.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141652140,"documentLineId":85009141652118,"documentAddressId":85009141652113,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141652141,"documentLineId":85009141652118,"documentAddressId":85009141652112,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141652112,"transactionId":85009141652111,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009141652113,"transactionId":85009141652111,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141652115,"documentId":85009141652111,"documentAddressId":85009141652113,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141652116,"documentId":85009141652111,"documentAddressId":85009141652112,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":30.00,"rate":0.230000,"tax":6.90,"taxCalculated":6.90,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:19 GMT
+ - Fri, 09 Sep 2022 08:58:43 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070780814
+ - /api/v2/companies/7799660/transactions/85009141652111
ServerDuration:
- - '00:00:00.0867291'
+ - '00:00:00.0899899'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - cc8e4462-df57-47c8-b637-cd93347bd15f
+ - dc9c47b4-be88-4409-88e6-32d403cb4f57
x-correlation-id:
- - cc8e4462-df57-47c8-b637-cd93347bd15f
+ - dc9c47b4-be88-4409-88e6-32d403cb4f57
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_with_discount.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_with_discount.yaml
index 7c0f211110..d38be879fa 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_with_discount.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_with_discount.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "54ca2faf-c245-4b0a-b6a0-60cfd2bab8a5", "date": "2022-09-08", "customerCode":
+ "75a8e58b-09e6-49fd-bd1d-b90a6809abf3", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070596547,"code":"54ca2faf-c245-4b0a-b6a0-60cfd2bab8a5","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070596549,"destinationAddressId":85009070596548,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:18.2962773Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070596553,"transactionId":85009070596547,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070596548,"originAddressId":85009070596549,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070596574,"transactionLineId":85009070596553,"transactionId":85009070596547,"addressId":85009070596548,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070596556,"documentLineId":85009070596553,"documentAddressId":85009070596549,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070596557,"documentLineId":85009070596553,"documentAddressId":85009070596548,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070596554,"transactionId":85009070596547,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070596548,"originAddressId":85009070596549,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070596594,"transactionLineId":85009070596554,"transactionId":85009070596547,"addressId":85009070596548,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070596576,"documentLineId":85009070596554,"documentAddressId":85009070596549,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070596577,"documentLineId":85009070596554,"documentAddressId":85009070596548,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070596548,"transactionId":85009070596547,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009070596549,"transactionId":85009070596547,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070596551,"documentId":85009070596547,"documentAddressId":85009070596549,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070596552,"documentId":85009070596547,"documentAddressId":85009070596548,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141729300,"code":"75a8e58b-09e6-49fd-bd1d-b90a6809abf3","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141729302,"destinationAddressId":85009141729301,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:58:37.5643408Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141729306,"transactionId":85009141729300,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141729301,"originAddressId":85009141729302,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141729327,"transactionLineId":85009141729306,"transactionId":85009141729300,"addressId":85009141729301,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141729309,"documentLineId":85009141729306,"documentAddressId":85009141729302,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141729310,"documentLineId":85009141729306,"documentAddressId":85009141729301,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141729307,"transactionId":85009141729300,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141729301,"originAddressId":85009141729302,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141729347,"transactionLineId":85009141729307,"transactionId":85009141729300,"addressId":85009141729301,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141729329,"documentLineId":85009141729307,"documentAddressId":85009141729302,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141729330,"documentLineId":85009141729307,"documentAddressId":85009141729301,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141729301,"transactionId":85009141729300,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009141729302,"transactionId":85009141729300,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141729304,"documentId":85009141729300,"documentAddressId":85009141729302,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141729305,"documentId":85009141729300,"documentAddressId":85009141729301,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":32.52,"rate":0.230000,"tax":7.48,"taxCalculated":7.48,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:18 GMT
+ - Fri, 09 Sep 2022 08:58:37 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070596547
+ - /api/v2/companies/7799660/transactions/85009141729300
ServerDuration:
- - '00:00:00.0907114'
+ - '00:00:00.0924860'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 5754950a-deec-404c-82f8-0c279bbfe735
+ - 76686c22-7d03-4a96-b5a9-9d3a3f6dddc2
x-correlation-id:
- - 5754950a-deec-404c-82f8-0c279bbfe735
+ - 76686c22-7d03-4a96-b5a9-9d3a3f6dddc2
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit.yaml
index d0c74714fd..cec4c15170 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "c976f3c6-4e40-4cc0-9099-7b5abcbb0eeb", "date": "2022-09-08", "customerCode":
+ "68222e3b-6838-43b0-bc23-24fb9b2bdc1f", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070781523,"code":"c976f3c6-4e40-4cc0-9099-7b5abcbb0eeb","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070781525,"destinationAddressId":85009070781524,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:25.4171086Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070781529,"transactionId":85009070781523,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070781524,"originAddressId":85009070781525,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070781550,"transactionLineId":85009070781529,"transactionId":85009070781523,"addressId":85009070781524,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070781532,"documentLineId":85009070781529,"documentAddressId":85009070781525,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070781533,"documentLineId":85009070781529,"documentAddressId":85009070781524,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070781530,"transactionId":85009070781523,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070781524,"originAddressId":85009070781525,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070781570,"transactionLineId":85009070781530,"transactionId":85009070781523,"addressId":85009070781524,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070781552,"documentLineId":85009070781530,"documentAddressId":85009070781525,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070781553,"documentLineId":85009070781530,"documentAddressId":85009070781524,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070781524,"transactionId":85009070781523,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070781525,"transactionId":85009070781523,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070781527,"documentId":85009070781523,"documentAddressId":85009070781525,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070781528,"documentId":85009070781523,"documentAddressId":85009070781524,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141658396,"code":"68222e3b-6838-43b0-bc23-24fb9b2bdc1f","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141658398,"destinationAddressId":85009141658397,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:29.7273766Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141658402,"transactionId":85009141658396,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141658397,"originAddressId":85009141658398,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141658423,"transactionLineId":85009141658402,"transactionId":85009141658396,"addressId":85009141658397,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141658405,"documentLineId":85009141658402,"documentAddressId":85009141658398,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141658406,"documentLineId":85009141658402,"documentAddressId":85009141658397,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141658403,"transactionId":85009141658396,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141658397,"originAddressId":85009141658398,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141658443,"transactionLineId":85009141658403,"transactionId":85009141658396,"addressId":85009141658397,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141658425,"documentLineId":85009141658403,"documentAddressId":85009141658398,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141658426,"documentLineId":85009141658403,"documentAddressId":85009141658397,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141658397,"transactionId":85009141658396,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141658398,"transactionId":85009141658396,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141658400,"documentId":85009141658396,"documentAddressId":85009141658398,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141658401,"documentId":85009141658396,"documentAddressId":85009141658397,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":32.52,"rate":0.230000,"tax":7.48,"taxCalculated":7.48,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:25 GMT
+ - Fri, 09 Sep 2022 08:59:29 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070781523
+ - /api/v2/companies/7799660/transactions/85009141658396
ServerDuration:
- - '00:00:00.0903939'
+ - '00:00:00.0913600'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 1db5feb7-641b-4bc5-996e-e3407f4c798c
+ - b472cad0-5509-4d0d-9f2f-4e6a234ebb54
x-correlation-id:
- - 1db5feb7-641b-4bc5-996e-e3407f4c798c
+ - b472cad0-5509-4d0d-9f2f-4e6a234ebb54
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit_in_JPY.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit_in_JPY.yaml
index 2fdcc82a1b..57756913e6 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit_in_JPY.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit_in_JPY.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "700.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "91d3b54f-43f3-4a8b-a979-a13abc7e5741", "date": "2022-09-08", "customerCode":
+ "8d59cedd-0385-4a80-9145-eeab7c97a686", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070688856,"code":"91d3b54f-43f3-4a8b-a979-a13abc7e5741","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"JPY","exchangeRateCurrencyCode":"JPY","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":3496.11,"totalExempt":0.17,"totalDiscount":0.0,"totalTax":803.0,"totalTaxable":3495.94,"totalTaxCalculated":803.0,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070688858,"destinationAddressId":85009070688857,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:26.9923269Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070688862,"transactionId":85009070688856,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070688857,"originAddressId":85009070688858,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.17,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"123","lineAmount":2927.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":673.0,"taxableAmount":2926.83,"taxCalculated":673.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070688883,"transactionLineId":85009070688862,"transactionId":85009070688856,"addressId":85009070688857,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":673.1700,"taxableAmount":2926.8300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":673.1700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":2926.8300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":2926.83,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":673.17,"reportingTaxCalculated":673.17,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070688865,"documentLineId":85009070688862,"documentAddressId":85009070688858,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070688866,"documentLineId":85009070688862,"documentAddressId":85009070688857,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070688863,"transactionId":85009070688856,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070688857,"originAddressId":85009070688858,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":569.1100,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":130.0,"taxableAmount":569.11,"taxCalculated":130.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070688903,"transactionLineId":85009070688863,"transactionId":85009070688856,"addressId":85009070688857,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":130.8900,"taxableAmount":569.1100,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":130.8900,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":569.1100,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":569.11,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":130.89,"reportingTaxCalculated":130.89,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070688885,"documentLineId":85009070688863,"documentAddressId":85009070688858,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070688886,"documentLineId":85009070688863,"documentAddressId":85009070688857,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070688857,"transactionId":85009070688856,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070688858,"transactionId":85009070688856,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070688860,"documentId":85009070688856,"documentAddressId":85009070688858,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070688861,"documentId":85009070688856,"documentAddressId":85009070688857,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141576262,"code":"8d59cedd-0385-4a80-9145-eeab7c97a686","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"JPY","exchangeRateCurrencyCode":"JPY","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":3496.11,"totalExempt":0.17,"totalDiscount":0.0,"totalTax":803.0,"totalTaxable":3495.94,"totalTaxCalculated":803.0,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141576264,"destinationAddressId":85009141576263,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:31.0756839Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141576268,"transactionId":85009141576262,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141576263,"originAddressId":85009141576264,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.17,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"123","lineAmount":2927.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":673.0,"taxableAmount":2926.83,"taxCalculated":673.0,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141576289,"transactionLineId":85009141576268,"transactionId":85009141576262,"addressId":85009141576263,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":673.1700,"taxableAmount":2926.8300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":673.1700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":2926.8300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":2926.83,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":673.17,"reportingTaxCalculated":673.17,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141576271,"documentLineId":85009141576268,"documentAddressId":85009141576264,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141576272,"documentLineId":85009141576268,"documentAddressId":85009141576263,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141576269,"transactionId":85009141576262,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141576263,"originAddressId":85009141576264,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":569.1100,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":130.0,"taxableAmount":569.11,"taxCalculated":130.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141576309,"transactionLineId":85009141576269,"transactionId":85009141576262,"addressId":85009141576263,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":130.8900,"taxableAmount":569.1100,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":130.8900,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":569.1100,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":569.11,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":130.89,"reportingTaxCalculated":130.89,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141576291,"documentLineId":85009141576269,"documentAddressId":85009141576264,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141576292,"documentLineId":85009141576269,"documentAddressId":85009141576263,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141576263,"transactionId":85009141576262,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141576264,"transactionId":85009141576262,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141576266,"documentId":85009141576262,"documentAddressId":85009141576264,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141576267,"documentId":85009141576262,"documentAddressId":85009141576263,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":3495.94,"rate":0.230000,"tax":804.06,"taxCalculated":804.06,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:27 GMT
+ - Fri, 09 Sep 2022 08:59:31 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070688856
+ - /api/v2/companies/7799660/transactions/85009141576262
ServerDuration:
- - '00:00:00.0920396'
+ - '00:00:00.0933661'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - af648189-ec58-4f6f-bccb-2d44e3515e71
+ - 73b6f5e3-bdb5-46e4-a796-d35642a8f837
x-correlation-id:
- - af648189-ec58-4f6f-bccb-2d44e3515e71
+ - 73b6f5e3-bdb5-46e4-a796-d35642a8f837
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit_with_discount.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit_with_discount.yaml
index f1512a9ea4..de52fc229b 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit_with_discount.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_unit_with_discount.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "085dedfc-c8d1-432f-a224-eb5c7b9239af", "date": "2022-09-08", "customerCode":
+ "720eb85a-8456-4607-96f1-1ef32b596206", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070689097,"code":"085dedfc-c8d1-432f-a224-eb5c7b9239af","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070689099,"destinationAddressId":85009070689098,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:28.5530109Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070689103,"transactionId":85009070689097,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070689098,"originAddressId":85009070689099,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070689124,"transactionLineId":85009070689103,"transactionId":85009070689097,"addressId":85009070689098,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070689106,"documentLineId":85009070689103,"documentAddressId":85009070689099,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070689107,"documentLineId":85009070689103,"documentAddressId":85009070689098,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070689104,"transactionId":85009070689097,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070689098,"originAddressId":85009070689099,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070689144,"transactionLineId":85009070689104,"transactionId":85009070689097,"addressId":85009070689098,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070689126,"documentLineId":85009070689104,"documentAddressId":85009070689099,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070689127,"documentLineId":85009070689104,"documentAddressId":85009070689098,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070689098,"transactionId":85009070689097,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070689099,"transactionId":85009070689097,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070689101,"documentId":85009070689097,"documentAddressId":85009070689099,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070689102,"documentId":85009070689097,"documentAddressId":85009070689098,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141737388,"code":"720eb85a-8456-4607-96f1-1ef32b596206","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141737390,"destinationAddressId":85009141737389,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:32.360697Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141737394,"transactionId":85009141737388,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141737389,"originAddressId":85009141737390,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141737415,"transactionLineId":85009141737394,"transactionId":85009141737388,"addressId":85009141737389,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141737397,"documentLineId":85009141737394,"documentAddressId":85009141737390,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141737398,"documentLineId":85009141737394,"documentAddressId":85009141737389,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141737395,"transactionId":85009141737388,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141737389,"originAddressId":85009141737390,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141737435,"transactionLineId":85009141737395,"transactionId":85009141737388,"addressId":85009141737389,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141737417,"documentLineId":85009141737395,"documentAddressId":85009141737390,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141737418,"documentLineId":85009141737395,"documentAddressId":85009141737389,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141737389,"transactionId":85009141737388,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141737390,"transactionId":85009141737388,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141737392,"documentId":85009141737388,"documentAddressId":85009141737390,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141737393,"documentId":85009141737388,"documentAddressId":85009141737389,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":32.52,"rate":0.230000,"tax":7.48,"taxCalculated":7.48,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:28 GMT
+ - Fri, 09 Sep 2022 08:59:32 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070689097
+ - /api/v2/companies/7799660/transactions/85009141737388
ServerDuration:
- - '00:00:00.0876378'
+ - '00:00:00.0898601'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - a6f21afc-00f7-4969-9b15-48c0b43af2cd
+ - 0058a539-668a-4774-9e81-0880d950cd5f
x-correlation-id:
- - a6f21afc-00f7-4969-9b15-48c0b43af2cd
+ - 0058a539-668a-4774-9e81-0880d950cd5f
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_without_sku_total.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_without_sku_total.yaml
index 2618caa3cd..7c6bba6b1d 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_without_sku_total.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_without_sku_total.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "UHJvZHVjdFZhcmlhbnQ6Mg", "discounted": false, "description":
"Test product"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000",
"taxIncluded": true, "itemCode": "Shipping", "discounted": false, "description":
- null}], "code": "e58e6d6e-b218-45c3-811f-0f778f595b85", "date": "2022-09-08",
+ null}], "code": "cc49a010-43dd-4e71-a5b8-6a9e1cd81671", "date": "2022-09-09",
"customerCode": 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa
7", "line2": null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode":
"53-601"}, "shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070596349,"code":"e58e6d6e-b218-45c3-811f-0f778f595b85","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070596351,"destinationAddressId":85009070596350,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:16.8242121Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070596355,"transactionId":85009070596349,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070596350,"originAddressId":85009070596351,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070596376,"transactionLineId":85009070596355,"transactionId":85009070596349,"addressId":85009070596350,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070596358,"documentLineId":85009070596355,"documentAddressId":85009070596351,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070596359,"documentLineId":85009070596355,"documentAddressId":85009070596350,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070596356,"transactionId":85009070596349,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070596350,"originAddressId":85009070596351,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070596396,"transactionLineId":85009070596356,"transactionId":85009070596349,"addressId":85009070596350,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070596378,"documentLineId":85009070596356,"documentAddressId":85009070596351,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070596379,"documentLineId":85009070596356,"documentAddressId":85009070596350,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070596350,"transactionId":85009070596349,"boundaryLevel":"Zip5","line1":"Olawska
- 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009070596351,"transactionId":85009070596349,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070596353,"documentId":85009070596349,"documentAddressId":85009070596351,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070596354,"documentId":85009070596349,"documentAddressId":85009070596350,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141650870,"code":"cc49a010-43dd-4e71-a5b8-6a9e1cd81671","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141650872,"destinationAddressId":85009141650871,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:58:36.1241141Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141650876,"transactionId":85009141650870,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141650871,"originAddressId":85009141650872,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"UHJvZHVjdFZhcmlhbnQ6Mg","lineAmount":24.3900,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141650897,"transactionLineId":85009141650876,"transactionId":85009141650870,"addressId":85009141650871,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.6100,"taxableAmount":24.3900,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.6100,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":24.3900,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141650879,"documentLineId":85009141650876,"documentAddressId":85009141650872,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141650880,"documentLineId":85009141650876,"documentAddressId":85009141650871,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141650877,"transactionId":85009141650870,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141650871,"originAddressId":85009141650872,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141650917,"transactionLineId":85009141650877,"transactionId":85009141650870,"addressId":85009141650871,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141650899,"documentLineId":85009141650877,"documentAddressId":85009141650872,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141650900,"documentLineId":85009141650877,"documentAddressId":85009141650871,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141650871,"transactionId":85009141650870,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85009141650872,"transactionId":85009141650870,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141650874,"documentId":85009141650870,"documentAddressId":85009141650872,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141650875,"documentId":85009141650870,"documentAddressId":85009141650871,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":32.52,"rate":0.230000,"tax":7.48,"taxCalculated":7.48,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:16 GMT
+ - Fri, 09 Sep 2022 08:58:36 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070596349
+ - /api/v2/companies/7799660/transactions/85009141650870
ServerDuration:
- - '00:00:00.0966689'
+ - '00:00:00.0967600'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 43bd2d3f-cc49-4f18-8248-5fdd4bf69708
+ - 3b006dd3-08b1-4175-b30e-8c924979d103
x-correlation-id:
- - 43bd2d3f-cc49-4f18-8248-5fdd4bf69708
+ - 3b006dd3-08b1-4175-b30e-8c924979d103
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping.yaml
index a4b05e10e3..3c8f0f6580 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "c43e0dd5-2408-4fc7-9dfe-d671c8d05d3f", "date": "2022-09-08", "customerCode":
+ "ce66dc34-3321-4c9c-99aa-140ebde530b4", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070781703,"code":"c43e0dd5-2408-4fc7-9dfe-d671c8d05d3f","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.77,"totalTaxable":38.13,"totalTaxCalculated":8.77,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070781705,"destinationAddressId":85009070781704,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:26.8778018Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070781709,"transactionId":85009070781703,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070781704,"originAddressId":85009070781705,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070781730,"transactionLineId":85009070781709,"transactionId":85009070781703,"addressId":85009070781704,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070781712,"documentLineId":85009070781709,"documentAddressId":85009070781705,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070781713,"documentLineId":85009070781709,"documentAddressId":85009070781704,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070781710,"transactionId":85009070781703,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070781704,"originAddressId":85009070781705,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070781750,"transactionLineId":85009070781710,"transactionId":85009070781703,"addressId":85009070781704,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070781732,"documentLineId":85009070781710,"documentAddressId":85009070781705,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070781733,"documentLineId":85009070781710,"documentAddressId":85009070781704,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070781704,"transactionId":85009070781703,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070781705,"transactionId":85009070781703,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070781707,"documentId":85009070781703,"documentAddressId":85009070781705,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070781708,"documentId":85009070781703,"documentAddressId":85009070781704,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141822486,"code":"ce66dc34-3321-4c9c-99aa-140ebde530b4","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.77,"totalTaxable":38.13,"totalTaxCalculated":8.77,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141822488,"destinationAddressId":85009141822487,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:19.6282927Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141822492,"transactionId":85009141822486,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141822487,"originAddressId":85009141822488,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141822513,"transactionLineId":85009141822492,"transactionId":85009141822486,"addressId":85009141822487,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141822495,"documentLineId":85009141822492,"documentAddressId":85009141822488,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141822496,"documentLineId":85009141822492,"documentAddressId":85009141822487,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141822493,"transactionId":85009141822486,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141822487,"originAddressId":85009141822488,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141822533,"transactionLineId":85009141822493,"transactionId":85009141822486,"addressId":85009141822487,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141822515,"documentLineId":85009141822493,"documentAddressId":85009141822488,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141822516,"documentLineId":85009141822493,"documentAddressId":85009141822487,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141822487,"transactionId":85009141822486,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141822488,"transactionId":85009141822486,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141822490,"documentId":85009141822486,"documentAddressId":85009141822488,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141822491,"documentId":85009141822486,"documentAddressId":85009141822487,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":38.13,"rate":0.230000,"tax":8.77,"taxCalculated":8.77,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:26 GMT
+ - Fri, 09 Sep 2022 08:59:19 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070781703
+ - /api/v2/companies/7799660/transactions/85009141822486
ServerDuration:
- - '00:00:00.0949974'
+ - '00:00:00.0920825'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 25e789b0-4843-4980-bbfd-483320d4e6cf
+ - 7946c7a8-5a6d-4967-b370-c2a1fd02d1c8
x-correlation-id:
- - 25e789b0-4843-4980-bbfd-483320d4e6cf
+ - 7946c7a8-5a6d-4967-b370-c2a1fd02d1c8
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_entire_order_voucher.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_entire_order_voucher.yaml
index d79418a5e1..c75a9af9fe 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_entire_order_voucher.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_entire_order_voucher.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": true, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "9ac3b1fa-18d0-490d-b912-8e34c5f5ec50", "date": "2022-09-08", "customerCode":
+ "981c7faf-10f3-44c4-b07a-dad6cc72a794", "date": "2022-09-09", "customerCode":
0, "discount": "10.000", "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070781232,"code":"9ac3b1fa-18d0-490d-b912-8e34c5f5ec50","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070781234,"destinationAddressId":85009070781233,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:23.4881598Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070781238,"transactionId":85009070781232,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070781233,"originAddressId":85009070781234,"discountAmount":10.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":31.8700,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":5.03,"taxableAmount":21.87,"taxCalculated":5.03,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070781259,"transactionLineId":85009070781238,"transactionId":85009070781232,"addressId":85009070781233,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.0300,"taxableAmount":21.8700,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.0300,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":21.8700,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":21.87,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.03,"reportingTaxCalculated":5.03,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070781241,"documentLineId":85009070781238,"documentAddressId":85009070781234,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070781242,"documentLineId":85009070781238,"documentAddressId":85009070781233,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070781239,"transactionId":85009070781232,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070781233,"originAddressId":85009070781234,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070781279,"transactionLineId":85009070781239,"transactionId":85009070781232,"addressId":85009070781233,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070781261,"documentLineId":85009070781239,"documentAddressId":85009070781234,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070781262,"documentLineId":85009070781239,"documentAddressId":85009070781233,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070781233,"transactionId":85009070781232,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070781234,"transactionId":85009070781232,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070781236,"documentId":85009070781232,"documentAddressId":85009070781234,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070781237,"documentId":85009070781232,"documentAddressId":85009070781233,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141735928,"code":"981c7faf-10f3-44c4-b07a-dad6cc72a794","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":40.0,"totalExempt":0.0,"totalDiscount":10.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141735930,"destinationAddressId":85009141735929,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:22.3808128Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141735934,"transactionId":85009141735928,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141735929,"originAddressId":85009141735930,"discountAmount":10.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":31.8700,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":5.03,"taxableAmount":21.87,"taxCalculated":5.03,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141735955,"transactionLineId":85009141735934,"transactionId":85009141735928,"addressId":85009141735929,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":5.0300,"taxableAmount":21.8700,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":5.0300,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":21.8700,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":21.87,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.03,"reportingTaxCalculated":5.03,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141735937,"documentLineId":85009141735934,"documentAddressId":85009141735930,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141735938,"documentLineId":85009141735934,"documentAddressId":85009141735929,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141735935,"transactionId":85009141735928,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141735929,"originAddressId":85009141735930,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141735975,"transactionLineId":85009141735935,"transactionId":85009141735928,"addressId":85009141735929,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141735957,"documentLineId":85009141735935,"documentAddressId":85009141735930,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141735958,"documentLineId":85009141735935,"documentAddressId":85009141735929,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141735929,"transactionId":85009141735928,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141735930,"transactionId":85009141735928,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141735932,"documentId":85009141735928,"documentAddressId":85009141735930,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141735933,"documentId":85009141735928,"documentAddressId":85009141735929,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":30.00,"rate":0.230000,"tax":6.90,"taxCalculated":6.90,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:23 GMT
+ - Fri, 09 Sep 2022 08:59:22 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070781232
+ - /api/v2/companies/7799660/transactions/85009141735928
ServerDuration:
- - '00:00:00.0886186'
+ - '00:00:00.0901713'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 0dcaa896-e31b-417c-85a5-c2509709e327
+ - f130f5d9-423c-463e-a281-1f13b6d88872
x-correlation-id:
- - 0dcaa896-e31b-417c-85a5-c2509709e327
+ - f130f5d9-423c-463e-a281-1f13b6d88872
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_free_shipping_voucher.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_free_shipping_voucher.yaml
index 5056d843d9..960044bd59 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_free_shipping_voucher.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_free_shipping_voucher.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "0.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "c1fc9199-c874-4a25-b215-083a9bbc5e80", "date": "2022-09-08", "customerCode":
+ "c31229d5-7c62-4b33-b514-38da8aa452a4", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070497726,"code":"c1fc9199-c874-4a25-b215-083a9bbc5e80","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":30.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070497728,"destinationAddressId":85009070497727,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:25.1197247Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070497732,"transactionId":85009070497726,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070497727,"originAddressId":85009070497728,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070497753,"transactionLineId":85009070497732,"transactionId":85009070497726,"addressId":85009070497727,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070497735,"documentLineId":85009070497732,"documentAddressId":85009070497728,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070497736,"documentLineId":85009070497732,"documentAddressId":85009070497727,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070497733,"transactionId":85009070497726,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070497727,"originAddressId":85009070497728,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"isSSTP":false,"itemCode":"Shipping","lineAmount":0.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070497773,"transactionLineId":85009070497733,"transactionId":85009070497726,"addressId":85009070497727,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.0000,"taxableAmount":0.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.0000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":0.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070497755,"documentLineId":85009070497733,"documentAddressId":85009070497728,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070497756,"documentLineId":85009070497733,"documentAddressId":85009070497727,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070497727,"transactionId":85009070497726,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070497728,"transactionId":85009070497726,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070497730,"documentId":85009070497726,"documentAddressId":85009070497728,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070497731,"documentId":85009070497726,"documentAddressId":85009070497727,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141736212,"code":"c31229d5-7c62-4b33-b514-38da8aa452a4","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":30.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141736214,"destinationAddressId":85009141736213,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:23.8462147Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141736218,"transactionId":85009141736212,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141736213,"originAddressId":85009141736214,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141736239,"transactionLineId":85009141736218,"transactionId":85009141736212,"addressId":85009141736213,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141736221,"documentLineId":85009141736218,"documentAddressId":85009141736214,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141736222,"documentLineId":85009141736218,"documentAddressId":85009141736213,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141736219,"transactionId":85009141736212,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141736213,"originAddressId":85009141736214,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"isSSTP":false,"itemCode":"Shipping","lineAmount":0.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141736259,"transactionLineId":85009141736219,"transactionId":85009141736212,"addressId":85009141736213,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.0000,"taxableAmount":0.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.0000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":0.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141736241,"documentLineId":85009141736219,"documentAddressId":85009141736214,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141736242,"documentLineId":85009141736219,"documentAddressId":85009141736213,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141736213,"transactionId":85009141736212,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141736214,"transactionId":85009141736212,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141736216,"documentId":85009141736212,"documentAddressId":85009141736214,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141736217,"documentId":85009141736212,"documentAddressId":85009141736213,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":30.00,"rate":0.230000,"tax":6.90,"taxCalculated":6.90,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:25 GMT
+ - Fri, 09 Sep 2022 08:59:23 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070497726
+ - /api/v2/companies/7799660/transactions/85009141736212
ServerDuration:
- - '00:00:00.0916959'
+ - '00:00:00.0931390'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - dd5de09b-6793-4057-835c-91de812a316a
+ - be70cf15-4e32-4cb1-af7c-64e631f6c6b3
x-correlation-id:
- - dd5de09b-6793-4057-835c-91de812a316a
+ - be70cf15-4e32-4cb1-af7c-64e631f6c6b3
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_not_shippable_order.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_not_shippable_order.yaml
index 9e5d6f434b..cfe66b5021 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_not_shippable_order.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_not_shippable_order.yaml
@@ -3,7 +3,7 @@ interactions:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
"lines": [{"quantity": 3, "amount": "36.900", "taxCode": "O9999999", "taxIncluded":
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"}],
- "code": "6e630c90-f22a-4c0e-91f0-4cb269462ca1", "date": "2022-09-08", "customerCode":
+ "code": "62cbb54b-6ff6-4533-a7c4-916abb97185e", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -26,11 +26,11 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070597500,"code":"6e630c90-f22a-4c0e-91f0-4cb269462ca1","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":30.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070597502,"destinationAddressId":85009070597501,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:23.7622314Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070597506,"transactionId":85009070597500,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070597501,"originAddressId":85009070597502,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070597526,"transactionLineId":85009070597506,"transactionId":85009070597500,"addressId":85009070597501,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070597508,"documentLineId":85009070597506,"documentAddressId":85009070597502,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070597509,"documentLineId":85009070597506,"documentAddressId":85009070597501,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0}],"addresses":[{"id":85009070597501,"transactionId":85009070597500,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070597502,"transactionId":85009070597500,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070597504,"documentId":85009070597500,"documentAddressId":85009070597502,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070597505,"documentId":85009070597500,"documentAddressId":85009070597501,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141658219,"code":"62cbb54b-6ff6-4533-a7c4-916abb97185e","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":30.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141658221,"destinationAddressId":85009141658220,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:28.4012313Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141658225,"transactionId":85009141658219,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141658220,"originAddressId":85009141658221,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141658245,"transactionLineId":85009141658225,"transactionId":85009141658219,"addressId":85009141658220,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141658227,"documentLineId":85009141658225,"documentAddressId":85009141658221,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141658228,"documentLineId":85009141658225,"documentAddressId":85009141658220,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0}],"addresses":[{"id":85009141658220,"transactionId":85009141658219,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141658221,"transactionId":85009141658219,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141658223,"documentId":85009141658219,"documentAddressId":85009141658221,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141658224,"documentId":85009141658219,"documentAddressId":85009141658220,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":30.00,"rate":0.230000,"tax":6.90,"taxCalculated":6.90,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -38,11 +38,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:23 GMT
+ - Fri, 09 Sep 2022 08:59:28 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070597500
+ - /api/v2/companies/7799660/transactions/85009141658219
ServerDuration:
- - '00:00:00.0874718'
+ - '00:00:00.0951993'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -56,9 +56,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 6aaa8dae-7945-4ce8-95eb-9f328dc7693d
+ - c29d2c7e-c1cd-4a0c-a6c3-21e7993797aa
x-correlation-id:
- - 6aaa8dae-7945-4ce8-95eb-9f328dc7693d
+ - c29d2c7e-c1cd-4a0c-a6c3-21e7993797aa
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_voucher_on_shipping.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_voucher_on_shipping.yaml
index 9df6d9ec2a..0fd638852d 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_voucher_on_shipping.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_voucher_on_shipping.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "5.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "3aec25de-b03a-4eb3-a733-54d104230d03", "date": "2022-09-08", "customerCode":
+ "5b2f4725-fb65-4ace-9f91-94183df8898d", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070688773,"code":"3aec25de-b03a-4eb3-a733-54d104230d03","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":34.07,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.83,"totalTaxable":34.07,"totalTaxCalculated":7.83,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070688775,"destinationAddressId":85009070688774,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:26.5910946Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070688779,"transactionId":85009070688773,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070688774,"originAddressId":85009070688775,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070688800,"transactionLineId":85009070688779,"transactionId":85009070688773,"addressId":85009070688774,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070688782,"documentLineId":85009070688779,"documentAddressId":85009070688775,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070688783,"documentLineId":85009070688779,"documentAddressId":85009070688774,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070688780,"transactionId":85009070688773,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070688774,"originAddressId":85009070688775,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":4.0700,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":0.93,"taxableAmount":4.07,"taxCalculated":0.93,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070688820,"transactionLineId":85009070688780,"transactionId":85009070688773,"addressId":85009070688774,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.9300,"taxableAmount":4.0700,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.9300,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":4.0700,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":4.07,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.93,"reportingTaxCalculated":0.93,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070688802,"documentLineId":85009070688780,"documentAddressId":85009070688775,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070688803,"documentLineId":85009070688780,"documentAddressId":85009070688774,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070688774,"transactionId":85009070688773,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070688775,"transactionId":85009070688773,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070688777,"documentId":85009070688773,"documentAddressId":85009070688775,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070688778,"documentId":85009070688773,"documentAddressId":85009070688774,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141575573,"code":"5b2f4725-fb65-4ace-9f91-94183df8898d","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":34.07,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.83,"totalTaxable":34.07,"totalTaxCalculated":7.83,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141575575,"destinationAddressId":85009141575574,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:25.2914151Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141575579,"transactionId":85009141575573,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141575574,"originAddressId":85009141575575,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141575600,"transactionLineId":85009141575579,"transactionId":85009141575573,"addressId":85009141575574,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141575582,"documentLineId":85009141575579,"documentAddressId":85009141575575,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141575583,"documentLineId":85009141575579,"documentAddressId":85009141575574,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141575580,"transactionId":85009141575573,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141575574,"originAddressId":85009141575575,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":4.0700,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":0.93,"taxableAmount":4.07,"taxCalculated":0.93,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141575620,"transactionLineId":85009141575580,"transactionId":85009141575573,"addressId":85009141575574,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.9300,"taxableAmount":4.0700,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.9300,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":4.0700,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":4.07,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.93,"reportingTaxCalculated":0.93,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141575602,"documentLineId":85009141575580,"documentAddressId":85009141575575,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141575603,"documentLineId":85009141575580,"documentAddressId":85009141575574,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141575574,"transactionId":85009141575573,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141575575,"transactionId":85009141575573,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141575577,"documentId":85009141575573,"documentAddressId":85009141575575,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141575578,"documentId":85009141575573,"documentAddressId":85009141575574,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":34.07,"rate":0.230000,"tax":7.83,"taxCalculated":7.83,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:26 GMT
+ - Fri, 09 Sep 2022 08:59:25 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070688773
+ - /api/v2/companies/7799660/transactions/85009141575573
ServerDuration:
- - '00:00:00.0930855'
+ - '00:00:00.0934859'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 974c8b3e-98a4-451c-9bf9-8d6be39a4d17
+ - eca5451a-50b5-46ca-bc29-3076b0f237c1
x-correlation-id:
- - 974c8b3e-98a4-451c-9bf9-8d6be39a4d17
+ - eca5451a-50b5-46ca-bc29-3076b0f237c1
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_zero_shipping_amount.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_zero_shipping_amount.yaml
index 483f68aabd..08d8eab0a7 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_zero_shipping_amount.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_zero_shipping_amount.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "0.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "7716b51b-8e49-41c6-9a37-6be54f25bf36", "date": "2022-09-08", "customerCode":
+ "bfbbe67b-20ad-4f4a-a847-af3372292d23", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070597899,"code":"7716b51b-8e49-41c6-9a37-6be54f25bf36","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":30.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070597901,"destinationAddressId":85009070597900,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:28.2711939Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070597905,"transactionId":85009070597899,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070597900,"originAddressId":85009070597901,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070597926,"transactionLineId":85009070597905,"transactionId":85009070597899,"addressId":85009070597900,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070597908,"documentLineId":85009070597905,"documentAddressId":85009070597901,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070597909,"documentLineId":85009070597905,"documentAddressId":85009070597900,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070597906,"transactionId":85009070597899,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070597900,"originAddressId":85009070597901,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"isSSTP":false,"itemCode":"Shipping","lineAmount":0.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070597946,"transactionLineId":85009070597906,"transactionId":85009070597899,"addressId":85009070597900,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.0000,"taxableAmount":0.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.0000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":0.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070597928,"documentLineId":85009070597906,"documentAddressId":85009070597901,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070597929,"documentLineId":85009070597906,"documentAddressId":85009070597900,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070597900,"transactionId":85009070597899,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070597901,"transactionId":85009070597899,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070597903,"documentId":85009070597899,"documentAddressId":85009070597901,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070597904,"documentId":85009070597899,"documentAddressId":85009070597900,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141658055,"code":"bfbbe67b-20ad-4f4a-a847-af3372292d23","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":30.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":6.9,"totalTaxable":30.0,"totalTaxCalculated":6.9,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141658057,"destinationAddressId":85009141658056,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:26.716823Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141658061,"transactionId":85009141658055,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141658056,"originAddressId":85009141658057,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141658082,"transactionLineId":85009141658061,"transactionId":85009141658055,"addressId":85009141658056,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141658064,"documentLineId":85009141658061,"documentAddressId":85009141658057,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141658065,"documentLineId":85009141658061,"documentAddressId":85009141658056,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141658062,"transactionId":85009141658055,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141658056,"originAddressId":85009141658057,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"isSSTP":false,"itemCode":"Shipping","lineAmount":0.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141658102,"transactionLineId":85009141658062,"transactionId":85009141658055,"addressId":85009141658056,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":0.0000,"taxableAmount":0.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":0.0000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":0.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141658084,"documentLineId":85009141658062,"documentAddressId":85009141658057,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141658085,"documentLineId":85009141658062,"documentAddressId":85009141658056,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141658056,"transactionId":85009141658055,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141658057,"transactionId":85009141658055,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141658059,"documentId":85009141658055,"documentAddressId":85009141658057,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141658060,"documentId":85009141658055,"documentAddressId":85009141658056,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":30.00,"rate":0.230000,"tax":6.90,"taxCalculated":6.90,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:28 GMT
+ - Fri, 09 Sep 2022 08:59:26 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070597899
+ - /api/v2/companies/7799660/transactions/85009141658055
ServerDuration:
- - '00:00:00.0923173'
+ - '00:00:00.0930873'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 69baac9e-a5fd-4a23-b57a-931a847ddb1e
+ - 3fb0decb-dff5-49aa-9f87-392237e8098e
x-correlation-id:
- - 69baac9e-a5fd-4a23-b57a-931a847ddb1e
+ - 3fb0decb-dff5-49aa-9f87-392237e8098e
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_total.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_total.yaml
index 986588e627..bc0b23edd8 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_total.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_total.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "52c6f604-1e3e-4f46-a94c-0936c4b1b31e", "date": "2022-09-08", "customerCode":
+ "d691de9e-e04d-4461-b2f2-b5f8b65f9f84", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070498141,"code":"52c6f604-1e3e-4f46-a94c-0936c4b1b31e","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.77,"totalTaxable":38.13,"totalTaxCalculated":8.77,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070498143,"destinationAddressId":85009070498142,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:28.5545031Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070498147,"transactionId":85009070498141,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070498142,"originAddressId":85009070498143,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070498168,"transactionLineId":85009070498147,"transactionId":85009070498141,"addressId":85009070498142,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070498150,"documentLineId":85009070498147,"documentAddressId":85009070498143,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070498151,"documentLineId":85009070498147,"documentAddressId":85009070498142,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070498148,"transactionId":85009070498141,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070498142,"originAddressId":85009070498143,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070498188,"transactionLineId":85009070498148,"transactionId":85009070498141,"addressId":85009070498142,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070498170,"documentLineId":85009070498148,"documentAddressId":85009070498143,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070498171,"documentLineId":85009070498148,"documentAddressId":85009070498142,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070498142,"transactionId":85009070498141,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070498143,"transactionId":85009070498141,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070498145,"documentId":85009070498141,"documentAddressId":85009070498143,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070498146,"documentId":85009070498141,"documentAddressId":85009070498142,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141735765,"code":"d691de9e-e04d-4461-b2f2-b5f8b65f9f84","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.77,"totalTaxable":38.13,"totalTaxCalculated":8.77,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141735767,"destinationAddressId":85009141735766,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:21.0309012Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141735771,"transactionId":85009141735765,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141735766,"originAddressId":85009141735767,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141735792,"transactionLineId":85009141735771,"transactionId":85009141735765,"addressId":85009141735766,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141735774,"documentLineId":85009141735771,"documentAddressId":85009141735767,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141735775,"documentLineId":85009141735771,"documentAddressId":85009141735766,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141735772,"transactionId":85009141735765,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141735766,"originAddressId":85009141735767,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141735812,"transactionLineId":85009141735772,"transactionId":85009141735765,"addressId":85009141735766,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141735794,"documentLineId":85009141735772,"documentAddressId":85009141735767,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141735795,"documentLineId":85009141735772,"documentAddressId":85009141735766,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141735766,"transactionId":85009141735765,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141735767,"transactionId":85009141735765,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141735769,"documentId":85009141735765,"documentAddressId":85009141735767,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141735770,"documentId":85009141735765,"documentAddressId":85009141735766,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":38.13,"rate":0.230000,"tax":8.77,"taxCalculated":8.77,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:28 GMT
+ - Fri, 09 Sep 2022 08:59:21 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070498141
+ - /api/v2/companies/7799660/transactions/85009141735765
ServerDuration:
- - '00:00:00.0884869'
+ - '00:00:00.0991907'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 3bc389ba-a454-4d90-8286-cd3be07dcbee
+ - f98ad52c-7702-4d12-9299-55ea14ca0009
x-correlation-id:
- - 3bc389ba-a454-4d90-8286-cd3be07dcbee
+ - f98ad52c-7702-4d12-9299-55ea14ca0009
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_cached_tax_codes_or_fetch.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_cached_tax_codes_or_fetch.yaml
index 402f90471c..150cefcc6c 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_cached_tax_codes_or_fetch.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_cached_tax_codes_or_fetch.yaml
@@ -5796,9 +5796,9 @@ interactions:
DatabaseDuration:
- 00:00:00
Date:
- - Thu, 08 Sep 2022 11:08:17 GMT
+ - Fri, 09 Sep 2022 09:29:42 GMT
ServerDuration:
- - '00:00:00.0016051'
+ - '00:00:00.0016306'
ServiceDuration:
- 00:00:00
X-Content-Type-Options:
@@ -5810,9 +5810,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains; preload
x-avalara-uid:
- - ecf63977-037f-4a28-b6aa-58ff448be40a
+ - f3d792ab-abd7-45af-b743-094518c73145
x-correlation-id:
- - ecf63977-037f-4a28-b6aa-58ff448be40a
+ - f3d792ab-abd7-45af-b743-094518c73145
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_cached_tax_codes_or_fetch_wrong_response.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_cached_tax_codes_or_fetch_wrong_response.yaml
index b98362bc19..145f3fe5bb 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_cached_tax_codes_or_fetch_wrong_response.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_cached_tax_codes_or_fetch_wrong_response.yaml
@@ -28,13 +28,13 @@ interactions:
Content-Type:
- application/json
Date:
- - Thu, 08 Sep 2022 10:53:28 GMT
+ - Fri, 09 Sep 2022 08:59:48 GMT
X-Content-Type-Options:
- nosniff
x-avalara-uid:
- - 0c3ddbb6-7c50-4e0d-a1c7-5f4586fb785c
+ - ee92e0c5-14f7-438f-8f8f-273ca6298cde
x-correlation-id:
- - 0c3ddbb6-7c50-4e0d-a1c7-5f4586fb785c
+ - ee92e0c5-14f7-438f-8f8f-273ca6298cde
status:
code: 401
message: Unauthorized
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate.yaml
index ccdffb1965..00dca48aac 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "ce8dde91-ea17-4a27-a079-e98d42f33021", "date": "2022-09-08", "customerCode":
+ "78b57980-2f4c-4bfb-a71a-a6b34c2be801", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"ce8dde91-ea17-4a27-a079-e98d42f33021","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:25.8177486Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"78b57980-2f4c-4bfb-a71a-a6b34c2be801","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:50.1560552Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:25 GMT
+ - Fri, 09 Sep 2022 08:59:50 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0159422'
+ - '00:00:00.0170201'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 1eb8ec60-6a42-4d7a-8cfe-fcee635e721e
+ - 240e61eb-c1ae-4911-91a2-a4eee1b098a8
x-correlation-id:
- - 1eb8ec60-6a42-4d7a-8cfe-fcee635e721e
+ - 240e61eb-c1ae-4911-91a2-a4eee1b098a8
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate_for_product_type_with_non_taxable_product.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate_for_product_type_with_non_taxable_product.yaml
index 5f34c08550..de9df40a97 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate_for_product_type_with_non_taxable_product.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate_for_product_type_with_non_taxable_product.yaml
@@ -3,16 +3,14 @@ interactions:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
true, "itemCode": "123", "discounted": false, "description": "Test product",
- "ref1": "123"}, {"quantity": 1, "amount": "10.00", "taxCode": "NT", "taxIncluded":
- true, "itemCode": "Product variant #1", "discounted": false, "description":
- "Test product with two variants", "ref1": "Product variant #1"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true, "itemCode":
- "Shipping", "discounted": false, "description": null}], "code": "bb68e463-a70e-4436-b6c8-24f01c351908",
- "date": "2022-09-08", "customerCode": 0, "discount": null, "addresses": {"shipFrom":
- {"line1": "Teczowa 7", "line2": null, "city": "Wroclaw", "region": "", "country":
- "PL", "postalCode": "53-601"}, "shipTo": {"line1": "T\u0119czowa 7", "line2":
- "", "city": "WROC\u0141AW", "region": "", "country": "PL", "postalCode": "53-601"}},
- "commit": false, "currencyCode": "USD", "email": "[email protected]"}}'
+ "ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
+ true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
+ "1f8b976f-59bc-4390-a222-5736028ec14f", "date": "2022-09-09", "customerCode":
+ 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
+ null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
+ "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
+ "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": "[email protected]"}}'
headers:
Accept:
- '*/*'
@@ -23,34 +21,31 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '1053'
+ - '845'
User-Agent:
- python-requests/2.28.1
method: POST
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"bb68e463-a70e-4436-b6c8-24f01c351908","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":44.39,"totalExempt":10.0,"totalDiscount":0.0,"totalTax":5.61,"totalTaxable":24.39,"totalTaxCalculated":5.61,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:27.6314146Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","description":"Test
- product with two variants","discountAmount":0.0,"exemptAmount":10.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Product
- variant #1","lineAmount":10.0,"quantity":1.0,"ref1":"Product variant #1","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"NT","taxCodeId":16740,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":10.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":10.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLSL230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"3","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":false,"itemCode":"Shipping","lineAmount":10.0000,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":10.0,"rate":0.230000,"tax":0.0,"taxableAmount":0.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":0.0,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":0.0,"reportingNonTaxableUnits":10.0,"reportingExemptUnits":0.0,"reportingTax":0.0,"reportingTaxCalculated":0.0,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
+ string: '{"id":0,"code":"1f8b976f-59bc-4390-a222-5736028ec14f","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T09:59:08.1239796Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
- Rate","rateType":"Standard","taxable":24.39,"rate":0.230000,"tax":5.61,"taxCalculated":5.61,"nonTaxable":20.0,"exemption":0.0}]}'
+ Rate","rateType":"Standard","taxable":32.52,"rate":0.230000,"tax":7.48,"taxCalculated":7.48,"nonTaxable":0.0,"exemption":0.0}]}'
headers:
Connection:
- keep-alive
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:27 GMT
+ - Fri, 09 Sep 2022 09:59:08 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0226374'
+ - '00:00:00.0160182'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -64,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - e8767cc5-20d4-4b95-9340-a6ee97296253
+ - c7be314b-2594-4551-bb74-3d5f143fb0f6
x-correlation-id:
- - e8767cc5-20d4-4b95-9340-a6ee97296253
+ - c7be314b-2594-4551-bb74-3d5f143fb0f6
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate_for_product_with_charge_taxes_set_to_false.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate_for_product_with_charge_taxes_set_to_false.yaml
new file mode 100644
index 0000000000..c409fd655b
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_line_tax_rate_for_product_with_charge_taxes_set_to_false.yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
+ false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
+ "5fc002a7-3b8c-4b35-8cc3-4c533d9e7399", "date": "2022-09-09", "customerCode":
+ 0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
+ null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
+ "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
+ "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": "[email protected]"}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate, br
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '680'
+ User-Agent:
+ - python-requests/2.28.1
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"5fc002a7-3b8c-4b35-8cc3-4c533d9e7399","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":10.0,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":2.3,"totalTaxable":10.0,"totalTaxCalculated":2.3,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T09:47:27.7125848Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":10.0,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":false,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.3,"taxableAmount":10.0,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.3,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":10.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.3,"reportingTaxCalculated":2.3,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ Rate","rateType":"Standard","taxable":10.0,"rate":0.230000,"tax":2.3,"taxCalculated":2.3,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Fri, 09 Sep 2022 09:47:27 GMT
+ Location:
+ - /api/v2/companies/7799660/transactions/0
+ ServerDuration:
+ - '00:00:00.0130660'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ api-supported-versions:
+ - '2.0'
+ cache-control:
+ - private, no-cache, no-store
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 48a4d7d9-48a7-43bc-8d16-ddf7b74f3f17
+ x-correlation-id:
+ - 48a4d7d9-48a7-43bc-8d16-ddf7b74f3f17
+ x-frame-options:
+ - sameorigin
+ x-permitted-cross-domain-policies:
+ - none
+ x-xss-protection:
+ - 1; mode=block
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_shipping_tax_rate.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_shipping_tax_rate.yaml
index 2a6357e24e..5fb6fbdebc 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_shipping_tax_rate.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_checkout_shipping_tax_rate.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "f3b82c58-3bba-4fbe-b78e-d9b7a4aa78ac", "date": "2022-09-08", "customerCode":
+ "5f719dc5-7b5e-4b20-aec7-b9b4c6cc7534", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"f3b82c58-3bba-4fbe-b78e-d9b7a4aa78ac","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:30.2260606Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"5f719dc5-7b5e-4b20-aec7-b9b4c6cc7534","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":32.52,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":7.48,"totalTaxable":32.52,"totalTaxCalculated":7.48,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:57.0903994Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.3900,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":5.61,"taxableAmount":24.39,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":5.61,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":24.39,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":5.61,"reportingTaxCalculated":5.61,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:30 GMT
+ - Fri, 09 Sep 2022 08:59:57 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0170884'
+ - '00:00:00.0170548'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - ddeeaf61-b871-4947-a256-1ede0aecc2d6
+ - 077e34db-4e68-4ef3-b31f-499bb1db21a9
x-correlation-id:
- - ddeeaf61-b871-4947-a256-1ede0aecc2d6
+ - 077e34db-4e68-4ef3-b31f-499bb1db21a9
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_order_line_tax_rate.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_order_line_tax_rate.yaml
index 213634270c..9372efcd4d 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_order_line_tax_rate.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_order_line_tax_rate.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "6339d27e-2a1f-4709-8fee-0d3fc7b9e44f", "date": "2022-09-08", "customerCode":
+ "73c219d4-c675-457e-975f-9fcd405c9783", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070782173,"code":"6339d27e-2a1f-4709-8fee-0d3fc7b9e44f","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.77,"totalTaxable":38.13,"totalTaxCalculated":8.77,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070782175,"destinationAddressId":85009070782174,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:30.2782731Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070782179,"transactionId":85009070782173,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070782174,"originAddressId":85009070782175,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070782200,"transactionLineId":85009070782179,"transactionId":85009070782173,"addressId":85009070782174,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070782182,"documentLineId":85009070782179,"documentAddressId":85009070782175,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070782183,"documentLineId":85009070782179,"documentAddressId":85009070782174,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070782180,"transactionId":85009070782173,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070782174,"originAddressId":85009070782175,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070782220,"transactionLineId":85009070782180,"transactionId":85009070782173,"addressId":85009070782174,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070782202,"documentLineId":85009070782180,"documentAddressId":85009070782175,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070782203,"documentLineId":85009070782180,"documentAddressId":85009070782174,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070782174,"transactionId":85009070782173,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070782175,"transactionId":85009070782173,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070782177,"documentId":85009070782173,"documentAddressId":85009070782175,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070782178,"documentId":85009070782173,"documentAddressId":85009070782174,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141661033,"code":"73c219d4-c675-457e-975f-9fcd405c9783","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.77,"totalTaxable":38.13,"totalTaxCalculated":8.77,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141661035,"destinationAddressId":85009141661034,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:54.951688Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141661039,"transactionId":85009141661033,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141661034,"originAddressId":85009141661035,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141661060,"transactionLineId":85009141661039,"transactionId":85009141661033,"addressId":85009141661034,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141661042,"documentLineId":85009141661039,"documentAddressId":85009141661035,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141661043,"documentLineId":85009141661039,"documentAddressId":85009141661034,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141661040,"transactionId":85009141661033,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141661034,"originAddressId":85009141661035,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141661080,"transactionLineId":85009141661040,"transactionId":85009141661033,"addressId":85009141661034,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141661062,"documentLineId":85009141661040,"documentAddressId":85009141661035,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141661063,"documentLineId":85009141661040,"documentAddressId":85009141661034,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141661034,"transactionId":85009141661033,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141661035,"transactionId":85009141661033,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141661037,"documentId":85009141661033,"documentAddressId":85009141661035,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141661038,"documentId":85009141661033,"documentAddressId":85009141661034,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":38.13,"rate":0.230000,"tax":8.77,"taxCalculated":8.77,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:30 GMT
+ - Fri, 09 Sep 2022 08:59:54 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070782173
+ - /api/v2/companies/7799660/transactions/85009141661033
ServerDuration:
- - '00:00:00.0880199'
+ - '00:00:00.0911704'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 17b4d8dd-778e-41b2-85d7-530afac54f15
+ - 1d73a033-4dcb-4c3d-b80d-c5ceef133b0e
x-correlation-id:
- - 17b4d8dd-778e-41b2-85d7-530afac54f15
+ - 1d73a033-4dcb-4c3d-b80d-c5ceef133b0e
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_order_shipping_tax_rate.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_order_shipping_tax_rate.yaml
index b75571af9a..70e42f645b 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_order_shipping_tax_rate.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_get_order_shipping_tax_rate.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "SKU_A", "discounted": false, "description": "Test product"},
{"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true,
"itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "642052f6-3486-46c7-a7c8-54a25f416278", "date": "2022-09-08", "customerCode":
+ "d2163756-546a-4105-9233-70f9e377f323", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -28,12 +28,12 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":85009070689278,"code":"642052f6-3486-46c7-a7c8-54a25f416278","companyId":7799660,"date":"2022-09-08","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.77,"totalTaxable":38.13,"totalTaxCalculated":8.77,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009070689280,"destinationAddressId":85009070689279,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-08T10:53:30.4192725Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":85009070689284,"transactionId":85009070689278,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
- product","destinationAddressId":85009070689279,"originAddressId":85009070689280,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070689305,"transactionLineId":85009070689284,"transactionId":85009070689278,"addressId":85009070689279,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070689287,"documentLineId":85009070689284,"documentAddressId":85009070689280,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070689288,"documentLineId":85009070689284,"documentAddressId":85009070689279,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009070689285,"transactionId":85009070689278,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009070689279,"originAddressId":85009070689280,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009070689325,"transactionLineId":85009070689285,"transactionId":85009070689278,"addressId":85009070689279,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009070689307,"documentLineId":85009070689285,"documentAddressId":85009070689280,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009070689308,"documentLineId":85009070689285,"documentAddressId":85009070689279,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009070689279,"transactionId":85009070689278,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009070689280,"transactionId":85009070689278,"boundaryLevel":"Zip5","line1":"Teczowa
- 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009070689282,"documentId":85009070689278,"documentAddressId":85009070689280,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009070689283,"documentId":85009070689278,"documentAddressId":85009070689279,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
+ string: '{"id":85009141579254,"code":"d2163756-546a-4105-9233-70f9e377f323","companyId":7799660,"date":"2022-09-09","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":38.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":8.77,"totalTaxable":38.13,"totalTaxCalculated":8.77,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"22.8.2.0","originAddressId":85009141579256,"destinationAddressId":85009141579255,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-09-09T08:59:59.6394141Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":85009141579260,"transactionId":85009141579254,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85009141579255,"originAddressId":85009141579256,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_A","lineAmount":30.0000,"quantity":3.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141579281,"transactionLineId":85009141579260,"transactionId":85009141579254,"addressId":85009141579255,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0000,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0000,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":30.0,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":6.9,"reportingTaxCalculated":6.9,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141579263,"documentLineId":85009141579260,"documentAddressId":85009141579256,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141579264,"documentLineId":85009141579260,"documentAddressId":85009141579255,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":85009141579261,"transactionId":85009141579254,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85009141579255,"originAddressId":85009141579256,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85009141579301,"transactionLineId":85009141579261,"transactionId":85009141579254,"addressId":85009141579255,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"","exemptAmount":0.0000,"exemptReasonId":4,"inState":true,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0000,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":411502,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.8700,"taxableAmount":8.1300,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.8700,"taxOverride":0.0000,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.1300,"nonTaxableUnits":0.0000,"exemptUnits":0.0000,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":85009141579283,"documentLineId":85009141579261,"documentAddressId":85009141579256,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85009141579284,"documentLineId":85009141579261,"documentAddressId":85009141579255,"locationTypeCode":"ShipTo"}],"parameters":[{"name":"Transport","value":"None"},{"name":"IsMarketplace","value":"False"},{"name":"IsTriangulation","value":"false"},{"name":"IsGoodsSecondHand","value":"false"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":85009141579255,"transactionId":85009141579254,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85009141579256,"transactionId":85009141579254,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85009141579258,"documentId":85009141579254,"documentAddressId":85009141579256,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85009141579259,"documentId":85009141579254,"documentAddressId":85009141579255,"locationTypeCode":"ShipTo"}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
Rate","rateType":"Standard","taxable":38.13,"rate":0.230000,"tax":8.77,"taxCalculated":8.77,"nonTaxable":0.00,"exemption":0.00}]}'
headers:
Connection:
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:30 GMT
+ - Fri, 09 Sep 2022 08:59:59 GMT
Location:
- - /api/v2/companies/7799660/transactions/85009070689278
+ - /api/v2/companies/7799660/transactions/85009141579254
ServerDuration:
- - '00:00:00.0907095'
+ - '00:00:00.0921583'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 7a6ec58a-274d-477c-8b50-6cba0b8ec861
+ - ca3938be-c7cb-4307-a1ad-62a6344a7670
x-correlation-id:
- - 7a6ec58a-274d-477c-8b50-6cba0b8ec861
+ - ca3938be-c7cb-4307-a1ad-62a6344a7670
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_plugin_uses_configuration_from_db.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_plugin_uses_configuration_from_db.yaml
index 51dc556c78..225feeb2d7 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_plugin_uses_configuration_from_db.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_plugin_uses_configuration_from_db.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "18a7dd60-08aa-46ad-94fc-bfeabf9e8181", "date": "2022-09-08", "customerCode":
+ "c0a16ae3-0fd5-4659-87d7-0de81e10550d", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"18a7dd60-08aa-46ad-94fc-bfeabf9e8181","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T11:05:09.2128621Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"c0a16ae3-0fd5-4659-87d7-0de81e10550d","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T10:05:24.5097954Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 11:05:09 GMT
+ - Fri, 09 Sep 2022 10:05:24 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0156506'
+ - '00:00:00.0195333'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 80fb97b9-484c-4d7c-975a-88b8b84e542f
+ - 5071472f-28aa-4de8-b080-2ed794484aed
x-correlation-id:
- - 80fb97b9-484c-4d7c-975a-88b8b84e542f
+ - 5071472f-28aa-4de8-b080-2ed794484aed
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
@@ -77,7 +77,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "18a7dd60-08aa-46ad-94fc-bfeabf9e8181", "date": "2022-09-08", "customerCode":
+ "c0a16ae3-0fd5-4659-87d7-0de81e10550d", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -112,13 +112,13 @@ interactions:
Content-Type:
- application/json
Date:
- - Thu, 08 Sep 2022 11:05:09 GMT
+ - Fri, 09 Sep 2022 10:05:25 GMT
X-Content-Type-Options:
- nosniff
x-avalara-uid:
- - 0093c91b-63a8-4d6e-b1d5-679fdb3ecb2b
+ - 0edbb7ca-96db-4065-bf2a-77f092e5f86d
x-correlation-id:
- - 0093c91b-63a8-4d6e-b1d5-679fdb3ecb2b
+ - 0edbb7ca-96db-4065-bf2a-77f092e5f86d
status:
code: 401
message: Unauthorized
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation.yaml
index 6b0321c49a..d562d33621 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "82708dc8-ad97-4acb-b8bc-e0769e64f6da", "date": "2022-09-08", "customerCode":
+ "55afca08-5afd-4e0f-9e44-e7b61e9639a6", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"82708dc8-ad97-4acb-b8bc-e0769e64f6da","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:30.4066055Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"55afca08-5afd-4e0f-9e44-e7b61e9639a6","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:43.6008104Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:30 GMT
+ - Fri, 09 Sep 2022 08:59:43 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0163167'
+ - '00:00:00.0170880'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - c7c401ec-8059-4134-9651-dccf1df6c9b3
+ - c7e52f5b-27ff-4db7-840c-223b9f91dbce
x-correlation-id:
- - c7c401ec-8059-4134-9651-dccf1df6c9b3
+ - c7e52f5b-27ff-4db7-840c-223b9f91dbce
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation_no_lines_data.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation_no_lines_data.yaml
index 85229d8b84..49c32573fd 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation_no_lines_data.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation_no_lines_data.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "da216a23-37f8-4a18-a9d9-a7aa414841ca", "date": "2022-09-08", "customerCode":
+ "7a9006ab-f563-447f-8c56-82f79e328857", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "O\u0142awska 10", "line2": "", "city": "WROC\u0141AW",
@@ -28,9 +28,9 @@ interactions:
uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"da216a23-37f8-4a18-a9d9-a7aa414841ca","companyId":7799660,"date":"2022-09-08","paymentDate":"2022-09-08","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-08","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-08T10:53:25.1250041Z","modifiedUserId":6479978,"taxDate":"2022-09-08","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
- product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-08","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
- Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-08","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-08","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ string: '{"id":0,"code":"7a9006ab-f563-447f-8c56-82f79e328857","companyId":7799660,"date":"2022-09-09","paymentDate":"2022-09-09","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":20.33,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":4.67,"totalTaxable":20.33,"totalTaxCalculated":4.67,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-09-09","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-09-09T08:59:44.9483225Z","modifiedUserId":6479978,"taxDate":"2022-09-09","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":12.2000,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-09-09","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"O9999999","taxCodeId":9111,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":2.8,"taxableAmount":12.2,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxCalculated":2.8,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":12.2,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":2.8,"reportingTaxCalculated":2.8,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230C","vatNumberTypeId":0},{"id":0,"transactionId":0,"lineNumber":"2","customerUsageType":"","entityUseCode":"","discountAmount":0.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"Shipping","lineAmount":8.1300,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2022-09-09","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":8550,"taxDate":"2022-09-09","taxIncluded":true,"details":[{"id":0,"transactionLineId":0,"transactionId":0,"country":"PL","region":"PL","exemptAmount":0.0,"jurisCode":"PL","jurisName":"POLAND","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"rate":0.230000,"tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxName":"Standard
Rate","taxAuthorityTypeId":45,"taxCalculated":1.87,"rateType":"Standard","rateTypeCode":"S","unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false,"reportingTaxableUnits":8.13,"reportingNonTaxableUnits":0.0,"reportingExemptUnits":0.0,"reportingTax":1.87,"reportingTaxCalculated":1.87,"liabilityType":"Seller"}],"nonPassthroughDetails":[],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230D","vatNumberTypeId":0}],"addresses":[{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Olawska
10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102,"latitude":"","longitude":""},{"id":0,"transactionId":0,"boundaryLevel":"Zip5","line1":"Teczowa
7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102,"latitude":"","longitude":""}],"summary":[{"country":"PL","region":"PL","jurisType":"Country","jurisCode":"PL","jurisName":"POLAND","taxAuthorityType":45,"stateAssignedNo":"","taxType":"Output","taxSubType":"O","taxName":"Standard
@@ -41,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 08 Sep 2022 10:53:25 GMT
+ - Fri, 09 Sep 2022 08:59:44 GMT
Location:
- /api/v2/companies/7799660/transactions/0
ServerDuration:
- - '00:00:00.0151546'
+ - '00:00:00.0176050'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -59,9 +59,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 71af66c2-cf68-4184-84fc-28dde106cf5f
+ - 18029fba-a8bb-4aa2-a68d-14c7a9283b65
x-correlation-id:
- - 71af66c2-cf68-4184-84fc-28dde106cf5f
+ - 18029fba-a8bb-4aa2-a68d-14c7a9283b65
x-frame-options:
- sameorigin
x-permitted-cross-domain-policies:
diff --git a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation_wrong_data.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation_wrong_data.yaml
index f48be5afef..02e1d92573 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation_wrong_data.yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_preprocess_order_creation_wrong_data.yaml
@@ -5,7 +5,7 @@ interactions:
true, "itemCode": "123", "discounted": false, "description": "Test product",
"ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
true, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
- "aa47aeb1-94c6-49e4-a05a-8ef59066021e", "date": "2022-09-08", "customerCode":
+ "7537c2e1-57f9-4222-a08f-057f3fc2f705", "date": "2022-09-09", "customerCode":
0, "discount": null, "addresses": {"shipFrom": {"line1": "Teczowa 7", "line2":
null, "city": "Wroclaw", "region": "", "country": "PL", "postalCode": "53-601"},
"shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
@@ -40,13 +40,13 @@ interactions:
Content-Type:
- application/json
Date:
- - Thu, 08 Sep 2022 10:53:26 GMT
+ - Fri, 09 Sep 2022 08:59:46 GMT
X-Content-Type-Options:
- nosniff
x-avalara-uid:
- - b077b5e5-5c80-4c04-a1d7-59bb3606fd66
+ - 622c1559-4ab7-49fc-89ef-8f76f80cf0c1
x-correlation-id:
- - b077b5e5-5c80-4c04-a1d7-59bb3606fd66
+ - 622c1559-4ab7-49fc-89ef-8f76f80cf0c1
status:
code: 401
message: Unauthorized
diff --git a/saleor/plugins/avatax/tests/conftest.py b/saleor/plugins/avatax/tests/conftest.py
index 0d979df43b..60d1d24d52 100644
--- a/saleor/plugins/avatax/tests/conftest.py
+++ b/saleor/plugins/avatax/tests/conftest.py
@@ -34,8 +34,6 @@ def plugin_configuration(db, channel_USD):
from_country_area="",
from_postal_code="53-601",
shipping_tax_code="FR000000",
- override_global_tax=False,
- include_taxes_in_prices=True,
):
channel = channel or channel_USD
data = {
@@ -54,8 +52,6 @@ def plugin_configuration(db, channel_USD):
{"name": "from_country_area", "value": from_country_area},
{"name": "from_postal_code", "value": from_postal_code},
{"name": "shipping_tax_code", "value": shipping_tax_code},
- {"name": "override_global_tax", "value": override_global_tax},
- {"name": "include_taxes_in_prices", "value": include_taxes_in_prices},
],
}
configuration = PluginConfiguration.objects.create(
@@ -108,6 +104,7 @@ def checkout_with_items_and_shipping_info(checkout_with_items_and_shipping):
convert_to_shipping_method_data(shipping_method, shipping_channel_listing),
shipping_address,
),
+ tax_configuration=channel.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
diff --git a/saleor/plugins/avatax/tests/test_avatax.py b/saleor/plugins/avatax/tests/test_avatax.py
index 54420b0c71..cf9d51d278 100644
--- a/saleor/plugins/avatax/tests/test_avatax.py
+++ b/saleor/plugins/avatax/tests/test_avatax.py
@@ -25,12 +25,14 @@ from ....order import OrderStatus
from ....product import ProductTypeKind
from ....product.models import Product, ProductType
from ....shipping.utils import convert_to_shipping_method_data
+from ....tax.models import TaxClass
from ...manager import get_plugins_manager
from ...models import PluginConfiguration
from .. import (
DEFAULT_TAX_CODE,
META_CODE_KEY,
META_DESCRIPTION_KEY,
+ TAX_CODE_NON_TAXABLE_PRODUCT,
AvataxConfiguration,
TransactionType,
_validate_adddress_details,
@@ -39,8 +41,8 @@ from .. import (
api_get_request,
api_post_request,
generate_request_data_from_checkout,
+ generate_request_data_from_checkout_lines,
get_cached_tax_codes_or_fetch,
- get_checkout_lines_data,
get_checkout_tax_data,
get_order_lines_data,
get_order_request_data,
@@ -50,6 +52,17 @@ from .. import (
from ..plugin import AvataxPlugin
+def order_set_shipping_method(order, shipping_method):
+ order.shipping_method = shipping_method
+ order.shipping_method_name = shipping_method.name
+ order.shipping_tax_class = shipping_method.tax_class
+ order.shipping_tax_class_name = shipping_method.tax_class.name
+ order.shipping_tax_class_metadata = shipping_method.tax_class.metadata
+ order.shipping_tax_class_private_metadata = (
+ shipping_method.tax_class.private_metadata
+ )
+
+
@pytest.fixture
def avatax_config():
return AvataxConfiguration(
@@ -66,7 +79,7 @@ def avatax_config():
@pytest.mark.vcr()
@pytest.mark.parametrize(
- "with_discount, expected_net, expected_gross, taxes_in_prices",
+ "with_discount, expected_net, expected_gross, prices_entered_with_tax",
[
(True, "12.20", "15.00", True),
(False, "24.39", "30.00", True),
@@ -79,12 +92,10 @@ def test_calculate_checkout_line_total(
with_discount,
expected_net,
expected_gross,
- taxes_in_prices,
+ prices_entered_with_tax,
discount_info,
checkout_with_item,
- address,
ship_to_pl_address,
- site_settings,
monkeypatch,
shipping_zone,
plugin_configuration,
@@ -95,13 +106,16 @@ def test_calculate_checkout_line_total(
checkout_with_item.shipping_address = ship_to_pl_address
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
checkout_with_item.save()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
+
+ tax_configuration = checkout_with_item.channel.tax_configuration
+ tax_configuration.charge_taxes = True
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
line = checkout_with_item.lines.first()
product = line.variant.product
product.metadata = {}
- product.charge_taxes = True
product.save()
product.product_type.save()
discounts = [discount_info] if with_discount else None
@@ -128,8 +142,6 @@ def test_calculate_checkout_line_total(
def test_calculate_checkout_line_total_with_variant_on_sale(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
discount_info,
@@ -153,9 +165,10 @@ def test_calculate_checkout_line_total_with_variant_on_sale(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -180,8 +193,6 @@ def test_calculate_checkout_line_total_with_variant_on_sale(
def test_calculate_checkout_line_total_with_voucher(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
voucher,
@@ -218,9 +229,10 @@ def test_calculate_checkout_line_total_with_voucher(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -245,8 +257,6 @@ def test_calculate_checkout_line_total_with_voucher(
def test_calculate_checkout_line_total_with_voucher_once_per_order(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
voucher,
@@ -280,9 +290,10 @@ def test_calculate_checkout_line_total_with_voucher_once_per_order(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -307,8 +318,6 @@ def test_calculate_checkout_line_total_with_voucher_once_per_order(
def test_calculate_checkout_line_total_with_variant_on_sale_and_voucher(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
voucher,
@@ -342,9 +351,10 @@ def test_calculate_checkout_line_total_with_variant_on_sale_and_voucher(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -369,8 +379,6 @@ def test_calculate_checkout_line_total_with_variant_on_sale_and_voucher(
def test_calculate_checkout_line_total_with_variant_on_sale_and_voucher_only_once(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
voucher,
@@ -405,9 +413,10 @@ def test_calculate_checkout_line_total_with_variant_on_sale_and_voucher_only_onc
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -429,7 +438,7 @@ def test_calculate_checkout_line_total_with_variant_on_sale_and_voucher_only_onc
@pytest.mark.vcr()
@pytest.mark.parametrize(
- "with_discount, expected_net, expected_gross, taxes_in_prices",
+ "with_discount, expected_net, expected_gross, prices_entered_with_tax",
[
(True, "12.20", "15.00", True),
(False, "24.39", "30.00", True),
@@ -442,12 +451,10 @@ def test_calculate_checkout_line_without_sku_total(
with_discount,
expected_net,
expected_gross,
- taxes_in_prices,
+ prices_entered_with_tax,
discount_info,
checkout_with_item,
- address,
ship_to_pl_address,
- site_settings,
monkeypatch,
shipping_zone,
plugin_configuration,
@@ -462,15 +469,18 @@ def test_calculate_checkout_line_without_sku_total(
checkout_with_item.shipping_address = ship_to_pl_address
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
checkout_with_item.save()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
+
+ tax_configuration = checkout_with_item.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
line = checkout_with_item.lines.first()
line.variant.sku = None
line.variant.save()
product = line.variant.product
product.metadata = {}
- product.charge_taxes = True
product.save()
product.product_type.save()
discounts = [discount_info] if with_discount else None
@@ -506,18 +516,33 @@ def test_calculate_order_line_total(
plugin_configuration()
manager = get_plugins_manager()
+ order = order_line.order
+
+ tax_configuration = order.channel.tax_configuration
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes"])
+ tax_configuration.country_exceptions.all().delete()
+
site_settings.company_address = address
site_settings.save(update_fields=["company_address"])
- order = order_line.order
order.shipping_address = ship_to_pl_address
- order.shipping_method = shipping_zone.shipping_methods.get()
- order.save(update_fields=["shipping_address", "shipping_method"])
+ shipping_method = shipping_zone.shipping_methods.get()
+ order_set_shipping_method(order, shipping_method)
+ order.save(
+ update_fields=[
+ "shipping_address",
+ "shipping_method",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_metadata",
+ "shipping_tax_class_private_metadata",
+ ]
+ )
variant = order_line.variant
product = variant.product
product.metadata = {}
- product.charge_taxes = True
product.save()
product.product_type.save()
@@ -565,15 +590,20 @@ def test_calculate_order_line_without_sku_total(
order = order_line.order
order.shipping_address = ship_to_pl_address
- order.shipping_method = shipping_zone.shipping_methods.get()
- order.save(update_fields=["shipping_address", "shipping_method"])
+ shipping_method = shipping_zone.shipping_methods.get()
+ order_set_shipping_method(order, shipping_method)
+ order.save()
+
+ tax_configuration = order.channel.tax_configuration
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes"])
+ tax_configuration.country_exceptions.all().delete()
variant = order_line.variant
variant.sku = None
variant.save()
product = variant.product
product.metadata = {}
- product.charge_taxes = True
product.save()
product.product_type.save()
@@ -618,13 +648,18 @@ def test_calculate_order_line_total_with_discount(
order = order_line.order
order.shipping_address = ship_to_pl_address
- order.shipping_method = shipping_zone.shipping_methods.get()
- order.save(update_fields=["shipping_address", "shipping_method"])
+ shipping_method = shipping_zone.shipping_methods.get()
+ order_set_shipping_method(order, shipping_method)
+ order.save()
+
+ tax_configuration = order.channel.tax_configuration
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes"])
+ tax_configuration.country_exceptions.all().delete()
variant = order_line.variant
product = variant.product
product.metadata = {}
- product.charge_taxes = True
product.save()
product.product_type.save()
@@ -666,7 +701,7 @@ def test_calculate_order_line_total_with_discount(
@pytest.mark.vcr()
@pytest.mark.parametrize(
- "expected_net, expected_gross, taxes_in_prices",
+ "expected_net, expected_gross, prices_entered_with_tax",
[
("16.26", "20.00", True),
("20.00", "24.60", False),
@@ -676,13 +711,11 @@ def test_calculate_order_line_total_with_discount(
def test_calculate_order_line_total_entire_order_voucher(
expected_net,
expected_gross,
- taxes_in_prices,
+ prices_entered_with_tax,
order_line,
- address,
ship_to_pl_address,
shipping_zone,
voucher,
- site_settings,
monkeypatch,
plugin_configuration,
):
@@ -690,23 +723,26 @@ def test_calculate_order_line_total_entire_order_voucher(
plugin_configuration()
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save(update_fields=["company_address", "include_taxes_in_prices"])
-
order = order_line.order
+ channel = order.channel
+
+ tax_configuration = channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
order.shipping_address = ship_to_pl_address
- order.shipping_method = shipping_zone.shipping_methods.get()
- order.save(update_fields=["shipping_address", "shipping_method"])
+ shipping_method = shipping_zone.shipping_methods.get()
+ order_set_shipping_method(order, shipping_method)
+ order.save()
variant = order_line.variant
product = variant.product
product.metadata = {}
- product.charge_taxes = True
product.save()
product.product_type.save()
- channel = order_line.order.channel
channel_listing = variant.channel_listings.get(channel=channel)
net = variant.get_price(product, [], channel, channel_listing)
@@ -757,7 +793,7 @@ def test_calculate_order_line_total_entire_order_voucher(
@pytest.mark.vcr()
@pytest.mark.parametrize(
- "expected_net, expected_gross, taxes_in_prices",
+ "expected_net, expected_gross, prices_entered_with_tax",
[
("24.39", "30.00", True),
("30.00", "36.90", False),
@@ -767,13 +803,11 @@ def test_calculate_order_line_total_entire_order_voucher(
def test_calculate_order_line_total_shipping_voucher(
expected_net,
expected_gross,
- taxes_in_prices,
+ prices_entered_with_tax,
order_line,
- address,
ship_to_pl_address,
shipping_zone,
voucher_free_shipping,
- site_settings,
monkeypatch,
plugin_configuration,
):
@@ -781,23 +815,26 @@ def test_calculate_order_line_total_shipping_voucher(
plugin_configuration()
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save(update_fields=["company_address", "include_taxes_in_prices"])
-
order = order_line.order
+ channel = order_line.order.channel
+
+ tax_configuration = channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
order.shipping_address = ship_to_pl_address
- order.shipping_method = shipping_zone.shipping_methods.get()
- order.save(update_fields=["shipping_address", "shipping_method"])
+ shipping_method = shipping_zone.shipping_methods.get()
+ order_set_shipping_method(order, shipping_method)
+ order.save()
variant = order_line.variant
product = variant.product
product.metadata = {}
- product.charge_taxes = True
product.save()
product.product_type.save()
- channel = order_line.order.channel
channel_listing = variant.channel_listings.get(channel=channel)
net = variant.get_price(product, [], channel, channel_listing)
@@ -863,7 +900,6 @@ def test_calculate_order_line_total_order_not_valid(
variant = order_line.variant
product = variant.product
product.metadata = {}
- product.charge_taxes = True
product.save()
product.product_type.save()
@@ -871,6 +907,11 @@ def test_calculate_order_line_total_order_not_valid(
channel = order.channel
channel_listing = variant.channel_listings.get(channel=channel)
+ tax_configuration = channel.tax_configuration
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes"])
+ tax_configuration.country_exceptions.all().delete()
+
net = variant.get_price(product, [], channel, channel_listing)
unit_price = TaxedMoney(net=net, gross=net)
order_line.base_unit_price = net
@@ -909,17 +950,21 @@ def test_calculate_order_shipping_order_not_valid(
variant = order_line.variant
product = variant.product
product.metadata = {}
- product.charge_taxes = True
product.save(update_fields=["metadata", "charge_taxes"])
order = order_line.order
+ tax_configuration = order.channel.tax_configuration
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes"])
+ tax_configuration.country_exceptions.all().delete()
+
expected_shipping_price = TaxedMoney(
net=Money("10.00", "USD"), gross=Money("10.00", "USD")
)
order.shipping_address = None
order.base_shipping_price = Money("10.00", "USD")
- order.shipping_method = shipping_method
+ order_set_shipping_method(order, shipping_method)
order.save()
order.shipping_method.channel_listings.filter(channel_id=order.channel_id).update(
@@ -939,7 +984,10 @@ def test_calculate_order_shipping_order_not_valid(
@pytest.mark.vcr
@pytest.mark.parametrize(
- "with_discount, expected_net, expected_gross, voucher_amount, taxes_in_prices",
+ (
+ "with_discount, expected_net, expected_gross, voucher_amount, "
+ "prices_entered_with_tax"
+ ),
[
(True, "22.32", "26.99", "0.0", True),
(True, "21.99", "26.73", "5.0", False),
@@ -953,7 +1001,7 @@ def test_calculate_checkout_total_uses_default_calculation(
expected_net,
expected_gross,
voucher_amount,
- taxes_in_prices,
+ prices_entered_with_tax,
checkout_with_item,
product_with_single_variant,
discount_info,
@@ -961,10 +1009,10 @@ def test_calculate_checkout_total_uses_default_calculation(
shipping_zone,
address,
ship_to_pl_address,
- site_settings,
monkeypatch,
plugin_configuration,
non_default_category,
+ tax_class_zero_rates,
):
plugin_configuration()
monkeypatch.setattr(
@@ -974,9 +1022,12 @@ def test_calculate_checkout_total_uses_default_calculation(
manager = get_plugins_manager()
checkout_with_item.shipping_address = ship_to_pl_address
checkout_with_item.save()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
+
+ tax_configuration = checkout_with_item.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
voucher_amount = Money(voucher_amount, "USD")
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
@@ -987,10 +1038,10 @@ def test_calculate_checkout_total_uses_default_calculation(
line = checkout_with_item.lines.first()
product = line.variant.product
product.metadata = {}
- manager.assign_tax_code_to_object_meta(product.product_type, "PC040156")
+ manager.assign_tax_code_to_object_meta(product.product_type.tax_class, "PC040156")
product.save()
product.product_type.save()
- product_with_single_variant.charge_taxes = False
+ product_with_single_variant.tax_class = tax_class_zero_rates
product_with_single_variant.category = non_default_category
product_with_single_variant.save()
discounts = [discount_info] if with_discount else None
@@ -1007,7 +1058,10 @@ def test_calculate_checkout_total_uses_default_calculation(
@pytest.mark.vcr
@pytest.mark.parametrize(
- "with_discount, expected_net, expected_gross, voucher_amount, taxes_in_prices",
+ (
+ "with_discount, expected_net, expected_gross, voucher_amount, "
+ "prices_entered_with_tax"
+ ),
[
(True, "22.32", "26.99", "0.0", True),
(True, "21.99", "26.73", "5.0", False),
@@ -1021,7 +1075,7 @@ def test_calculate_checkout_total(
expected_net,
expected_gross,
voucher_amount,
- taxes_in_prices,
+ prices_entered_with_tax,
checkout_with_item,
product_with_single_variant,
discount_info,
@@ -1029,15 +1083,15 @@ def test_calculate_checkout_total(
shipping_zone,
address,
ship_to_pl_address,
- site_settings,
monkeypatch,
plugin_configuration,
non_default_category,
+ tax_class_zero_rates,
):
plugin_configuration()
monkeypatch.setattr(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
- lambda _: {"PS081282": "desc"},
+ lambda _: {"PS081282": "desc", TAX_CODE_NON_TAXABLE_PRODUCT: "desc"},
)
monkeypatch.setattr(
"saleor.plugins.avatax.plugin.AvataxPlugin._skip_plugin", lambda *_: False
@@ -1045,9 +1099,12 @@ def test_calculate_checkout_total(
manager = get_plugins_manager()
checkout_with_item.shipping_address = ship_to_pl_address
checkout_with_item.save()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
+
+ tax_configuration = checkout_with_item.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
voucher_amount = Money(voucher_amount, "USD")
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
@@ -1057,14 +1114,19 @@ def test_calculate_checkout_total(
checkout_with_item.save()
line = checkout_with_item.lines.first()
product = line.variant.product
- product.metadata = {}
- manager.assign_tax_code_to_object_meta(product.product_type, "PS081282")
+
+ manager.assign_tax_code_to_object_meta(product.tax_class, "PS081282")
product.save()
- product.product_type.save()
+ product.tax_class.save()
- product_with_single_variant.charge_taxes = False
+ product_with_single_variant.tax_class = tax_class_zero_rates
product_with_single_variant.category = non_default_category
- product_with_single_variant.save()
+ product_with_single_variant.save(
+ update_fields=[
+ "category",
+ "tax_class",
+ ]
+ )
discounts = [discount_info] if with_discount else None
checkout_info = fetch_checkout_info(checkout_with_item, [], discounts, manager)
add_variant_to_checkout(checkout_info, product_with_single_variant.variants.get())
@@ -1080,7 +1142,7 @@ def test_calculate_checkout_total(
@pytest.mark.vcr
@pytest.mark.parametrize(
- "expected_net, expected_gross, taxes_in_prices",
+ "expected_net, expected_gross, prices_entered_with_tax",
[
("8.13", "10.00", True),
("10.00", "12.30", False),
@@ -1090,12 +1152,11 @@ def test_calculate_checkout_total(
def test_calculate_checkout_total_voucher_on_entire_order(
expected_net,
expected_gross,
- taxes_in_prices,
+ prices_entered_with_tax,
checkout_with_item,
voucher_percentage,
stock,
monkeypatch,
- site_settings,
ship_to_pl_address,
shipping_zone,
address,
@@ -1111,11 +1172,13 @@ def test_calculate_checkout_total_voucher_on_entire_order(
lambda _: {"PC040156": "desc"},
)
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
-
channel = checkout_with_item.channel
+
+ tax_configuration = channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
channel_listing = variant.channel_listings.get(channel=channel)
net = (
variant.get_price(
@@ -1230,7 +1293,6 @@ def test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes(
voucher_percentage,
stock,
monkeypatch,
- site_settings,
ship_to_pl_address,
shipping_zone,
address,
@@ -1246,11 +1308,14 @@ def test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes(
lambda _: {"PC040156": "desc"},
)
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
channel = checkout_with_item.channel
+
+ tax_configuration = channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.charge_taxes = False
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
channel_listing = variant.channel_listings.get(channel=channel)
net = (
variant.get_price(
@@ -1270,11 +1335,6 @@ def test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes(
shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
shipping_price = shipping_channel_listings.price
- line = checkout_with_item.lines.first()
- product = line.variant.product
- product.charge_taxes = False
- product.save(update_fields=["charge_taxes"])
-
discounts = None
checkout_info = fetch_checkout_info(checkout_with_item, [], discounts, manager)
lines, _ = fetch_checkout_lines(checkout_with_item)
@@ -1297,7 +1357,7 @@ def test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes(
@pytest.mark.vcr
@pytest.mark.parametrize(
- "expected_net, expected_gross, taxes_in_prices",
+ "expected_net, expected_gross, prices_entered_with_tax",
[
("24.39", "30.00", True),
("30.00", "36.90", False),
@@ -1307,15 +1367,13 @@ def test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes(
def test_calculate_checkout_total_voucher_on_shipping(
expected_net,
expected_gross,
- taxes_in_prices,
+ prices_entered_with_tax,
checkout_with_item,
voucher_free_shipping,
stock,
monkeypatch,
- site_settings,
ship_to_pl_address,
shipping_zone,
- address,
plugin_configuration,
):
"""Ensure that when the free shipping voucher is applied the total price
@@ -1327,11 +1385,13 @@ def test_calculate_checkout_total_voucher_on_shipping(
lambda _: {"PC040156": "desc"},
)
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
-
channel = checkout_with_item.channel
+
+ tax_configuration = channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
shipping_method = shipping_zone.shipping_methods.get()
shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
@@ -1362,9 +1422,7 @@ def test_calculate_checkout_total_voucher_on_shipping(
def test_calculate_checkout_total_not_charged_product_and_shipping_with_0_price(
checkout_with_item,
shipping_zone,
- address,
ship_to_pl_address,
- site_settings,
monkeypatch,
plugin_configuration,
):
@@ -1379,11 +1437,14 @@ def test_calculate_checkout_total_not_charged_product_and_shipping_with_0_price(
manager = get_plugins_manager()
checkout_with_item.shipping_address = ship_to_pl_address
checkout_with_item.save()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
channel = checkout_with_item.channel
+
+ tax_configuration = channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.charge_taxes = False
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
shipping_method = shipping_zone.shipping_methods.get()
shipping_channel_listing = shipping_method.channel_listings.get(channel=channel)
shipping_channel_listing.price = Money(0, "USD")
@@ -1395,9 +1456,8 @@ def test_calculate_checkout_total_not_charged_product_and_shipping_with_0_price(
line = checkout_with_item.lines.first()
variant = line.variant
product = variant.product
- product.charge_taxes = False
product.metadata = {}
- manager.assign_tax_code_to_object_meta(product.product_type, "PS081282")
+ manager.assign_tax_code_to_object_meta(product.product_type.tax_class, "PS081282")
product.save()
product.product_type.save()
@@ -1455,7 +1515,7 @@ def test_calculate_checkout_shipping(
@pytest.mark.vcr
@pytest.mark.parametrize(
- "with_discount, expected_net, expected_gross, taxes_in_prices",
+ "with_discount, expected_net, expected_gross, prices_entered_with_tax",
[
(True, "25.00", "30.75", False),
(False, "40.65", "50.00", True),
@@ -1468,12 +1528,11 @@ def test_calculate_checkout_subtotal(
with_discount,
expected_net,
expected_gross,
- taxes_in_prices,
+ prices_entered_with_tax,
discount_info,
checkout_with_item,
stock,
monkeypatch,
- site_settings,
ship_to_pl_address,
shipping_zone,
address,
@@ -1486,9 +1545,12 @@ def test_calculate_checkout_subtotal(
lambda _: {"PC040156": "desc"},
)
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
+
+ tax_configuration = checkout_with_item.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_with_item.shipping_address = ship_to_pl_address
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
@@ -1513,7 +1575,6 @@ def test_calculate_checkout_subtotal_for_product_without_tax(
checkout,
stock,
monkeypatch,
- site_settings,
ship_to_pl_address,
shipping_zone,
address,
@@ -1530,9 +1591,12 @@ def test_calculate_checkout_subtotal_for_product_without_tax(
lambda _: {"PC040156": "desc"},
)
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.charge_taxes = False
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout.shipping_address = ship_to_pl_address
checkout.shipping_method = shipping_zone.shipping_methods.get()
@@ -1564,15 +1628,14 @@ def test_calculate_checkout_subtotal_for_product_without_tax(
@pytest.mark.vcr
[email protected]("taxes_in_prices", [True, False])
[email protected]("prices_entered_with_tax", [True, False])
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
def test_calculate_checkout_subtotal_voucher_on_entire_order(
- taxes_in_prices,
+ prices_entered_with_tax,
checkout_with_item,
voucher_percentage,
stock,
monkeypatch,
- site_settings,
ship_to_pl_address,
shipping_zone,
address,
@@ -1588,11 +1651,13 @@ def test_calculate_checkout_subtotal_voucher_on_entire_order(
lambda _: {"PC040156": "desc"},
)
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
-
channel = checkout_with_item.channel
+
+ tax_configuration = channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
channel_listing = variant.channel_listings.get(channel=channel)
net = (
variant.get_price(
@@ -1623,7 +1688,7 @@ def test_calculate_checkout_subtotal_voucher_on_entire_order(
@pytest.mark.vcr
@pytest.mark.parametrize(
- "expected_net, expected_gross, taxes_in_prices",
+ "expected_net, expected_gross, prices_entered_with_tax",
[
("24.39", "30.00", True),
("30.00", "36.90", False),
@@ -1633,12 +1698,11 @@ def test_calculate_checkout_subtotal_voucher_on_entire_order(
def test_calculate_checkout_subtotal_voucher_on_shipping(
expected_net,
expected_gross,
- taxes_in_prices,
+ prices_entered_with_tax,
checkout_with_item,
voucher_free_shipping,
stock,
monkeypatch,
- site_settings,
ship_to_pl_address,
shipping_zone,
address,
@@ -1653,11 +1717,13 @@ def test_calculate_checkout_subtotal_voucher_on_shipping(
lambda _: {"PC040156": "desc"},
)
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
-
channel = checkout_with_item.channel
+
+ tax_configuration = channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
shipping_method = shipping_zone.shipping_methods.get()
shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
@@ -1693,8 +1759,7 @@ def test_calculate_order_shipping(
order = order_line.order
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
site_settings.company_address = address
@@ -1715,8 +1780,7 @@ def test_calculate_order_total(
order = order_line.order
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
site_settings.company_address = address
@@ -1757,8 +1821,7 @@ def test_calculate_order_shipping_entire_order_voucher(
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.total = total
order.undiscounted_total = total
order.voucher = voucher
@@ -1812,8 +1875,7 @@ def test_calculate_order_shipping_free_shipping_voucher(
)
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.total = total
order.undiscounted_total = total
order.voucher = voucher_free_shipping
@@ -1867,8 +1929,7 @@ def test_calculate_order_shipping_voucher_on_shipping(
)
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.total = total
order.undiscounted_total = total
order.voucher = voucher_shipping_type
@@ -1895,8 +1956,7 @@ def test_calculate_order_shipping_zero_shipping_amount(
order = order_line.order
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
channel_listing = method.channel_listings.get(channel=order.channel)
@@ -1920,8 +1980,7 @@ def test_calculate_order_shipping_no_channel_listing(
order = order_line.order
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
method.channel_listings.all().delete()
@@ -1984,8 +2043,7 @@ def test_calculate_order_line_unit(
order = order_line.order
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
site_settings.company_address = address_usa
@@ -2028,8 +2086,7 @@ def test_calculate_order_line_unit_in_JPY(
order = order_line_JPY.order
method = shipping_zone_JPY.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
site_settings.company_address = address
@@ -2072,8 +2129,7 @@ def test_calculate_order_line_unit_with_discount(
order = order_line.order
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
site_settings.company_address = address_usa
@@ -2100,8 +2156,6 @@ def test_calculate_checkout_line_unit_price(
charge_taxes,
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
):
@@ -2110,9 +2164,6 @@ def test_calculate_checkout_line_unit_price(
lines, _ = fetch_checkout_lines(checkout_with_item)
checkout_line = lines[0]
- product = checkout_line.variant.product
- product.charge_taxes = charge_taxes
- product.save(update_fields=["charge_taxes"])
manager = get_plugins_manager()
@@ -2122,9 +2173,11 @@ def test_calculate_checkout_line_unit_price(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.charge_taxes = charge_taxes
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
line_price = manager.calculate_checkout_line_unit_price(
@@ -2151,9 +2204,7 @@ def test_calculate_checkout_line_unit_price(
def test_calculate_checkout_line_unit_price_in_JPY(
checkout_JPY_with_item,
shipping_zone_JPY,
- site_settings,
ship_to_pl_address,
- address,
channel_JPY,
plugin_configuration,
):
@@ -2171,9 +2222,10 @@ def test_calculate_checkout_line_unit_price_in_JPY(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout, lines, [], manager)
line_price = manager.calculate_checkout_line_unit_price(
@@ -2191,8 +2243,6 @@ def test_calculate_checkout_line_unit_price_in_JPY(
def test_calculate_checkout_line_unit_price_with_variant_on_sale(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
discount_info,
@@ -2212,9 +2262,10 @@ def test_calculate_checkout_line_unit_price_with_variant_on_sale(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -2239,8 +2290,6 @@ def test_calculate_checkout_line_unit_price_with_variant_on_sale(
def test_calculate_checkout_line_unit_price_with_voucher(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
voucher,
@@ -2273,9 +2322,10 @@ def test_calculate_checkout_line_unit_price_with_voucher(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -2300,8 +2350,6 @@ def test_calculate_checkout_line_unit_price_with_voucher(
def test_calculate_checkout_line_unit_price_with_voucher_once_per_order(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
voucher,
@@ -2335,9 +2383,10 @@ def test_calculate_checkout_line_unit_price_with_voucher_once_per_order(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -2363,8 +2412,6 @@ def test_calculate_checkout_line_unit_price_with_voucher_once_per_order(
def test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
voucher,
@@ -2398,9 +2445,10 @@ def test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher(
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -2425,8 +2473,6 @@ def test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher(
def test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher_only_once(
checkout_with_item,
shipping_zone,
- site_settings,
- address_usa,
address,
plugin_configuration,
voucher,
@@ -2461,9 +2507,10 @@ def test_calculate_checkout_line_unit_price_with_variant_on_sale_and_voucher_onl
checkout.shipping_method = method
checkout.save()
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = True
- site_settings.save()
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
currency = checkout_info.checkout.currency
@@ -2612,9 +2659,7 @@ def test_checkout_needs_new_fetch(checkout_with_item, address, shipping_method):
manager = get_plugins_manager()
lines, _ = fetch_checkout_lines(checkout_with_item)
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_data = generate_request_data_from_checkout(
- checkout_info, lines, config, tax_included=True
- )
+ checkout_data = generate_request_data_from_checkout(checkout_info, lines, config)
assert taxes_need_new_fetch(checkout_data, None)
@@ -2647,9 +2692,7 @@ def test_generate_request_data_from_checkout_for_cc(
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
# when
- request_data = generate_request_data_from_checkout(
- checkout_info, lines, config, tax_included=True
- )
+ request_data = generate_request_data_from_checkout(checkout_info, lines, config)
# then
expected_address_data = address_other_country.as_data()
@@ -2697,9 +2740,7 @@ def test_generate_request_data_from_checkout_for_cc_and_single_location(
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
# when
- request_data = generate_request_data_from_checkout(
- checkout_info, lines, config, tax_included=True
- )
+ request_data = generate_request_data_from_checkout(checkout_info, lines, config)
# then
addresses = request_data["createTransactionModel"]["addresses"]
@@ -2753,9 +2794,7 @@ def test_get_checkout_tax_data_with_single_point(
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
# when
- response = get_checkout_tax_data(
- checkout_info, lines, tax_included=True, discounts=[], config=config
- )
+ response = get_checkout_tax_data(checkout_info, lines, discounts=[], config=config)
# then
assert len(response.get("addresses", [])) == 1
@@ -2776,9 +2815,7 @@ def test_taxes_need_new_fetch_uses_cached_data(checkout_with_item, address):
manager = get_plugins_manager()
lines, _ = fetch_checkout_lines(checkout_with_item)
checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_data = generate_request_data_from_checkout(
- checkout_info, lines, config, tax_included=True
- )
+ checkout_data = generate_request_data_from_checkout(checkout_info, lines, config)
assert not taxes_need_new_fetch(checkout_data, (checkout_data, None))
@@ -2821,6 +2858,7 @@ def test_get_checkout_line_tax_rate(
billing_address=None,
channel=checkout_with_item.channel,
user=None,
+ tax_configuration=checkout_with_item.channel.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
@@ -2850,6 +2888,7 @@ def test_get_checkout_line_tax_rate_for_product_with_charge_taxes_set_to_false(
plugin_configuration,
shipping_zone,
site_settings,
+ tax_class_zero_rates,
):
# given
site_settings.company_address = address
@@ -2863,6 +2902,11 @@ def test_get_checkout_line_tax_rate_for_product_with_charge_taxes_set_to_false(
manager = get_plugins_manager()
+ tax_configuration = checkout_with_item.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = False
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
checkout_with_item.shipping_address = address
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
checkout_with_item.save(update_fields=["shipping_address", "shipping_method"])
@@ -2880,14 +2924,15 @@ def test_get_checkout_line_tax_rate_for_product_with_charge_taxes_set_to_false(
billing_address=None,
channel=checkout_with_item.channel,
user=None,
+ tax_configuration=checkout_with_item.channel.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
lines, _ = fetch_checkout_lines(checkout_with_item)
checkout_line_info = lines[0]
product = checkout_line_info.product
- product.charge_taxes = False
- product.save(update_fields=["charge_taxes"])
+ product.tax_class = tax_class_zero_rates
+ product.save(update_fields=["tax_class"])
# when
tax_rate = manager.get_checkout_line_tax_rate(
@@ -2913,6 +2958,7 @@ def test_get_checkout_line_tax_rate_for_product_type_with_non_taxable_product(
shipping_zone,
site_settings,
product_with_two_variants,
+ tax_class_zero_rates,
):
# given
site_settings.company_address = address
@@ -2927,11 +2973,10 @@ def test_get_checkout_line_tax_rate_for_product_type_with_non_taxable_product(
manager = get_plugins_manager()
product_type = ProductType.objects.create(
- name="non-taxable", kind=ProductTypeKind.NORMAL
+ name="non-taxable", kind=ProductTypeKind.NORMAL, tax_class=tax_class_zero_rates
)
product2 = product_with_two_variants
product2.product_type = product_type
- manager.assign_tax_code_to_object_meta(product_type, "NT")
product2.save()
product_type.save()
@@ -2954,6 +2999,7 @@ def test_get_checkout_line_tax_rate_for_product_type_with_non_taxable_product(
billing_address=None,
channel=checkout_with_item.channel,
user=None,
+ tax_configuration=checkout_with_item.channel.tax_configuration,
valid_pick_up_points=[],
all_shipping_methods=[],
)
@@ -3074,8 +3120,7 @@ def test_get_order_line_tax_rate(
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
# when
@@ -3136,8 +3181,7 @@ def test_get_order_line_tax_rate_error_in_response(
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
# when
@@ -3325,8 +3369,7 @@ def test_get_order_shipping_tax_rate(
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
# when
@@ -3371,8 +3414,7 @@ def test_get_order_shipping_tax_rate_error_in_response(
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
# when
@@ -3399,8 +3441,7 @@ def test_get_order_shipping_tax_rate_skip_plugin(
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
+ order_set_shipping_method(order, method)
order.save()
# when
@@ -3580,8 +3621,6 @@ def test_order_created(
"from_country": conf["from_country"],
"from_country_area": conf["from_country_area"],
"shipping_tax_code": conf["shipping_tax_code"],
- "override_global_tax": conf["override_global_tax"],
- "include_taxes_in_prices": conf["include_taxes_in_prices"],
}
api_post_request_task_mock.assert_called_once_with(
@@ -3666,13 +3705,13 @@ def test_skip_disabled_plugin(settings, plugin_configuration):
def test_get_tax_code_from_object_meta(product, settings, plugin_configuration):
- product.store_value_in_metadata(
+ product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "KEY", META_DESCRIPTION_KEY: "DESC"}
)
plugin_configuration(username=None, password=None)
settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
manager = get_plugins_manager()
- tax_type = manager.get_tax_code_from_object_meta(product)
+ tax_type = manager.get_tax_code_from_object_meta(product.tax_class)
assert isinstance(tax_type, TaxType)
assert tax_type.code == "KEY"
@@ -3736,11 +3775,13 @@ def test_api_post_request_handles_json_errors(product, monkeypatch, avatax_confi
def test_get_order_request_data_checks_when_taxes_are_included_to_price(
- order_with_lines, shipping_zone, site_settings, address
+ order_with_lines, shipping_zone
):
- site_settings.include_taxes_in_prices = True
- site_settings.company_address = address
- site_settings.save()
+ tax_configuration = order_with_lines.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
method = shipping_zone.shipping_methods.get()
line = order_with_lines.lines.first()
line.unit_price_gross_amount = line.unit_price_net_amount
@@ -3761,7 +3802,7 @@ def test_get_order_request_data_checks_when_taxes_are_included_to_price(
from_postal_code="53-601",
from_country="PL",
)
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
lines_data = request_data["createTransactionModel"]["lines"]
assert all([line for line in lines_data if line["taxIncluded"] is True])
@@ -3801,7 +3842,7 @@ def test_get_order_request_data_uses_correct_address_for_cc(
)
# when
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
# then
expected_address_data = address_other_country.as_data()
@@ -3852,7 +3893,7 @@ def test_get_order_request_data_uses_correct_address_for_cc_with_single_location
from_country=address_data.get("country"),
)
# when
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
# then
addresses = request_data["createTransactionModel"]["addresses"]
@@ -3870,15 +3911,16 @@ def test_get_order_request_data_uses_correct_address_for_cc_with_single_location
def test_get_order_request_data_for_line_with_already_included_taxes_in_price(
- order_with_lines, shipping_zone, site_settings, address_usa
+ order_with_lines, shipping_zone
):
"""Ensure that when line already has calculated taxes, the `taxIncluded` flag
is set based on site settings, and we are sending the base price of line."""
# given
- include_taxes_in_prices = False
- site_settings.company_address = address_usa
- site_settings.include_taxes_in_prices = include_taxes_in_prices
- site_settings.save()
+ prices_entered_with_tax = False
+ tax_configuration = order_with_lines.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
method = shipping_zone.shipping_methods.get()
line_1, line_2 = order_with_lines.lines.all()
@@ -3904,9 +3946,7 @@ def test_get_order_request_data_for_line_with_already_included_taxes_in_price(
)
# when
- request_data = get_order_request_data(
- order_with_lines, config, tax_included=include_taxes_in_prices
- )
+ request_data = get_order_request_data(order_with_lines, config)
# then
lines_data = request_data["createTransactionModel"]["lines"]
@@ -3915,21 +3955,24 @@ def test_get_order_request_data_for_line_with_already_included_taxes_in_price(
assert lines_1_data["amount"] == str(
line_1.base_unit_price.amount * line_1.quantity
)
- assert lines_1_data["taxIncluded"] == include_taxes_in_prices
+ assert lines_1_data["taxIncluded"] == prices_entered_with_tax
lines_2_data = lines_data[1]
assert lines_2_data["itemCode"] == line_2.product_sku
assert lines_2_data["amount"] == str(
line_2.base_unit_price.amount * line_2.quantity
)
- assert lines_2_data["taxIncluded"] == include_taxes_in_prices
+ assert lines_2_data["taxIncluded"] == prices_entered_with_tax
def test_get_order_request_data_confirmed_order_with_voucher(
- order_with_lines, shipping_zone, site_settings, address, voucher
+ order_with_lines, shipping_zone, voucher
):
- site_settings.company_address = address
- site_settings.save()
+ tax_configuration = order_with_lines.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
method = shipping_zone.shipping_methods.get()
line = order_with_lines.lines.first()
line.unit_price_gross_amount = line.unit_price_net_amount
@@ -3946,14 +3989,17 @@ def test_get_order_request_data_confirmed_order_with_voucher(
order_with_lines.status = OrderStatus.UNFULFILLED
order_with_lines.shipping_address = order_with_lines.billing_address.get_copy()
- order_with_lines.shipping_method_name = method.name
- order_with_lines.shipping_method = method
+ order_set_shipping_method(order_with_lines, method)
order_with_lines.save(
update_fields=[
"status",
"shipping_address",
"shipping_method_name",
"shipping_method",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_metadata",
+ "shipping_tax_class_private_metadata",
]
)
@@ -3967,7 +4013,7 @@ def test_get_order_request_data_confirmed_order_with_voucher(
from_postal_code="53-601",
from_country="PL",
)
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
lines_data = request_data["createTransactionModel"]["lines"]
# extra one from shipping data
@@ -3979,11 +4025,13 @@ def test_get_order_request_data_confirmed_order_with_voucher(
def test_get_order_request_data_confirmed_order_with_sale(
- order_with_lines, shipping_zone, site_settings, address, sale
+ order_with_lines, shipping_zone, sale
):
- site_settings.include_taxes_in_prices = True
- site_settings.company_address = address
- site_settings.save()
+ tax_configuration = order_with_lines.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
method = shipping_zone.shipping_methods.get()
line = order_with_lines.lines.first()
line.unit_price_gross_amount = line.unit_price_net_amount
@@ -3993,14 +4041,17 @@ def test_get_order_request_data_confirmed_order_with_sale(
order_with_lines.status = OrderStatus.UNFULFILLED
order_with_lines.shipping_address = order_with_lines.billing_address.get_copy()
- order_with_lines.shipping_method_name = method.name
- order_with_lines.shipping_method = method
+ order_set_shipping_method(order_with_lines, method)
order_with_lines.save(
update_fields=[
"status",
"shipping_address",
"shipping_method_name",
"shipping_method",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_metadata",
+ "shipping_tax_class_private_metadata",
]
)
@@ -4014,7 +4065,7 @@ def test_get_order_request_data_confirmed_order_with_sale(
from_postal_code="53-601",
from_country="PL",
)
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
lines_data = request_data["createTransactionModel"]["lines"]
# extra one from shipping data
@@ -4022,12 +4073,14 @@ def test_get_order_request_data_confirmed_order_with_sale(
def test_get_order_request_data_draft_order_with_voucher(
- order_with_lines, shipping_zone, site_settings, address, voucher
+ order_with_lines, shipping_zone, voucher
):
# given
- site_settings.include_taxes_in_prices = True
- site_settings.company_address = address
- site_settings.save()
+ tax_configuration = order_with_lines.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
method = shipping_zone.shipping_methods.get()
line = order_with_lines.lines.first()
line.base_unit_price_amount = line.unit_price_net_amount
@@ -4045,14 +4098,17 @@ def test_get_order_request_data_draft_order_with_voucher(
order_with_lines.status = OrderStatus.DRAFT
order_with_lines.shipping_address = order_with_lines.billing_address.get_copy()
- order_with_lines.shipping_method_name = method.name
- order_with_lines.shipping_method = method
+ order_set_shipping_method(order_with_lines, method)
order_with_lines.save(
update_fields=[
"status",
"shipping_address",
"shipping_method_name",
"shipping_method",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_metadata",
+ "shipping_tax_class_private_metadata",
]
)
@@ -4068,7 +4124,7 @@ def test_get_order_request_data_draft_order_with_voucher(
)
# when
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
# then
lines_data = request_data["createTransactionModel"]["lines"]
@@ -4083,12 +4139,14 @@ def test_get_order_request_data_draft_order_with_voucher(
def test_get_order_request_data_draft_order_with_shipping_voucher(
- order_with_lines, shipping_zone, site_settings, address, voucher_free_shipping
+ order_with_lines, shipping_zone, voucher_free_shipping
):
# given
- site_settings.include_taxes_in_prices = True
- site_settings.company_address = address
- site_settings.save()
+ tax_configuration = order_with_lines.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
method = shipping_zone.shipping_methods.get()
method_listing = method.channel_listings.get(channel=order_with_lines.channel)
line = order_with_lines.lines.first()
@@ -4107,8 +4165,7 @@ def test_get_order_request_data_draft_order_with_shipping_voucher(
order_with_lines.status = OrderStatus.DRAFT
order_with_lines.shipping_address = order_with_lines.billing_address.get_copy()
- order_with_lines.shipping_method_name = method.name
- order_with_lines.shipping_method = method
+ order_set_shipping_method(order_with_lines, method)
order_with_lines.base_shipping_price = zero_money(order_with_lines.currency)
order_with_lines.voucher = voucher_free_shipping
order_with_lines.save(
@@ -4119,6 +4176,10 @@ def test_get_order_request_data_draft_order_with_shipping_voucher(
"shipping_address",
"shipping_method_name",
"shipping_method",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_metadata",
+ "shipping_tax_class_private_metadata",
]
)
@@ -4134,7 +4195,7 @@ def test_get_order_request_data_draft_order_with_shipping_voucher(
)
# when
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
# then
lines_data = request_data["createTransactionModel"]["lines"]
@@ -4146,13 +4207,16 @@ def test_get_order_request_data_draft_order_with_shipping_voucher(
def test_get_order_request_data_draft_order_shipping_voucher_amount_too_high(
- order_with_lines, shipping_zone, site_settings, address, voucher_free_shipping
+ order_with_lines, shipping_zone, voucher_free_shipping
):
"""Ensure that when order has shipping voucher with price bigger than shipping
price, the shipping price will not be negative."""
# given
- site_settings.company_address = address
- site_settings.save()
+ tax_configuration = order_with_lines.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
method = shipping_zone.shipping_methods.get()
method_listing = method.channel_listings.get(channel=order_with_lines.channel)
line = order_with_lines.lines.first()
@@ -4171,8 +4235,7 @@ def test_get_order_request_data_draft_order_shipping_voucher_amount_too_high(
order_with_lines.status = OrderStatus.DRAFT
order_with_lines.shipping_address = order_with_lines.billing_address.get_copy()
- order_with_lines.shipping_method_name = method.name
- order_with_lines.shipping_method = method
+ order_set_shipping_method(order_with_lines, method)
order_with_lines.base_shipping_price = zero_money(order_with_lines.currency)
order_with_lines.voucher = voucher_free_shipping
order_with_lines.save(
@@ -4183,6 +4246,10 @@ def test_get_order_request_data_draft_order_shipping_voucher_amount_too_high(
"shipping_address",
"shipping_method_name",
"shipping_method",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_metadata",
+ "shipping_tax_class_private_metadata",
]
)
@@ -4198,7 +4265,7 @@ def test_get_order_request_data_draft_order_shipping_voucher_amount_too_high(
)
# when
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
# then
lines_data = request_data["createTransactionModel"]["lines"]
@@ -4210,12 +4277,14 @@ def test_get_order_request_data_draft_order_shipping_voucher_amount_too_high(
def test_get_order_request_data_draft_order_with_sale(
- order_with_lines, shipping_zone, site_settings, address, sale
+ order_with_lines, shipping_zone, sale
):
# given
- site_settings.include_taxes_in_prices = True
- site_settings.company_address = address
- site_settings.save()
+ tax_configuration = order_with_lines.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = True
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
+
method = shipping_zone.shipping_methods.get()
line = order_with_lines.lines.first()
line.base_unit_price_amount = line.unit_price_net_amount
@@ -4226,14 +4295,17 @@ def test_get_order_request_data_draft_order_with_sale(
order_with_lines.status = OrderStatus.DRAFT
order_with_lines.shipping_address = order_with_lines.billing_address.get_copy()
- order_with_lines.shipping_method_name = method.name
- order_with_lines.shipping_method = method
+ order_set_shipping_method(order_with_lines, method)
order_with_lines.save(
update_fields=[
"status",
"shipping_address",
"shipping_method_name",
"shipping_method",
+ "shipping_tax_class",
+ "shipping_tax_class_name",
+ "shipping_tax_class_metadata",
+ "shipping_tax_class_private_metadata",
]
)
@@ -4249,7 +4321,7 @@ def test_get_order_request_data_draft_order_with_sale(
)
# when
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
# then
lines_data = request_data["createTransactionModel"]["lines"]
@@ -4273,10 +4345,10 @@ def test_get_order_tax_data(
get_cached_response_or_fetch_mock.return_value = return_value
# when
- response = get_order_tax_data(order, conf, tax_included=True)
+ response = get_order_tax_data(order, conf)
# then
- get_order_request_data_mock.assert_called_once_with(order, conf, True)
+ get_order_request_data_mock.assert_called_once_with(order, conf)
assert response == return_value
@@ -4315,7 +4387,7 @@ def test_get_order_tax_data_with_single_location(
)
# when
- response = get_order_tax_data(order, config, tax_included=True)
+ response = get_order_tax_data(order, config)
# then
assert len(response.get("addresses", [])) == 1
@@ -4329,7 +4401,7 @@ def test_get_order_tax_data_empty_data(
conf = plugin_configuration()
# when
- response = get_order_tax_data(order, conf, tax_included=True)
+ response = get_order_tax_data(order, conf)
# then
assert response is None
@@ -4351,7 +4423,7 @@ def test_get_order_tax_data_raised_error(
# when
with pytest.raises(TaxError) as e:
- get_order_tax_data(order, conf, tax_included=True)
+ get_order_tax_data(order, conf)
# then
assert e._excinfo[1].args[0] == return_value["error"]
@@ -4473,7 +4545,69 @@ def test_validate_checkout_click_and_collect(
assert response is True
-def test_get_checkout_lines_data_sets_different_tax_code_for_zero_amount(
+def test_generate_request_data_from_checkout_lines_uses_tax_code_from_product_tax_class(
+ settings, channel_USD, plugin_configuration, checkout_with_item, avatax_config
+):
+ # given
+ settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
+ plugin_configuration(channel=channel_USD)
+
+ line = checkout_with_item.lines.first()
+ tax_class = line.variant.product.tax_class
+ tax_code = "banana"
+ tax_class.store_value_in_metadata(
+ {META_CODE_KEY: tax_code, META_DESCRIPTION_KEY: "tax_description"}
+ )
+ tax_class.save()
+
+ lines, _ = fetch_checkout_lines(checkout_with_item)
+ checkout_info = fetch_checkout_info(
+ checkout_with_item, lines, [], get_plugins_manager()
+ )
+
+ config = avatax_config
+
+ # when
+ lines_data = generate_request_data_from_checkout_lines(checkout_info, lines, config)
+
+ # then
+ assert lines_data[0]["taxCode"] == tax_code
+
+
+def test_generate_request_data_from_checkout_lines_uses_tax_code_from_product_type_tax_class( # noqa: E501
+ settings, channel_USD, plugin_configuration, checkout_with_item, avatax_config
+):
+ # given
+ settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
+ plugin_configuration(channel=channel_USD)
+
+ line = checkout_with_item.lines.first()
+ product = line.variant.product
+ product.tax_class = None
+ product.save()
+
+ tax_class = product.product_type.tax_class
+ tax_code = "banana"
+ tax_class.store_value_in_metadata(
+ {META_CODE_KEY: tax_code, META_DESCRIPTION_KEY: "tax_description"}
+ )
+ tax_class.save()
+
+ lines, _ = fetch_checkout_lines(checkout_with_item)
+ checkout_info = fetch_checkout_info(
+ checkout_with_item, lines, [], get_plugins_manager()
+ )
+
+ config = avatax_config
+
+ # when
+ lines_data = generate_request_data_from_checkout_lines(checkout_info, lines, config)
+
+ # then
+ assert lines_data[0]["taxCode"] == tax_code
+
+
+def test_generate_request_data_from_checkout_lines_sets_different_tax_code_for_zero_amount( # noqa: E501
settings, channel_USD, plugin_configuration, checkout_with_item, avatax_config
):
# given
@@ -4483,10 +4617,10 @@ def test_get_checkout_lines_data_sets_different_tax_code_for_zero_amount(
line = checkout_with_item.lines.first()
variant = line.variant
variant.channel_listings.all().update(price_amount=Decimal("0"))
- variant.product.store_value_in_metadata(
+ variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
- variant.product.save()
+ variant.product.tax_class.save()
lines, _ = fetch_checkout_lines(checkout_with_item)
checkout_info = fetch_checkout_info(
@@ -4496,16 +4630,14 @@ def test_get_checkout_lines_data_sets_different_tax_code_for_zero_amount(
config = avatax_config
# when
- lines_data = get_checkout_lines_data(
- checkout_info, lines, config, tax_included=True
- )
+ lines_data = generate_request_data_from_checkout_lines(checkout_info, lines, config)
# then
assert lines_data[0]["amount"] == "0.00"
assert lines_data[0]["taxCode"] == DEFAULT_TAX_CODE
-def test_get_checkout_lines_data_sets_different_tax_code_only_for_zero_amount(
+def test_generate_request_data_from_checkout_lines_sets_different_tax_code_only_for_zero_amount( # noqa: E501
settings, channel_USD, plugin_configuration, checkout_with_item, avatax_config
):
# given
@@ -4518,10 +4650,10 @@ def test_get_checkout_lines_data_sets_different_tax_code_only_for_zero_amount(
variant = line.variant
variant.channel_listings.all().update(price_amount=Decimal("11"))
- variant.product.store_value_in_metadata(
+ variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
- variant.product.save()
+ variant.product.tax_class.save()
lines, _ = fetch_checkout_lines(checkout_with_item)
checkout_info = fetch_checkout_info(
@@ -4531,16 +4663,14 @@ def test_get_checkout_lines_data_sets_different_tax_code_only_for_zero_amount(
config = avatax_config
# when
- lines_data = get_checkout_lines_data(
- checkout_info, lines, config, tax_included=True
- )
+ lines_data = generate_request_data_from_checkout_lines(checkout_info, lines, config)
# then
assert lines_data[0]["amount"] == "11.00"
assert lines_data[0]["taxCode"] == "taxcode"
-def test_get_checkout_lines_data_with_collection_point(
+def test_generate_request_data_from_checkout_lines_with_collection_point(
settings,
channel_USD,
plugin_configuration,
@@ -4558,10 +4688,10 @@ def test_get_checkout_lines_data_with_collection_point(
variant = line.variant
variant.channel_listings.all().update(price_amount=Decimal("11"))
- variant.product.store_value_in_metadata(
+ variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
- variant.product.save()
+ variant.product.tax_class.save()
checkout_with_item.shipping_method = None
checkout_with_item.collection_point = warehouse
@@ -4574,15 +4704,13 @@ def test_get_checkout_lines_data_with_collection_point(
config = avatax_config
# when
- lines_data = get_checkout_lines_data(
- checkout_info, lines, config, tax_included=True
- )
+ lines_data = generate_request_data_from_checkout_lines(checkout_info, lines, config)
# then
assert len(lines_data) == checkout_with_item.lines.count()
-def test_get_checkout_lines_data_with_shipping_method(
+def test_generate_request_data_from_checkout_lines_with_shipping_method(
settings,
channel_USD,
plugin_configuration,
@@ -4600,10 +4728,10 @@ def test_get_checkout_lines_data_with_shipping_method(
variant = line.variant
variant.channel_listings.all().update(price_amount=Decimal("11"))
- variant.product.store_value_in_metadata(
+ variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
- variant.product.save()
+ variant.product.tax_class.save()
checkout_with_item.shipping_method = shipping_method
checkout_with_item.collection_point = None
@@ -4616,15 +4744,83 @@ def test_get_checkout_lines_data_with_shipping_method(
config = avatax_config
# when
- lines_data = get_checkout_lines_data(
- checkout_info, lines, config, tax_included=True
- )
+ lines_data = generate_request_data_from_checkout_lines(checkout_info, lines, config)
# then
assert len(lines_data) == checkout_with_item.lines.count() + 1
assert lines_data[-1]["itemCode"] == "Shipping"
+def test_get_order_lines_data_gets_tax_code_from_product_tax_class(
+ settings, channel_USD, plugin_configuration, order_with_lines
+):
+ # given
+ settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
+ plugin_configuration(channel=channel_USD)
+
+ line = order_with_lines.lines.first()
+ tax_class = line.variant.product.tax_class
+ tax_code = "banana"
+ tax_class.store_value_in_metadata(
+ {META_CODE_KEY: tax_code, META_DESCRIPTION_KEY: "tax_description"}
+ )
+ tax_class.save()
+
+ config = AvataxConfiguration(
+ username_or_account="test",
+ password_or_license="test",
+ use_sandbox=False,
+ from_street_address="Tęczowa 7",
+ from_city="WROCŁAW",
+ from_country_area="",
+ from_postal_code="53-601",
+ from_country="PL",
+ )
+
+ # when
+ lines_data = get_order_lines_data(order_with_lines, config, discounted=False)
+
+ # then
+ assert lines_data[0]["taxCode"] == tax_code
+
+
+def test_get_order_lines_data_gets_tax_code_from_product_type_tax_class(
+ settings, channel_USD, plugin_configuration, order_with_lines
+):
+ # given
+ settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
+ plugin_configuration(channel=channel_USD)
+
+ line = order_with_lines.lines.first()
+ product = line.variant.product
+ product.tax_class = None
+ product.save()
+
+ tax_class = product.product_type.tax_class
+ tax_code = "banana"
+ tax_class.store_value_in_metadata(
+ {META_CODE_KEY: tax_code, META_DESCRIPTION_KEY: "tax_description"}
+ )
+ tax_class.save()
+
+ config = AvataxConfiguration(
+ username_or_account="test",
+ password_or_license="test",
+ use_sandbox=False,
+ from_street_address="Tęczowa 7",
+ from_city="WROCŁAW",
+ from_country_area="",
+ from_postal_code="53-601",
+ from_country="PL",
+ )
+
+ # when
+ lines_data = get_order_lines_data(order_with_lines, config, discounted=False)
+
+ # then
+ assert lines_data[0]["taxCode"] == tax_code
+
+
def test_get_order_lines_data_sets_different_tax_code_for_zero_amount(
settings, channel_USD, plugin_configuration, order_with_lines
):
@@ -4642,10 +4838,10 @@ def test_get_order_lines_data_sets_different_tax_code_for_zero_amount(
]
)
variant = line.variant
- variant.product.store_value_in_metadata(
+ variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
- variant.product.save()
+ variant.product.tax_class.save()
config = AvataxConfiguration(
username_or_account="test",
@@ -4659,9 +4855,7 @@ def test_get_order_lines_data_sets_different_tax_code_for_zero_amount(
)
# when
- lines_data = get_order_lines_data(
- order_with_lines, config, tax_included=True, discounted=False
- )
+ lines_data = get_order_lines_data(order_with_lines, config, discounted=False)
# then
assert lines_data[0]["amount"] == "0.000"
@@ -4686,10 +4880,10 @@ def test_get_order_lines_data_with_discounted(
]
)
variant = order_line.variant
- variant.product.store_value_in_metadata(
+ variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
- variant.product.save()
+ variant.product.tax_class.save()
config = AvataxConfiguration(
username_or_account="test",
@@ -4703,7 +4897,7 @@ def test_get_order_lines_data_with_discounted(
)
# when
- lines_data = get_order_lines_data(order, config, tax_included=True, discounted=True)
+ lines_data = get_order_lines_data(order, config, discounted=True)
# then
assert len(lines_data) == 1
@@ -4731,17 +4925,15 @@ def test_get_order_lines_data_sets_different_tax_code_only_for_zero_amount(
]
)
variant = line.variant
- variant.product.store_value_in_metadata(
+ variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
- variant.product.save()
+ variant.product.tax_class.save()
config = avatax_config
# when
- lines_data = get_order_lines_data(
- order_with_lines, config, tax_included=True, discounted=False
- )
+ lines_data = get_order_lines_data(order_with_lines, config, discounted=False)
# then
assert lines_data[0]["amount"] == "10.000"
@@ -4766,10 +4958,10 @@ def test_assign_tax_code_to_object_meta(
manager = get_plugins_manager()
# when
- manager.assign_tax_code_to_object_meta(product, tax_code)
+ manager.assign_tax_code_to_object_meta(product.tax_class, tax_code)
# then
- assert product.metadata == {
+ assert product.tax_class.metadata == {
META_CODE_KEY: tax_code,
META_DESCRIPTION_KEY: description,
}
@@ -4792,7 +4984,7 @@ def test_assign_tax_code_to_object_meta_none_as_tax_code(
manager = get_plugins_manager()
# when
- manager.assign_tax_code_to_object_meta(product, tax_code)
+ manager.assign_tax_code_to_object_meta(product.tax_class, tax_code)
# then
assert product.metadata == {}
@@ -4813,14 +5005,14 @@ def test_assign_tax_code_to_object_meta_no_obj_id_and_none_as_tax_code(
lambda _: {"standard": description},
)
- product = Product(name="A new product.")
+ tax_class = TaxClass(name="A new tax class.")
manager = get_plugins_manager()
# when
- manager.assign_tax_code_to_object_meta(product, tax_code)
+ manager.assign_tax_code_to_object_meta(tax_class, tax_code)
# then
- assert product.metadata == {}
+ assert tax_class.metadata == {}
def test_assign_tax_code_to_object_meta_no_obj_id(
@@ -4837,51 +5029,112 @@ def test_assign_tax_code_to_object_meta_no_obj_id(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
lambda _: {tax_code: description},
)
- product = Product(name="A new product.")
+ tax_class = TaxClass(name="A new product.")
manager = get_plugins_manager()
# when
- manager.assign_tax_code_to_object_meta(product, tax_code)
+ manager.assign_tax_code_to_object_meta(tax_class, tax_code)
# then
- assert product.metadata == {
+ assert tax_class.metadata == {
META_CODE_KEY: tax_code,
META_DESCRIPTION_KEY: description,
}
- "global_include_taxes_in_prices, override_global_tax, "
- "include_taxes_in_prices, expected_tax_included",
- [(True, False, False, True), (True, True, True, True), (True, True, False, False)],
-)
-@patch("saleor.plugins.avatax.plugin.api_post_request_task.delay")
-@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
-def test_plugin_tax_override_setting(
- api_post_request_task_mock,
- global_include_taxes_in_prices,
- override_global_tax,
- include_taxes_in_prices,
- expected_tax_included,
- site_settings,
- order_line,
- plugin_configuration,
+@patch("saleor.plugins.avatax.plugin.get_checkout_tax_data")
+def test_calculate_checkout_shipping_validates_checkout(
+ mocked_func, settings, channel_USD, plugin_configuration, checkout_with_item
):
# given
- site_settings.include_taxes_in_prices = global_include_taxes_in_prices
- site_settings.save()
+ settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
+ plugin_configuration(channel=channel_USD)
+ manager = get_plugins_manager()
+ checkout = checkout_with_item
+ lines, _ = fetch_checkout_lines(checkout)
+
+ checkout.shipping_method = None
+ checkout.save(update_fields=["shipping_method"])
+
+ for line in lines:
+ line.product_type.is_shipping_required = True
+ line.product_type.save()
+
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+
+ # when
+ manager.calculate_checkout_shipping(
+ checkout_info,
+ lines,
+ checkout.shipping_address,
+ discounts=[],
+ )
+
+ # then
+ assert not mocked_func.called
+
+
+@patch("saleor.plugins.avatax.plugin.get_checkout_tax_data")
+def test_calculate_checkout_line_total_validates_checkout(
+ mocked_func, settings, channel_USD, plugin_configuration, checkout_with_item
+):
+ # given
+ settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
+ plugin_configuration(channel=channel_USD)
+ manager = get_plugins_manager()
+ checkout = checkout_with_item
+ lines, _ = fetch_checkout_lines(checkout)
+
+ checkout.shipping_method = None
+ checkout.save(update_fields=["shipping_method"])
+
+ for line in lines:
+ line.product_type.is_shipping_required = True
+ line.product_type.save()
- plugin_configuration(
- override_global_tax=override_global_tax,
- include_taxes_in_prices=include_taxes_in_prices,
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+
+ # when
+ manager.calculate_checkout_line_total(
+ checkout_info,
+ lines,
+ lines[0],
+ checkout.shipping_address,
+ discounts=[],
)
+ # then
+ assert not mocked_func.called
+
+
+@patch("saleor.plugins.avatax.plugin.get_checkout_tax_data")
+def test_calculate_checkout_line_unit_price_validates_checkout(
+ mocked_func, settings, channel_USD, plugin_configuration, checkout_with_item
+):
+ # given
+ settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
+ plugin_configuration(channel=channel_USD)
manager = get_plugins_manager()
+ checkout = checkout_with_item
+ lines, _ = fetch_checkout_lines(checkout)
+
+ checkout.shipping_method = None
+ checkout.save(update_fields=["shipping_method"])
+
+ for line in lines:
+ line.product_type.is_shipping_required = True
+ line.product_type.save()
+
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
# when
- manager.order_created(order_line.order)
+ manager.calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
+ lines[0],
+ checkout.shipping_address,
+ discounts=[],
+ )
# then
- transaction = api_post_request_task_mock.call_args[0][1]["createTransactionModel"]
- transaction_line = transaction["lines"][0]
- assert transaction_line["taxIncluded"] == expected_tax_included
+ assert not mocked_func.called
diff --git a/saleor/plugins/avatax/tests/test_avatax_caching.py b/saleor/plugins/avatax/tests/test_avatax_caching.py
index 710169bbe4..c5036d1a6d 100644
--- a/saleor/plugins/avatax/tests/test_avatax_caching.py
+++ b/saleor/plugins/avatax/tests/test_avatax_caching.py
@@ -33,7 +33,7 @@ def test_calculate_checkout_total_use_cache(
site_settings.save()
lines, _ = fetch_checkout_lines(checkout)
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_cache = Mock(
return_value=(
@@ -94,7 +94,7 @@ def test_calculate_checkout_total_save_avatax_response_in_cache(
assert result == TaxedMoney(net=Money("72.2", "USD"), gross=Money("75", "USD"))
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_avalara.assert_called_once_with(ANY, avalara_request_data, plugin.config)
@@ -122,7 +122,7 @@ def test_calculate_checkout_subtotal_use_cache(
site_settings.save()
lines, _ = fetch_checkout_lines(checkout)
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_cache = Mock(
return_value=(
@@ -183,7 +183,7 @@ def test_calculate_checkout_subtotal_save_avatax_response_in_cache(
assert result == TaxedMoney(net=Money("64.07", "USD"), gross=Money("65", "USD"))
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_avalara.assert_called_once_with(ANY, avalara_request_data, plugin.config)
@@ -211,7 +211,7 @@ def test_calculate_checkout_shipping_use_cache(
site_settings.save()
lines, _ = fetch_checkout_lines(checkout)
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_cache = Mock(
return_value=(
@@ -272,7 +272,7 @@ def test_calculate_checkout_shipping_save_avatax_response_in_cache(
assert result == TaxedMoney(net=Money("8.13", "USD"), gross=Money("10", "USD"))
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_avalara.assert_called_once_with(ANY, avalara_request_data, plugin.config)
@@ -301,7 +301,7 @@ def test_calculate_checkout_line_total_use_cache(
lines, _ = fetch_checkout_lines(checkout)
checkout_line_info = lines[0]
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_cache = Mock(
return_value=(
@@ -363,7 +363,7 @@ def test_calculate_checkout_line_save_avatax_response_in_cache(
assert result == TaxedMoney(net=Money("4.07", "USD"), gross=Money("5", "USD"))
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_avalara.assert_called_once_with(ANY, avalara_request_data, plugin.config)
@@ -392,7 +392,7 @@ def test_calculate_checkout_line_unit_price_use_cache(
lines, _ = fetch_checkout_lines(checkout)
checkout_line_info = lines[0]
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_cache = Mock(
return_value=(
@@ -466,7 +466,7 @@ def test_calculate_checkout_line_unit_price_save_avatax_response_in_cache(
assert result == TaxedMoney(net=Money("4.07", "USD"), gross=Money("5", "USD"))
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_avalara.assert_called_once_with(ANY, avalara_request_data, plugin.config)
@@ -495,7 +495,7 @@ def test_get_checkout_line_tax_rate_use_cache(
lines, _ = fetch_checkout_lines(checkout)
checkout_line_info = lines[0]
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_cache = Mock(
return_value=(
@@ -574,7 +574,7 @@ def test_get_checkout_line_tax_rate_save_avatax_response_in_cache(
assert result == Decimal("0.36")
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_avalara.assert_called_once_with(ANY, avalara_request_data, plugin.config)
@@ -602,7 +602,7 @@ def test_get_checkout_shipping_tax_rate_use_cache(
site_settings.save()
lines, _ = fetch_checkout_lines(checkout)
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_cache = Mock(
return_value=(
@@ -665,6 +665,6 @@ def test_get_checkout_shipping_tax_rate_save_avatax_response_in_cache(
assert result == Decimal("0.46")
avalara_request_data = generate_request_data_from_checkout(
- checkout_info, lines, plugin.config, tax_included=True, transaction_token=[]
+ checkout_info, lines, plugin.config, transaction_token=[]
)
mocked_avalara.assert_called_once_with(ANY, avalara_request_data, plugin.config)
diff --git a/saleor/plugins/avatax/tests/test_tasks.py b/saleor/plugins/avatax/tests/test_tasks.py
index ca878d3281..0fbe9bf33e 100644
--- a/saleor/plugins/avatax/tests/test_tasks.py
+++ b/saleor/plugins/avatax/tests/test_tasks.py
@@ -30,7 +30,7 @@ def test_api_post_request_task_sends_request(
from_postal_code="53-601",
from_country="PL",
)
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
transaction_url = urljoin(
get_api_url(config.use_sandbox), "transactions/createoradjust"
@@ -62,7 +62,7 @@ def test_api_post_request_task_creates_order_event(
from_postal_code="53-601",
from_country="PL",
)
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
transaction_url = urljoin(
get_api_url(config.use_sandbox), "transactions/createoradjust"
@@ -95,7 +95,7 @@ def test_api_post_request_task_missing_response(
from_postal_code="53-601",
from_country="PL",
)
- request_data = get_order_request_data(order_with_lines, config, tax_included=True)
+ request_data = get_order_request_data(order_with_lines, config)
transaction_url = urljoin(
get_api_url(config.use_sandbox), "transactions/createoradjust"
diff --git a/saleor/plugins/base_plugin.py b/saleor/plugins/base_plugin.py
index b15a917574..afce2265fd 100644
--- a/saleor/plugins/base_plugin.py
+++ b/saleor/plugins/base_plugin.py
@@ -17,11 +17,10 @@ from typing import (
from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse
from django.utils.functional import SimpleLazyObject
-from django_countries.fields import Country
from graphene import Mutation
from graphql import GraphQLError, ResolveInfo
from graphql.execution import ExecutionResult
-from prices import Money, TaxedMoney
+from prices import TaxedMoney
from promise.promise import Promise
from ..core.models import EventDelivery
@@ -62,6 +61,7 @@ if TYPE_CHECKING:
)
from ..shipping.interface import ShippingMethodData
from ..shipping.models import ShippingMethod, ShippingZone
+ from ..tax.models import TaxClass
from ..warehouse.models import Warehouse
PluginConfigurationType = List[dict]
@@ -185,17 +185,8 @@ class BasePlugin:
# status is changed.
app_status_changed: Callable[["App", None], None]
- # Apply taxes to the product price based on the customer country.
- #
- # Overwrite this method if you want to show products with taxes.
- apply_taxes_to_product: Callable[
- ["Product", Money, Country, TaxedMoney], TaxedMoney
- ]
-
# Assign tax code dedicated to plugin.
- assign_tax_code_to_object_meta: Callable[
- [Union["Product", "ProductType"], Union[str, None], Any], Any
- ]
+ assign_tax_code_to_object_meta: Callable[["TaxClass", Union[str, None], Any], Any]
# Trigger when attribute is created.
#
@@ -240,14 +231,6 @@ class BasePlugin:
authorize_payment: Callable[["PaymentData", Any], GatewayResponse]
- # Update order lines taxes.
- #
- # Overwrite this method if you need to apply specific logic for applying taxes on
- # order lines. Return Iterable["OrderLine"].
- update_taxes_for_order_lines: Callable[
- ["Order", List["OrderLine"], List["OrderLine"]], List["OrderLine"]
- ]
-
# Calculate checkout line total.
#
# Overwrite this method if you need to apply specific logic for the calculation
@@ -491,9 +474,6 @@ class BasePlugin:
Tuple[Union["User", None], dict],
]
- # Triggered when ShopFetchTaxRates mutation is called.
- fetch_taxes_data: Callable[[Any], Any]
-
# Trigger when fulfillment is created.
#
# Overwrite this method if you need to trigger specific logic when a fulfillment is
@@ -566,14 +546,7 @@ class BasePlugin:
# Return tax code from object meta.
get_tax_code_from_object_meta: Callable[
- [Union["Product", "ProductType"], "TaxType"], "TaxType"
- ]
-
- # Return tax rate percentage value for a given tax rate type in a country.
- #
- # It is used only by the old storefront.
- get_tax_rate_percentage_value: Callable[
- [Union["Product", "ProductType"], Country, Any], Decimal
+ [Union["Product", "ProductType", "TaxClass"], "TaxType"], "TaxType"
]
# Return list of all tax categories.
diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.py
index 7232798c6b..f8aec2852c 100644
--- a/saleor/plugins/manager.py
+++ b/saleor/plugins/manager.py
@@ -18,11 +18,10 @@ from django.conf import settings
from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse, HttpResponseNotFound
from django.utils.module_loading import import_string
-from django_countries.fields import Country
from graphene import Mutation
from graphql import GraphQLError, ResolveInfo
from graphql.execution import ExecutionResult
-from prices import Money, TaxedMoney
+from prices import TaxedMoney
from ..channel.models import Channel
from ..checkout import base_calculations
@@ -33,6 +32,7 @@ from ..core.taxes import TaxData, TaxType, zero_money, zero_taxed_money
from ..discount import DiscountInfo
from ..order import base_calculations as base_order_calculations
from ..order.interface import OrderTaxedPricesData
+from ..tax.utils import calculate_tax_rate
from .base_plugin import ExcludedShippingMethod, ExternalAccessTokens
from .models import PluginConfiguration
@@ -68,6 +68,7 @@ if TYPE_CHECKING:
)
from ..shipping.interface import ShippingMethodData
from ..shipping.models import ShippingMethod, ShippingZone
+ from ..tax.models import TaxClass
from ..translation.models import Translation
from ..warehouse.models import Stock, Warehouse
from .base_plugin import BasePlugin
@@ -342,7 +343,7 @@ class PluginsManager(PaymentInterface):
discounts: Iterable[DiscountInfo],
shipping_price: TaxedMoney,
):
- default_value = base_calculations.base_tax_rate(shipping_price)
+ default_value = calculate_tax_rate(shipping_price)
return self.__run_method_on_plugins(
"get_checkout_shipping_tax_rate",
default_value,
@@ -354,7 +355,7 @@ class PluginsManager(PaymentInterface):
).quantize(Decimal(".0001"))
def get_order_shipping_tax_rate(self, order: "Order", shipping_price: TaxedMoney):
- default_value = base_calculations.base_tax_rate(shipping_price)
+ default_value = calculate_tax_rate(shipping_price)
return self.__run_method_on_plugins(
"get_order_shipping_tax_rate",
default_value,
@@ -362,20 +363,6 @@ class PluginsManager(PaymentInterface):
channel_slug=order.channel.slug,
).quantize(Decimal(".0001"))
- def update_taxes_for_order_lines(
- self,
- order: "Order",
- lines: List["OrderLine"],
- ):
- lines = self.__run_method_on_plugins(
- "update_taxes_for_order_lines",
- lines,
- order,
- lines,
- channel_slug=order.channel.slug,
- )
- return lines
-
def calculate_checkout_line_total(
self,
checkout_info: "CheckoutInfo",
@@ -499,7 +486,7 @@ class PluginsManager(PaymentInterface):
discounts: Iterable[DiscountInfo],
unit_price: TaxedMoney,
) -> Decimal:
- default_value = base_calculations.base_tax_rate(unit_price)
+ default_value = calculate_tax_rate(unit_price)
return self.__run_method_on_plugins(
"get_checkout_line_tax_rate",
default_value,
@@ -519,7 +506,7 @@ class PluginsManager(PaymentInterface):
address: Optional["Address"],
unit_price: TaxedMoney,
) -> Decimal:
- default_value = base_calculations.base_tax_rate(unit_price)
+ default_value = calculate_tax_rate(unit_price)
return self.__run_method_on_plugins(
"get_order_line_tax_rate",
default_value,
@@ -551,24 +538,6 @@ class PluginsManager(PaymentInterface):
"get_taxes_for_order", order, channel_slug=order.channel.slug
)
- def apply_taxes_to_product(
- self, product: "Product", price: Money, country: Country, channel_slug: str
- ):
- default_value = quantize_price(
- TaxedMoney(net=price, gross=price), price.currency
- )
- return quantize_price(
- self.__run_method_on_plugins(
- "apply_taxes_to_product",
- default_value,
- product,
- price,
- country,
- channel_slug=channel_slug,
- ),
- price.currency,
- )
-
def preprocess_order_creation(
self,
checkout_info: "CheckoutInfo",
@@ -1443,30 +1412,20 @@ class PluginsManager(PaymentInterface):
# FIXME these methods should be more generic
- def assign_tax_code_to_object_meta(
- self, obj: Union["Product", "ProductType"], tax_code: Optional[str]
- ):
+ def assign_tax_code_to_object_meta(self, obj: "TaxClass", tax_code: Optional[str]):
default_value = None
return self.__run_method_on_plugins(
"assign_tax_code_to_object_meta", default_value, obj, tax_code
)
def get_tax_code_from_object_meta(
- self, obj: Union["Product", "ProductType"]
+ self, obj: Union["Product", "ProductType", "TaxClass"]
) -> TaxType:
default_value = TaxType(code="", description="")
return self.__run_method_on_plugins(
"get_tax_code_from_object_meta", default_value, obj
)
- def get_tax_rate_percentage_value(
- self, obj: Union["Product", "ProductType"], country: Country
- ) -> Decimal:
- default_value = Decimal("0").quantize(Decimal("1."))
- return self.__run_method_on_plugins(
- "get_tax_rate_percentage_value", default_value, obj, country
- ).quantize(Decimal("1."))
-
def save_plugin_configuration(
self, plugin_id, channel_slug: Optional[str], cleaned_data: dict
):
@@ -1504,10 +1463,6 @@ class PluginsManager(PaymentInterface):
return plugin
return None
- def fetch_taxes_data(self) -> bool:
- default_value = False
- return self.__run_method_on_plugins("fetch_taxes_data", default_value)
-
def webhook_endpoint_without_channel(
self, request: WSGIRequest, plugin_id: str
) -> HttpResponse:
diff --git a/saleor/plugins/tests/fixtures.py b/saleor/plugins/tests/fixtures.py
index 115229b27a..88e812a288 100644
--- a/saleor/plugins/tests/fixtures.py
+++ b/saleor/plugins/tests/fixtures.py
@@ -1,8 +1,6 @@
import copy
import pytest
-from django_prices_vatlayer.models import VAT
-from django_prices_vatlayer.utils import get_tax_for_rate
from ..base_plugin import ConfigurationTypeField
from ..manager import PluginsManager
@@ -95,67 +93,6 @@ def new_config_structure():
return {"type": ConfigurationTypeField.STRING, "help_text": "foo", "label": "foo"}
-def tax_rates():
- return {
- "standard_rate": 23,
- "reduced_rates": {
- "pharmaceuticals": 8,
- "medical": 8,
- "passenger transport": 8,
- "newspapers": 8,
- "hotels": 8,
- "restaurants": 8,
- "admission to cultural events": 8,
- "admission to sporting events": 8,
- "admission to entertainment events": 8,
- "foodstuffs": 5,
- },
- }
-
-
-def taxes(tax_rates):
- taxes = {
- "standard": {
- "value": tax_rates["standard_rate"],
- "tax": get_tax_for_rate(tax_rates),
- }
- }
- if tax_rates["reduced_rates"]:
- taxes.update(
- {
- rate: {
- "value": tax_rates["reduced_rates"][rate],
- "tax": get_tax_for_rate(tax_rates, rate),
- }
- for rate in tax_rates["reduced_rates"]
- }
- )
- return taxes
-
-
-def vatlayer(db, tax_rates, taxes, setup_vatlayer):
- VAT.objects.create(country_code="PL", data=tax_rates)
-
- tax_rates_2 = {
- "standard_rate": 19,
- "reduced_rates": {
- "admission to cultural events": 7,
- "admission to entertainment events": 7,
- "books": 7,
- "foodstuffs": 7,
- "hotels": 7,
- "medical": 7,
- "newspapers": 7,
- "passenger transport": 7,
- },
- }
- VAT.objects.create(country_code="DE", data=tax_rates_2)
- return taxes
-
-
@pytest.fixture
def plugins_manager():
return PluginsManager(plugins=[])
diff --git a/saleor/plugins/tests/sample_plugins.py b/saleor/plugins/tests/sample_plugins.py
index 9a0cdc31b3..6810f20d0a 100644
--- a/saleor/plugins/tests/sample_plugins.py
+++ b/saleor/plugins/tests/sample_plugins.py
@@ -12,7 +12,6 @@ from typing import (
from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse, HttpResponseNotFound, JsonResponse
-from django_countries.fields import Country
from graphene import Mutation
from graphql import GraphQLError, ResolveInfo
from graphql.execution import ExecutionResult
@@ -31,7 +30,7 @@ if TYPE_CHECKING:
from ...discount import DiscountInfo
from ...discount.models import Sale
from ...order.models import Order, OrderLine
- from ...product.models import Product, ProductType, ProductVariant
+ from ...product.models import Product, ProductVariant
def sample_tax_data(obj_with_lines: Union["Order", "Checkout"]) -> TaxData:
@@ -185,15 +184,6 @@ class PluginSample(BasePlugin):
def show_taxes_on_storefront(self, previous_value: bool) -> bool:
return True
- def apply_taxes_to_product(self, product, price, country, previous_value, **kwargs):
- price = Money("1.0", price.currency)
- return TaxedMoney(price, price)
-
- def get_tax_rate_percentage_value(
- self, obj: Union["Product", "ProductType"], country: Country, previous_value
- ) -> Decimal:
- return Decimal("15.0").quantize(Decimal("1."))
-
def external_authentication_url(
self, data: dict, request: WSGIRequest, previous_value
) -> dict:
diff --git a/saleor/plugins/tests/test_manager.py b/saleor/plugins/tests/test_manager.py
index f99844d9d8..4af03c0ddf 100644
--- a/saleor/plugins/tests/test_manager.py
+++ b/saleor/plugins/tests/test_manager.py
@@ -5,7 +5,6 @@ from unittest import mock
import pytest
from django.http import HttpResponseNotFound, JsonResponse
-from django_countries.fields import Country
from prices import Money, TaxedMoney
from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines
@@ -569,29 +568,6 @@ def test_manager_get_taxes_for_order(
) == expected_tax_data(order)
- "plugins, price",
- [(["saleor.plugins.tests.sample_plugins.PluginSample"], "1.0"), ([], "10.0")],
-)
-def test_manager_apply_taxes_to_product(product, plugins, price, channel_USD):
- country = Country("PL")
- variant = product.variants.all()[0]
- variant_channel_listing = variant.channel_listings.get(channel=channel_USD)
- currency = variant.get_price(
- variant.product, [], channel_USD, variant_channel_listing, None
- ).currency
- expected_price = Money(price, currency)
- taxed_price = PluginsManager(plugins=plugins).apply_taxes_to_product(
- product,
- variant.get_price(
- variant.product, [], channel_USD, variant_channel_listing, None
- ),
- country,
- channel_USD.slug,
- )
- assert TaxedMoney(expected_price, expected_price) == taxed_price
-
-
def test_manager_sale_created(sale):
plugins = ["saleor.plugins.tests.sample_plugins.PluginSample"]
@@ -650,18 +626,6 @@ def test_manager_sale_toggle(sale):
assert current_catalogue == current_catalogue_returned
- "plugins, amount",
- [(["saleor.plugins.tests.sample_plugins.PluginSample"], "15.0"), ([], "0")],
-)
-def test_manager_get_tax_rate_percentage_value(plugins, amount, product):
- country = Country("PL")
- tax_rate_value = PluginsManager(plugins=plugins).get_tax_rate_percentage_value(
- product, country
- )
- assert tax_rate_value == Decimal(amount)
-
-
def test_manager_get_plugin_configuration(plugin_configuration):
plugins = [
"saleor.plugins.tests.sample_plugins.PluginSample",
diff --git a/saleor/plugins/vatlayer/__init__.py b/saleor/plugins/vatlayer/__init__.py
deleted file mode 100644
index 7cc8861b79..0000000000
--- a/saleor/plugins/vatlayer/__init__.py
+++ /dev/null
@@ -1,187 +0,0 @@
-from dataclasses import dataclass
-from typing import TYPE_CHECKING, Iterable, List, Optional
-
-from django_prices_vatlayer.utils import get_tax_for_rate, get_tax_rates_for_country
-from prices import Money, MoneyRange, TaxedMoney, TaxedMoneyRange
-
-from ...checkout import base_calculations
-from ...core.prices import quantize_price
-from ...core.taxes import charge_taxes_on_shipping, include_taxes_in_prices, zero_money
-from ...discount import VoucherType
-
-if TYPE_CHECKING:
- from ...checkout.fetch import CheckoutInfo, CheckoutLineInfo
- from ...discount import DiscountInfo
-
-DEFAULT_TAX_RATE_NAME = "standard"
-
-
-@dataclass
-class VatlayerConfiguration:
- access_key: str
- excluded_countries: Optional[List[str]]
- countries_from_origin: Optional[List[str]]
- origin_country: Optional[str]
-
-
-def _convert_to_naive_taxed_money(base, taxes, rate_name):
- """Naively convert Money to TaxedMoney.
-
- It is meant for consistency with price handling logic across the codebase,
- passthrough other money types.
- """
- if isinstance(base, Money):
- return TaxedMoney(net=base, gross=base)
- if isinstance(base, MoneyRange):
- return TaxedMoneyRange(
- apply_tax_to_price(taxes, rate_name, base.start),
- apply_tax_to_price(taxes, rate_name, base.stop),
- )
- if isinstance(base, (TaxedMoney, TaxedMoneyRange)):
- return base
- raise TypeError("Unknown base for flat_tax: %r" % (base,))
-
-
-def apply_tax_to_price(taxes, rate_name, base):
- if not taxes or not rate_name:
- return _convert_to_naive_taxed_money(base, taxes, rate_name)
-
- if rate_name in taxes:
- tax_to_apply = taxes[rate_name]["tax"]
- else:
- tax_to_apply = taxes[DEFAULT_TAX_RATE_NAME]["tax"]
-
- keep_gross = include_taxes_in_prices()
- return tax_to_apply(base, keep_gross=keep_gross)
-
-
-def get_taxes_for_country(country):
- tax_rates = get_tax_rates_for_country(country.code)
- if tax_rates is None:
- return None
-
- taxes = {
- DEFAULT_TAX_RATE_NAME: {
- "value": tax_rates["standard_rate"],
- "tax": get_tax_for_rate(tax_rates),
- }
- }
- if tax_rates["reduced_rates"]:
- taxes.update(
- {
- rate_name: {
- "value": tax_rates["reduced_rates"][rate_name],
- "tax": get_tax_for_rate(tax_rates, rate_name),
- }
- for rate_name in tax_rates["reduced_rates"]
- }
- )
- return taxes
-
-
-def get_tax_rate_by_name(rate_name, taxes=None):
- """Return value of tax rate for current taxes."""
- if not taxes or not rate_name:
- tax_rate = 0
- elif rate_name in taxes:
- tax_rate = taxes[rate_name]["value"]
- else:
- tax_rate = taxes[DEFAULT_TAX_RATE_NAME]["value"]
-
- return tax_rate
-
-
-def get_taxed_shipping_price(shipping_price, taxes):
- """Calculate shipping price based on settings and taxes."""
- if not charge_taxes_on_shipping():
- taxes = None
- return apply_tax_to_price(taxes, DEFAULT_TAX_RATE_NAME, shipping_price)
-
-
-def apply_checkout_discount_on_checkout_line(
- checkout_info: "CheckoutInfo",
- lines: List["CheckoutLineInfo"],
- checkout_line_info: "CheckoutLineInfo",
- discounts: Iterable["DiscountInfo"],
- line_price: Money,
-):
- """Calculate the checkout line price with discounts.
-
- Include the entire order voucher discount.
-
- The discount amount is calculated for every line proportionally to
- the rate of total line price to checkout total price.
- """
- voucher = checkout_info.voucher
- if (
- not voucher
- or voucher.apply_once_per_order
- or voucher.type in [VoucherType.SHIPPING, VoucherType.SPECIFIC_PRODUCT]
- ):
- return line_price
-
- line_quantity = checkout_line_info.line.quantity
- total_discount_amount = checkout_info.checkout.discount_amount
- line_total_price = line_price * line_quantity
- currency = checkout_info.checkout.currency
-
- # if the checkout has a single line, the whole discount amount will be applied
- # to this line
- if len(lines) == 1:
- return max(
- (line_total_price - Money(total_discount_amount, currency)) / line_quantity,
- zero_money(currency),
- )
-
- # if the checkout has more lines we need to propagate the discount amount
- # proportionally to total prices of items
- lines_total_prices = [
- base_calculations.calculate_base_line_unit_price(
- line_info,
- checkout_info.channel,
- discounts,
- ).amount
- * line_info.line.quantity
- for line_info in lines
- if line_info.line.id != checkout_line_info.line.id
- ]
-
- total_price = sum(lines_total_prices) + line_total_price.amount
-
- last_element = lines[-1].line.id == checkout_line_info.line.id
- if last_element:
- discount_amount = _calculate_discount_for_last_element(
- lines_total_prices, total_price, total_discount_amount, currency
- )
- else:
- discount_amount = quantize_price(
- line_total_price.amount / total_price * total_discount_amount, currency
- )
- return max(
- quantize_price(
- (line_total_price - Money(discount_amount, currency)) / line_quantity,
- currency,
- ),
- zero_money(currency),
- )
-
-
-def _calculate_discount_for_last_element(
- lines_total_prices, total_price, total_discount_amount, currency
-):
- """Calculate the discount for last element.
-
- If the given line is last on the list we should calculate the discount by difference
- between total discount amount and sum of discounts applied to rest of the lines,
- otherwise the sum of discounts won't be equal to the discount amount.
- """
- sum_of_discounts_other_elements = sum(
- [
- quantize_price(
- line_total_price / total_price * total_discount_amount,
- currency,
- )
- for line_total_price in lines_total_prices
- ]
- )
- return total_discount_amount - sum_of_discounts_other_elements
diff --git a/saleor/plugins/vatlayer/plugin.py b/saleor/plugins/vatlayer/plugin.py
deleted file mode 100644
index dd7ee30e4a..0000000000
--- a/saleor/plugins/vatlayer/plugin.py
+++ /dev/null
@@ -1,652 +0,0 @@
-from decimal import Decimal
-from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Union
-
-import opentracing
-import opentracing.tags
-from django.conf import settings
-from django.contrib.sites.models import Site
-from django.core.exceptions import ValidationError
-from django_countries import countries
-from django_countries.fields import Country
-from django_prices_vatlayer.utils import (
- fetch_rate_types,
- fetch_rates,
- get_tax_rate_types,
-)
-from prices import Money, TaxedMoney, TaxedMoneyRange
-
-from ...checkout import base_calculations
-from ...core.prices import quantize_price
-from ...core.taxes import TaxType, zero_money, zero_taxed_money
-from ...discount import OrderDiscountType, VoucherType
-from ...order.interface import OrderTaxedPricesData
-from ...order.utils import get_total_order_discount_excluding_shipping
-from ...plugins.error_codes import PluginErrorCode
-from ...product.models import ProductType
-from ..base_plugin import BasePlugin, ConfigurationTypeField
-from ..manager import get_plugins_manager
-from . import (
- DEFAULT_TAX_RATE_NAME,
- VatlayerConfiguration,
- apply_checkout_discount_on_checkout_line,
- apply_tax_to_price,
- get_taxed_shipping_price,
- get_taxes_for_country,
-)
-
-if TYPE_CHECKING:
- from ...account.models import Address
- from ...channel.models import Channel
- from ...checkout.fetch import CheckoutInfo, CheckoutLineInfo
- from ...discount import DiscountInfo
- from ...order.models import Order, OrderLine
- from ...product.models import Product, ProductVariant
- from ..models import PluginConfiguration
-
-
-class VatlayerPlugin(BasePlugin):
- PLUGIN_ID = "mirumee.taxes.vatlayer"
- PLUGIN_NAME = "Vatlayer"
- META_CODE_KEY = "vatlayer.code"
- META_DESCRIPTION_KEY = "vatlayer.description"
-
- DEFAULT_CONFIGURATION = [
- {"name": "Access key", "value": None},
- {"name": "origin_country", "value": None},
- {"name": "countries_to_calculate_taxes_from_origin", "value": None},
- {"name": "excluded_countries", "value": None},
- ]
-
- CONFIG_STRUCTURE = {
- "origin_country": {
- "type": ConfigurationTypeField.STRING,
- "help_test": (
- "Country code in ISO format, required to calculate taxes for countries "
- "from `Countries for which taxes will be calculated from origin "
- "country`."
- ),
- "label": "Origin country",
- },
- "countries_to_calculate_taxes_from_origin": {
- "type": ConfigurationTypeField.STRING,
- "help_text": (
- "List of destination countries (separated by comma), in ISO format "
- "which will use origin country to calculate taxes."
- ),
- "label": "Countries for which taxes will be calculated from origin country",
- },
- "excluded_countries": {
- "type": ConfigurationTypeField.STRING,
- "help_text": (
- "List of countries (separated by comma), in ISO format for which no "
- "VAT should be added."
- ),
- "label": "Countries for which no VAT will be added.",
- },
- "Access key": {
- "type": ConfigurationTypeField.PASSWORD,
- "help_text": "Required to authenticate to Vatlayer API.",
- "label": "Access key",
- },
- }
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- # Convert to dict to easier take config elements
- configuration = {item["name"]: item["value"] for item in self.configuration}
-
- origin_country = configuration["origin_country"] or ""
- origin_country = countries.alpha2(origin_country.strip())
-
- countries_from_origin = configuration[
- "countries_to_calculate_taxes_from_origin"
- ]
- countries_from_origin = countries_from_origin or ""
- countries_from_origin = [
- countries.alpha2(c.strip()) for c in countries_from_origin.split(",")
- ]
- countries_from_origin = list(filter(None, countries_from_origin))
-
- excluded_countries = configuration["excluded_countries"] or ""
- excluded_countries = [
- countries.alpha2(c.strip()) for c in excluded_countries.split(",")
- ]
- excluded_countries = list(filter(None, excluded_countries))
-
- self.config = VatlayerConfiguration(
- access_key=configuration["Access key"],
- origin_country=origin_country,
- excluded_countries=excluded_countries,
- countries_from_origin=countries_from_origin,
- )
- self._cached_taxes = {}
-
- def _skip_plugin(
- self,
- previous_value: Union[
- TaxedMoney,
- TaxedMoneyRange,
- Decimal,
- OrderTaxedPricesData,
- ],
- ) -> bool:
- if not self.active or not self.config.access_key:
- return True
-
- # The previous plugin already calculated taxes so we can skip our logic
- if isinstance(previous_value, TaxedMoneyRange):
- start = previous_value.start
- stop = previous_value.stop
-
- return start.net != start.gross and stop.net != stop.gross
-
- if isinstance(previous_value, TaxedMoney):
- return previous_value.net != previous_value.gross
-
- if isinstance(previous_value, OrderTaxedPricesData):
- return (
- previous_value.price_with_discounts.net
- != previous_value.price_with_discounts.gross
- )
-
- return False
-
- def calculate_checkout_total(
- self,
- checkout_info: "CheckoutInfo",
- lines: List["CheckoutLineInfo"],
- address: Optional["Address"],
- discounts: List["DiscountInfo"],
- previous_value: TaxedMoney,
- ) -> TaxedMoney:
- if self._skip_plugin(previous_value):
- return previous_value
-
- manager = get_plugins_manager()
- return manager.calculate_checkout_subtotal(
- checkout_info, lines, address, discounts
- ) + manager.calculate_checkout_shipping(
- checkout_info, lines, address, discounts
- )
-
- def calculate_order_total(
- self,
- order: "Order",
- lines: Iterable["OrderLine"],
- previous_value: TaxedMoney,
- ) -> TaxedMoney:
- if self._skip_plugin(previous_value):
- return previous_value
-
- currency = order.currency
-
- total = zero_taxed_money(currency)
- undiscounted_subtotal = zero_taxed_money(currency)
- for line in lines:
- total += line.total_price
- undiscounted_subtotal += line.undiscounted_total_price
- total += order.shipping_price
-
- # Vatlayer doesn't propagate order discount to shipping we should include
- # remaining amount in total calculation.
- order_discount = order.discounts.filter(type=OrderDiscountType.MANUAL).first()
- if order_discount and order_discount.amount > undiscounted_subtotal.gross:
- remaining_amount = order_discount.amount - undiscounted_subtotal.gross
- total -= remaining_amount
- return max(total, zero_taxed_money(currency))
-
- def _get_taxes_for_country(self, country: Country):
- """Try to fetch cached taxes on the plugin level.
-
- If the plugin doesn't have cached taxes for a given country it will fetch it
- from cache or db.
- """
- if not country:
- origin_country_code = self.config.origin_country
- if not origin_country_code:
- company_address = Site.objects.get_current().settings.company_address
- origin_country_code = (
- company_address.country
- if company_address
- else settings.DEFAULT_COUNTRY
- )
-
- country = Country(origin_country_code)
- country_code = country.code
-
- if country_code in self.config.countries_from_origin:
- country_code = self.config.origin_country
-
- if country_code in self.config.excluded_countries:
- return None
-
- if country_code in self._cached_taxes:
- return self._cached_taxes[country_code]
-
- country = Country(country_code)
- taxes = get_taxes_for_country(country)
- self._cached_taxes[country_code] = taxes
- return taxes
-
- def calculate_checkout_shipping(
- self,
- checkout_info: "CheckoutInfo",
- lines: List["CheckoutLineInfo"],
- address: Optional["Address"],
- discounts: List["DiscountInfo"],
- previous_value: TaxedMoney,
- ) -> TaxedMoney:
- """Calculate shipping gross for checkout."""
- if self._skip_plugin(previous_value):
- return previous_value
-
- taxes = None
- if address:
- taxes = self._get_taxes_for_country(address.country)
- if not checkout_info.delivery_method_info.delivery_method:
- return previous_value
- shipping_price = getattr(
- checkout_info.delivery_method_info.delivery_method, "price", previous_value
- )
- voucher = checkout_info.voucher
- is_shipping_discount = (
- voucher.type == VoucherType.SHIPPING if voucher else False
- )
- if is_shipping_discount:
- shipping_price = max(
- shipping_price - checkout_info.checkout.discount,
- zero_money(shipping_price.currency),
- )
-
- return get_taxed_shipping_price(shipping_price, taxes)
-
- def calculate_order_shipping(
- self, order: "Order", previous_value: TaxedMoney
- ) -> TaxedMoney:
- if self._skip_plugin(previous_value):
- return previous_value
-
- address = order.shipping_address or order.billing_address
- taxes = None
- if address:
- taxes = self._get_taxes_for_country(address.country)
- if not order.shipping_method:
- return previous_value
-
- return get_taxed_shipping_price(order.base_shipping_price, taxes)
-
- def update_taxes_for_order_lines(
- self,
- order: "Order",
- lines: List["OrderLine"],
- previous_value: List["OrderLine"],
- ) -> List["OrderLine"]:
- if self._skip_plugin(previous_value):
- return previous_value
-
- address = order.shipping_address or order.billing_address
- country = address.country if address else None
- currency = order.currency
-
- total_discount_amount = get_total_order_discount_excluding_shipping(
- order
- ).amount
- order_total_price = sum(
- [line.base_unit_price.amount * line.quantity for line in lines]
- )
- total_line_discounts = 0
- for line in lines:
- variant = line.variant
- if not variant:
- continue
- product = variant.product # type: ignore
-
- line_total_price = line.base_unit_price * line.quantity
- price_with_discounts = line.base_unit_price
- if total_discount_amount:
- if line is lines[-1]:
- # for the last line applied remaining discount
- discount_amount = total_discount_amount - total_line_discounts
- else:
- # calculate discount proportionally to the rate of total line price
- # to order total price.
- discount_amount = quantize_price(
- line_total_price.amount
- / order_total_price
- * total_discount_amount,
- currency,
- )
- price_with_discounts = max(
- quantize_price(
- (line_total_price - Money(discount_amount, currency))
- / line.quantity,
- currency,
- ),
- zero_money(currency),
- )
- # sum already applied discounts
- total_line_discounts += discount_amount
-
- self._update_line_prices(line, price_with_discounts, product, country)
-
- return lines
-
- def _update_line_prices(
- self,
- line: "OrderLine",
- price_with_discounts: Money,
- product: "Product",
- country: "Country",
- ):
- line.unit_price = self.__apply_taxes_to_product(
- product, price_with_discounts, country
- )
- line.undiscounted_unit_price = self.__apply_taxes_to_product(
- product, line.undiscounted_base_unit_price, country
- )
- line.total_price = line.unit_price * line.quantity
- line.undiscounted_total_price = line.undiscounted_unit_price * line.quantity
- if line.unit_price.net == zero_money(line.currency):
- line.tax_rate = Decimal("0")
- else:
- line.tax_rate = (line.unit_price.tax / line.unit_price.net).quantize(
- Decimal(".0001")
- )
-
- def calculate_checkout_line_total(
- self,
- checkout_info: "CheckoutInfo",
- lines: List["CheckoutLineInfo"],
- checkout_line_info: "CheckoutLineInfo",
- address: Optional["Address"],
- discounts: Iterable["DiscountInfo"],
- previous_value: TaxedMoney,
- ) -> TaxedMoney:
- unit_taxed_price = self.__calculate_checkout_line_unit_price(
- checkout_info,
- lines,
- checkout_line_info,
- checkout_info.channel,
- discounts,
- address,
- previous_value,
- )
- if unit_taxed_price is None:
- return previous_value
-
- quantity = checkout_line_info.line.quantity
- return unit_taxed_price * quantity
-
- def calculate_checkout_line_unit_price(
- self,
- checkout_info: "CheckoutInfo",
- lines: List["CheckoutLineInfo"],
- checkout_line_info: "CheckoutLineInfo",
- address: Optional["Address"],
- discounts: Iterable["DiscountInfo"],
- previous_value: TaxedMoney,
- ) -> TaxedMoney:
- unit_taxed_price = self.__calculate_checkout_line_unit_price(
- checkout_info,
- lines,
- checkout_line_info,
- checkout_info.channel,
- discounts,
- address,
- previous_value,
- )
- return unit_taxed_price if unit_taxed_price is not None else previous_value
-
- def __calculate_checkout_line_unit_price(
- self,
- checkout_info: "CheckoutInfo",
- lines: List["CheckoutLineInfo"],
- checkout_line_info: "CheckoutLineInfo",
- channel: "Channel",
- discounts: Iterable["DiscountInfo"],
- address: Optional["Address"],
- previous_value: TaxedMoney,
- ):
- if self._skip_plugin(previous_value):
- return
-
- unit_price = base_calculations.calculate_base_line_unit_price(
- checkout_line_info,
- channel,
- discounts,
- )
-
- unit_price = apply_checkout_discount_on_checkout_line(
- checkout_info,
- lines,
- checkout_line_info,
- discounts,
- unit_price,
- )
-
- country = address.country if address else None
- return self.__apply_taxes_to_product(
- checkout_line_info.product, unit_price, country
- )
-
- def get_checkout_line_tax_rate(
- self,
- checkout_info: "CheckoutInfo",
- lines: Iterable["CheckoutLineInfo"],
- checkout_line_info: "CheckoutLineInfo",
- address: Optional["Address"],
- discounts: Iterable["DiscountInfo"],
- previous_value: Decimal,
- ) -> Decimal:
- return self._get_tax_rate(checkout_line_info.product, address, previous_value)
-
- def get_order_line_tax_rate(
- self,
- order: "Order",
- product: "Product",
- variant: "ProductVariant",
- address: Optional["Address"],
- previous_value: Decimal,
- ) -> Decimal:
- return self._get_tax_rate(product, address, previous_value)
-
- def _get_tax_rate(
- self, product: "Product", address: Optional["Address"], previous_value: Decimal
- ):
- if self._skip_plugin(previous_value):
- return previous_value
- country = address.country if address else None
- taxes, tax_rate = self.__get_tax_data_for_product(product, country)
- if not taxes or not tax_rate:
- return previous_value
- tax = taxes.get(tax_rate) or taxes.get(DEFAULT_TAX_RATE_NAME)
- # tax value is given in percentage so it need be be converted into decimal value
- return Decimal(tax["value"] / 100)
-
- def get_checkout_shipping_tax_rate(
- self,
- checkout_info: "CheckoutInfo",
- lines: Iterable["CheckoutLineInfo"],
- address: Optional["Address"],
- discounts: Iterable["DiscountInfo"],
- previous_value: Decimal,
- ):
- return self._get_shipping_tax_rate(address, previous_value)
-
- def get_order_shipping_tax_rate(self, order: "Order", previous_value: Decimal):
- address = order.shipping_address or order.billing_address
- return self._get_shipping_tax_rate(address, previous_value)
-
- def _get_shipping_tax_rate(
- self, address: Optional["Address"], previous_value: Decimal
- ):
- if self._skip_plugin(previous_value):
- return previous_value
- country = address.country if address else None
- taxes = self._get_taxes_for_country(country)
- if not taxes:
- return previous_value
- tax = taxes.get(DEFAULT_TAX_RATE_NAME)
- # tax value is given in percentage so it need be be converted into decimal value
- return Decimal(tax["value"]) / 100
-
- def get_tax_rate_type_choices(
- self, previous_value: List["TaxType"]
- ) -> List["TaxType"]:
- if not self.active:
- return previous_value
-
- rate_types = get_tax_rate_types() + [DEFAULT_TAX_RATE_NAME]
- choices = [
- TaxType(code=rate_name, description=rate_name) for rate_name in rate_types
- ]
- # sort choices alphabetically by translations
- return sorted(choices, key=lambda x: x.code)
-
- def show_taxes_on_storefront(self, previous_value: bool) -> bool:
- if not self.active:
- return previous_value
- return True
-
- def apply_taxes_to_product(
- self,
- product: "Product",
- price: Money,
- country: Country,
- previous_value: TaxedMoney,
- ) -> TaxedMoney:
- if self._skip_plugin(previous_value):
- return previous_value
- return self.__apply_taxes_to_product(product, price, country)
-
- def __apply_taxes_to_product(
- self, product: "Product", price: Money, country: Country
- ):
- taxes, tax_rate = self.__get_tax_data_for_product(product, country)
- return apply_tax_to_price(taxes, tax_rate, price)
-
- def __get_tax_data_for_product(self, product: "Product", country: Country):
- taxes = None
- if country and product.charge_taxes:
- taxes = self._get_taxes_for_country(country)
- product_tax_rate = self.__get_tax_code_from_object_meta(product).code
- tax_rate = (
- product_tax_rate
- or self.__get_tax_code_from_object_meta(product.product_type).code
- )
- return taxes, tax_rate
-
- def assign_tax_code_to_object_meta(
- self,
- obj: Union["Product", "ProductType"],
- tax_code: Optional[str],
- previous_value: Any,
- ):
- if not self.active:
- return previous_value
-
- if tax_code is None and obj.pk:
- obj.delete_value_from_metadata(self.META_CODE_KEY)
- obj.delete_value_from_metadata(self.META_DESCRIPTION_KEY)
- elif tax_code is not None:
- tax_item = {
- self.META_CODE_KEY: tax_code,
- self.META_DESCRIPTION_KEY: tax_code,
- }
- obj.store_value_in_metadata(items=tax_item)
- return previous_value
-
- def get_tax_code_from_object_meta(
- self, obj: Union["Product", "ProductType"], previous_value: "TaxType"
- ) -> "TaxType":
- if not self.active:
- return previous_value
- return self.__get_tax_code_from_object_meta(obj)
-
- def __get_tax_code_from_object_meta(
- self, obj: Union["Product", "ProductType"]
- ) -> "TaxType":
-
- # Product has None as it determines if we overwrite taxes for the product
- default_tax_code = None
- default_tax_description = None
- if isinstance(obj, ProductType):
- default_tax_code = DEFAULT_TAX_RATE_NAME
- default_tax_description = DEFAULT_TAX_RATE_NAME
-
- tax_code = obj.get_value_from_metadata(self.META_CODE_KEY, default_tax_code)
- tax_description = obj.get_value_from_metadata(
- self.META_DESCRIPTION_KEY, default_tax_description
- )
- return TaxType(code=tax_code, description=tax_description)
-
- def get_tax_rate_percentage_value(
- self, obj: Union["Product", "ProductType"], country: Country, previous_value
- ) -> Decimal:
- """Return tax rate percentage value for given tax rate type in the country."""
- if not self.active:
- return previous_value
- taxes = self._get_taxes_for_country(country)
- if not taxes:
- return Decimal(0)
- rate_name = self.__get_tax_code_from_object_meta(obj).code
- tax = taxes.get(rate_name) or taxes.get(DEFAULT_TAX_RATE_NAME)
- return Decimal(tax["value"])
-
- def fetch_taxes_data(self, previous_value: Any) -> Any:
- """Triggered when ShopFetchTaxRates mutation is called."""
- if not self.active:
- return previous_value
- with opentracing.global_tracer().start_active_span(
- "vatlayer.fetch_taxes_data"
- ) as scope:
- span = scope.span
- span.set_tag(opentracing.tags.COMPONENT, "tax")
- span.set_tag("service.name", "vatlayer")
- fetch_rates(self.config.access_key)
- return True
-
- @classmethod
- def validate_plugin_configuration(
- cls, plugin_configuration: "PluginConfiguration", **kwargs
- ):
- """Validate if provided configuration is correct."""
- configuration = plugin_configuration.configuration
- configuration = {item["name"]: item["value"] for item in configuration}
-
- access_key = configuration.get("Access key")
- if plugin_configuration.active and not access_key:
- raise ValidationError(
- {
- "Access key": ValidationError(
- "Cannot be enabled without provided Access key",
- code=PluginErrorCode.INVALID.value,
- )
- }
- )
- if access_key and plugin_configuration.active:
- # let's check if access_key works
- fetched_data = fetch_rate_types(access_key=access_key)
- if not fetched_data["success"]:
- raise ValidationError(
- {
- "Access key": ValidationError(
- "Cannot enable Vatlayer. Incorrect API key.",
- code=PluginErrorCode.INVALID.value,
- )
- }
- )
- countries_from_origin = configuration.get(
- "countries_to_calculate_taxes_from_origin"
- )
- origin_country = configuration.get("origin_country")
- if countries_from_origin and not origin_country:
- raise ValidationError(
- {
- "origin_country": ValidationError(
- "Source country required when `Countries for which taxes will "
- "be calculated from origin country` provided.",
- code=PluginErrorCode.INVALID.value,
- )
- }
- )
diff --git a/saleor/plugins/vatlayer/tests/conftest.py b/saleor/plugins/vatlayer/tests/conftest.py
deleted file mode 100644
index 3cb0250a37..0000000000
--- a/saleor/plugins/vatlayer/tests/conftest.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from unittest.mock import patch
-
-import pytest
-
-from ...manager import get_plugins_manager
-from ..plugin import VatlayerPlugin
-
-
-def vatlayer_plugin(settings, vatlayer, channel_USD):
- def fun(
- active=True,
- access_key="key",
- origin_country=None,
- countries_to_calculate_taxes_from_origin=None,
- excluded_countries=None,
- ):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- with patch("saleor.plugins.vatlayer.plugin.fetch_rate_types"):
- manager.save_plugin_configuration(
- VatlayerPlugin.PLUGIN_ID,
- channel_USD.slug,
- {
- "active": active,
- "configuration": [
- {"name": "Access key", "value": access_key},
- {"name": "origin_country", "value": origin_country},
- {
- "name": "countries_to_calculate_taxes_from_origin",
- "value": countries_to_calculate_taxes_from_origin,
- },
- {"name": "excluded_countries", "value": excluded_countries},
- ],
- },
- )
- manager = get_plugins_manager()
- return manager.plugins_per_channel[channel_USD.slug][0]
-
- return fun
diff --git a/saleor/plugins/vatlayer/tests/test_vatlayer.py b/saleor/plugins/vatlayer/tests/test_vatlayer.py
deleted file mode 100644
index cd92c9466c..0000000000
--- a/saleor/plugins/vatlayer/tests/test_vatlayer.py
+++ /dev/null
@@ -1,2528 +0,0 @@
-from decimal import Decimal
-from urllib.parse import urlparse
-
-import pytest
-from django.core.exceptions import ValidationError
-from django.test import override_settings
-from django_countries.fields import Country
-from prices import Money, MoneyRange, TaxedMoney, TaxedMoneyRange
-
-from ....checkout import calculations
-from ....checkout.fetch import fetch_checkout_info, fetch_checkout_lines
-from ....checkout.utils import add_variant_to_checkout
-from ....core.prices import quantize_price
-from ....core.taxes import zero_money, zero_taxed_money
-from ....discount import DiscountValueType, OrderDiscountType
-from ....product.models import Product
-from ...manager import get_plugins_manager
-from ...models import PluginConfiguration
-from ...vatlayer import (
- DEFAULT_TAX_RATE_NAME,
- apply_tax_to_price,
- get_tax_rate_by_name,
- get_taxed_shipping_price,
- get_taxes_for_country,
-)
-from ..plugin import VatlayerPlugin
-
-
-def get_url_path(url):
- parsed_url = urlparse(url)
- return parsed_url.path
-
-
-def get_redirect_location(response):
- # Due to Django 1.8 compatibility, we have to handle both cases
- return get_url_path(response["Location"])
-
-
-def compare_taxes():
- def fun(taxes_1, taxes_2):
- assert len(taxes_1) == len(taxes_2)
-
- for rate_name, tax in taxes_1.items():
- value_1 = tax["value"]
- value_2 = taxes_2.get(rate_name)["value"]
- assert value_1 == value_2
-
- return fun
-
-
-def test_get_tax_rate_by_name(taxes):
- rate_name = "pharmaceuticals"
- tax_rate = get_tax_rate_by_name(rate_name, taxes)
-
- assert tax_rate == taxes[rate_name]["value"]
-
-
-def test_get_tax_rate_by_name_fallback_to_standard(taxes):
- rate_name = "unexisting tax rate"
- tax_rate = get_tax_rate_by_name(rate_name, taxes)
-
- assert tax_rate == taxes[DEFAULT_TAX_RATE_NAME]["value"]
-
-
-def test_get_tax_rate_by_name_empty_taxes(product):
- rate_name = "unexisting tax rate"
- tax_rate = get_tax_rate_by_name(rate_name)
-
- assert tax_rate == 0
-
-
- "price, charge_taxes, expected_price",
- [
- (
- Money(10, "USD"),
- False,
- TaxedMoney(net=Money(10, "USD"), gross=Money(10, "USD")),
- ),
- (
- Money(10, "USD"),
- True,
- TaxedMoney(net=Money("8.13", "USD"), gross=Money(10, "USD")),
- ),
- ],
-)
-def test_get_taxed_shipping_price(
- site_settings, vatlayer, price, charge_taxes, expected_price
-):
- site_settings.charge_taxes_on_shipping = charge_taxes
- site_settings.save()
-
- shipping_price = get_taxed_shipping_price(price, taxes=vatlayer)
-
- assert shipping_price == expected_price
-
-
-def test_get_taxes_for_country(vatlayer, compare_taxes):
- taxes = get_taxes_for_country(Country("PL"))
- compare_taxes(taxes, vatlayer)
-
-
-def test_apply_tax_to_price_do_not_include_tax(site_settings, taxes):
- site_settings.include_taxes_in_prices = False
- site_settings.save()
-
- money = Money(100, "USD")
- assert apply_tax_to_price(taxes, "standard", money) == TaxedMoney(
- net=Money(100, "USD"), gross=Money(123, "USD")
- )
- assert apply_tax_to_price(taxes, "medical", money) == TaxedMoney(
- net=Money(100, "USD"), gross=Money(108, "USD")
- )
-
- taxed_money = TaxedMoney(net=Money(100, "USD"), gross=Money(100, "USD"))
- assert apply_tax_to_price(taxes, "standard", taxed_money) == TaxedMoney(
- net=Money(100, "USD"), gross=Money(123, "USD")
- )
- assert apply_tax_to_price(taxes, "medical", taxed_money) == TaxedMoney(
- net=Money(100, "USD"), gross=Money(108, "USD")
- )
-
-
-def test_apply_tax_to_price_do_not_include_tax_fallback_to_standard_rate(
- site_settings, taxes
-):
- site_settings.include_taxes_in_prices = False
- site_settings.save()
-
- money = Money(100, "USD")
- taxed_money = TaxedMoney(net=Money(100, "USD"), gross=Money(123, "USD"))
- assert apply_tax_to_price(taxes, "space suits", money) == taxed_money
-
-
-def test_apply_tax_to_price_include_tax(taxes):
- money = Money(100, "USD")
- assert apply_tax_to_price(taxes, "standard", money) == TaxedMoney(
- net=Money("81.30", "USD"), gross=Money(100, "USD")
- )
- assert apply_tax_to_price(taxes, "medical", money) == TaxedMoney(
- net=Money("92.59", "USD"), gross=Money(100, "USD")
- )
-
-
-def test_apply_tax_to_price_include_fallback_to_standard_rate(taxes):
- money = Money(100, "USD")
- assert apply_tax_to_price(taxes, "space suits", money) == TaxedMoney(
- net=Money("81.30", "USD"), gross=Money(100, "USD")
- )
-
- taxed_money = TaxedMoney(net=Money(100, "USD"), gross=Money(100, "USD"))
- assert apply_tax_to_price(taxes, "space suits", taxed_money) == TaxedMoney(
- net=Money("81.30", "USD"), gross=Money(100, "USD")
- )
-
-
-def test_apply_tax_to_price_raise_typeerror_for_invalid_type(taxes):
- with pytest.raises(TypeError):
- assert apply_tax_to_price(taxes, "standard", 100)
-
-
-def test_apply_tax_to_price_no_taxes_return_taxed_money():
- money = Money(100, "USD")
- taxed_money = TaxedMoney(net=Money(100, "USD"), gross=Money(100, "USD"))
-
- assert apply_tax_to_price(None, "standard", money) == taxed_money
- assert apply_tax_to_price(None, "medical", taxed_money) == taxed_money
-
-
-def test_apply_tax_to_price_no_taxes_return_taxed_money_range():
- money_range = MoneyRange(Money(100, "USD"), Money(200, "USD"))
- taxed_money_range = TaxedMoneyRange(
- TaxedMoney(net=Money(100, "USD"), gross=Money(100, "USD")),
- TaxedMoney(net=Money(200, "USD"), gross=Money(200, "USD")),
- )
-
- assert apply_tax_to_price(None, "standard", money_range) == taxed_money_range
- assert apply_tax_to_price(None, "standard", taxed_money_range) == taxed_money_range
-
-
-def test_apply_tax_to_price_no_taxes_raise_typeerror_for_invalid_type():
- with pytest.raises(TypeError):
- assert apply_tax_to_price(None, "standard", 100)
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_assign_tax_code_to_object_meta(vatlayer, product):
- # given
- manager = get_plugins_manager()
- tax_code = "standard"
-
- # when
- manager.assign_tax_code_to_object_meta(product, tax_code)
-
- # then
- assert product.metadata == {
- VatlayerPlugin.META_CODE_KEY: tax_code,
- VatlayerPlugin.META_DESCRIPTION_KEY: tax_code,
- }
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_assign_tax_code_to_object_meta_none_as_tax_code(vatlayer, product):
- # given
- manager = get_plugins_manager()
- tax_code = None
-
- # when
- manager.assign_tax_code_to_object_meta(product, tax_code)
-
- # then
- assert product.metadata == {}
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_assign_tax_code_to_object_meta_no_obj_id_and_none_as_tax_code(vatlayer):
- # given
- manager = get_plugins_manager()
- product = Product(name="A new product.")
- tax_code = None
-
- # when
- manager.assign_tax_code_to_object_meta(product, tax_code)
-
- # then
- assert product.metadata == {}
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_assign_tax_code_to_object_meta_no_obj_id(vatlayer):
- # given
- manager = get_plugins_manager()
- product = Product(name="A new product.")
- tax_code = "standard"
-
- # when
- manager.assign_tax_code_to_object_meta(product, tax_code)
-
- # then
- assert product.metadata == {
- VatlayerPlugin.META_CODE_KEY: tax_code,
- VatlayerPlugin.META_DESCRIPTION_KEY: tax_code,
- }
-
-
- "with_discount, expected_net, expected_gross, voucher_amount, taxes_in_prices",
- [
- (True, "20.34", "25.00", "0.0", True),
- (True, "20.00", "24.60", "5.0", False),
- (False, "40.00", "49.20", "0.0", False),
- (False, "30.09", "37.00", "3.0", True),
- ],
-)
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_total(
- site_settings,
- vatlayer,
- checkout_with_item,
- address,
- shipping_zone,
- discount_info,
- voucher,
- with_discount,
- expected_net,
- expected_gross,
- voucher_amount,
- taxes_in_prices,
-):
- # given
- manager = get_plugins_manager()
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- voucher_amount = Money(voucher_amount, "USD")
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.voucher_code = voucher.code
- checkout_with_item.discount = voucher_amount
- checkout_with_item.save()
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
-
- discounts = [discount_info] if with_discount else None
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, discounts, manager)
-
- # when
- total = manager.calculate_checkout_total(checkout_info, lines, address, discounts)
-
- # then
- total = quantize_price(total, total.currency)
- assert total == TaxedMoney(
- net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
- )
-
-
- "with_discount, expected_net, expected_gross, voucher_amount, taxes_in_prices",
- [
- (True, "20.34", "25.00", "0.0", True),
- (True, "20.00", "24.60", "5.0", False),
- (False, "40.00", "49.20", "0.0", False),
- (False, "30.08", "37.00", "3.0", True),
- ],
-)
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_total_shipping_voucher(
- site_settings,
- vatlayer,
- checkout_with_item,
- address,
- shipping_zone,
- discount_info,
- voucher_shipping_type,
- with_discount,
- expected_net,
- expected_gross,
- voucher_amount,
- taxes_in_prices,
-):
- # given
- manager = get_plugins_manager()
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- voucher_amount = Money(voucher_amount, "USD")
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.voucher_code = voucher_shipping_type.code
- checkout_with_item.discount = voucher_amount
- checkout_with_item.save()
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
-
- discounts = [discount_info] if with_discount else None
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, discounts, manager)
-
- # when
- total = manager.calculate_checkout_total(checkout_info, lines, address, discounts)
-
- # then
- total = quantize_price(total, total.currency)
- assert total == TaxedMoney(
- net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
- )
-
-
-def test_calculate_checkout_total_from_origin_country(
- vatlayer_plugin,
- checkout_with_item,
- address,
- shipping_zone,
- discount_info,
-):
- plugin = vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
-
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
- line = checkout_with_item.lines.first()
- product = line.variant.product
- plugin.assign_tax_code_to_object_meta(product, "standard", None)
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
- total = manager.calculate_checkout_total(
- checkout_info, lines, address, [discount_info]
- )
- total = quantize_price(total, total.currency)
-
- # make sure that address has PL code
- assert address.country.code == "PL"
-
- # make sure that we applied DE taxes (19%)
- assert total == TaxedMoney(net=Money("21.00", "USD"), gross=Money("25.00", "USD"))
-
-
-def test_calculate_checkout_total_with_excluded_country(
- vatlayer_plugin,
- checkout_with_item,
- address,
- shipping_zone,
- discount_info,
-):
- plugin = vatlayer_plugin(origin_country="PL", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
-
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
- line = checkout_with_item.lines.first()
- product = line.variant.product
- plugin.assign_tax_code_to_object_meta(product, "standard", None)
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
- total = manager.calculate_checkout_total(
- checkout_info, lines, address, [discount_info]
- )
- total = quantize_price(total, total.currency)
-
- # make sure that we not have VAT
- assert total == TaxedMoney(net=Money("25.00", "USD"), gross=Money("25.00", "USD"))
-
-
- "with_discount, expected_net, expected_gross, taxes_in_prices",
- [
- (True, "20.35", "25.00", True),
- (False, "40.65", "50.00", True),
- (True, "25.00", "30.75", False),
- (False, "50.00", "61.50", False),
- ],
-)
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_subtotal(
- site_settings,
- vatlayer,
- checkout_with_item,
- address,
- shipping_zone,
- discount_info,
- with_discount,
- expected_net,
- expected_gross,
- taxes_in_prices,
- stock,
-):
- variant = stock.product_variant
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
-
- manager = get_plugins_manager()
-
- product = variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- discounts = [discount_info] if with_discount else None
- checkout_info = fetch_checkout_info(checkout_with_item, [], discounts, manager)
- add_variant_to_checkout(checkout_info, variant, 2)
- lines, _ = fetch_checkout_lines(checkout_with_item)
- total = manager.calculate_checkout_subtotal(
- checkout_info, lines, address, discounts
- )
- total = quantize_price(total, total.currency)
- assert total == TaxedMoney(
- net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
- )
-
-
-def test_calculate_checkout_subtotal_from_origin_country(
- site_settings,
- vatlayer_plugin,
- checkout_with_item,
- address,
- shipping_zone,
- discount_info,
-):
- plugin = vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
-
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
- line = checkout_with_item.lines.first()
- product = line.variant.product
- plugin.assign_tax_code_to_object_meta(product, "standard", None)
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
- total = manager.calculate_checkout_subtotal(
- checkout_info, lines, address, [discount_info]
- )
- total = quantize_price(total, total.currency)
-
- # make sure that address has PL code
- assert address.country.code == "PL"
-
- # make sure that we applied DE taxes (19%)
- assert total == TaxedMoney(net=Money("12.60", "USD"), gross=Money("15.00", "USD"))
-
-
-def test_calculate_checkout_subtotal_with_excluded_country(
- site_settings,
- vatlayer_plugin,
- checkout_with_item,
- address,
- shipping_zone,
- discount_info,
-):
- plugin = vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
-
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
- line = checkout_with_item.lines.first()
- product = line.variant.product
- plugin.assign_tax_code_to_object_meta(product, "standard", None)
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
- total = manager.calculate_checkout_subtotal(
- checkout_info, lines, address, [discount_info]
- )
- total = quantize_price(total, total.currency)
-
- # make sure that we not have VAT
- assert total == TaxedMoney(net=Money("15.00", "USD"), gross=Money("15.00", "USD"))
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculations_calculate_order_total(vatlayer, order_with_lines):
- # given
- manager = get_plugins_manager()
- order = order_with_lines
- lines = order.lines.all()
- order.shipping_price = manager.calculate_order_shipping(order)
- lines = manager.update_taxes_for_order_lines(order, lines)
-
- # when
- total = manager.calculate_order_total(order, lines)
- total = quantize_price(total, total.currency)
-
- # then
- assert total == TaxedMoney(net=Money("65.04", "USD"), gross=Money("80.00", "USD"))
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculations_calculate_order_total_voucher(vatlayer, order_with_lines):
- # given
- manager = get_plugins_manager()
- order = order_with_lines
- lines = list(order.lines.all())
- discount_amount = 10
- order.discounts.create(
- type=OrderDiscountType.VOUCHER,
- value_type=DiscountValueType.FIXED,
- value=discount_amount,
- name="Voucher",
- translated_name="VoucherPL",
- currency=order.currency,
- amount_value=10,
- )
- order.shipping_price = manager.calculate_order_shipping(order)
- manager.update_taxes_for_order_lines(order, lines)
-
- # when
- total = manager.calculate_order_total(order, lines)
- total = quantize_price(total, total.currency)
-
- # then
- assert total == TaxedMoney(net=Money("56.92", "USD"), gross=Money("70.01", "USD"))
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculations_calculate_order_total_with_manual_discount(
- vatlayer, order_with_lines
-):
- # given
- manager = get_plugins_manager()
- order = order_with_lines
- lines = list(order.lines.all())
- order.discounts.create(
- type=OrderDiscountType.MANUAL,
- value_type=DiscountValueType.FIXED,
- value=10,
- name="StaffDiscount",
- translated_name="StaffDiscountPL",
- currency=order.currency,
- amount_value=10,
- )
- order.shipping_price = manager.calculate_order_shipping(order)
- manager.update_taxes_for_order_lines(order, lines)
-
- # when
- total = manager.calculate_order_total(order, lines)
- total = quantize_price(total, total.currency)
-
- # then
- assert total == TaxedMoney(net=Money("56.92", "USD"), gross=Money("70.01", "USD"))
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculations_calculate_order_total_with_discount_for_order_total(
- vatlayer, order_with_lines
-):
- # given
- manager = get_plugins_manager()
- order = order_with_lines
- lines = list(order.lines.all())
- order.discounts.create(
- type=OrderDiscountType.MANUAL,
- value_type=DiscountValueType.FIXED,
- value=80,
- name="StaffDiscount",
- translated_name="StaffDiscountPL",
- currency=order.currency,
- amount_value=80,
- )
- order.shipping_price = manager.calculate_order_shipping(order)
- manager.update_taxes_for_order_lines(order, lines)
-
- # when
- total = manager.calculate_order_total(order, lines)
- total = quantize_price(total, total.currency)
-
- # then
- assert total == TaxedMoney(net=Money("0", "USD"), gross=Money("0", "USD"))
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculations_calculate_order_total_with_discount_for_subtotal_and_shipping(
- vatlayer, order_with_lines
-):
- # given
- manager = get_plugins_manager()
- order = order_with_lines
- lines = list(order.lines.all())
- order.discounts.create(
- type=OrderDiscountType.MANUAL,
- value_type=DiscountValueType.FIXED,
- value=75,
- name="StaffDiscount",
- translated_name="StaffDiscountPL",
- currency=order.currency,
- amount_value=75,
- )
- order.shipping_price = manager.calculate_order_shipping(order)
- manager.update_taxes_for_order_lines(order, lines)
-
- # when
- total = manager.calculate_order_total(order, lines)
- total = quantize_price(total, total.currency)
-
- # then
- assert total == TaxedMoney(net=Money("3.13", "USD"), gross=Money("5.00", "USD"))
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculations_calculate_order_total_with_discount_for_more_than_order_total(
- vatlayer, order_with_lines
-):
- # given
- manager = get_plugins_manager()
- order = order_with_lines
- lines = list(order.lines.all())
- order.discounts.create(
- type=OrderDiscountType.MANUAL,
- value_type=DiscountValueType.FIXED,
- value=100,
- name="StaffDiscount",
- translated_name="StaffDiscountPL",
- currency=order.currency,
- amount_value=100,
- )
- order.shipping_price = manager.calculate_order_shipping(order)
- manager.update_taxes_for_order_lines(order, lines)
-
- # when
- total = manager.calculate_order_total(order, lines)
- total = quantize_price(total, total.currency)
-
- # then
- assert total == TaxedMoney(net=Money("0", "USD"), gross=Money("0", "USD"))
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculations_calculate_order_total_with_manual_discount_and_voucher(
- vatlayer, order_with_lines
-):
- # given
- manager = get_plugins_manager()
- order = order_with_lines
- lines = list(order.lines.all())
- order.discounts.create(
- type=OrderDiscountType.MANUAL,
- value_type=DiscountValueType.FIXED,
- value=10,
- name="StaffDiscount",
- translated_name="StaffDiscountPL",
- currency=order.currency,
- amount_value=10,
- )
- order.discounts.create(
- type=OrderDiscountType.VOUCHER,
- value_type=DiscountValueType.FIXED,
- value=10,
- name="Voucher",
- translated_name="VoucherPL",
- currency=order.currency,
- amount_value=10,
- )
- order.shipping_price = manager.calculate_order_shipping(order)
- manager.update_taxes_for_order_lines(order, lines)
-
- # when
- total = manager.calculate_order_total(order, lines)
- total = quantize_price(total, total.currency)
-
- # then
- assert total == TaxedMoney(net=Money("48.77", "USD"), gross=Money("60.00", "USD"))
-
-
-def test_calculate_order_shipping(vatlayer, order_line, shipping_zone, site_settings):
- manager = get_plugins_manager()
- order = order_line.order
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.base_shipping_price = method.channel_listings.get(channel=order.channel).price
- order.save()
- price = manager.calculate_order_shipping(order)
- price = quantize_price(price, price.currency)
- assert price == TaxedMoney(net=Money("8.13", "USD"), gross=Money("10.00", "USD"))
-
-
-def test_calculate_order_shipping_from_origin_country(
- vatlayer_plugin, order_line, shipping_zone, site_settings
-):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- order = order_line.order
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.base_shipping_price = method.channel_listings.get(channel=order.channel).price
- order.shipping_method = method
- order.save()
-
- price = manager.calculate_order_shipping(order)
- price = quantize_price(price, price.currency)
-
- # make sure that address has PL code
- assert order.shipping_address.country.code == "PL"
-
- # make sure that we applied DE taxes (19%)
- assert price == TaxedMoney(net=Money("8.40", "USD"), gross=Money("10.00", "USD"))
-
-
-def test_calculate_order_shipping_with_excluded_country(
- vatlayer_plugin, order_line, shipping_zone, site_settings
-):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- order = order_line.order
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.base_shipping_price = method.channel_listings.get(channel=order.channel).price
- order.save()
-
- price = manager.calculate_order_shipping(order)
- price = quantize_price(price, price.currency)
-
- assert price == TaxedMoney(net=Money("10.00", "USD"), gross=Money("10.00", "USD"))
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_order_shipping_for_order_without_shipping(
- vatlayer, order_line, shipping_zone, site_settings
-):
- manager = get_plugins_manager()
- order = order_line.order
- order.shipping_method = None
- order.save()
- price = manager.calculate_order_shipping(order)
- assert price == zero_taxed_money(order.currency)
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_order_shipping_voucher_on_shipping(
- vatlayer, order_line, shipping_zone, voucher_shipping_type
-):
- # given
- manager = get_plugins_manager()
- order = order_line.order
- currency = order.currency
- discount_amount = Decimal("5.0")
-
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.base_shipping_price = method.channel_listings.get(
- channel=order.channel
- ).price - Money(discount_amount, currency)
- order.voucher = voucher_shipping_type
- order.save()
-
- order.discounts.create(
- type=OrderDiscountType.VOUCHER,
- value_type=DiscountValueType.FIXED,
- value=discount_amount,
- name=voucher_shipping_type.code,
- currency=currency,
- amount_value=discount_amount,
- )
- channel = order.channel
- shipping_channel_listings = method.channel_listings.get(channel=channel)
- shipping_price = shipping_channel_listings.price
-
- # when
- price = manager.calculate_order_shipping(order)
-
- # then
- price = quantize_price(price, price.currency)
- expected_gross_amount = shipping_price.amount - discount_amount
- assert price == TaxedMoney(
- net=quantize_price(
- Money(expected_gross_amount / Decimal("1.23"), currency), currency
- ),
- gross=Money(expected_gross_amount, currency),
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_order_shipping_free_shipping_voucher(
- vatlayer, order_line, shipping_zone, voucher_shipping_type
-):
- # given
- manager = get_plugins_manager()
- order = order_line.order
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = order.billing_address.get_copy()
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.base_shipping_price = zero_money(order.currency)
- order.voucher = voucher_shipping_type
- order.save()
-
- currency = order.currency
- channel = order.channel
- shipping_channel_listings = method.channel_listings.get(channel=channel)
- shipping_price = shipping_channel_listings.price
-
- order.discounts.create(
- type=OrderDiscountType.VOUCHER,
- value_type=DiscountValueType.PERCENTAGE,
- value=Decimal("100.0"),
- name=voucher_shipping_type.code,
- currency=currency,
- amount_value=shipping_price.amount,
- )
-
- # when
- price = manager.calculate_order_shipping(order)
-
- # then
- price = quantize_price(price, price.currency)
- assert price == zero_taxed_money(currency)
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_line_total(
- vatlayer, checkout_with_item, shipping_zone, address, site_settings
-):
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
- assert line.quantity > 1
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- checkout_with_item.save()
-
- variant = line.variant
- product = variant.product
- manager.assign_tax_code_to_object_meta(variant.product, "standard")
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- line_price = manager.calculate_checkout_line_total(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- assert line_price == TaxedMoney(
- net=Money("8.13", "USD") * line.quantity,
- gross=Money("10.00", "USD") * line.quantity,
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_line_total_voucher_on_entire_order(
- vatlayer, checkout_with_item, shipping_zone, address, voucher
-):
- # given
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
- assert line.quantity > 1
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- discount_amount = Decimal("5")
- checkout_with_item.discount_amount = discount_amount
- checkout_with_item.voucher_code = voucher.code
- checkout_with_item.save()
-
- variant = line.variant
- product = variant.product
- channel = checkout_with_item.channel
- channel_listing = variant.channel_listings.get(channel=channel)
- total_price = channel_listing.price * line.quantity
-
- manager.assign_tax_code_to_object_meta(variant.product, "standard")
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- # when
- line_price = manager.calculate_checkout_line_total(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- # then
- currency = checkout_with_item.currency
- total_gross = Money(total_price.amount - discount_amount, currency)
- unit_net = quantize_price(total_gross / line.quantity / Decimal("1.23"), currency)
- assert line_price == TaxedMoney(
- net=quantize_price(unit_net * line.quantity, currency),
- gross=quantize_price(total_gross, currency),
- )
-
-
-def test_calculate_checkout_line_total_from_origin_country(
- vatlayer_plugin, checkout_with_item, shipping_zone, address, site_settings
-):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
- assert line.quantity > 1
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- checkout_with_item.save()
-
- variant = line.variant
- product = variant.product
- manager.assign_tax_code_to_object_meta(variant.product, "standard")
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- line_price = manager.calculate_checkout_line_total(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- # make sure that we applied DE taxes (19%)
- assert line_price == TaxedMoney(
- net=Money("8.40", "USD") * line.quantity,
- gross=Money("10.00", "USD") * line.quantity,
- )
-
-
-def test_calculate_checkout_line_total_with_excluded_country(
- vatlayer_plugin, checkout_with_item, shipping_zone, address, site_settings
-):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
- assert line.quantity > 1
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- checkout_with_item.save()
-
- variant = line.variant
- product = variant.product
- manager.assign_tax_code_to_object_meta(variant.product, "standard")
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- line_price = manager.calculate_checkout_line_total(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- assert line_price == TaxedMoney(
- net=Money("10.00", "USD") * line.quantity,
- gross=Money("10.00", "USD") * line.quantity,
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_update_taxes_for_order_lines(vatlayer, order_with_lines):
- # given
- currency = order_with_lines.currency
- manager = get_plugins_manager()
-
- # when
- lines = manager.update_taxes_for_order_lines(
- order_with_lines, list(order_with_lines.lines.all())
- )
-
- # then
- for line in lines:
- assert line.unit_price == TaxedMoney(
- net=quantize_price(line.base_unit_price / Decimal("1.23"), currency),
- gross=line.base_unit_price,
- )
- assert line.undiscounted_unit_price == line.unit_price
- assert line.total_price == TaxedMoney(
- net=quantize_price(
- line.base_unit_price / Decimal("1.23") * line.quantity, currency
- ),
- gross=line.base_unit_price * line.quantity,
- )
- assert line.undiscounted_total_price == line.total_price
- assert line.tax_rate == Decimal("0.23")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_update_taxes_for_order_lines_voucher_on_entire_order(
- vatlayer, order_with_lines, voucher
-):
- # given
- order = order_with_lines
- currency = order.currency
- manager = get_plugins_manager()
-
- order.voucher = voucher
- lines = list(order.lines.all())
- total_amount = sum([line.base_unit_price.amount * line.quantity for line in lines])
- order.undiscounted_total_gross_amount = total_amount
- order.undiscounted_total_net_amount = total_amount
- order.save(
- update_fields=[
- "voucher",
- "undiscounted_total_gross_amount",
- "undiscounted_total_net_amount",
- ]
- )
-
- order_discount_amount = Decimal("5.0")
- order.discounts.create(
- type=OrderDiscountType.VOUCHER,
- value_type=DiscountValueType.FIXED,
- value=order_discount_amount,
- name=voucher.code,
- currency=currency,
- amount_value=order_discount_amount,
- )
-
- # when
- lines = manager.update_taxes_for_order_lines(order, lines)
-
- # then
- for line in lines:
- total_line_price = line.base_unit_price * line.quantity
- discount_amount = quantize_price(
- total_line_price.amount / total_amount * order_discount_amount, currency
- )
- unit_gross = (
- total_line_price - Money(discount_amount, currency)
- ) / line.quantity
- assert line.unit_price == TaxedMoney(
- net=quantize_price(unit_gross / Decimal("1.23"), currency),
- gross=quantize_price(unit_gross, currency),
- )
- assert line.undiscounted_unit_price == TaxedMoney(
- net=quantize_price(line.base_unit_price / Decimal("1.23"), currency),
- gross=line.base_unit_price,
- )
- assert line.total_price == TaxedMoney(
- net=quantize_price(unit_gross / Decimal("1.23"), currency) * line.quantity,
- gross=quantize_price(unit_gross, currency) * line.quantity,
- )
- assert line.undiscounted_total_price == TaxedMoney(
- net=quantize_price(line.base_unit_price / Decimal("1.23"), currency)
- * line.quantity,
- gross=quantize_price(line.base_unit_price * line.quantity, currency),
- )
- assert line.tax_rate == (line.unit_price.tax / line.unit_price.net).quantize(
- Decimal(".0001")
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_update_taxes_for_order_lines_voucher_on_shipping(
- vatlayer, order_with_lines, voucher_shipping_type
-):
- # given
- order = order_with_lines
- currency = order_with_lines.currency
- manager = get_plugins_manager()
-
- order.voucher = voucher_shipping_type
- lines = list(order.lines.all())
- total_amount = sum([line.base_unit_price.amount * line.quantity for line in lines])
- order.undiscounted_total_gross_amount = total_amount
- order.undiscounted_total_net_amount = total_amount
- order.save(
- update_fields=[
- "voucher",
- "undiscounted_total_gross_amount",
- "undiscounted_total_net_amount",
- ]
- )
-
- order_discount_amount = Decimal("5.0")
- order.discounts.create(
- type=OrderDiscountType.VOUCHER,
- value_type=DiscountValueType.FIXED,
- value=order_discount_amount,
- name=voucher_shipping_type.code,
- currency=currency,
- amount_value=order_discount_amount,
- )
-
- # when
- lines = manager.update_taxes_for_order_lines(
- order_with_lines, list(order_with_lines.lines.all())
- )
-
- # then
- for line in lines:
- assert line.unit_price == TaxedMoney(
- net=quantize_price(line.base_unit_price / Decimal("1.23"), currency),
- gross=line.base_unit_price,
- )
- assert line.undiscounted_unit_price == line.unit_price
- assert line.total_price == TaxedMoney(
- net=quantize_price(
- line.base_unit_price / Decimal("1.23") * line.quantity, currency
- ),
- gross=line.base_unit_price * line.quantity,
- )
- assert line.undiscounted_total_price == line.total_price
- assert line.tax_rate == Decimal("0.23")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_line_unit_price(
- vatlayer, checkout_with_item, shipping_zone, address, site_settings
-):
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- checkout_with_item.save()
-
- variant = line.variant
- product = variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- line_price = manager.calculate_checkout_line_unit_price(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- assert line_price == TaxedMoney(
- net=Money("8.13", "USD"), gross=Money("10.00", "USD")
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_line_unit_price_with_voucher_one_line(
- vatlayer, checkout_with_item, shipping_zone, address, voucher, site_settings
-):
- # given
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- discount_amount = Decimal("5")
- checkout_with_item.discount_amount = discount_amount
- checkout_with_item.voucher_code = voucher.code
- checkout_with_item.save()
-
- variant = line.variant
- product = variant.product
- channel = checkout_with_item.channel
- channel_listing = variant.channel_listings.get(channel=channel)
- total_price = channel_listing.price * line.quantity
- manager.assign_tax_code_to_object_meta(variant.product, "standard")
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- # when
- line_price = manager.calculate_checkout_line_unit_price(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- # then
- currency = checkout_with_item.currency
- unit_gross = Money(total_price.amount - discount_amount, currency) / line.quantity
- assert line_price == TaxedMoney(
- net=quantize_price(unit_gross / Decimal("1.23"), currency),
- gross=quantize_price(unit_gross, currency),
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_line_unit_price_with_voucher_multiple_lines(
- vatlayer, checkout_with_item, shipping_zone, address, voucher, product_list
-):
- # given
- manager = get_plugins_manager()
-
- checkout_with_item
- checkout_info = fetch_checkout_info(checkout_with_item, [], [], manager)
- variant_1 = product_list[0].variants.last()
- variant_2 = product_list[1].variants.last()
- qty_1 = 2
- qty_2 = 3
- add_variant_to_checkout(checkout_info, variant_1, qty_1)
- add_variant_to_checkout(checkout_info, variant_2, qty_2)
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- discount_amount = Decimal("5")
- checkout_with_item.discount_amount = discount_amount
- checkout_with_item.voucher_code = voucher.code
- checkout_with_item.save()
-
- line = checkout_with_item.lines.first()
- variant = line.variant
- product = variant.product
- channel = checkout_with_item.channel
- channel_listing = variant.channel_listings.get(channel=channel)
- total_line_price = channel_listing.price * line.quantity
- manager.assign_tax_code_to_object_meta(variant.product, "standard")
- product.save()
-
- total_unit_prices = (
- variant_1.channel_listings.get(channel=channel).price * qty_1
- + variant_2.channel_listings.get(channel=channel).price * qty_2
- + total_line_price
- )
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- # when
- line_price = manager.calculate_checkout_line_unit_price(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- # then
- currency = checkout_with_item.currency
- discount_amount = quantize_price(
- total_line_price / total_unit_prices * discount_amount, currency
- )
- unit_gross = (total_line_price - Money(discount_amount, currency)) / line.quantity
- assert line_price == TaxedMoney(
- net=quantize_price(unit_gross / Decimal("1.23"), currency),
- gross=quantize_price(unit_gross, currency),
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_line_unit_price_with_voucher_multiple_lines_last_line(
- vatlayer, checkout_with_item, shipping_zone, address, voucher, product_list
-):
- # given
- manager = get_plugins_manager()
- currency = checkout_with_item.currency
-
- checkout_info = fetch_checkout_info(checkout_with_item, [], [], manager)
- variant_1 = product_list[0].variants.last()
- variant_2 = product_list[1].variants.last()
- qty_1 = 2
- qty_2 = 3
- add_variant_to_checkout(checkout_info, variant_1, qty_1)
- add_variant_to_checkout(checkout_info, variant_2, qty_2)
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- discount_amount = Decimal("5")
- checkout_with_item.discount_amount = discount_amount
- checkout_with_item.voucher_code = voucher.code
- checkout_with_item.save()
-
- line = checkout_with_item.lines.last()
- variant = line.variant
- product = variant.product
- channel = checkout_with_item.channel
- channel_listing = variant.channel_listings.get(channel=channel)
- total_line_price = channel_listing.price * line.quantity
- manager.assign_tax_code_to_object_meta(variant.product, "standard")
- product.save()
-
- total_unit_prices = Money(
- sum(
- [
- line.variant.channel_listings.get(channel=channel).price.amount
- * line.quantity
- for line in checkout_with_item.lines.all()
- ]
- ),
- currency,
- )
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[-1]
-
- # when
- line_price = manager.calculate_checkout_line_unit_price(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- # then
- discount_amount = (
- discount_amount
- - (total_unit_prices - total_line_price) / total_unit_prices * discount_amount
- )
- unit_gross = (total_line_price - Money(discount_amount, currency)) / line.quantity
- assert line_price == TaxedMoney(
- net=quantize_price(unit_gross / Decimal("1.23"), currency),
- gross=quantize_price(unit_gross, currency),
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_line_unit_price_with_shipping_voucher(
- vatlayer,
- checkout_with_item,
- shipping_zone,
- address,
- voucher_shipping_type,
- site_settings,
-):
- # given
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
-
- method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method_name = method.name
- checkout_with_item.shipping_method = method
- checkout_with_item.discount_amount = Decimal("5")
- checkout_with_item.voucher_code = voucher_shipping_type.code
- checkout_with_item.save()
-
- variant = line.variant
- product = variant.product
- channel = checkout_with_item.channel
- channel_listing = variant.channel_listings.get(channel=channel)
- unit_gross = channel_listing.price
- manager.assign_tax_code_to_object_meta(variant.product, "standard")
- product.save()
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- # when
- line_price = manager.calculate_checkout_line_unit_price(
- checkout_info,
- lines,
- checkout_line_info,
- address,
- [],
- )
-
- # then
- assert line_price == TaxedMoney(
- net=quantize_price(unit_gross / Decimal("1.23"), checkout_with_item.currency),
- gross=unit_gross,
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_tax_rate_percentage_value(
- vatlayer, order_line, shipping_zone, site_settings, product
-):
- manager = get_plugins_manager()
- country = Country("PL")
- tax_rate = manager.get_tax_rate_percentage_value(product, country)
- assert tax_rate == Decimal("23")
-
-
-def test_get_tax_rate_percentage_value_from_origin_country(
- vatlayer_plugin, order_line, shipping_zone, site_settings, product
-):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- country = Country("PL")
- tax_rate = manager.get_tax_rate_percentage_value(product, country)
- # make sure that we return DE tax rate
- assert tax_rate == Decimal("19")
-
-
-def test_get_tax_rate_percentage_value_with_excluded_country(
- vatlayer_plugin, order_line, shipping_zone, site_settings, product
-):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- country = Country("PL")
- tax_rate = manager.get_tax_rate_percentage_value(product, country)
-
- assert tax_rate == Decimal("0")
-
-
-def test_save_plugin_configuration(vatlayer, settings, channel_USD):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- manager.save_plugin_configuration(
- VatlayerPlugin.PLUGIN_ID, channel_USD.slug, {"active": False}
- )
-
- configuration = PluginConfiguration.objects.get(identifier=VatlayerPlugin.PLUGIN_ID)
- assert not configuration.active
-
-
-def test_save_plugin_configuration_cannot_be_enabled_without_config(
- settings, channel_USD
-):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- with pytest.raises(ValidationError):
- manager.save_plugin_configuration(
- VatlayerPlugin.PLUGIN_ID,
- channel_USD.slug,
- {"active": True},
- )
-
-
-def test_show_taxes_on_storefront(vatlayer, settings):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- assert manager.show_taxes_on_storefront() is True
-
-
-def test_get_tax_rate_type_choices(vatlayer, settings, monkeypatch):
- expected_choices = [
- "accommodation",
- "admission to cultural events",
- "admission to entertainment events",
- ]
- monkeypatch.setattr(
- "saleor.plugins.vatlayer.plugin.get_tax_rate_types",
- lambda: expected_choices,
- )
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- choices = manager.get_tax_rate_type_choices()
-
- # add a default choice
- expected_choices.append("standard")
-
- assert len(choices) == 4
- for choice in choices:
- assert choice.code in expected_choices
-
-
-def test_apply_taxes_to_product(
- vatlayer, settings, variant, discount_info, channel_USD
-):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- country = Country("PL")
- manager = get_plugins_manager()
- variant.product.metadata = {
- "vatlayer.code": "standard",
- "vatlayer.description": "standard",
- }
- variant_channel_listing = variant.channel_listings.get(channel=channel_USD)
- price = manager.apply_taxes_to_product(
- variant.product,
- variant.get_price(
- variant.product, [], channel_USD, variant_channel_listing, [discount_info]
- ),
- country,
- channel_USD.slug,
- )
- assert price == TaxedMoney(net=Money("4.07", "USD"), gross=Money("5.00", "USD"))
-
-
-def test_apply_taxes_to_product_from_origin_country(
- vatlayer_plugin, settings, variant, discount_info, channel_USD
-):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- country = Country("PL")
-
- variant.product.metadata = {
- "vatlayer.code": "standard",
- "vatlayer.description": "standard",
- }
- variant_channel_listing = variant.channel_listings.get(channel=channel_USD)
-
- price = manager.apply_taxes_to_product(
- variant.product,
- variant.get_price(
- variant.product, [], channel_USD, variant_channel_listing, [discount_info]
- ),
- country,
- channel_USD.slug,
- )
-
- assert price == TaxedMoney(net=Money("4.20", "USD"), gross=Money("5.00", "USD"))
-
-
-def test_apply_taxes_to_product_with_excluded_country(
- vatlayer_plugin, settings, variant, discount_info, channel_USD
-):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- country = Country("PL")
-
- variant.product.metadata = {
- "vatlayer.code": "standard",
- "vatlayer.description": "standard",
- }
- variant_channel_listing = variant.channel_listings.get(channel=channel_USD)
-
- price = manager.apply_taxes_to_product(
- variant.product,
- variant.get_price(
- variant.product, [], channel_USD, variant_channel_listing, [discount_info]
- ),
- country,
- channel_USD.slug,
- )
-
- assert price == TaxedMoney(net=Money("5.00", "USD"), gross=Money("5.00", "USD"))
-
-
-def test_apply_taxes_to_product_uses_taxes_from_product_type(
- vatlayer, settings, variant, discount_info, channel_USD
-):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- country = Country("PL")
- manager = get_plugins_manager()
- product = variant.product
- product.metadata = {}
- product.product_type.metadata = {
- "vatlayer.code": "standard",
- "vatlayer.description": "standard",
- }
- variant_channel_listing = variant.channel_listings.get(channel=channel_USD)
- price = manager.apply_taxes_to_product(
- product,
- variant.get_price(
- product, [], channel_USD, variant_channel_listing, [discount_info]
- ),
- country,
- channel_USD.slug,
- )
- assert price == TaxedMoney(net=Money("4.07", "USD"), gross=Money("5.00", "USD"))
-
-
-def test_calculations_checkout_total_with_vatlayer(
- vatlayer, settings, checkout_with_item
-):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_subtotal = calculations.checkout_total(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=checkout_with_item.shipping_address,
- )
- assert checkout_subtotal == TaxedMoney(
- net=Money("30", "USD"), gross=Money("30", "USD")
- )
-
-
-def test_calculations_checkout_subtotal_with_vatlayer(
- vatlayer, settings, checkout_with_item
-):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_subtotal = calculations.checkout_subtotal(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=checkout_with_item.shipping_address,
- )
- assert checkout_subtotal == TaxedMoney(
- net=Money("30", "USD"), gross=Money("30", "USD")
- )
-
-
-def test_calculations_checkout_shipping_price_with_vatlayer(
- vatlayer, settings, checkout_with_item
-):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_shipping_price = calculations.checkout_shipping_price(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=checkout_with_item.shipping_address,
- )
- assert checkout_shipping_price == TaxedMoney(
- net=Money("0", "USD"), gross=Money("0", "USD")
- )
-
-
-def test_skip_disabled_plugin(settings, channel_USD):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- manager = get_plugins_manager()
- plugin: VatlayerPlugin = manager.get_plugin(
- VatlayerPlugin.PLUGIN_ID, channel_USD.slug
- )
-
- assert (
- plugin._skip_plugin(
- previous_value=TaxedMoney(net=Money(0, "USD"), gross=Money(0, "USD"))
- )
- is True
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_checkout_line_tax_rate(
- site_settings,
- vatlayer,
- checkout_with_item,
- address,
- shipping_zone,
-):
- manager = get_plugins_manager()
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
- tax_rate = manager.get_checkout_line_tax_rate(
- checkout_info,
- lines,
- checkout_line_info,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0.230")
-
-
-def test_get_checkout_line_tax_rate_from_origin_country(
- site_settings,
- vatlayer_plugin,
- checkout_with_item,
- address,
- shipping_zone,
-):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
- tax_rate = manager.get_checkout_line_tax_rate(
- checkout_info,
- lines,
- checkout_line_info,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0.190")
-
-
-def test_get_checkout_line_tax_rate_with_excluded_country(
- site_settings,
- vatlayer_plugin,
- checkout_with_item,
- address,
- shipping_zone,
-):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(15, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
- tax_rate = manager.get_checkout_line_tax_rate(
- checkout_info,
- lines,
- checkout_line_info,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_checkout_line_tax_rate_order_not_valid(
- site_settings,
- vatlayer,
- checkout_with_item,
-):
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
- checkout_line_info = lines[0]
-
- tax_rate = manager.get_checkout_line_tax_rate(
- checkout_info,
- lines,
- checkout_line_info,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0.25")
-
-
-def test_get_order_line_tax_rate_from_origin_country(
- site_settings,
- vatlayer_plugin,
- order_line,
- address,
- shipping_zone,
-):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
- product.save()
-
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = address
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.save()
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_line_tax_rate(
- order, product, order_line.variant, address, unit_price
- )
- assert tax_rate == Decimal("0.190")
-
-
-def test_get_order_line_tax_rate_with_excluded_country(
- site_settings,
- vatlayer_plugin,
- order_line,
- address,
- shipping_zone,
-):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
- product.save()
-
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = address
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.save()
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(15, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_line_tax_rate(
- order, product, order_line.variant, address, unit_price
- )
- assert tax_rate == Decimal("0")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_order_line_tax_rate(
- site_settings,
- vatlayer,
- order_line,
- address,
- shipping_zone,
-):
- manager = get_plugins_manager()
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
- product.save()
-
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = address
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.save()
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_line_tax_rate(
- order, product, order_line.variant, address, unit_price
- )
- assert tax_rate == Decimal("0.230")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_order_line_tax_rate_order_no_address_given(
- site_settings,
- order_line,
- vatlayer,
-):
- manager = get_plugins_manager()
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_line_tax_rate(
- order, product, order_line.variant, None, unit_price
- )
- assert tax_rate == Decimal("0.25")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_checkout_shipping_tax_rate(
- site_settings,
- vatlayer,
- checkout_with_item,
- address,
- shipping_zone,
-):
- manager = get_plugins_manager()
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
-
- tax_rate = manager.get_checkout_shipping_tax_rate(
- checkout_info,
- lines,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0.230")
-
-
-def test_get_checkout_shipping_tax_rate_from_origin_country(
- site_settings,
- vatlayer_plugin,
- checkout_with_item,
- address,
- shipping_zone,
-):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
-
- tax_rate = manager.get_checkout_shipping_tax_rate(
- checkout_info,
- lines,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0.190")
-
-
-def test_get_checkout_shipping_tax_rate_with_excluded_country(
- site_settings,
- vatlayer_plugin,
- checkout_with_item,
- address,
- shipping_zone,
-):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(15, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
-
- tax_rate = manager.get_checkout_shipping_tax_rate(
- checkout_info,
- lines,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_checkout_shipping_tax_rate_no_address(
- site_settings,
- vatlayer,
- checkout_with_item,
-):
- manager = get_plugins_manager()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
-
- tax_rate = manager.get_checkout_shipping_tax_rate(
- checkout_info,
- lines,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0.25")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_checkout_shipping_tax_rate_skip_plugin(
- site_settings, vatlayer, checkout_with_item, monkeypatch, address, shipping_zone
-):
- manager = get_plugins_manager()
- monkeypatch.setattr(
- "saleor.plugins.vatlayer.plugin.VatlayerPlugin._skip_plugin",
- lambda *_: True,
- )
-
- checkout_with_item.shipping_address = address
- checkout_with_item.save()
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
-
- line = checkout_with_item.lines.first()
- product = line.variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- unit_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(checkout_with_item, lines, [], manager)
-
- tax_rate = manager.get_checkout_shipping_tax_rate(
- checkout_info,
- lines,
- checkout_with_item.shipping_address,
- [],
- unit_price,
- )
- assert tax_rate == Decimal("0.25")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_order_shipping_tax_rate(
- site_settings,
- vatlayer,
- order_line,
- address,
- shipping_zone,
-):
- manager = get_plugins_manager()
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
- product.save()
-
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = address
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.save()
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- shipping_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_shipping_tax_rate(order, shipping_price)
- assert tax_rate == Decimal("0.230")
-
-
-def test_get_order_shipping_tax_rate_from_origin_country(
- site_settings,
- vatlayer_plugin,
- order_line,
- address,
- shipping_zone,
-):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
- manager = get_plugins_manager()
-
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
- product.save()
-
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = address
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.save()
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- shipping_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_shipping_tax_rate(order, shipping_price)
- assert tax_rate == Decimal("0.190")
-
-
-def test_get_order_shipping_tax_rate_with_excluded_country(
- site_settings,
- vatlayer_plugin,
- order_line,
- address,
- shipping_zone,
-):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
- manager = get_plugins_manager()
-
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
- product.save()
-
- method = shipping_zone.shipping_methods.get()
- order.shipping_address = address
- order.shipping_method_name = method.name
- order.shipping_method = method
- order.save()
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- shipping_price = TaxedMoney(Money(15, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_shipping_tax_rate(order, shipping_price)
- assert tax_rate == Decimal("0")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_order_shipping_tax_rate_no_address_given(
- site_settings,
- order_line,
- vatlayer,
-):
- manager = get_plugins_manager()
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- order.shipping_address = None
- order.billing_address = None
- order.save(update_fields=["shipping_address", "billing_address"])
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- shipping_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_shipping_tax_rate(order, shipping_price)
- assert tax_rate == Decimal("0.25")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_get_order_shipping_tax_rate_skip_plugin(
- site_settings, order_line, vatlayer, monkeypatch
-):
- manager = get_plugins_manager()
- monkeypatch.setattr(
- "saleor.plugins.vatlayer.plugin.VatlayerPlugin._skip_plugin",
- lambda *_: True,
- )
- order = order_line.order
- product = Product.objects.get(name=order_line.product_name)
-
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
-
- site_settings.include_taxes_in_prices = True
- site_settings.save()
-
- shipping_price = TaxedMoney(Money(12, "USD"), Money(15, "USD"))
-
- tax_rate = manager.get_order_shipping_tax_rate(order, shipping_price)
- assert tax_rate == Decimal("0.25")
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_shipping(
- checkout_with_item,
- shipping_zone,
- discount_info,
- address,
- site_settings,
- vatlayer,
-):
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
- shipping_price = manager.calculate_checkout_shipping(
- checkout_info, lines, address, [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")
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_shipping_no_shipping_price(
- checkout_with_item,
- discount_info,
- address,
- warehouse_for_cc,
- vatlayer,
-):
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- checkout_with_item.collection_point = warehouse_for_cc
- checkout_with_item.save(update_fields=["shipping_address", "collection_point"])
-
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
- shipping_price = manager.calculate_checkout_shipping(
- checkout_info, lines, address, [discount_info]
- )
- shipping_price = quantize_price(shipping_price, shipping_price.currency)
- assert shipping_price == TaxedMoney(
- net=Money("0.00", "USD"), gross=Money("0.00", "USD")
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_shipping_voucher_on_shipping(
- checkout_with_item,
- shipping_zone,
- discount_info,
- address,
- voucher_shipping_type,
- site_settings,
- vatlayer,
-):
- # given
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_method = shipping_method
- checkout_with_item.voucher_code = voucher_shipping_type.code
- discount_amount = Decimal("5.0")
- checkout_with_item.discount_amount = discount_amount
- checkout_with_item.save()
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
- channel = checkout_with_item.channel
- shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
- price = shipping_channel_listings.price
-
- # when
- shipping_price = manager.calculate_checkout_shipping(
- checkout_info, lines, address, [discount_info]
- )
-
- # then
- shipping_price = quantize_price(shipping_price, shipping_price.currency)
- currency = checkout_with_item.currency
- expected_gross_shipping_price = Money(price.amount - discount_amount, currency)
- assert shipping_price == TaxedMoney(
- net=quantize_price(expected_gross_shipping_price / Decimal(1.23), currency),
- gross=expected_gross_shipping_price,
- )
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_shipping_free_shipping_voucher(
- checkout_with_item,
- shipping_zone,
- discount_info,
- address,
- voucher_shipping_type,
- site_settings,
- vatlayer,
-):
- # given
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_method = shipping_method
- checkout_with_item.voucher_code = voucher_shipping_type.code
- channel = checkout_with_item.channel
- shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
- price = shipping_channel_listings.price
- checkout_with_item.discount_amount = price.amount
- checkout_with_item.save()
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
-
- # when
- shipping_price = manager.calculate_checkout_shipping(
- checkout_info, lines, address, [discount_info]
- )
-
- # then
- shipping_price = quantize_price(shipping_price, shipping_price.currency)
- assert shipping_price == zero_taxed_money(checkout_with_item.currency)
-
-
-@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_checkout_shipping_free_entire_order_voucher(
- checkout_with_item,
- shipping_zone,
- discount_info,
- address,
- voucher,
- site_settings,
- vatlayer,
-):
- # given
- manager = get_plugins_manager()
-
- checkout_with_item.shipping_address = address
- shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.shipping_method = shipping_method
- checkout_with_item.voucher_code = voucher.code
- channel = checkout_with_item.channel
- shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
- discount_amount = Decimal("5.0")
- checkout_with_item.discount_amount = discount_amount
- checkout_with_item.save()
- lines, _ = fetch_checkout_lines(checkout_with_item)
- checkout_info = fetch_checkout_info(
- checkout_with_item, lines, [discount_info], manager
- )
-
- # when
- shipping_price = manager.calculate_checkout_shipping(
- checkout_info, lines, address, [discount_info]
- )
-
- # then
- shipping_price = quantize_price(shipping_price, shipping_price.currency)
- assert (
- shipping_price
- == shipping_price
- == TaxedMoney(
- net=quantize_price(
- shipping_channel_listings.price / Decimal(1.23),
- checkout_with_item.currency,
- ),
- gross=shipping_channel_listings.price,
- )
- )
diff --git a/saleor/plugins/webhook/plugin.py b/saleor/plugins/webhook/plugin.py
index b64b6f472e..0196504653 100644
--- a/saleor/plugins/webhook/plugin.py
+++ b/saleor/plugins/webhook/plugin.py
@@ -88,6 +88,7 @@ if TYPE_CHECKING:
)
from ...shipping.interface import ShippingMethodData
from ...shipping.models import ShippingMethod, ShippingZone
+ from ...tax.models import TaxClass
from ...translation.models import Translation
from ...warehouse.models import Stock, Warehouse
@@ -1502,7 +1503,7 @@ class WebhookPlugin(BasePlugin):
return methods
def get_tax_code_from_object_meta(
- self, obj: Union["Product", "ProductType"], previous_value: Any
+ self, obj: Union["Product", "ProductType", "TaxClass"], previous_value: Any
):
"""Get tax code and description for a product or product type.
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_taxes.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_taxes.py
index be4d63839c..a114fa6e84 100644
--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_taxes.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_taxes.py
@@ -3,6 +3,7 @@ from decimal import Decimal
from functools import partial
from unittest.mock import ANY
+import pytest
from freezegun import freeze_time
from prices import Money, fixed_discount
@@ -81,10 +82,12 @@ subscription {
@freeze_time("2020-03-18 12:00:00")
[email protected]("charge_taxes", [True, False])
def test_checkout_calculate_taxes(
checkout_ready_to_complete,
webhook_app,
permission_handle_taxes,
+ charge_taxes,
):
# given
webhook_app.permissions.add(permission_handle_taxes)
@@ -98,6 +101,11 @@ def test_checkout_calculate_taxes(
event_type = WebhookEventSyncType.CHECKOUT_CALCULATE_TAXES
webhook.events.create(event_type=event_type)
+ tax_configuration = checkout_ready_to_complete.channel.tax_configuration
+ tax_configuration.charge_taxes = charge_taxes
+ tax_configuration.save(update_fields=["charge_taxes"])
+ tax_configuration.country_exceptions.all().delete()
+
# when
deliveries = create_delivery_for_subscription_sync_event(
event_type, checkout_ready_to_complete, webhook
@@ -115,7 +123,6 @@ def test_checkout_calculate_taxes(
"channel": {"id": to_global_id_or_none(checkout_ready_to_complete.channel)},
"lines": [
{
- "chargeTaxes": True,
"productName": "Test product",
"productSku": "123",
"quantity": 3,
@@ -125,6 +132,7 @@ def test_checkout_calculate_taxes(
),
"__typename": "CheckoutLine",
},
+ "chargeTaxes": charge_taxes,
"totalPrice": {"amount": 30.0},
"unitPrice": {"amount": 10.0},
"variantName": "",
@@ -342,8 +350,9 @@ def test_checkout_calculate_taxes_empty_checkout(
@freeze_time("2020-03-18 12:00:00")
[email protected]("charge_taxes", [True, False])
def test_order_calculate_taxes(
- order_line, webhook_app, permission_handle_taxes, shipping_zone
+ order_line, webhook_app, permission_handle_taxes, shipping_zone, charge_taxes
):
# given
@@ -364,6 +373,11 @@ def test_order_calculate_taxes(
event_type = WebhookEventSyncType.ORDER_CALCULATE_TAXES
webhook.events.create(event_type=event_type)
+ tax_configuration = order.channel.tax_configuration
+ tax_configuration.charge_taxes = charge_taxes
+ tax_configuration.save(update_fields=["charge_taxes"])
+ tax_configuration.country_exceptions.all().delete()
+
# when
deliveries = create_delivery_for_subscription_sync_event(event_type, order, webhook)
@@ -382,7 +396,7 @@ def test_order_calculate_taxes(
"channel": {"id": to_global_id_or_none(order.channel)},
"lines": [
{
- "chargeTaxes": True,
+ "chargeTaxes": charge_taxes,
"productName": "Test product",
"productSku": "SKU_A",
"quantity": 3,
diff --git a/saleor/product/migrations/0177_product_tax_class_producttype_tax_class.py b/saleor/product/migrations/0177_product_tax_class_producttype_tax_class.py
new file mode 100644
index 0000000000..083c3887a3
--- /dev/null
+++ b/saleor/product/migrations/0177_product_tax_class_producttype_tax_class.py
@@ -0,0 +1,37 @@
+# Generated by Django 4.0.7 on 2022-10-26 09:46
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("tax", "0001_initial"),
+ ("product", "0176_merge_20221007_1324"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="product",
+ name="tax_class",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="products",
+ to="tax.taxclass",
+ ),
+ ),
+ migrations.AddField(
+ model_name="producttype",
+ name="tax_class",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="product_types",
+ to="tax.taxclass",
+ ),
+ ),
+ ]
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 5abe282bc6..ea0d26a3d9 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -56,6 +56,7 @@ from ..core.weight import zero_weight
from ..discount import DiscountInfo
from ..discount.utils import calculate_discounted_price
from ..seo.models import SeoModel, SeoModelTranslation
+from ..tax.models import TaxClass
from . import ProductMediaTypes, ProductTypeKind
if TYPE_CHECKING:
@@ -153,6 +154,13 @@ class ProductType(ModelWithMetadata):
unit_choices=WeightUnits.CHOICES, # type: ignore
default=zero_weight,
)
+ tax_class = models.ForeignKey(
+ TaxClass,
+ related_name="product_types",
+ on_delete=models.SET_NULL,
+ blank=True,
+ null=True,
+ )
class Meta(ModelWithMetadata.Meta):
ordering = ("slug",)
@@ -418,6 +426,13 @@ class Product(SeoModel, ModelWithMetadata):
related_name="+",
)
rating = models.FloatField(null=True, blank=True)
+ tax_class = models.ForeignKey(
+ TaxClass,
+ related_name="products",
+ blank=True,
+ null=True,
+ on_delete=models.SET_NULL,
+ )
objects = models.Manager.from_queryset(ProductsQueryset)()
translated = TranslationProxy()
diff --git a/saleor/product/tests/test_product.py b/saleor/product/tests/test_product.py
index fea5c7c53c..2dbb88ab79 100644
--- a/saleor/product/tests/test_product.py
+++ b/saleor/product/tests/test_product.py
@@ -245,27 +245,6 @@ def test_get_price(
assert price.amount == expected_price
-def test_product_get_price_do_not_charge_taxes(
- product_type, category, discount_info, channel_USD
-):
- product = models.Product.objects.create(
- product_type=product_type,
- category=category,
- charge_taxes=False,
- )
- variant = product.variants.create()
- channel_listing = models.ProductVariantChannelListing.objects.create(
- variant=variant,
- channel=channel_USD,
- price_amount=Decimal(10),
- currency=channel_USD.currency_code,
- )
- price = variant.get_price(
- product, [], channel_USD, channel_listing, discounts=[discount_info]
- )
- assert price == Money("5.00", "USD")
-
-
def test_digital_product_view(client, digital_content_url):
"""Ensure a user (anonymous or not) can download a non-expired digital good
using its associated token and that all associated events
diff --git a/saleor/product/tests/test_product_availability.py b/saleor/product/tests/test_product_availability.py
index 5b9d75045c..6a840e501d 100644
--- a/saleor/product/tests/test_product_availability.py
+++ b/saleor/product/tests/test_product_availability.py
@@ -3,37 +3,45 @@ from decimal import Decimal
from unittest.mock import Mock
from django.utils import timezone
-from django_countries.fields import Country
from freezegun import freeze_time
from prices import Money, TaxedMoney, TaxedMoneyRange
-from ...plugins.manager import PluginsManager, get_plugins_manager
+from ...tax import TaxCalculationStrategy
from .. import models
from ..utils.availability import get_product_availability
def test_availability(stock, monkeypatch, settings, channel_USD):
product = stock.product_variant.product
+ tax_class = product.tax_class or product.product_type.tax_class
+
+ tc = channel_USD.tax_configuration
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.charge_taxes = True
+ tc.prices_entered_with_tax = False
+ tc.save()
+
+ tax_rate = Decimal(23)
+ country = "PL"
+ tax_class.country_rates.update_or_create(rate=tax_rate, country=country)
+
product_channel_listing = product.channel_listings.first()
variants = product.variants.all()
variants_channel_listing = models.ProductVariantChannelListing.objects.filter(
variant__in=variants
)
taxed_price = TaxedMoney(Money("10.0", "USD"), Money("12.30", "USD"))
- monkeypatch.setattr(
- PluginsManager, "apply_taxes_to_product", Mock(return_value=taxed_price)
- )
- manager = get_plugins_manager()
availability = get_product_availability(
product=product,
product_channel_listing=product_channel_listing,
variants=product.variants.all(),
variants_channel_listing=variants_channel_listing,
channel=channel_USD,
- manager=manager,
collections=[],
discounts=[],
- country=Country("PL"),
+ tax_rate=tax_rate,
+ tax_calculation_strategy=tc.tax_calculation_strategy,
+ prices_entered_with_tax=tc.prices_entered_with_tax,
)
taxed_price_range = TaxedMoneyRange(start=taxed_price, stop=taxed_price)
assert availability.price_range == taxed_price_range
@@ -53,9 +61,10 @@ def test_availability(stock, monkeypatch, settings, channel_USD):
collections=[],
discounts=[],
channel=channel_USD,
- manager=manager,
local_currency="PLN",
- country=Country("PL"),
+ tax_rate=tax_rate,
+ tax_calculation_strategy=tc.tax_calculation_strategy,
+ prices_entered_with_tax=tc.prices_entered_with_tax,
)
assert availability.price_range_local_currency.start.currency == "PLN"
@@ -67,8 +76,9 @@ def test_availability(stock, monkeypatch, settings, channel_USD):
collections=[],
discounts=[],
channel=channel_USD,
- manager=manager,
- country=Country("PL"),
+ tax_rate=tax_rate,
+ tax_calculation_strategy=tc.tax_calculation_strategy,
+ prices_entered_with_tax=tc.prices_entered_with_tax,
)
assert availability.price_range.start.tax.amount
assert availability.price_range.stop.tax.amount
@@ -78,6 +88,8 @@ def test_availability(stock, monkeypatch, settings, channel_USD):
def test_availability_with_all_variant_channel_listings(stock, channel_USD):
# given
+ tax_config = channel_USD.tax_configuration
+
product = stock.product_variant.product
product_channel_listing = product.channel_listings.first()
variants = product.variants.all()
@@ -87,7 +99,6 @@ def test_availability_with_all_variant_channel_listings(stock, channel_USD):
[variant1_channel_listing, variant2_channel_listing] = variants_channel_listing
variant2_channel_listing.price_amount = Decimal(15)
variant2_channel_listing.save()
- manager = get_plugins_manager()
# when
availability = get_product_availability(
@@ -96,10 +107,11 @@ def test_availability_with_all_variant_channel_listings(stock, channel_USD):
variants=variants,
variants_channel_listing=variants_channel_listing,
channel=channel_USD,
- manager=manager,
collections=[],
discounts=[],
- country=Country("PL"),
+ prices_entered_with_tax=tax_config.prices_entered_with_tax,
+ tax_calculation_strategy=tax_config.tax_calculation_strategy,
+ tax_rate=Decimal(0),
)
# then
@@ -111,6 +123,7 @@ def test_availability_with_all_variant_channel_listings(stock, channel_USD):
def test_availability_with_missing_variant_channel_listings(stock, channel_USD):
# given
product = stock.product_variant.product
+
product_channel_listing = product.channel_listings.first()
variants = product.variants.all()
variants_channel_listing = models.ProductVariantChannelListing.objects.filter(
@@ -118,7 +131,6 @@ def test_availability_with_missing_variant_channel_listings(stock, channel_USD):
)
[variant1_channel_listing, variant2_channel_listing] = variants_channel_listing
variant2_channel_listing.delete()
- manager = get_plugins_manager()
# when
availability = get_product_availability(
@@ -127,10 +139,11 @@ def test_availability_with_missing_variant_channel_listings(stock, channel_USD):
variants=variants,
variants_channel_listing=variants_channel_listing,
channel=channel_USD,
- manager=manager,
collections=[],
discounts=[],
- country=Country("PL"),
+ prices_entered_with_tax=channel_USD.tax_configuration.prices_entered_with_tax,
+ tax_calculation_strategy=None,
+ tax_rate=Decimal(0),
)
# then
@@ -147,7 +160,6 @@ def test_availability_without_variant_channel_listings(stock, channel_USD):
models.ProductVariantChannelListing.objects.filter(
variant__in=variants, channel=channel_USD
).delete()
- manager = get_plugins_manager()
# when
availability = get_product_availability(
@@ -156,10 +168,11 @@ def test_availability_without_variant_channel_listings(stock, channel_USD):
variants=variants,
variants_channel_listing=[],
channel=channel_USD,
- manager=manager,
collections=[],
discounts=[],
- country=Country("PL"),
+ tax_rate=Decimal(0),
+ tax_calculation_strategy=None,
+ prices_entered_with_tax=True,
)
# then
diff --git a/saleor/product/utils/availability.py b/saleor/product/utils/availability.py
index cb34663bd0..c540913c4c 100644
--- a/saleor/product/utils/availability.py
+++ b/saleor/product/utils/availability.py
@@ -1,8 +1,8 @@
from dataclasses import dataclass
-from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union
+from decimal import Decimal
+from typing import Iterable, List, Optional, Tuple, Union
-from django_countries.fields import Country
-from prices import MoneyRange, TaxedMoney, TaxedMoneyRange
+from prices import Money, MoneyRange, TaxedMoney, TaxedMoneyRange
from ...channel.models import Channel
from ...core.utils import to_local_currency
@@ -15,9 +15,8 @@ from ...product.models import (
ProductVariant,
ProductVariantChannelListing,
)
-
-if TYPE_CHECKING:
- from ...plugins.manager import PluginsManager
+from ...tax import TaxCalculationStrategy
+from ...tax.calculations import calculate_flat_rate_tax
@dataclass
@@ -134,6 +133,20 @@ def get_product_price_range(
return None
+def _calculate_product_price_with_taxes(
+ price: Money,
+ tax_rate: Decimal,
+ tax_calculation_strategy: str,
+ prices_entered_with_tax: bool,
+):
+ # Currently only FLAT_RATES strategy allows calculating taxes for product types;
+ # support for apps will be added in the future.
+ if tax_calculation_strategy == TaxCalculationStrategy.FLAT_RATES:
+ return calculate_flat_rate_tax(price, tax_rate, prices_entered_with_tax)
+ else:
+ return TaxedMoney(price, price)
+
+
def get_product_availability(
*,
product: Product,
@@ -143,12 +156,11 @@ def get_product_availability(
collections: Iterable[Collection],
discounts: Iterable[DiscountInfo],
channel: Channel,
- manager: "PluginsManager",
- country: Country,
local_currency: Optional[str] = None,
+ prices_entered_with_tax: bool,
+ tax_calculation_strategy: str,
+ tax_rate: Decimal
) -> ProductAvailability:
- channel_slug = channel.slug
-
discounted = None
discounted_net_range = get_product_price_range(
product=product,
@@ -160,17 +172,17 @@ def get_product_availability(
)
if discounted_net_range is not None:
discounted = TaxedMoneyRange(
- start=manager.apply_taxes_to_product(
- product,
+ start=_calculate_product_price_with_taxes(
discounted_net_range.start,
- country,
- channel_slug=channel_slug,
+ tax_rate,
+ tax_calculation_strategy,
+ prices_entered_with_tax,
),
- stop=manager.apply_taxes_to_product(
- product,
+ stop=_calculate_product_price_with_taxes(
discounted_net_range.stop,
- country,
- channel_slug=channel_slug,
+ tax_rate,
+ tax_calculation_strategy,
+ prices_entered_with_tax,
),
)
@@ -185,17 +197,17 @@ def get_product_availability(
)
if undiscounted_net_range is not None:
undiscounted = TaxedMoneyRange(
- start=manager.apply_taxes_to_product(
- product,
+ start=_calculate_product_price_with_taxes(
undiscounted_net_range.start,
- country,
- channel_slug=channel_slug,
+ tax_rate,
+ tax_calculation_strategy,
+ prices_entered_with_tax,
),
- stop=manager.apply_taxes_to_product(
- product,
+ stop=_calculate_product_price_with_taxes(
undiscounted_net_range.stop,
- country,
- channel_slug=channel_slug,
+ tax_rate,
+ tax_calculation_strategy,
+ prices_entered_with_tax,
),
)
@@ -224,6 +236,7 @@ def get_product_availability(
def get_variant_availability(
+ *,
variant: ProductVariant,
variant_channel_listing: ProductVariantChannelListing,
product: Product,
@@ -231,42 +244,43 @@ def get_variant_availability(
collections: Iterable[Collection],
discounts: Iterable[DiscountInfo],
channel: Channel,
- plugins: "PluginsManager",
- country: Country,
local_currency: Optional[str] = None,
+ prices_entered_with_tax: bool,
+ tax_calculation_strategy: str,
+ tax_rate: Decimal
) -> VariantAvailability:
- channel_slug = channel.slug
- discounted = plugins.apply_taxes_to_product(
- product,
- get_variant_price(
- variant=variant,
- variant_channel_listing=variant_channel_listing,
- product=product,
- collections=collections,
- discounts=discounts,
- channel=channel,
- ),
- country,
- channel_slug=channel_slug,
+ discounted_price = get_variant_price(
+ variant=variant,
+ variant_channel_listing=variant_channel_listing,
+ product=product,
+ collections=collections,
+ discounts=discounts,
+ channel=channel,
)
- undiscounted = plugins.apply_taxes_to_product(
- product,
- get_variant_price(
- variant=variant,
- variant_channel_listing=variant_channel_listing,
- product=product,
- collections=collections,
- discounts=[],
- channel=channel,
- ),
- country,
- channel_slug=channel_slug,
+ discounted_price_taxed = _calculate_product_price_with_taxes(
+ discounted_price,
+ tax_rate,
+ tax_calculation_strategy,
+ prices_entered_with_tax,
)
-
- discount = _get_total_discount(undiscounted, discounted)
+ undiscounted_price = get_variant_price(
+ variant=variant,
+ variant_channel_listing=variant_channel_listing,
+ product=product,
+ collections=collections,
+ discounts=[],
+ channel=channel,
+ )
+ undiscounted_price_taxed = _calculate_product_price_with_taxes(
+ undiscounted_price,
+ tax_rate,
+ tax_calculation_strategy,
+ prices_entered_with_tax,
+ )
+ discount = _get_total_discount(undiscounted_price_taxed, discounted_price_taxed)
if local_currency:
- price_local_currency = to_local_currency(discounted, local_currency)
+ price_local_currency = to_local_currency(discounted_price_taxed, local_currency)
discount_local_currency = to_local_currency(discount, local_currency)
else:
price_local_currency = None
@@ -279,8 +293,8 @@ def get_variant_availability(
return VariantAvailability(
on_sale=is_on_sale,
- price=discounted,
- price_undiscounted=undiscounted,
+ price=discounted_price_taxed,
+ price_undiscounted=undiscounted_price_taxed,
discount=discount,
price_local_currency=price_local_currency,
discount_local_currency=discount_local_currency,
diff --git a/saleor/settings.py b/saleor/settings.py
index 23cda89a6d..86027fec33 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -243,10 +243,10 @@ INSTALLED_APPS = [
"saleor.site",
"saleor.page",
"saleor.payment",
+ "saleor.tax",
"saleor.warehouse",
"saleor.webhook",
"saleor.app",
- "saleor.tax",
"saleor.thumbnail",
"saleor.schedulers",
# External apps
@@ -678,7 +678,6 @@ FEDERATED_QUERY_MAX_ENTITIES = int(os.environ.get("FEDERATED_QUERY_MAX_ENTITIES"
BUILTIN_PLUGINS = [
"saleor.plugins.avatax.plugin.AvataxPlugin",
- "saleor.plugins.vatlayer.plugin.VatlayerPlugin",
"saleor.plugins.webhook.plugin.WebhookPlugin",
"saleor.payment.gateways.dummy.plugin.DummyGatewayPlugin",
"saleor.payment.gateways.dummy_credit_card.plugin.DummyCreditCardGatewayPlugin",
diff --git a/saleor/shipping/interface.py b/saleor/shipping/interface.py
index 21f233e794..9be3a89f21 100644
--- a/saleor/shipping/interface.py
+++ b/saleor/shipping/interface.py
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
-from typing import Dict, Optional
+from typing import TYPE_CHECKING, Dict, Optional
import graphene
import graphql
@@ -9,6 +9,9 @@ from prices import Money
from ..graphql.core.utils import from_global_id_or_error
from ..plugins.webhook.utils import APP_ID_PREFIX
+if TYPE_CHECKING:
+ from ..tax.models import TaxClass
+
@dataclass
class ShippingMethodData:
@@ -27,6 +30,7 @@ class ShippingMethodData:
minimum_delivery_days: Optional[int] = None
metadata: Dict[str, str] = field(default_factory=dict)
private_metadata: Dict[str, str] = field(default_factory=dict)
+ tax_class: Optional["TaxClass"] = None
active: bool = True
message: str = ""
diff --git a/saleor/shipping/migrations/0032_shippingmethod_tax_class.py b/saleor/shipping/migrations/0032_shippingmethod_tax_class.py
new file mode 100644
index 0000000000..8d1c20ab7c
--- /dev/null
+++ b/saleor/shipping/migrations/0032_shippingmethod_tax_class.py
@@ -0,0 +1,26 @@
+# Generated by Django 4.0.7 on 2022-09-14 13:15
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("tax", "0001_initial"),
+ ("shipping", "0031_alter_shippingmethodtranslation_language_code"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="shippingmethod",
+ name="tax_class",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="shipping_methods",
+ to="tax.taxclass",
+ ),
+ ),
+ ]
diff --git a/saleor/shipping/models.py b/saleor/shipping/models.py
index b39f4806d4..109b976637 100644
--- a/saleor/shipping/models.py
+++ b/saleor/shipping/models.py
@@ -17,6 +17,7 @@ from ..core.units import WeightUnits
from ..core.utils.editorjs import clean_editor_js
from ..core.utils.translations import Translation, TranslationProxy
from ..core.weight import convert_weight, get_default_weight_unit, zero_weight
+from ..tax.models import TaxClass
from . import PostalCodeRuleInclusionType, ShippingMethodType
from .postal_codes import filter_shipping_methods_by_postal_code_rules
@@ -203,6 +204,13 @@ class ShippingMethod(ModelWithMetadata):
maximum_delivery_days = models.PositiveIntegerField(null=True, blank=True)
minimum_delivery_days = models.PositiveIntegerField(null=True, blank=True)
description = SanitizedJSONField(blank=True, null=True, sanitizer=clean_editor_js)
+ tax_class = models.ForeignKey(
+ TaxClass,
+ related_name="shipping_methods",
+ on_delete=models.SET_NULL,
+ blank=True,
+ null=True,
+ )
objects = models.Manager.from_queryset(ShippingMethodQueryset)()
translated = TranslationProxy()
diff --git a/saleor/shipping/utils.py b/saleor/shipping/utils.py
index c9015904f9..0016e89f6e 100644
--- a/saleor/shipping/utils.py
+++ b/saleor/shipping/utils.py
@@ -51,6 +51,7 @@ def convert_to_shipping_method_data(
metadata=shipping_method.metadata,
private_metadata=shipping_method.private_metadata,
price=price,
+ tax_class=shipping_method.tax_class,
minimum_order_price=minimum_order_price,
maximum_order_price=maximum_order_price,
)
diff --git a/saleor/site/models.py b/saleor/site/models.py
index 6699ad4430..b6103586ad 100644
--- a/saleor/site/models.py
+++ b/saleor/site/models.py
@@ -43,9 +43,6 @@ class SiteSettings(models.Model):
bottom_menu = models.ForeignKey(
"menu.Menu", on_delete=models.SET_NULL, related_name="+", blank=True, null=True
)
- include_taxes_in_prices = models.BooleanField(default=True)
- display_gross_prices = models.BooleanField(default=True)
- charge_taxes_on_shipping = models.BooleanField(default=True)
track_inventory_by_default = models.BooleanField(default=True)
default_weight_unit = models.CharField(
max_length=30,
@@ -97,6 +94,11 @@ class SiteSettings(models.Model):
gift_card_expiry_period = models.PositiveIntegerField(null=True, blank=True)
automatically_fulfill_non_shippable_gift_card = models.BooleanField(default=True)
+ # deprecated
+ charge_taxes_on_shipping = models.BooleanField(default=True)
+ include_taxes_in_prices = models.BooleanField(default=True)
+ display_gross_prices = models.BooleanField(default=True)
+
translated = TranslationProxy()
class Meta:
diff --git a/saleor/static/populatedb_data.json b/saleor/static/populatedb_data.json
index c50085094b..1961848c7f 100644
--- a/saleor/static/populatedb_data.json
+++ b/saleor/static/populatedb_data.json
@@ -538,7 +538,6 @@
"category": 26,
"created_at": "2022-05-12T22:07:58.327Z",
"updated_at": "2022-05-19T09:20:18.453Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -573,7 +572,6 @@
"category": 28,
"created_at": "2022-05-13T14:34:39.934Z",
"updated_at": "2022-05-13T20:11:18.993Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -608,7 +606,6 @@
"category": 28,
"created_at": "2022-05-13T20:14:01.299Z",
"updated_at": "2022-05-13T20:39:54.551Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -643,7 +640,6 @@
"category": 28,
"created_at": "2022-05-13T20:44:05.403Z",
"updated_at": "2022-05-13T20:47:18.902Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -678,7 +674,6 @@
"category": 28,
"created_at": "2022-05-13T20:50:54.123Z",
"updated_at": "2022-05-13T21:15:21.592Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -701,7 +696,6 @@
"category": 29,
"created_at": "2022-05-13T21:07:45.009Z",
"updated_at": "2022-05-13T21:10:33.993Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -724,7 +718,6 @@
"category": 29,
"created_at": "2022-05-13T21:11:28.525Z",
"updated_at": "2022-05-16T16:40:43.118Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -747,7 +740,6 @@
"category": 29,
"created_at": "2022-05-13T21:13:28.944Z",
"updated_at": "2022-05-13T21:14:28.328Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -782,7 +774,6 @@
"category": 39,
"created_at": "2022-05-13T21:20:59.727Z",
"updated_at": "2022-05-15T09:38:17.179Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -817,7 +808,6 @@
"category": 39,
"created_at": "2022-05-13T21:29:38.009Z",
"updated_at": "2022-05-14T21:37:02.094Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -852,7 +842,6 @@
"category": 40,
"created_at": "2022-05-13T21:37:35.753Z",
"updated_at": "2022-05-14T21:36:42.372Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -887,7 +876,6 @@
"category": 39,
"created_at": "2022-05-13T21:41:46.295Z",
"updated_at": "2022-05-14T21:36:18.923Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -922,7 +910,6 @@
"category": 39,
"created_at": "2022-05-13T21:44:02.972Z",
"updated_at": "2022-05-14T21:36:31.780Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -945,7 +932,6 @@
"category": 35,
"created_at": "2022-05-13T23:50:16.297Z",
"updated_at": "2022-05-14T21:33:36.545Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -968,7 +954,6 @@
"category": 36,
"created_at": "2022-05-14T21:10:01.383Z",
"updated_at": "2022-05-14T21:33:04.263Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -991,7 +976,6 @@
"category": 37,
"created_at": "2022-05-14T21:24:57.725Z",
"updated_at": "2022-05-14T21:25:09.229Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1024,7 +1008,6 @@
"category": 26,
"created_at": "2022-05-14T21:53:34.556Z",
"updated_at": "2022-05-19T09:15:38.806Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1057,7 +1040,6 @@
"category": 26,
"created_at": "2022-05-15T09:03:06.009Z",
"updated_at": "2022-05-19T09:19:50.290Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1092,7 +1074,6 @@
"category": 26,
"created_at": "2022-05-15T09:10:17.077Z",
"updated_at": "2022-05-19T09:22:29.677Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1127,7 +1108,6 @@
"category": 41,
"created_at": "2022-05-15T09:28:13.067Z",
"updated_at": "2022-05-15T09:28:13.368Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1162,7 +1142,6 @@
"category": 41,
"created_at": "2022-05-15T09:32:27.163Z",
"updated_at": "2022-05-16T16:38:35.766Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1197,7 +1176,6 @@
"category": 43,
"created_at": "2022-05-16T16:19:50.880Z",
"updated_at": "2022-05-18T12:21:40.815Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1232,7 +1210,6 @@
"category": 43,
"created_at": "2022-05-16T16:25:11.442Z",
"updated_at": "2022-05-16T16:25:11.768Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1267,7 +1244,6 @@
"category": 43,
"created_at": "2022-05-16T16:27:16.648Z",
"updated_at": "2022-05-16T16:27:16.933Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1302,7 +1278,6 @@
"category": 43,
"created_at": "2022-05-16T16:28:14.885Z",
"updated_at": "2022-05-17T12:36:31.471Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1325,7 +1300,6 @@
"category": 37,
"created_at": "2022-05-17T11:44:16.884Z",
"updated_at": "2022-05-17T11:44:17.205Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1360,7 +1334,6 @@
"category": 39,
"created_at": "2022-05-17T11:48:18.537Z",
"updated_at": "2022-05-17T11:50:42.152Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1393,7 +1366,6 @@
"category": 44,
"created_at": "2022-05-17T11:57:19.204Z",
"updated_at": "2022-05-18T19:30:32.578Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1428,7 +1400,6 @@
"category": 39,
"created_at": "2022-05-17T12:02:44.850Z",
"updated_at": "2022-05-18T12:21:19.661Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1463,7 +1434,6 @@
"category": 41,
"created_at": "2022-05-18T12:06:53.986Z",
"updated_at": "2022-05-18T12:07:49.831Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1486,7 +1456,6 @@
"category": 44,
"created_at": "2022-05-18T19:29:35.052Z",
"updated_at": "2022-05-18T19:29:47.127Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
@@ -1509,7 +1478,6 @@
"category": 44,
"created_at": "2022-05-18T19:31:14.463Z",
"updated_at": "2022-05-18T19:31:14.751Z",
- "charge_taxes": false,
"weight": null,
"rating": 0.0
}
diff --git a/saleor/tax/__init__.py b/saleor/tax/__init__.py
index e69de29bb2..1eb3ead6a2 100644
--- a/saleor/tax/__init__.py
+++ b/saleor/tax/__init__.py
@@ -0,0 +1,5 @@
+class TaxCalculationStrategy:
+ FLAT_RATES = "FLAT_RATES"
+ TAX_APP = "TAX_APP"
+
+ CHOICES = [(FLAT_RATES, "Flat rates"), (TAX_APP, "Tax app")]
diff --git a/saleor/tax/calculations/__init__.py b/saleor/tax/calculations/__init__.py
new file mode 100644
index 0000000000..a9ce7f6214
--- /dev/null
+++ b/saleor/tax/calculations/__init__.py
@@ -0,0 +1,20 @@
+from decimal import Decimal
+
+from prices import Money, TaxedMoney
+
+
+def calculate_flat_rate_tax(
+ money: "Money", tax_rate: "Decimal", prices_entered_with_tax: bool
+) -> TaxedMoney:
+ currency = money.currency
+ tax_rate = Decimal(1 + tax_rate / 100)
+
+ if prices_entered_with_tax:
+ net_amount = money.amount / tax_rate
+ gross_amount = money.amount
+ else:
+ net_amount = money.amount
+ gross_amount = money.amount * tax_rate
+ return TaxedMoney(
+ net=Money(net_amount, currency), gross=Money(gross_amount, currency)
+ )
diff --git a/saleor/tax/calculations/checkout.py b/saleor/tax/calculations/checkout.py
new file mode 100644
index 0000000000..0a0057b123
--- /dev/null
+++ b/saleor/tax/calculations/checkout.py
@@ -0,0 +1,226 @@
+from decimal import Decimal
+from typing import TYPE_CHECKING, Iterable, Optional
+
+from prices import Money, TaxedMoney
+
+from ...checkout import base_calculations
+from ...core.prices import quantize_price
+from ...core.taxes import zero_money, zero_taxed_money
+from ...discount import DiscountInfo, VoucherType
+from ..models import TaxClassCountryRate
+from ..utils import get_tax_rate_for_tax_class, normalize_tax_rate_for_db
+from . import calculate_flat_rate_tax
+
+if TYPE_CHECKING:
+ from ...account.models import Address
+ from ...channel.models import Channel
+ from ...checkout.fetch import CheckoutInfo, CheckoutLineInfo
+ from ...checkout.models import Checkout
+
+
+def update_checkout_prices_with_flat_rates(
+ checkout: "Checkout",
+ checkout_info: "CheckoutInfo",
+ lines: Iterable["CheckoutLineInfo"],
+ prices_entered_with_tax: bool,
+ address: Optional["Address"] = None,
+ discounts: Optional[Iterable[DiscountInfo]] = None,
+):
+ if not discounts:
+ discounts = []
+
+ country_code = (
+ address.country.code if address else checkout_info.channel.default_country.code
+ )
+ default_country_rate_obj = TaxClassCountryRate.objects.filter(
+ country=country_code, tax_class=None
+ ).first()
+ default_tax_rate = (
+ default_country_rate_obj.rate if default_country_rate_obj else Decimal(0)
+ )
+ currency = checkout.currency
+
+ # Calculate checkout line totals.
+ for line_info in lines:
+ line = line_info.line
+ tax_class = line_info.tax_class
+ tax_rate = get_tax_rate_for_tax_class(
+ tax_class,
+ tax_class.country_rates.all() if tax_class else [],
+ default_tax_rate,
+ country_code,
+ )
+ line_total_price = calculate_checkout_line_total(
+ checkout_info,
+ lines,
+ line_info,
+ discounts,
+ tax_rate,
+ prices_entered_with_tax,
+ )
+ line.total_price = line_total_price
+ line.tax_rate = normalize_tax_rate_for_db(tax_rate)
+
+ # Calculate shipping price.
+ shipping_method = checkout_info.delivery_method_info.delivery_method
+ tax_class = getattr(shipping_method, "tax_class", None)
+ shipping_tax_rate = get_tax_rate_for_tax_class(
+ tax_class,
+ tax_class.country_rates.all() if tax_class else [],
+ default_tax_rate,
+ country_code,
+ )
+ shipping_price = calculate_checkout_shipping(
+ checkout_info, lines, shipping_tax_rate, prices_entered_with_tax
+ )
+ checkout.shipping_price = shipping_price
+ checkout.shipping_tax_rate = normalize_tax_rate_for_db(shipping_tax_rate)
+
+ # Calculate subtotal and total.
+ subtotal = sum(
+ [line_info.line.total_price for line_info in lines], zero_taxed_money(currency)
+ )
+ checkout.subtotal = subtotal
+ checkout.total = subtotal + shipping_price
+
+
+def calculate_checkout_shipping(
+ checkout_info: "CheckoutInfo",
+ lines: Iterable["CheckoutLineInfo"],
+ tax_rate: Decimal,
+ prices_entered_with_tax: bool,
+) -> TaxedMoney:
+ shipping_price = base_calculations.base_checkout_delivery_price(
+ checkout_info, lines
+ )
+ shipping_price_taxed = calculate_flat_rate_tax(
+ shipping_price, tax_rate, prices_entered_with_tax
+ )
+ return quantize_price(shipping_price_taxed, shipping_price_taxed.currency)
+
+
+def calculate_checkout_line_total(
+ checkout_info: "CheckoutInfo",
+ lines: Iterable["CheckoutLineInfo"],
+ checkout_line_info: "CheckoutLineInfo",
+ discounts: Iterable["DiscountInfo"],
+ tax_rate: Decimal,
+ prices_entered_with_tax: bool,
+) -> TaxedMoney:
+ unit_taxed_price = _calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ checkout_info.channel,
+ discounts,
+ tax_rate,
+ prices_entered_with_tax,
+ )
+ quantity = checkout_line_info.line.quantity
+ return quantize_price(unit_taxed_price * quantity, unit_taxed_price.currency)
+
+
+def _calculate_checkout_line_unit_price(
+ checkout_info: "CheckoutInfo",
+ lines: Iterable["CheckoutLineInfo"],
+ checkout_line_info: "CheckoutLineInfo",
+ channel: "Channel",
+ discounts: Iterable["DiscountInfo"],
+ tax_rate: Decimal,
+ prices_entered_with_tax: bool,
+):
+ unit_price = base_calculations.calculate_base_line_unit_price(
+ checkout_line_info,
+ channel,
+ discounts,
+ )
+ unit_price = apply_checkout_discount_on_checkout_line(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ discounts,
+ unit_price,
+ )
+ return calculate_flat_rate_tax(unit_price, tax_rate, prices_entered_with_tax)
+
+
+def apply_checkout_discount_on_checkout_line(
+ checkout_info: "CheckoutInfo",
+ lines: Iterable["CheckoutLineInfo"],
+ checkout_line_info: "CheckoutLineInfo",
+ discounts: Iterable["DiscountInfo"],
+ line_price: Money,
+):
+ """Calculate the checkout line price with discounts.
+
+ Include the entire order voucher discount.
+ The discount amount is calculated for every line proportionally to
+ the rate of total line price to checkout total price.
+ """
+ voucher = checkout_info.voucher
+ if (
+ not voucher
+ or voucher.apply_once_per_order
+ or voucher.type in [VoucherType.SHIPPING, VoucherType.SPECIFIC_PRODUCT]
+ ):
+ return line_price
+
+ line_quantity = checkout_line_info.line.quantity
+ total_discount_amount = checkout_info.checkout.discount_amount
+ line_total_price = line_price * line_quantity
+ currency = checkout_info.checkout.currency
+
+ lines = list(lines)
+
+ # if the checkout has a single line, the whole discount amount will be applied
+ # to this line
+ if len(lines) == 1:
+ return max(
+ (line_total_price - Money(total_discount_amount, currency)) / line_quantity,
+ zero_money(currency),
+ )
+
+ # if the checkout has more lines we need to propagate the discount amount
+ # proportionally to total prices of items
+ lines_total_prices = [
+ base_calculations.calculate_base_line_unit_price(
+ line_info,
+ checkout_info.channel,
+ discounts,
+ ).amount
+ * line_info.line.quantity
+ for line_info in lines
+ if line_info.line.id != checkout_line_info.line.id
+ ]
+
+ total_price = sum(lines_total_prices) + line_total_price.amount
+
+ last_element = lines[-1].line.id == checkout_line_info.line.id
+ if last_element:
+ discount_amount = _calculate_discount_for_last_element(
+ lines_total_prices, total_price, total_discount_amount, currency
+ )
+ else:
+ discount_amount = line_total_price.amount / total_price * total_discount_amount
+ return max(
+ (line_total_price - Money(discount_amount, currency)) / line_quantity,
+ zero_money(currency),
+ )
+
+
+def _calculate_discount_for_last_element(
+ lines_total_prices, total_price, total_discount_amount, currency
+):
+ """Calculate the discount for last element.
+
+ If the given line is last on the list we should calculate the discount by difference
+ between total discount amount and sum of discounts applied to rest of the lines,
+ otherwise the sum of discounts won't be equal to the discount amount.
+ """
+ sum_of_discounts_other_elements = sum(
+ [
+ line_total_price / total_price * total_discount_amount
+ for line_total_price in lines_total_prices
+ ]
+ )
+ return total_discount_amount - sum_of_discounts_other_elements
diff --git a/saleor/tax/calculations/order.py b/saleor/tax/calculations/order.py
new file mode 100644
index 0000000000..07993cc6b6
--- /dev/null
+++ b/saleor/tax/calculations/order.py
@@ -0,0 +1,188 @@
+from decimal import Decimal
+from typing import TYPE_CHECKING, Iterable, Tuple
+
+from prices import Money, TaxedMoney
+
+from ...core.prices import quantize_price
+from ...core.taxes import zero_money, zero_taxed_money
+from ...discount import OrderDiscountType
+from ...order import base_calculations
+from ...order.utils import (
+ get_order_country,
+ get_total_order_discount_excluding_shipping,
+)
+from ..models import TaxClassCountryRate
+from ..utils import (
+ denormalize_tax_rate_from_db,
+ get_tax_rate_for_tax_class,
+ normalize_tax_rate_for_db,
+)
+from . import calculate_flat_rate_tax
+
+if TYPE_CHECKING:
+ from ...order.models import Order, OrderLine
+
+
+def update_order_prices_with_flat_rates(
+ order: "Order",
+ lines: Iterable["OrderLine"],
+ prices_entered_with_tax: bool,
+):
+ country_code = get_order_country(order)
+ default_country_rate_obj = TaxClassCountryRate.objects.filter(
+ country=country_code, tax_class=None
+ ).first()
+ default_tax_rate = (
+ default_country_rate_obj.rate if default_country_rate_obj else Decimal(0)
+ )
+
+ # Calculate order line totals.
+ _, undiscounted_subtotal = update_taxes_for_order_lines(
+ order, lines, country_code, default_tax_rate, prices_entered_with_tax
+ )
+
+ # Calculate order shipping.
+ shipping_method = order.shipping_method
+ shipping_tax_class = getattr(shipping_method, "tax_class", None)
+ if shipping_tax_class:
+ shipping_tax_rate = get_tax_rate_for_tax_class(
+ shipping_tax_class,
+ shipping_tax_class.country_rates.all(),
+ default_tax_rate,
+ country_code,
+ )
+ elif order.shipping_tax_rate is not None:
+ # Use order.shipping_tax_rate if it was ever set before (it's non-null now).
+ # This is a valid case when recalculating shipping price and the tax class is
+ # null, because it was removed from the system.
+ shipping_tax_rate = denormalize_tax_rate_from_db(order.shipping_tax_rate)
+ else:
+ shipping_tax_rate = default_tax_rate
+
+ order.shipping_price = _calculate_order_shipping(
+ order, shipping_tax_rate, prices_entered_with_tax
+ )
+ order.shipping_tax_rate = normalize_tax_rate_for_db(shipping_tax_rate)
+
+ # Calculate order total.
+ order.undiscounted_total = undiscounted_subtotal + order.base_shipping_price
+ order.total = _calculate_order_total(order, lines)
+
+
+def _calculate_order_total(
+ order: "Order",
+ lines: Iterable["OrderLine"],
+) -> TaxedMoney:
+ currency = order.currency
+
+ default_value = base_calculations.base_order_total(order, lines)
+ default_value = TaxedMoney(default_value, default_value)
+ if default_value <= zero_taxed_money(currency):
+ return quantize_price(default_value, currency)
+
+ total = zero_taxed_money(currency)
+ undiscounted_subtotal = zero_taxed_money(currency)
+ for line in lines:
+ total += line.total_price
+ undiscounted_subtotal += line.undiscounted_total_price
+ total += order.shipping_price
+
+ order_discount = order.discounts.filter(type=OrderDiscountType.MANUAL).first()
+ if order_discount and order_discount.amount > undiscounted_subtotal.gross:
+ remaining_amount = order_discount.amount - undiscounted_subtotal.gross
+ total -= remaining_amount
+ return quantize_price(max(total, zero_taxed_money(currency)), currency)
+
+
+def _calculate_order_shipping(
+ order: "Order", tax_rate: Decimal, prices_entered_with_tax: bool
+) -> TaxedMoney:
+ shipping_price = order.base_shipping_price
+ taxed_shipping_price = calculate_flat_rate_tax(
+ shipping_price, tax_rate, prices_entered_with_tax
+ )
+ return quantize_price(taxed_shipping_price, taxed_shipping_price.currency)
+
+
+def update_taxes_for_order_lines(
+ order: "Order",
+ lines: Iterable["OrderLine"],
+ country_code: str,
+ default_tax_rate: Decimal,
+ prices_entered_with_tax: bool,
+) -> Tuple[Iterable["OrderLine"], TaxedMoney]:
+ currency = order.currency
+ lines = list(lines)
+
+ total_discount_amount = get_total_order_discount_excluding_shipping(order).amount
+ order_total_price = sum(
+ [line.base_unit_price.amount * line.quantity for line in lines]
+ )
+ total_line_discounts = 0
+
+ undiscounted_subtotal = zero_taxed_money(order.currency)
+
+ for line in lines:
+ variant = line.variant
+ if not variant:
+ continue
+
+ tax_class = line.tax_class
+ if tax_class:
+ tax_rate = get_tax_rate_for_tax_class(
+ tax_class,
+ tax_class.country_rates.all() if tax_class else [],
+ default_tax_rate,
+ country_code,
+ )
+ elif line.tax_rate is not None:
+ # line.tax_class can be None when the tax class was removed from DB. In
+ # this case try to use line.tax_rate which stores the denormalized tax rate
+ # value that was originally used.
+ tax_rate = denormalize_tax_rate_from_db(line.tax_rate)
+ else:
+ tax_rate = default_tax_rate
+
+ line_total_price = line.base_unit_price * line.quantity
+ undiscounted_subtotal += line_total_price
+
+ price_with_discounts = line.base_unit_price
+ if total_discount_amount:
+ if line is lines[-1]:
+ # for the last line applied remaining discount
+ discount_amount = total_discount_amount - total_line_discounts
+ else:
+ # calculate discount proportionally to the rate of total line price
+ # to order total price.
+ discount_amount = quantize_price(
+ line_total_price.amount / order_total_price * total_discount_amount,
+ currency,
+ )
+ price_with_discounts = max(
+ quantize_price(
+ (line_total_price - Money(discount_amount, currency))
+ / line.quantity,
+ currency,
+ ),
+ zero_money(currency),
+ )
+ # sum already applied discounts
+ total_line_discounts += discount_amount
+
+ unit_price = calculate_flat_rate_tax(
+ price_with_discounts, tax_rate, prices_entered_with_tax
+ )
+ undiscounted_unit_price = calculate_flat_rate_tax(
+ line.undiscounted_base_unit_price, tax_rate, prices_entered_with_tax
+ )
+
+ line.unit_price = quantize_price(unit_price, currency)
+ line.undiscounted_unit_price = quantize_price(undiscounted_unit_price, currency)
+
+ line.total_price = quantize_price(unit_price * line.quantity, currency)
+ line.undiscounted_total_price = quantize_price(
+ undiscounted_unit_price * line.quantity, currency
+ )
+ line.tax_rate = normalize_tax_rate_for_db(tax_rate)
+
+ return lines, undiscounted_subtotal
diff --git a/saleor/tax/error_codes.py b/saleor/tax/error_codes.py
index 7aa2e20469..d1c8cd4cd3 100644
--- a/saleor/tax/error_codes.py
+++ b/saleor/tax/error_codes.py
@@ -6,3 +6,43 @@ class TaxExemptionManageErrorCode(Enum):
INVALID = "invalid"
NOT_FOUND = "not_found"
NOT_EDITABLE_ORDER = "not_editable_order"
+
+
+class TaxConfigurationUpdateErrorCode(Enum):
+ DUPLICATED_INPUT_ITEM = "duplicated_input_item"
+ GRAPHQL_ERROR = "graphql_error"
+ INVALID = "invalid"
+ NOT_FOUND = "not_found"
+
+
+class TaxClassCreateErrorCode(Enum):
+ GRAPHQL_ERROR = "graphql_error"
+ INVALID = "invalid"
+ NOT_FOUND = "not_found"
+
+
+class TaxClassUpdateErrorCode(Enum):
+ DUPLICATED_INPUT_ITEM = "duplicated_input_item"
+ GRAPHQL_ERROR = "graphql_error"
+ INVALID = "invalid"
+ NOT_FOUND = "not_found"
+
+
+class TaxClassDeleteErrorCode(Enum):
+ GRAPHQL_ERROR = "graphql_error"
+ INVALID = "invalid"
+ NOT_FOUND = "not_found"
+
+
+class TaxCountryConfigurationUpdateErrorCode(Enum):
+ GRAPHQL_ERROR = "graphql_error"
+ INVALID = "invalid"
+ NOT_FOUND = "not_found"
+ ONLY_ONE_DEFAULT_COUNTRY_RATE_ALLOWED = "only_one_default_country_rate_allowed"
+ CANNOT_CREATE_NEGATIVE_RATE = "cannot_create_negative_rate"
+
+
+class TaxCountryConfigurationDeleteErrorCode(Enum):
+ GRAPHQL_ERROR = "graphql_error"
+ INVALID = "invalid"
+ NOT_FOUND = "not_found"
diff --git a/saleor/tax/migrations/0001_initial.py b/saleor/tax/migrations/0001_initial.py
new file mode 100644
index 0000000000..a13a7d10d7
--- /dev/null
+++ b/saleor/tax/migrations/0001_initial.py
@@ -0,0 +1,196 @@
+# Generated by Django 4.0.7 on 2022-09-14 13:15
+
+from django.db import migrations, models
+import django.db.models.deletion
+import django.db.models.expressions
+import django_countries.fields
+import saleor.core.utils.json_serializer
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ("channel", "0005_channel_allocation_strategy"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="TaxClass",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "private_metadata",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ (
+ "metadata",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ],
+ options={
+ "ordering": ("name", "pk"),
+ },
+ ),
+ migrations.CreateModel(
+ name="TaxConfiguration",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "private_metadata",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ (
+ "metadata",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,
+ null=True,
+ ),
+ ),
+ ("charge_taxes", models.BooleanField(default=True)),
+ (
+ "tax_calculation_strategy",
+ models.CharField(
+ blank=True,
+ choices=[("FLAT_RATES", "Flat rates"), ("TAX_APP", "Tax app")],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("display_gross_prices", models.BooleanField(default=True)),
+ ("prices_entered_with_tax", models.BooleanField(default=True)),
+ (
+ "channel",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tax_configuration",
+ to="channel.channel",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ("pk",),
+ },
+ ),
+ migrations.CreateModel(
+ name="TaxClassCountryRate",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("country", django_countries.fields.CountryField(max_length=2)),
+ ("rate", models.DecimalField(decimal_places=3, max_digits=12)),
+ (
+ "tax_class",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="country_rates",
+ to="tax.taxclass",
+ ),
+ ),
+ ],
+ options={
+ "ordering": (
+ "country",
+ django.db.models.expressions.OrderBy(
+ django.db.models.expressions.F("tax_class_id"), nulls_first=True
+ ),
+ "pk",
+ ),
+ },
+ ),
+ migrations.CreateModel(
+ name="TaxConfigurationPerCountry",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("country", django_countries.fields.CountryField(max_length=2)),
+ ("charge_taxes", models.BooleanField(default=True)),
+ (
+ "tax_calculation_strategy",
+ models.CharField(
+ blank=True,
+ choices=[("FLAT_RATES", "Flat rates"), ("TAX_APP", "Tax app")],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("display_gross_prices", models.BooleanField(default=True)),
+ (
+ "tax_configuration",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="country_exceptions",
+ to="tax.taxconfiguration",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ("country", "pk"),
+ "unique_together": {("tax_configuration", "country")},
+ },
+ ),
+ migrations.AddConstraint(
+ model_name="taxclasscountryrate",
+ constraint=models.UniqueConstraint(
+ fields=("country", "tax_class"), name="unique_country_tax_class"
+ ),
+ ),
+ migrations.AddConstraint(
+ model_name="taxclasscountryrate",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("tax_class", None)),
+ fields=("country",),
+ name="unique_country_without_tax_class",
+ ),
+ ),
+ ]
diff --git a/saleor/tax/migrations/0002_add_default_tax_configs.py b/saleor/tax/migrations/0002_add_default_tax_configs.py
new file mode 100644
index 0000000000..be51b2722d
--- /dev/null
+++ b/saleor/tax/migrations/0002_add_default_tax_configs.py
@@ -0,0 +1,107 @@
+# Generated by Django 3.2.13 on 2022-05-27 12:23
+
+from django.db import migrations
+
+from .. import TaxCalculationStrategy
+
+
+AVATAX_PLUGIN_ID = "mirumee.taxes.avalara"
+VATLAYER_ID = "mirumee.taxes.vatlayer"
+
+CHECKOUT_CALCULATE_TAXES = "checkout_calculate_taxes"
+ORDER_CALCULATE_TAXES = "order_calculate_taxes"
+
+
+def add_tax_configuration_for_channels(apps, schema_editor):
+ Channel = apps.get_model("channel", "Channel")
+ TaxConfiguration = apps.get_model("tax", "TaxConfiguration")
+ SiteSettings = apps.get_model("site", "SiteSettings")
+
+ site_settings = SiteSettings.objects.first()
+
+ tax_configurations = []
+ for channel in Channel.objects.all():
+ tax_configurations.append(
+ TaxConfiguration(
+ channel=channel,
+ charge_taxes=True,
+ display_gross_prices=site_settings.display_gross_prices,
+ prices_entered_with_tax=site_settings.include_taxes_in_prices,
+ )
+ )
+ TaxConfiguration.objects.bulk_create(tax_configurations)
+
+
+def populate_tax_calculation_strategy(apps, schema_editor):
+ App = apps.get_model("app", "App")
+ PluginConfiguration = apps.get_model("plugins", "PluginConfiguration")
+ TaxConfiguration = apps.get_model("tax", "TaxConfiguration")
+
+ def _get_tax_app():
+ permissions = {}
+ permissions["permissions__content_type__app_label"] = "checkout"
+ permissions["permissions__codename"] = "handle_taxes"
+ return App.objects.filter(
+ is_active=True,
+ webhooks__is_active=True,
+ webhooks__events__event_type__in=[
+ CHECKOUT_CALCULATE_TAXES,
+ ORDER_CALCULATE_TAXES,
+ ],
+ **permissions,
+ )
+
+ # If there is any tax app enabled, turn on TAX_APP strategy for all channels.
+
+ is_tax_app_enabled = _get_tax_app().exists()
+ if is_tax_app_enabled:
+ TaxConfiguration.objects.update(
+ tax_calculation_strategy=TaxCalculationStrategy.TAX_APP
+ )
+ return
+
+ # Set TAX_APP calculation strategy for the channels where Avalara is configured.
+ # Set FLAT_RATES tax calculation strategy for channels where Vatlayer is enabled.
+
+ avatax_configs = PluginConfiguration.objects.filter(
+ active=True, identifier=AVATAX_PLUGIN_ID
+ )
+ avatax_tax_configs = []
+ for config in avatax_configs:
+ config_dict = {item["name"]: item["value"] for item in config.configuration}
+ tc = config.channel.tax_configuration
+ tc.tax_calculation_strategy = TaxCalculationStrategy.TAX_APP
+
+ override_global_tax = config_dict.get("override_global_tax")
+ if override_global_tax:
+ include_taxes_in_prices = config_dict.get("include_taxes_in_prices")
+ if include_taxes_in_prices is not None:
+ tc.prices_entered_with_tax = include_taxes_in_prices
+
+ avatax_tax_configs.append(tc)
+ TaxConfiguration.objects.bulk_update(
+ avatax_tax_configs, ["prices_entered_with_tax", "tax_calculation_strategy"]
+ )
+
+ vatlayer_channels = PluginConfiguration.objects.filter(
+ active=True, identifier=VATLAYER_ID
+ ).values_list("channel_id", flat=True)
+ TaxConfiguration.objects.filter(channel_id__in=vatlayer_channels).update(
+ tax_calculation_strategy=TaxCalculationStrategy.FLAT_RATES
+ )
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [("tax", "0001_initial"), ("plugins", "0010_auto_20220104_1239")]
+
+ operations = [
+ migrations.RunPython(
+ add_tax_configuration_for_channels,
+ migrations.RunPython.noop,
+ ),
+ migrations.RunPython(
+ populate_tax_calculation_strategy,
+ migrations.RunPython.noop,
+ ),
+ ]
diff --git a/saleor/tax/migrations/0003_add_manage_taxes_permission.py b/saleor/tax/migrations/0003_add_manage_taxes_permission.py
new file mode 100644
index 0000000000..9484ec4fe8
--- /dev/null
+++ b/saleor/tax/migrations/0003_add_manage_taxes_permission.py
@@ -0,0 +1,39 @@
+# Generated by Django 3.2.13 on 2022-05-27 13:17
+
+from django.db import migrations
+from django.db.models.signals import post_migrate
+
+
+def assign_permissions(apps, schema_editor):
+ def on_migrations_complete(sender=None, **kwargs):
+ Permission = apps.get_model("auth", "Permission")
+ Group = apps.get_model("auth", "Group")
+ ContentType = apps.get_model("contenttypes", "ContentType")
+
+ ct, _ = ContentType.objects.get_or_create(
+ app_label="checkout", model="checkout"
+ )
+ manage_taxes, _ = Permission.objects.get_or_create(
+ name="Manage taxes", content_type=ct, codename="manage_taxes"
+ )
+
+ # Assign MANAGE_TAXES to groups with MANAGE_SETTINGS
+ groups = Group.objects.filter(
+ permissions__content_type__app_label="site",
+ permissions__codename="manage_settings",
+ )
+ for group in groups:
+ group.permissions.add(manage_taxes)
+
+ post_migrate.connect(on_migrations_complete, weak=False)
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("tax", "0002_add_default_tax_configs"),
+ ]
+
+ operations = [
+ migrations.RunPython(assign_permissions, migrations.RunPython.noop),
+ ]
diff --git a/saleor/tax/migrations/0004_migrate_tax_classes.py b/saleor/tax/migrations/0004_migrate_tax_classes.py
new file mode 100644
index 0000000000..63b3f1423b
--- /dev/null
+++ b/saleor/tax/migrations/0004_migrate_tax_classes.py
@@ -0,0 +1,159 @@
+# Generated by Django 3.2.14 on 2022-07-27 16:05
+
+from collections import defaultdict
+from django_countries import countries
+from django.db import migrations
+from django.db.models import Q
+
+
+AVATAX_CODE_META_KEY = "avatax.code"
+AVATAX_DESCRIPTION_META_KEY = "avatax.description"
+VATLAYER_CODE_META_KEY = "vatlayer.code"
+
+# Non-taxable product's tax code for Avalara.
+TAX_CODE_NON_TAXABLE_PRODUCT = "NT"
+
+TAX_CLASS_ZERO_RATE = "No Taxes"
+
+AVATAX_PLUGIN_ID = "mirumee.taxes.avalara"
+
+BATCH_SIZE = 500
+
+
+def queryset_in_batches(queryset):
+ """Slice a queryset into batches.
+
+ Input queryset should be sorted be pk.
+ """
+ start_pk = 0
+ while True:
+ qs = queryset.filter(pk__gt=start_pk)[:BATCH_SIZE]
+ pks = list(qs.values_list("pk", flat=True))
+ if not pks:
+ break
+ yield pks
+ start_pk = pks[-1]
+
+
+def _populate_tax_class_name_and_metadata(obj):
+ avatax_code = obj.metadata.get(AVATAX_CODE_META_KEY)
+ avatax_description = obj.metadata.get(AVATAX_DESCRIPTION_META_KEY)
+ vatlayer_code = obj.metadata.get(VATLAYER_CODE_META_KEY)
+
+ name = None
+ metadata = {}
+
+ if avatax_code:
+ name = avatax_description or avatax_code
+ metadata = {
+ AVATAX_CODE_META_KEY: avatax_code,
+ AVATAX_DESCRIPTION_META_KEY: avatax_description,
+ }
+ elif vatlayer_code:
+ name = vatlayer_code
+ metadata = {VATLAYER_CODE_META_KEY: vatlayer_code}
+
+ return name, metadata
+
+
+def migrate_product_tax_codes(apps, _schema_editor):
+ """Create tax classes by migrating currently used tax codes.
+
+ Tax codes are stored in metadata of products and product types. For each found code
+ we get or create a TaxClass instance and assign the object to the tax class.
+ If object has both Avalara and Vatlayer codes, keep only the Avalara code.
+ """
+
+ Product = apps.get_model("product", "Product")
+ ProductType = apps.get_model("product", "ProductType")
+ TaxClass = apps.get_model("tax", "TaxClass")
+
+ query = Q(metadata__has_key=VATLAYER_CODE_META_KEY) | Q(
+ metadata__has_key=AVATAX_CODE_META_KEY
+ )
+
+ tax_class_metadata = {}
+
+ product_types = (
+ ProductType.objects.filter(query).values("id", "metadata").order_by("pk")
+ )
+ for batch_pks in queryset_in_batches(product_types):
+ tax_classes_from_product_types = defaultdict(list)
+ product_types = ProductType.objects.filter(pk__in=batch_pks)
+ for product_type in product_types:
+ tax_class_name, metadata = _populate_tax_class_name_and_metadata(
+ product_type
+ )
+ if tax_class_name:
+ tax_classes_from_product_types[tax_class_name].append(product_type.pk)
+ tax_class_metadata[tax_class_name] = metadata
+
+ for name, ids in tax_classes_from_product_types.items():
+ tax_class, _ = TaxClass.objects.get_or_create(
+ name=name, metadata=tax_class_metadata.get(name, {})
+ )
+ ProductType.objects.filter(id__in=ids).update(tax_class=tax_class)
+
+ products = Product.objects.filter(query).values("id", "metadata").order_by("pk")
+ tax_classes_from_products = defaultdict(list)
+ for batch_pks in queryset_in_batches(products):
+ products = Product.objects.filter(pk__in=batch_pks)
+ for product in products:
+ tax_class_name, metadata = _populate_tax_class_name_and_metadata(product)
+ if tax_class_name:
+ tax_classes_from_products[tax_class_name].append(product.pk)
+ tax_class_metadata[tax_class_name] = metadata
+
+ for name, ids in tax_classes_from_products.items():
+ tax_class, _ = TaxClass.objects.get_or_create(
+ name=name, metadata=tax_class_metadata.get(name, {})
+ )
+ Product.objects.filter(id__in=ids).update(tax_class=tax_class)
+
+
+def migrate_products_with_disabled_taxes(apps, _schema_editor):
+ Product = apps.get_model("product", "Product")
+ TaxClass = apps.get_model("tax", "TaxClass")
+ TaxClassCountryRate = apps.get_model("tax", "TaxClassCountryRate")
+
+ zero_rate_tax_class = None
+ qs = Product.objects.filter(charge_taxes=False).order_by("pk")
+ if qs.exists():
+ zero_rate_tax_class, _ = TaxClass.objects.get_or_create(
+ name=TAX_CLASS_ZERO_RATE,
+ defaults={
+ "metadata": {
+ AVATAX_CODE_META_KEY: TAX_CODE_NON_TAXABLE_PRODUCT,
+ AVATAX_DESCRIPTION_META_KEY: "Non-taxable product",
+ }
+ },
+ )
+
+ # Create 0% rates for all countries
+ rates = [
+ TaxClassCountryRate(tax_class=zero_rate_tax_class, rate=0, country=code)
+ for code in countries.countries.keys()
+ ]
+ TaxClassCountryRate.objects.bulk_create(rates)
+
+ # Assign products with charge_taxes=False to the 0% rate tax class
+ if zero_rate_tax_class:
+ for batch_pks in queryset_in_batches(qs):
+ Product.objects.filter(id__in=batch_pks).update(
+ tax_class=zero_rate_tax_class
+ )
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("tax", "0003_add_manage_taxes_permission"),
+ ("product", "0177_product_tax_class_producttype_tax_class"),
+ ]
+
+ operations = [
+ migrations.RunPython(migrate_product_tax_codes, migrations.RunPython.noop),
+ migrations.RunPython(
+ migrate_products_with_disabled_taxes, migrations.RunPython.noop
+ ),
+ ]
diff --git a/saleor/tax/migrations/0005_migrate_vatlayer.py b/saleor/tax/migrations/0005_migrate_vatlayer.py
new file mode 100644
index 0000000000..8583242fa0
--- /dev/null
+++ b/saleor/tax/migrations/0005_migrate_vatlayer.py
@@ -0,0 +1,122 @@
+# Generated by Django 3.2.14 on 2022-08-18 10:31
+
+from typing import List, Optional
+from django_countries import countries
+from django.db import migrations
+
+
+VATLAYER_ID = "mirumee.taxes.vatlayer"
+
+
+# Must be the same as in 0004_migrate_tax_class.py
+TAX_CLASS_ZERO_RATE = "No Taxes"
+
+
+def _clear_country_code(country_code: str) -> Optional[str]:
+ return countries.alpha2(country_code.strip()) if country_code else None
+
+
+def _clear_str_list_country_codes(country_codes: str) -> List[str]:
+ countries = [_clear_country_code(cc) for cc in country_codes.split(",")]
+ return [cc for cc in countries if cc]
+
+
+def create_tax_configurations(apps, vatlayer_configs):
+ TaxConfigurationPerCountry = apps.get_model("tax", "TaxConfigurationPerCountry")
+
+ # Map of countries to use origin country's tax, based on the
+ # `countries_to_calculate_taxes_from_origin` setting. If a country code appears
+ # more than once in the list, we override is with the last seen origin_country.
+ use_origin_country_map = {}
+
+ for vatlayer_config in vatlayer_configs:
+ config_dict = {
+ item["name"]: item["value"] for item in vatlayer_config.configuration
+ }
+ channel = vatlayer_config.channel
+
+ # Migrate `countries_to_calculate_taxes_from_origin` setting.
+ origin_country = _clear_country_code(config_dict.get("origin_country", ""))
+ countries_to_calculate_taxes_from_origin = _clear_str_list_country_codes(
+ config_dict.get("countries_to_calculate_taxes_from_origin", [])
+ )
+ if origin_country and countries_to_calculate_taxes_from_origin:
+ for country in countries_to_calculate_taxes_from_origin:
+ use_origin_country_map[country] = origin_country
+
+ # Migrate `excluded_countries` to new tax configuration.
+ excluded_countries = _clear_str_list_country_codes(
+ config_dict.get("excluded_countries", [])
+ )
+ if excluded_countries:
+ tax_configuration = channel.tax_configuration
+ for country in excluded_countries:
+ TaxConfigurationPerCountry.objects.update_or_create(
+ tax_configuration=tax_configuration,
+ country=country,
+ defaults={"charge_taxes": False},
+ )
+
+ return use_origin_country_map
+
+
+def create_tax_rates(apps, use_origin_country_map):
+ TaxClass = apps.get_model("tax", "TaxClass")
+ TaxClassCountryRate = apps.get_model("tax", "TaxClassCountryRate")
+ VAT = apps.get_model("django_prices_vatlayer", "VAT")
+
+ tax_classes = TaxClass.objects.exclude(name=TAX_CLASS_ZERO_RATE)
+ vat_rates = VAT.objects.all()
+
+ rates = {}
+ for tax_class in tax_classes:
+ for vat in vat_rates:
+ # Collect standard rates to create
+ standard_rate = TaxClassCountryRate(
+ tax_class=tax_class,
+ country=vat.country_code,
+ rate=vat.data["standard_rate"],
+ )
+ rates[(tax_class.id, vat.country_code)] = standard_rate
+
+ # Collect reduced rates to create
+ if tax_class.name in vat.data["reduced_rates"]:
+ reduced_rate = TaxClassCountryRate(
+ tax_class=tax_class,
+ country=vat.country_code,
+ rate=vat.data["reduced_rates"][tax_class.name],
+ )
+ rates[(tax_class.id, vat.country_code)] = reduced_rate
+
+ # Swap rates for countries that should use origin country tax rate instead of
+ # own rates.
+ for country_code, origin in use_origin_country_map.items():
+ country_rate_obj = rates.get((tax_class.id, country_code))
+ origin_rate_obj = rates.get((tax_class.id, origin))
+ if country_rate_obj and origin_rate_obj:
+ country_rate_obj.rate = origin_rate_obj.rate
+ rates[(tax_class.id, country_code)] = country_rate_obj
+
+ TaxClassCountryRate.objects.bulk_create(rates.values())
+
+
+def migrate_vatlayer(apps, _schema_editor):
+ PluginConfiguration = apps.get_model("plugins", "PluginConfiguration")
+
+ vatlayer_configs = PluginConfiguration.objects.filter(
+ active=True, identifier=VATLAYER_ID
+ )
+ is_vatlayer_enabled = vatlayer_configs.exists()
+
+ if is_vatlayer_enabled:
+ use_origin_country_map = create_tax_configurations(apps, vatlayer_configs)
+ create_tax_rates(apps, use_origin_country_map)
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("tax", "0004_migrate_tax_classes"),
+ ]
+
+ operations = [migrations.RunPython(migrate_vatlayer, migrations.RunPython.noop)]
diff --git a/saleor/tax/migrations/__init__.py b/saleor/tax/migrations/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/saleor/tax/models.py b/saleor/tax/models.py
new file mode 100644
index 0000000000..be8b0afd8b
--- /dev/null
+++ b/saleor/tax/models.py
@@ -0,0 +1,82 @@
+from django.conf import settings
+from django.db import models
+from django_countries.fields import CountryField
+
+from ..channel.models import Channel
+from ..core.models import ModelWithMetadata
+from . import TaxCalculationStrategy
+
+
+class TaxClass(ModelWithMetadata):
+ name = models.CharField(max_length=255)
+
+ class Meta:
+ ordering = ("name", "pk")
+
+ def __str__(self):
+ return self.name
+
+
+class TaxClassCountryRate(models.Model):
+ tax_class = models.ForeignKey(
+ TaxClass, related_name="country_rates", on_delete=models.CASCADE, null=True
+ )
+ country = CountryField()
+ rate = models.DecimalField(
+ max_digits=settings.DEFAULT_MAX_DIGITS,
+ decimal_places=settings.DEFAULT_DECIMAL_PLACES,
+ )
+
+ class Meta:
+ ordering = ("country", models.F("tax_class_id").asc(nulls_first=True), "pk")
+ # Custom constraints to restrict unique pairs of ("country", "tax_class") and
+ # allow exactly one object per country when tax_class is null ("country", None).
+ # TaxClassCountryRate with tax_class=null is considered a default tax rate
+ # value for a country.
+ constraints = [
+ models.constraints.UniqueConstraint(
+ fields=("country", "tax_class"), name="unique_country_tax_class"
+ ),
+ models.constraints.UniqueConstraint(
+ fields=("country",),
+ condition=models.Q(tax_class=None),
+ name="unique_country_without_tax_class",
+ ),
+ ]
+
+ def __str__(self):
+ return f"{self.country}: {self.rate}"
+
+
+class TaxConfiguration(ModelWithMetadata):
+ channel = models.OneToOneField(
+ Channel, related_name="tax_configuration", on_delete=models.CASCADE
+ )
+ charge_taxes = models.BooleanField(default=True)
+ tax_calculation_strategy = models.CharField(
+ max_length=20, choices=TaxCalculationStrategy.CHOICES, blank=True, null=True
+ )
+ display_gross_prices = models.BooleanField(default=True)
+ prices_entered_with_tax = models.BooleanField(default=True)
+
+ class Meta:
+ ordering = ("pk",)
+
+
+class TaxConfigurationPerCountry(models.Model):
+ tax_configuration = models.ForeignKey(
+ TaxConfiguration, related_name="country_exceptions", on_delete=models.CASCADE
+ )
+ country = CountryField()
+ charge_taxes = models.BooleanField(default=True)
+ tax_calculation_strategy = models.CharField(
+ max_length=20, choices=TaxCalculationStrategy.CHOICES, blank=True, null=True
+ )
+ display_gross_prices = models.BooleanField(default=True)
+
+ class Meta:
+ ordering = ("country", "pk")
+ unique_together = (("tax_configuration", "country"),)
+
+ def __str__(self):
+ return str(self.country)
diff --git a/saleor/tax/tests/__init__.py b/saleor/tax/tests/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/saleor/tax/tests/fixtures.py b/saleor/tax/tests/fixtures.py
new file mode 100644
index 0000000000..e695087aee
--- /dev/null
+++ b/saleor/tax/tests/fixtures.py
@@ -0,0 +1,74 @@
+import pytest
+from django_countries import countries
+
+from ...plugins.avatax import (
+ DEFAULT_TAX_CODE,
+ META_CODE_KEY,
+ META_DESCRIPTION_KEY,
+ TAX_CODE_NON_TAXABLE_PRODUCT,
+)
+from ..models import TaxClass, TaxClassCountryRate
+
+
[email protected](autouse=True)
+def default_tax_class(db):
+ tax_class, _ = TaxClass.objects.get_or_create(
+ name="Default",
+ defaults={
+ "metadata": {
+ META_CODE_KEY: DEFAULT_TAX_CODE,
+ META_DESCRIPTION_KEY: "Default tax code",
+ },
+ "private_metadata": {
+ META_CODE_KEY: DEFAULT_TAX_CODE,
+ META_DESCRIPTION_KEY: "Default tax code",
+ },
+ },
+ )
+ TaxClassCountryRate.objects.bulk_create(
+ [
+ TaxClassCountryRate(country="PL", rate=23, tax_class=tax_class),
+ TaxClassCountryRate(country="DE", rate=19, tax_class=tax_class),
+ ]
+ )
+ return tax_class
+
+
+def tax_classes(db):
+ objects = []
+ for name in ["Books", "Groceries"]:
+ tax_class, _ = TaxClass.objects.get_or_create(
+ name=name,
+ defaults={
+ "metadata": {"key": "value"},
+ "private_metadata": {"key": "value"},
+ },
+ )
+ TaxClassCountryRate.objects.bulk_create(
+ [
+ TaxClassCountryRate(country="PL", rate=23, tax_class=tax_class),
+ TaxClassCountryRate(country="DE", rate=19, tax_class=tax_class),
+ ]
+ )
+ objects.append(tax_class)
+ return objects
+
+
+def tax_class_zero_rates(db):
+ zero_rate_tax_class = TaxClass.objects.create(
+ name="No taxes",
+ metadata={
+ META_CODE_KEY: TAX_CODE_NON_TAXABLE_PRODUCT,
+ META_DESCRIPTION_KEY: "Non-taxable product",
+ },
+ )
+
+ # Create 0% rates for all countries
+ rates = [
+ TaxClassCountryRate(tax_class=zero_rate_tax_class, rate=0, country=code)
+ for code in countries.countries.keys()
+ ]
+ TaxClassCountryRate.objects.bulk_create(rates)
+ return zero_rate_tax_class
diff --git a/saleor/tax/tests/test_calculations.py b/saleor/tax/tests/test_calculations.py
new file mode 100644
index 0000000000..4fbf7f7cdb
--- /dev/null
+++ b/saleor/tax/tests/test_calculations.py
@@ -0,0 +1,22 @@
+from decimal import Decimal
+
+import pytest
+from prices import Money
+
+from ...core.prices import quantize_price
+from ..calculations import calculate_flat_rate_tax
+
+
+ "amount, net, gross, rate, prices_entered_with_tax",
+ [
+ ("10.00", "10.00", "12.30", Decimal(23), False),
+ ("10.00", "8.13", "10.00", Decimal(23), True),
+ ],
+)
+def test_calculate_flat_tax_rate(amount, net, gross, rate, prices_entered_with_tax):
+ currency = "PLN"
+ money = Money(amount=amount, currency=currency)
+ taxed_money = calculate_flat_rate_tax(money, rate, prices_entered_with_tax)
+ assert quantize_price(taxed_money.net.amount, currency) == Decimal(net)
+ assert quantize_price(taxed_money.gross.amount, currency) == Decimal(gross)
diff --git a/saleor/tax/tests/test_checkout_calculations.py b/saleor/tax/tests/test_checkout_calculations.py
new file mode 100644
index 0000000000..101694ccbe
--- /dev/null
+++ b/saleor/tax/tests/test_checkout_calculations.py
@@ -0,0 +1,828 @@
+from decimal import Decimal
+
+import pytest
+from prices import Money, TaxedMoney
+
+from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines
+from ...checkout.utils import add_variant_to_checkout
+from ...core.prices import quantize_price
+from ...core.taxes import zero_taxed_money
+from ...plugins.manager import get_plugins_manager
+from ...tax.models import TaxClassCountryRate
+from .. import TaxCalculationStrategy
+from ..calculations.checkout import (
+ _calculate_checkout_line_unit_price,
+ calculate_checkout_line_total,
+ calculate_checkout_shipping,
+ update_checkout_prices_with_flat_rates,
+)
+
+
+def _enable_flat_rates(checkout, prices_entered_with_tax):
+ tc = checkout.channel.tax_configuration
+ tc.country_exceptions.all().delete()
+ tc.prices_entered_with_tax = prices_entered_with_tax
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.save()
+
+
+ "with_discount, expected_net, expected_gross, voucher_amount, "
+ "prices_entered_with_tax",
+ [
+ (True, "20.33", "25.00", "0.0", True),
+ (True, "20.00", "24.60", "5.0", False),
+ (False, "40.00", "49.20", "0.0", False),
+ (False, "30.08", "37.00", "3.0", True),
+ ],
+)
+def test_calculate_checkout_total(
+ checkout_with_item,
+ address,
+ shipping_zone,
+ discount_info,
+ voucher,
+ with_discount,
+ expected_net,
+ expected_gross,
+ voucher_amount,
+ prices_entered_with_tax,
+):
+ # given
+ checkout = checkout_with_item
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout.shipping_address = address
+ voucher_amount = Money(voucher_amount, "USD")
+ checkout.shipping_method = shipping_zone.shipping_methods.get()
+ checkout.voucher_code = voucher.code
+ checkout.discount = voucher_amount
+ checkout.save()
+
+ line = checkout.lines.first()
+ product = line.variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=23)
+
+ discounts = [discount_info] if with_discount else None
+ lines, _ = fetch_checkout_lines(checkout)
+ manager = get_plugins_manager()
+ checkout_info = fetch_checkout_info(checkout, lines, discounts, manager)
+
+ # when
+ update_checkout_prices_with_flat_rates(
+ checkout, checkout_info, lines, prices_entered_with_tax, address, discounts
+ )
+
+ # then
+ assert checkout.total == TaxedMoney(
+ net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
+ )
+
+
+def test_calculate_checkout_total_no_tax_rates(
+ checkout_with_item,
+ address,
+ shipping_zone,
+):
+ # given
+ checkout = checkout_with_item
+ prices_entered_with_tax = False
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout.shipping_address = address
+ shipping_method = shipping_zone.shipping_methods.get()
+ checkout.shipping_method = shipping_method
+ checkout.save()
+
+ TaxClassCountryRate.objects.all().delete()
+
+ lines, _ = fetch_checkout_lines(checkout)
+ manager = get_plugins_manager()
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+
+ # when
+ update_checkout_prices_with_flat_rates(
+ checkout, checkout_info, lines, prices_entered_with_tax, address, []
+ )
+
+ # then
+ assert checkout.total == TaxedMoney(
+ net=Money("40.00", "USD"), gross=Money("40.00", "USD")
+ )
+
+
+def test_calculate_checkout_total_default_tax_rate_for_country(
+ checkout_with_item,
+ address,
+ shipping_zone,
+):
+ # given
+ checkout = checkout_with_item
+ prices_entered_with_tax = False
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout.shipping_address = address
+ shipping_method = shipping_zone.shipping_methods.get()
+ checkout.shipping_method = shipping_method
+ checkout.save()
+
+ TaxClassCountryRate.objects.all().delete()
+ TaxClassCountryRate.objects.create(country=address.country, rate=23)
+
+ lines, _ = fetch_checkout_lines(checkout)
+ manager = get_plugins_manager()
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+
+ # when
+ update_checkout_prices_with_flat_rates(
+ checkout, checkout_info, lines, prices_entered_with_tax, address, []
+ )
+
+ # then
+ assert checkout.total == TaxedMoney(
+ net=Money("40.00", "USD"), gross=Money("49.20", "USD")
+ )
+
+
+ "with_discount, expected_net, expected_gross, voucher_amount, "
+ "prices_entered_with_tax",
+ [
+ (True, "20.33", "25.00", "0.0", True),
+ (True, "20.00", "24.60", "5.0", False),
+ (False, "40.00", "49.20", "0.0", False),
+ (False, "30.08", "37.00", "3.0", True),
+ ],
+)
+def test_calculate_checkout_total_shipping_voucher(
+ checkout_with_item,
+ address,
+ shipping_zone,
+ discount_info,
+ voucher_shipping_type,
+ with_discount,
+ expected_net,
+ expected_gross,
+ voucher_amount,
+ prices_entered_with_tax,
+):
+ # given
+ checkout = checkout_with_item
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ manager = get_plugins_manager()
+ checkout.shipping_address = address
+ checkout.save()
+ voucher_amount = Money(voucher_amount, "USD")
+
+ checkout.shipping_method = shipping_zone.shipping_methods.get()
+ checkout.voucher_code = voucher_shipping_type.code
+ checkout.discount = voucher_amount
+ checkout.save()
+
+ line = checkout.lines.first()
+ product = line.variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=23)
+
+ discounts = [discount_info] if with_discount else None
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, discounts, manager)
+
+ # when
+ update_checkout_prices_with_flat_rates(
+ checkout, checkout_info, lines, prices_entered_with_tax, address, discounts
+ )
+
+ # then
+ assert checkout.total == TaxedMoney(
+ net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
+ )
+
+
+ "with_discount, expected_net, expected_gross, prices_entered_with_tax",
+ [
+ (True, "20.33", "25.00", True),
+ (False, "40.65", "50.00", True),
+ (True, "25.00", "30.75", False),
+ (False, "50.00", "61.50", False),
+ ],
+)
+def test_calculate_checkout_subtotal(
+ checkout_with_item,
+ address,
+ shipping_zone,
+ discount_info,
+ with_discount,
+ expected_net,
+ expected_gross,
+ prices_entered_with_tax,
+ stock,
+):
+ # given
+ checkout = checkout_with_item
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ variant = stock.product_variant
+ product = variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=23)
+
+ checkout.shipping_address = address
+ checkout.shipping_method = shipping_zone.shipping_methods.get()
+ checkout.save()
+
+ discounts = [discount_info] if with_discount else None
+ manager = get_plugins_manager()
+ checkout_info = fetch_checkout_info(checkout, [], discounts, manager)
+ add_variant_to_checkout(checkout_info, variant, 2)
+ lines, _ = fetch_checkout_lines(checkout)
+
+ # when
+ update_checkout_prices_with_flat_rates(
+ checkout, checkout_info, lines, prices_entered_with_tax, address, discounts
+ )
+
+ # then
+ assert checkout.subtotal == TaxedMoney(
+ net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
+ )
+
+
+def test_calculate_checkout_line_total(checkout_with_item, shipping_zone, address):
+ manager = get_plugins_manager()
+ checkout = checkout_with_item
+
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ line = checkout.lines.first()
+ assert line.quantity > 1
+
+ method = shipping_zone.shipping_methods.get()
+ checkout.shipping_address = address
+ checkout.shipping_method_name = method.name
+ checkout.shipping_method = method
+ checkout.save()
+
+ variant = line.variant
+ product = variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=rate)
+
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+ checkout_line_info = lines[0]
+
+ line_price = calculate_checkout_line_total(
+ checkout_info, lines, checkout_line_info, [], rate, prices_entered_with_tax
+ )
+
+ assert line_price == TaxedMoney(
+ net=Money("8.13", "USD") * line.quantity,
+ gross=Money("10.00", "USD") * line.quantity,
+ )
+
+
+def test_calculate_checkout_line_total_voucher_on_entire_order(
+ checkout_with_item, shipping_zone, address, voucher
+):
+ # given
+ checkout = checkout_with_item
+ manager = get_plugins_manager()
+
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ line = checkout.lines.first()
+ assert line.quantity > 1
+
+ method = shipping_zone.shipping_methods.get()
+ checkout.shipping_address = address
+ checkout.shipping_method_name = method.name
+ checkout.shipping_method = method
+ discount_amount = Decimal(5)
+ checkout.discount_amount = discount_amount
+ checkout.voucher_code = voucher.code
+ checkout.save()
+
+ variant = line.variant
+ product = variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=rate)
+
+ channel = checkout.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
+ total_price = channel_listing.price * line.quantity
+
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+ checkout_line_info = lines[0]
+
+ # when
+ line_price = calculate_checkout_line_total(
+ checkout_info, lines, checkout_line_info, [], rate, prices_entered_with_tax
+ )
+
+ # then
+ currency = checkout.currency
+ total_gross = Money(total_price.amount - discount_amount, currency)
+ unit_net = total_gross / line.quantity / Decimal("1.23")
+ assert line_price == TaxedMoney(
+ net=quantize_price(unit_net * line.quantity, currency),
+ gross=quantize_price(total_gross, currency),
+ )
+
+
+def test_calculate_checkout_line_unit_price(checkout_with_item, shipping_zone, address):
+ # given
+ manager = get_plugins_manager()
+ checkout = checkout_with_item
+ channel = checkout.channel
+ line = checkout_with_item.lines.first()
+
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ method = shipping_zone.shipping_methods.get()
+ checkout.shipping_address = address
+ checkout.shipping_method_name = method.name
+ checkout.shipping_method = method
+ checkout.save()
+
+ variant = line.variant
+ product = variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=rate)
+
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+ checkout_line_info = lines[0]
+
+ # when
+ line_price = _calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ channel,
+ [],
+ rate,
+ prices_entered_with_tax,
+ )
+
+ # then
+ assert quantize_price(line_price, line_price.currency) == TaxedMoney(
+ net=Money("8.13", "USD"), gross=Money("10.00", "USD")
+ )
+
+
+def test_calculate_checkout_line_unit_price_with_voucher_one_line(
+ checkout_with_item, shipping_zone, address, voucher
+):
+ # given
+ checkout = checkout_with_item
+ manager = get_plugins_manager()
+ line = checkout_with_item.lines.first()
+
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ method = shipping_zone.shipping_methods.get()
+ checkout.shipping_address = address
+ checkout.shipping_method_name = method.name
+ checkout.shipping_method = method
+ discount_amount = Decimal(5)
+ checkout.discount_amount = discount_amount
+ checkout.voucher_code = voucher.code
+ checkout.save()
+
+ variant = line.variant
+ product = variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=rate)
+
+ channel = checkout.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
+ total_price = channel_listing.price * line.quantity
+
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+ checkout_line_info = lines[0]
+
+ # when
+ line_price = _calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ channel,
+ [],
+ rate,
+ prices_entered_with_tax,
+ )
+
+ # then
+ currency = checkout_with_item.currency
+ unit_gross = Money(total_price.amount - discount_amount, currency) / line.quantity
+ assert quantize_price(line_price, line_price.currency) == TaxedMoney(
+ net=quantize_price(unit_gross / Decimal(1.23), currency),
+ gross=quantize_price(unit_gross, currency),
+ )
+
+
+def test_calculate_checkout_line_unit_price_with_voucher_multiple_lines(
+ checkout_with_item, shipping_zone, address, voucher, product_list
+):
+ # given
+ manager = get_plugins_manager()
+ checkout = checkout_with_item
+
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout_info = fetch_checkout_info(checkout, [], [], manager)
+ variant_1 = product_list[0].variants.last()
+ variant_2 = product_list[1].variants.last()
+ qty_1 = 2
+ qty_2 = 3
+ add_variant_to_checkout(checkout_info, variant_1, qty_1)
+ add_variant_to_checkout(checkout_info, variant_2, qty_2)
+
+ method = shipping_zone.shipping_methods.get()
+ checkout.shipping_address = address
+ checkout.shipping_method_name = method.name
+ checkout.shipping_method = method
+ discount_amount = Decimal("5")
+ checkout.discount_amount = discount_amount
+ checkout.voucher_code = voucher.code
+ checkout.save()
+
+ line = checkout.lines.first()
+ variant = line.variant
+ product = variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=rate)
+
+ channel = checkout.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
+ total_line_price = channel_listing.price * line.quantity
+
+ total_unit_prices = (
+ variant_1.channel_listings.get(channel=channel).price * qty_1
+ + variant_2.channel_listings.get(channel=channel).price * qty_2
+ + total_line_price
+ )
+
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+ checkout_line_info = lines[0]
+
+ # when
+ line_price = _calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ channel,
+ [],
+ rate,
+ prices_entered_with_tax,
+ )
+
+ # then
+ currency = checkout.currency
+ discount_amount = quantize_price(
+ total_line_price / total_unit_prices * discount_amount, currency
+ )
+ unit_gross = (total_line_price - Money(discount_amount, currency)) / line.quantity
+ assert quantize_price(line_price, currency) == TaxedMoney(
+ net=quantize_price(unit_gross / Decimal("1.23"), currency),
+ gross=quantize_price(unit_gross, currency),
+ )
+
+
+def test_calculate_checkout_line_unit_price_with_voucher_multiple_lines_last_line(
+ checkout_with_item, shipping_zone, address, voucher, product_list
+):
+ # given
+ manager = get_plugins_manager()
+ checkout = checkout_with_item
+
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ currency = checkout.currency
+
+ checkout_info = fetch_checkout_info(checkout, [], [], manager)
+ variant_1 = product_list[0].variants.last()
+ variant_2 = product_list[1].variants.last()
+ qty_1 = 2
+ qty_2 = 3
+ add_variant_to_checkout(checkout_info, variant_1, qty_1)
+ add_variant_to_checkout(checkout_info, variant_2, qty_2)
+
+ method = shipping_zone.shipping_methods.get()
+ checkout.shipping_address = address
+ checkout.shipping_method_name = method.name
+ checkout.shipping_method = method
+ discount_amount = Decimal("5")
+ checkout.discount_amount = discount_amount
+ checkout.voucher_code = voucher.code
+ checkout.save()
+
+ line = checkout.lines.last()
+ variant = line.variant
+ product = variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=rate)
+
+ channel = checkout.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
+ total_line_price = channel_listing.price * line.quantity
+
+ total_unit_prices = Money(
+ sum(
+ [
+ line.variant.channel_listings.get(channel=channel).price.amount
+ * line.quantity
+ for line in checkout.lines.all()
+ ]
+ ),
+ currency,
+ )
+
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+ checkout_line_info = lines[-1]
+
+ # when
+ line_price = _calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ channel,
+ [],
+ rate,
+ prices_entered_with_tax,
+ )
+
+ # then
+ discount_amount = (
+ discount_amount
+ - (total_unit_prices - total_line_price) / total_unit_prices * discount_amount
+ )
+ unit_gross = (total_line_price - Money(discount_amount, currency)) / line.quantity
+ assert quantize_price(line_price, currency) == TaxedMoney(
+ net=quantize_price(unit_gross / Decimal("1.23"), currency),
+ gross=quantize_price(unit_gross, currency),
+ )
+
+
+def test_calculate_checkout_line_unit_price_with_shipping_voucher(
+ checkout_with_item,
+ shipping_zone,
+ address,
+ voucher_shipping_type,
+):
+ # given
+ manager = get_plugins_manager()
+ checkout = checkout_with_item
+
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ line = checkout.lines.first()
+
+ method = shipping_zone.shipping_methods.get()
+ checkout.shipping_address = address
+ checkout.shipping_method_name = method.name
+ checkout.shipping_method = method
+ checkout.discount_amount = Decimal("5")
+ checkout.voucher_code = voucher_shipping_type.code
+ checkout.save()
+
+ variant = line.variant
+ product = variant.product
+ product.tax_class.country_rates.update_or_create(country=address.country, rate=rate)
+
+ channel = checkout.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
+ unit_gross = channel_listing.price
+
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [], manager)
+ checkout_line_info = lines[0]
+
+ # when
+ line_price = _calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ channel,
+ [],
+ rate,
+ prices_entered_with_tax,
+ )
+
+ # then
+ assert quantize_price(line_price, checkout.currency) == TaxedMoney(
+ net=quantize_price(unit_gross / Decimal("1.23"), checkout.currency),
+ gross=unit_gross,
+ )
+
+
+def test_calculate_checkout_shipping(
+ checkout_with_item,
+ shipping_zone,
+ discount_info,
+ address,
+):
+ # given
+ checkout = checkout_with_item
+ manager = get_plugins_manager()
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout.shipping_address = address
+ checkout.shipping_method = shipping_zone.shipping_methods.get()
+ checkout.shipping_method.tax_class.country_rates.update_or_create(
+ country=address.country, rate=rate
+ )
+ checkout.save()
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [discount_info], manager)
+
+ # when
+ shipping_price = calculate_checkout_shipping(
+ checkout_info, lines, rate, prices_entered_with_tax
+ )
+
+ # then
+ shipping_price = quantize_price(shipping_price, shipping_price.currency)
+ assert shipping_price == TaxedMoney(
+ net=Money("8.13", "USD"), gross=Money("10.00", "USD")
+ )
+
+
+def test_calculate_checkout_shipping_no_shipping_price(
+ checkout_with_item,
+ discount_info,
+ address,
+ warehouse_for_cc,
+):
+ # given
+ checkout = checkout_with_item
+ manager = get_plugins_manager()
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout.shipping_address = address
+ checkout.collection_point = warehouse_for_cc
+ checkout.save(update_fields=["shipping_address", "collection_point"])
+
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [discount_info], manager)
+
+ # when
+ shipping_price = calculate_checkout_shipping(
+ checkout_info, lines, rate, prices_entered_with_tax
+ )
+
+ # then
+ shipping_price = quantize_price(shipping_price, shipping_price.currency)
+ assert shipping_price == TaxedMoney(
+ net=Money("0.00", "USD"), gross=Money("0.00", "USD")
+ )
+
+
+def test_calculate_checkout_shipping_voucher_on_shipping(
+ checkout_with_item,
+ shipping_zone,
+ discount_info,
+ address,
+ voucher_shipping_type,
+):
+ # given
+ checkout = checkout_with_item
+ manager = get_plugins_manager()
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout.shipping_address = address
+ shipping_method = shipping_zone.shipping_methods.get()
+ checkout.shipping_method = shipping_method
+ checkout.shipping_method.tax_class.country_rates.update_or_create(
+ country=address.country, rate=rate
+ )
+ checkout.voucher_code = voucher_shipping_type.code
+ discount_amount = Decimal("5.0")
+ checkout.discount_amount = discount_amount
+ checkout.save()
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [discount_info], manager)
+ channel = checkout.channel
+ shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
+ price = shipping_channel_listings.price
+
+ # when
+ shipping_price = calculate_checkout_shipping(
+ checkout_info, lines, rate, prices_entered_with_tax
+ )
+
+ # then
+ shipping_price = quantize_price(shipping_price, shipping_price.currency)
+ currency = checkout.currency
+ expected_gross_shipping_price = Money(price.amount - discount_amount, currency)
+ assert shipping_price == TaxedMoney(
+ net=quantize_price(expected_gross_shipping_price / Decimal(1.23), currency),
+ gross=expected_gross_shipping_price,
+ )
+
+
+def test_calculate_checkout_shipping_free_shipping_voucher(
+ checkout_with_item,
+ shipping_zone,
+ discount_info,
+ address,
+ voucher_shipping_type,
+):
+ # given
+ checkout = checkout_with_item
+ manager = get_plugins_manager()
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout.shipping_address = address
+ shipping_method = shipping_zone.shipping_methods.get()
+ checkout.shipping_method = shipping_method
+ checkout.shipping_method.tax_class.country_rates.update_or_create(
+ country=address.country, rate=rate
+ )
+ checkout.voucher_code = voucher_shipping_type.code
+ channel = checkout.channel
+ shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
+ price = shipping_channel_listings.price
+ checkout.discount_amount = price.amount
+ checkout.save()
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [discount_info], manager)
+
+ # when
+ shipping_price = calculate_checkout_shipping(
+ checkout_info, lines, rate, prices_entered_with_tax
+ )
+
+ # then
+ shipping_price = quantize_price(shipping_price, shipping_price.currency)
+ assert shipping_price == zero_taxed_money(checkout.currency)
+
+
+def test_calculate_checkout_shipping_free_entire_order_voucher(
+ checkout_with_item,
+ shipping_zone,
+ discount_info,
+ address,
+ voucher,
+):
+ # given
+ checkout = checkout_with_item
+ manager = get_plugins_manager()
+ rate = Decimal(23)
+ prices_entered_with_tax = True
+ _enable_flat_rates(checkout, prices_entered_with_tax)
+
+ checkout.shipping_address = address
+ shipping_method = shipping_zone.shipping_methods.get()
+ checkout.shipping_method = shipping_method
+ checkout.shipping_method.tax_class.country_rates.update_or_create(
+ country=address.country, rate=rate
+ )
+ checkout.voucher_code = voucher.code
+ channel = checkout.channel
+ shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
+ discount_amount = Decimal("5.0")
+ checkout.discount_amount = discount_amount
+ checkout.save()
+ lines, _ = fetch_checkout_lines(checkout)
+ checkout_info = fetch_checkout_info(checkout, lines, [discount_info], manager)
+
+ # when
+ shipping_price = calculate_checkout_shipping(
+ checkout_info, lines, rate, prices_entered_with_tax
+ )
+
+ # then
+ shipping_price = quantize_price(shipping_price, shipping_price.currency)
+ assert (
+ shipping_price
+ == shipping_price
+ == TaxedMoney(
+ net=quantize_price(
+ shipping_channel_listings.price / Decimal(1.23),
+ checkout.currency,
+ ),
+ gross=shipping_channel_listings.price,
+ )
+ )
diff --git a/saleor/tax/tests/test_order_calculations.py b/saleor/tax/tests/test_order_calculations.py
new file mode 100644
index 0000000000..1478145232
--- /dev/null
+++ b/saleor/tax/tests/test_order_calculations.py
@@ -0,0 +1,629 @@
+from decimal import Decimal
+
+from prices import Money, TaxedMoney
+
+from saleor.tax.models import TaxClassCountryRate
+
+from ...core.prices import quantize_price
+from ...core.taxes import zero_money, zero_taxed_money
+from ...discount import DiscountValueType, OrderDiscountType
+from ...order.utils import get_order_country
+from .. import TaxCalculationStrategy
+from ..calculations.order import (
+ update_order_prices_with_flat_rates,
+ update_taxes_for_order_lines,
+)
+
+
+def _enable_flat_rates(order, prices_entered_with_tax):
+ tc = order.channel.tax_configuration
+ tc.country_exceptions.all().delete()
+ tc.prices_entered_with_tax = prices_entered_with_tax
+ tc.tax_calculation_strategy = TaxCalculationStrategy.FLAT_RATES
+ tc.save()
+
+
+def test_calculations_calculate_order_total(order_with_lines):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("65.04", "USD"), gross=Money("80.00", "USD")
+ )
+
+
+def test_calculations_calculate_order_undiscounted_total(
+ order_with_lines, voucher_shipping_type
+):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ order.discounts.create(
+ type=OrderDiscountType.MANUAL,
+ value_type=DiscountValueType.FIXED,
+ value=10,
+ name="StaffDiscount",
+ translated_name="StaffDiscountPL",
+ currency=order.currency,
+ amount_value=10,
+ )
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal(5.0),
+ name=voucher_shipping_type.code,
+ currency=order.currency,
+ amount_value=Decimal(5.0),
+ )
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.undiscounted_total == TaxedMoney(
+ net=Money("80.00", "USD"), gross=Money("80.00", "USD")
+ )
+
+
+def test_calculations_calculate_order_total_use_product_type_tax_class(
+ order_with_lines,
+):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+ for line in lines:
+ line.variant.product.tax_class = None
+ line.variant.product.save()
+
+ country = get_order_country(order)
+ TaxClassCountryRate.objects.filter(tax_class=None, country=country).delete()
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("65.04", "USD"), gross=Money("80.00", "USD")
+ )
+
+
+def test_calculations_calculate_order_total_no_rates(order_with_lines):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ TaxClassCountryRate.objects.all().delete()
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("80.00", "USD"), gross=Money("80.00", "USD")
+ )
+
+
+def test_calculations_calculate_order_total_default_country_rate(order_with_lines):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ country = get_order_country(order)
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ TaxClassCountryRate.objects.all().delete()
+ TaxClassCountryRate.objects.create(country=country, rate=23)
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("65.04", "USD"), gross=Money("80.00", "USD")
+ )
+
+
+def test_calculations_calculate_order_total_voucher(order_with_lines):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ discount_amount = 10
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=discount_amount,
+ name="Voucher",
+ translated_name="VoucherPL",
+ currency=order.currency,
+ amount_value=10,
+ )
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("56.92", "USD"), gross=Money("70.01", "USD")
+ )
+
+
+def test_calculations_calculate_order_total_with_manual_discount(order_with_lines):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ order.discounts.create(
+ type=OrderDiscountType.MANUAL,
+ value_type=DiscountValueType.FIXED,
+ value=10,
+ name="StaffDiscount",
+ translated_name="StaffDiscountPL",
+ currency=order.currency,
+ amount_value=10,
+ )
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("56.92", "USD"), gross=Money("70.01", "USD")
+ )
+
+
+def test_calculations_calculate_order_total_with_discount_for_order_total(
+ order_with_lines,
+):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ order.discounts.create(
+ type=OrderDiscountType.MANUAL,
+ value_type=DiscountValueType.FIXED,
+ value=80,
+ name="StaffDiscount",
+ translated_name="StaffDiscountPL",
+ currency=order.currency,
+ amount_value=80,
+ )
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(net=Money("0", "USD"), gross=Money("0", "USD"))
+
+
+def test_calculations_calculate_order_total_with_discount_for_subtotal_and_shipping(
+ order_with_lines,
+):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ order.discounts.create(
+ type=OrderDiscountType.MANUAL,
+ value_type=DiscountValueType.FIXED,
+ value=75,
+ name="StaffDiscount",
+ translated_name="StaffDiscountPL",
+ currency=order.currency,
+ amount_value=75,
+ )
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("3.13", "USD"), gross=Money("5.00", "USD")
+ )
+
+
+def test_calculations_calculate_order_total_with_discount_for_more_than_order_total(
+ order_with_lines,
+):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ order.discounts.create(
+ type=OrderDiscountType.MANUAL,
+ value_type=DiscountValueType.FIXED,
+ value=100,
+ name="StaffDiscount",
+ translated_name="StaffDiscountPL",
+ currency=order.currency,
+ amount_value=100,
+ )
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(net=Money("0", "USD"), gross=Money("0", "USD"))
+
+
+def test_calculations_calculate_order_total_with_manual_discount_and_voucher(
+ order_with_lines,
+):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ order.discounts.create(
+ type=OrderDiscountType.MANUAL,
+ value_type=DiscountValueType.FIXED,
+ value=10,
+ name="StaffDiscount",
+ translated_name="StaffDiscountPL",
+ currency=order.currency,
+ amount_value=10,
+ )
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=10,
+ name="Voucher",
+ translated_name="VoucherPL",
+ currency=order.currency,
+ amount_value=10,
+ )
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("48.78", "USD"), gross=Money("60.00", "USD")
+ )
+
+
+def test_calculate_order_shipping(order_line, shipping_zone):
+ # given
+ order = order_line.order
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ method = shipping_zone.shipping_methods.get()
+ order.shipping_address = order.billing_address.get_copy()
+ order.shipping_method_name = method.name
+ order.shipping_method = method
+ order.base_shipping_price = method.channel_listings.get(channel=order.channel).price
+ order.save()
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ price = order.shipping_price
+ price = quantize_price(price, price.currency)
+ assert price == TaxedMoney(net=Money("8.13", "USD"), gross=Money("10.00", "USD"))
+
+
+def test_calculate_order_shipping_for_order_without_shipping(order_line, shipping_zone):
+ # given
+ order = order_line.order
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ order.shipping_method = None
+ order.save()
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ price = order.shipping_price
+ assert price == zero_taxed_money(order.currency)
+
+
+def test_calculate_order_shipping_voucher_on_shipping(
+ order_line, shipping_zone, voucher_shipping_type
+):
+ # given
+ order = order_line.order
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+ currency = order.currency
+ discount_amount = Decimal("5.0")
+
+ method = shipping_zone.shipping_methods.get()
+ order.shipping_address = order.billing_address.get_copy()
+ order.shipping_method_name = method.name
+ order.shipping_method = method
+ order.base_shipping_price = method.channel_listings.get(
+ channel=order.channel
+ ).price - Money(discount_amount, currency)
+ order.voucher = voucher_shipping_type
+ order.save()
+
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=discount_amount,
+ name=voucher_shipping_type.code,
+ currency=currency,
+ amount_value=discount_amount,
+ )
+ channel = order.channel
+ shipping_channel_listings = method.channel_listings.get(channel=channel)
+ shipping_price = shipping_channel_listings.price
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ price = order.shipping_price
+ price = quantize_price(price, price.currency)
+ expected_gross_amount = shipping_price.amount - discount_amount
+ assert price == TaxedMoney(
+ net=quantize_price(
+ Money(expected_gross_amount / Decimal("1.23"), currency), currency
+ ),
+ gross=Money(expected_gross_amount, currency),
+ )
+
+
+def test_calculate_order_shipping_free_shipping_voucher(
+ order_line, shipping_zone, voucher_shipping_type
+):
+ # given
+ order = order_line.order
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+
+ method = shipping_zone.shipping_methods.get()
+ order.shipping_address = order.billing_address.get_copy()
+ order.shipping_method_name = method.name
+ order.shipping_method = method
+ order.base_shipping_price = zero_money(order.currency)
+ order.voucher = voucher_shipping_type
+ order.save()
+
+ currency = order.currency
+ channel = order.channel
+ shipping_channel_listings = method.channel_listings.get(channel=channel)
+ shipping_price = shipping_channel_listings.price
+
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.PERCENTAGE,
+ value=Decimal("100.0"),
+ name=voucher_shipping_type.code,
+ currency=currency,
+ amount_value=shipping_price.amount,
+ )
+
+ # when
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ price = order.shipping_price
+ price = quantize_price(price, price.currency)
+ assert price == zero_taxed_money(currency)
+
+
+def test_update_taxes_for_order_lines(order_with_lines):
+ # given
+ order = order_with_lines
+ currency = order.currency
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+ country_code = get_order_country(order)
+
+ # when
+ lines, _ = update_taxes_for_order_lines(
+ order, lines, country_code, Decimal(23), prices_entered_with_tax
+ )
+
+ # then
+
+ for line in lines:
+ assert line.unit_price == TaxedMoney(
+ net=quantize_price(line.base_unit_price / Decimal("1.23"), currency),
+ gross=line.base_unit_price,
+ )
+ assert line.undiscounted_unit_price == line.unit_price
+ assert line.total_price == TaxedMoney(
+ net=quantize_price(
+ line.base_unit_price / Decimal("1.23") * line.quantity, currency
+ ),
+ gross=line.base_unit_price * line.quantity,
+ )
+ assert line.undiscounted_total_price == line.total_price
+ assert line.tax_rate == Decimal("0.23")
+
+
+def test_update_taxes_for_order_lines_voucher_on_entire_order(
+ order_with_lines, voucher
+):
+ # given
+ order = order_with_lines
+ currency = order.currency
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+ country_code = get_order_country(order)
+
+ order.voucher = voucher
+ lines = list(order.lines.all())
+ total_amount = sum([line.base_unit_price.amount * line.quantity for line in lines])
+ order.undiscounted_total_gross_amount = total_amount
+ order.undiscounted_total_net_amount = total_amount
+ order.save(
+ update_fields=[
+ "voucher",
+ "undiscounted_total_gross_amount",
+ "undiscounted_total_net_amount",
+ ]
+ )
+
+ order_discount_amount = Decimal("5.0")
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=order_discount_amount,
+ name=voucher.code,
+ currency=currency,
+ amount_value=order_discount_amount,
+ )
+
+ # when
+ lines, _ = update_taxes_for_order_lines(
+ order, lines, country_code, Decimal(23), prices_entered_with_tax
+ )
+
+ # then
+ for line in lines:
+ total_line_price = line.base_unit_price * line.quantity
+ discount_amount = quantize_price(
+ total_line_price.amount / total_amount * order_discount_amount, currency
+ )
+ unit_gross = quantize_price(
+ (total_line_price - Money(discount_amount, currency)) / line.quantity,
+ currency,
+ )
+ assert line.unit_price == TaxedMoney(
+ net=quantize_price(unit_gross / Decimal("1.23"), currency),
+ gross=quantize_price(unit_gross, currency),
+ )
+ assert line.undiscounted_unit_price == TaxedMoney(
+ net=quantize_price(line.base_unit_price / Decimal("1.23"), currency),
+ gross=line.base_unit_price,
+ )
+ assert line.total_price == TaxedMoney(
+ net=quantize_price(unit_gross / Decimal("1.23") * line.quantity, currency),
+ gross=quantize_price(unit_gross * line.quantity, currency),
+ )
+ assert line.undiscounted_total_price == TaxedMoney(
+ net=quantize_price(
+ line.base_unit_price / Decimal("1.23") * line.quantity, currency
+ ),
+ gross=quantize_price(line.base_unit_price * line.quantity, currency),
+ )
+ assert line.tax_rate == (line.unit_price.tax / line.unit_price.net).quantize(
+ Decimal(".001")
+ )
+
+
+def test_update_taxes_for_order_lines_voucher_on_shipping(
+ order_with_lines, voucher_shipping_type
+):
+ # given
+ order = order_with_lines
+ currency = order.currency
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+ country_code = get_order_country(order)
+
+ order.voucher = voucher_shipping_type
+ lines = list(order.lines.all())
+ total_amount = sum([line.base_unit_price.amount * line.quantity for line in lines])
+ order.undiscounted_total_gross_amount = total_amount
+ order.undiscounted_total_net_amount = total_amount
+ order.save(
+ update_fields=[
+ "voucher",
+ "undiscounted_total_gross_amount",
+ "undiscounted_total_net_amount",
+ ]
+ )
+
+ order_discount_amount = Decimal("5.0")
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=order_discount_amount,
+ name=voucher_shipping_type.code,
+ currency=currency,
+ amount_value=order_discount_amount,
+ )
+
+ # when
+ lines, _ = update_taxes_for_order_lines(
+ order, lines, country_code, Decimal(23), prices_entered_with_tax
+ )
+
+ # then
+ for line in lines:
+ assert line.unit_price == TaxedMoney(
+ net=quantize_price(line.base_unit_price / Decimal("1.23"), currency),
+ gross=line.base_unit_price,
+ )
+ assert line.undiscounted_unit_price == line.unit_price
+ assert line.total_price == TaxedMoney(
+ net=quantize_price(
+ line.base_unit_price / Decimal("1.23") * line.quantity, currency
+ ),
+ gross=line.base_unit_price * line.quantity,
+ )
+ assert line.undiscounted_total_price == line.total_price
+ assert line.tax_rate == Decimal("0.23")
+
+
+def test_use_original_tax_rate_when_tax_class_is_removed_from_order_line(
+ order_with_lines,
+):
+ # given
+ order = order_with_lines
+ prices_entered_with_tax = True
+ _enable_flat_rates(order, prices_entered_with_tax)
+ lines = order.lines.all()
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # when
+ for line in lines:
+ tax_class = line.variant.product.tax_class
+ if tax_class:
+ tax_class.delete()
+ tax_class = line.variant.product.product_type.tax_class
+ if tax_class:
+ tax_class.delete()
+ line.refresh_from_db()
+
+ shipping_tax_class = order.shipping_method.tax_class
+ if shipping_tax_class:
+ shipping_tax_class.delete()
+ order.shipping_method.refresh_from_db()
+
+ update_order_prices_with_flat_rates(order, lines, prices_entered_with_tax)
+
+ # then
+ assert order.total == TaxedMoney(
+ net=Money("65.04", "USD"), gross=Money("80.00", "USD")
+ )
diff --git a/saleor/tax/tests/test_utils.py b/saleor/tax/tests/test_utils.py
new file mode 100644
index 0000000000..23efdfd508
--- /dev/null
+++ b/saleor/tax/tests/test_utils.py
@@ -0,0 +1,84 @@
+from ..utils import get_charge_taxes, get_display_gross_prices, get_tax_country
+
+
+def test_get_display_gross_prices(channel_USD):
+ # given
+ tax_configuration = channel_USD.tax_configuration
+ tax_configuration.display_gross_prices = True
+ tax_configuration.save(update_fields=["charge_taxes"])
+ country_exception = tax_configuration.country_exceptions.first()
+ country_exception.display_gross_prices = False
+ country_exception.save(update_fields=["charge_taxes"])
+
+ # then
+ assert (
+ get_display_gross_prices(tax_configuration, None)
+ == tax_configuration.display_gross_prices
+ )
+ assert (
+ get_display_gross_prices(tax_configuration, country_exception)
+ == country_exception.display_gross_prices
+ )
+
+
+def test_get_charge_taxes(channel_USD):
+ # given
+ tax_configuration = channel_USD.tax_configuration
+ tax_configuration.charge_taxes = True
+ tax_configuration.save(update_fields=["charge_taxes"])
+ country_exception = tax_configuration.country_exceptions.first()
+ country_exception.charge_taxes = False
+ country_exception.save(update_fields=["charge_taxes"])
+
+ # then
+ assert get_charge_taxes(tax_configuration, None) == tax_configuration.charge_taxes
+ assert (
+ get_charge_taxes(tax_configuration, country_exception)
+ == country_exception.charge_taxes
+ )
+
+
+def test_get_tax_country_use_shipping_address(
+ channel_USD, address_usa, address_other_country
+):
+ # given
+ is_shipping_required = True
+ shipping_address = address_usa
+ billing_address = address_other_country
+
+ # when
+ country = get_tax_country(
+ channel_USD, is_shipping_required, shipping_address, billing_address
+ )
+
+ # then
+ assert country == address_usa.country.code
+
+
+def test_get_tax_country_use_billing_address(
+ channel_USD, address_usa, address_other_country
+):
+ # given
+ is_shipping_required = False
+ shipping_address = address_usa
+ billing_address = address_other_country
+
+ # when
+ country = get_tax_country(
+ channel_USD, is_shipping_required, shipping_address, billing_address
+ )
+
+ # then
+ assert country == address_other_country.country.code
+
+
+def test_get_tax_country_fallbacks_to_channel_country(channel_USD):
+ # given
+ shipping_address = None
+ billing_address = None
+
+ # when
+ country = get_tax_country(channel_USD, True, shipping_address, billing_address)
+
+ # then
+ assert country == channel_USD.default_country.code
diff --git a/saleor/tax/utils.py b/saleor/tax/utils.py
new file mode 100644
index 0000000000..1c97016235
--- /dev/null
+++ b/saleor/tax/utils.py
@@ -0,0 +1,234 @@
+from decimal import Decimal
+from typing import TYPE_CHECKING, Iterable, Optional, Tuple
+
+from prices import TaxedMoney
+
+if TYPE_CHECKING:
+ from ..account.models import Address
+ from ..channel.models import Channel
+ from ..checkout.fetch import CheckoutInfo, CheckoutLineInfo
+ from ..order.models import Order
+ from ..tax.models import TaxClass, TaxClassCountryRate
+ from .models import TaxConfiguration, TaxConfigurationPerCountry
+
+
+def get_tax_country(
+ channel: "Channel",
+ is_shipping_required: bool,
+ shipping_address: Optional["Address"] = None,
+ billing_address: Optional["Address"] = None,
+):
+ """Get country code for tax calculations.
+
+ For checkouts and orders, there are following rules for determining the country
+ code that should be used for tax calculations:
+ - when shipping is required, use the shipping address's country code,
+ - when shipping is not required (e.g. because of having only digital products), use
+ the billing address's country code,
+ - fallback to channel's default country when addresses are not provided.
+ """
+ if shipping_address and is_shipping_required:
+ return shipping_address.country.code
+
+ if billing_address and not is_shipping_required:
+ return billing_address.country.code
+
+ return channel.default_country.code
+
+
+def get_display_gross_prices(
+ channel_tax_configuration: "TaxConfiguration",
+ country_tax_configuration: Optional["TaxConfigurationPerCountry"],
+):
+ """Get display_gross_prices value for tax channel configuration.
+
+ :param channel_tax_configuration: Channel-specific tax configuration.
+ :param country_tax_configuration: Country-specific tax configuration for the given
+ channel.
+ """
+ return (
+ country_tax_configuration.display_gross_prices
+ if country_tax_configuration
+ else channel_tax_configuration.display_gross_prices
+ )
+
+
+def get_charge_taxes(
+ channel_tax_configuration: "TaxConfiguration",
+ country_tax_configuration: Optional["TaxConfigurationPerCountry"],
+) -> bool:
+ """Get charge_taxes value for tax channel configuration.
+
+ :param channel_tax_configuration: Channel-specific tax configuration.
+ :param country_tax_configuration: Country-specific tax configuration for the given
+ channel.
+ """
+ return (
+ country_tax_configuration.charge_taxes
+ if country_tax_configuration
+ else channel_tax_configuration.charge_taxes
+ )
+
+
+def get_tax_calculation_strategy(
+ channel_tax_configuration: "TaxConfiguration",
+ country_tax_configuration: Optional["TaxConfigurationPerCountry"],
+) -> Optional[str]:
+ """Get tax_calculation_strategy value for tax channel configuration.
+
+ :param channel_tax_configuration: Channel-specific tax configuration.
+ :param country_tax_configuration: Country-specific tax configuration for the given
+ channel.
+ """
+ return (
+ country_tax_configuration.tax_calculation_strategy
+ if country_tax_configuration
+ else channel_tax_configuration.tax_calculation_strategy
+ )
+
+
+def get_charge_taxes_for_order(order: "Order") -> bool:
+ """Get charge_taxes value for order."""
+ channel = order.channel
+ tax_configuration = channel.tax_configuration
+ country_code = get_tax_country(
+ channel,
+ order.is_shipping_required(),
+ order.shipping_address,
+ order.billing_address,
+ )
+ country_tax_configuration = next(
+ (
+ tc
+ for tc in tax_configuration.country_exceptions.all()
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ return get_charge_taxes(tax_configuration, country_tax_configuration)
+
+
+def get_tax_calculation_strategy_for_order(order: "Order"):
+ """Get tax_calculation_strategy value for order."""
+ channel = order.channel
+ tax_configuration = channel.tax_configuration
+ country_code = get_tax_country(
+ channel,
+ order.is_shipping_required(),
+ order.shipping_address,
+ order.billing_address,
+ )
+ country_tax_configuration = next(
+ (
+ tc
+ for tc in tax_configuration.country_exceptions.all()
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ return get_tax_calculation_strategy(tax_configuration, country_tax_configuration)
+
+
+def _get_tax_configuration_for_checkout(
+ checkout_info: "CheckoutInfo", lines: Iterable["CheckoutLineInfo"]
+) -> Tuple["TaxConfiguration", Optional["TaxConfigurationPerCountry"]]:
+ from ..checkout.utils import is_shipping_required
+
+ tax_configuration = checkout_info.tax_configuration
+ country_code = get_tax_country(
+ checkout_info.channel,
+ is_shipping_required(lines),
+ checkout_info.shipping_address,
+ checkout_info.billing_address,
+ )
+ country_tax_configuration = next(
+ (
+ tc
+ for tc in tax_configuration.country_exceptions.all()
+ if tc.country.code == country_code
+ ),
+ None,
+ )
+ return tax_configuration, country_tax_configuration
+
+
+def get_charge_taxes_for_checkout(
+ checkout_info: "CheckoutInfo", lines: Iterable["CheckoutLineInfo"]
+):
+ """Get charge_taxes value for checkout."""
+ tax_configuration, country_tax_configuration = _get_tax_configuration_for_checkout(
+ checkout_info, lines
+ )
+ return get_charge_taxes(tax_configuration, country_tax_configuration)
+
+
+def get_tax_calculation_strategy_for_checkout(
+ checkout_info: "CheckoutInfo", lines: Iterable["CheckoutLineInfo"]
+):
+ """Get tax_calculation_strategy value for checkout."""
+ tax_configuration, country_tax_configuration = _get_tax_configuration_for_checkout(
+ checkout_info, lines
+ )
+ return get_tax_calculation_strategy(tax_configuration, country_tax_configuration)
+
+
+def normalize_tax_rate_for_db(tax_rate: Decimal) -> Decimal:
+ # Percentage values are used to represent tax rates in tax apps and flat rates, but
+ # in the database rates are stored as fractional values. Example: tax app returns
+ # `10%` as `10`, but in the database it's stored as `0.1`.
+ return tax_rate / 100
+
+
+def denormalize_tax_rate_from_db(tax_rate: Decimal) -> Decimal:
+ # Revert results of `normalize_tax_rate_for_db`.
+ return tax_rate * 100
+
+
+def calculate_tax_rate(price: TaxedMoney) -> Decimal:
+ """Calculate the tax rate as percentage value from given price.
+
+ Requires a TaxedMoney instance with net and gross amounts set.
+ """
+ tax_rate = Decimal("0.0")
+ # The condition will return False when unit_price.gross or unit_price.net is 0.0
+ if not isinstance(price, Decimal) and all((price.gross, price.net)):
+ tax_rate = price.tax / price.net
+ return tax_rate
+
+
+def get_tax_rate_for_tax_class(
+ tax_class: Optional["TaxClass"],
+ tax_class_country_rates: Iterable["TaxClassCountryRate"],
+ default_tax_rate: Decimal,
+ country_code: str,
+) -> Decimal:
+ tax_rate = default_tax_rate
+ if tax_class:
+ for country_rate in tax_class_country_rates:
+ if country_rate.country == country_code:
+ tax_rate = country_rate.rate
+ return tax_rate
+
+
+def get_tax_class_kwargs_for_order_line(tax_class: Optional["TaxClass"]):
+ if not tax_class:
+ return {}
+
+ return {
+ "tax_class": tax_class,
+ "tax_class_name": tax_class.name,
+ "tax_class_private_metadata": tax_class.private_metadata,
+ "tax_class_metadata": tax_class.metadata,
+ }
+
+
+def get_shipping_tax_class_kwargs_for_order(tax_class: Optional["TaxClass"]):
+ if not tax_class:
+ return {}
+
+ return {
+ "shipping_tax_class": tax_class,
+ "shipping_tax_class_name": tax_class.name,
+ "shipping_tax_class_private_metadata": tax_class.private_metadata,
+ "shipping_tax_class_metadata": tax_class.metadata,
+ }
diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.py
index b98bd08449..c1dad19e4d 100644
--- a/saleor/tests/fixtures.py
+++ b/saleor/tests/fixtures.py
@@ -89,8 +89,6 @@ from ..payment import ChargeStatus, TransactionKind
from ..payment.interface import AddressData, GatewayConfig, GatewayResponse, PaymentData
from ..payment.models import Payment, TransactionItem
from ..plugins.manager import get_plugins_manager
-from ..plugins.models import PluginConfiguration
-from ..plugins.vatlayer.plugin import VatlayerPlugin
from ..plugins.webhook.tasks import WebhookResponse
from ..plugins.webhook.tests.subscription_webhooks import subscription_queries
from ..plugins.webhook.utils import to_payment_app_id
@@ -124,6 +122,7 @@ from ..shipping.models import (
)
from ..shipping.utils import convert_to_shipping_method_data
from ..site.models import SiteSettings
+from ..tax.utils import calculate_tax_rate, get_tax_class_kwargs_for_order_line
from ..warehouse import WarehouseClickAndCollectOption
from ..warehouse.models import (
Allocation,
@@ -223,20 +222,6 @@ def assert_max_num_queries(capture_queries):
return partial(capture_queries, exact=False)
-def setup_vatlayer(settings, channel_USD):
- settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
- data = {
- "active": True,
- "channel": channel_USD,
- "configuration": [
- {"name": "Access key", "value": "vatlayer_access_key"},
- ],
- }
- PluginConfiguration.objects.create(identifier=VatlayerPlugin.PLUGIN_ID, **data)
- return settings
-
-
@pytest.fixture(autouse=True)
def setup_dummy_gateways(settings):
settings.PLUGINS = [
@@ -1020,7 +1005,7 @@ def staff_users(staff_user):
@pytest.fixture
-def shipping_zone(db, channel_USD): # pylint: disable=W0613
+def shipping_zone(db, channel_USD, default_tax_class): # pylint: disable=W0613
shipping_zone = ShippingZone.objects.create(
name="Europe", countries=[code for code, name in countries]
)
@@ -1029,6 +1014,7 @@ def shipping_zone(db, channel_USD): # pylint: disable=W0613
name="DHL",
type=ShippingMethodType.PRICE_BASED,
shipping_zone=shipping_zone,
+ tax_class=default_tax_class,
)
ShippingMethodChannelListing.objects.create(
channel=channel_USD,
@@ -1182,13 +1168,14 @@ def shipping_zone_without_countries(db, channel_USD): # pylint: disable=W0613
@pytest.fixture
-def shipping_method(shipping_zone, channel_USD):
+def shipping_method(shipping_zone, channel_USD, default_tax_class):
method = ShippingMethod.objects.create(
name="DHL",
type=ShippingMethodType.PRICE_BASED,
shipping_zone=shipping_zone,
maximum_delivery_days=10,
minimum_delivery_days=5,
+ tax_class=default_tax_class,
)
ShippingMethodChannelListing.objects.create(
shipping_method=method,
@@ -2002,13 +1989,14 @@ def permission_manage_taxes():
@pytest.fixture
-def product_type(color_attribute, size_attribute):
+def product_type(color_attribute, size_attribute, default_tax_class):
product_type = ProductType.objects.create(
name="Default Type",
slug="default-type",
kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
+ tax_class=default_tax_class,
)
product_type.product_attributes.add(color_attribute)
product_type.variant_attributes.add(
@@ -2068,7 +2056,7 @@ def product_type_without_variant():
@pytest.fixture
-def product(product_type, category, warehouse, channel_USD):
+def product(product_type, category, warehouse, channel_USD, default_tax_class):
product_attr = product_type.product_attributes.first()
product_attr_value = product_attr.values.first()
@@ -2077,6 +2065,7 @@ def product(product_type, category, warehouse, channel_USD):
slug="test-product-11",
product_type=product_type,
category=category,
+ tax_class=default_tax_class,
)
ProductChannelListing.objects.create(
product=product,
@@ -2891,7 +2880,9 @@ def product_without_category(product):
@pytest.fixture
-def product_list(product_type, category, warehouse, channel_USD, channel_PLN):
+def product_list(
+ product_type, category, warehouse, channel_USD, channel_PLN, default_tax_class
+):
product_attr = product_type.product_attributes.first()
attr_value = product_attr.values.first()
@@ -2904,6 +2895,7 @@ def product_list(product_type, category, warehouse, channel_USD, channel_PLN):
description_plaintext="big blue product",
category=category,
product_type=product_type,
+ tax_class=default_tax_class,
),
Product(
name="Test product 2",
@@ -2911,6 +2903,7 @@ def product_list(product_type, category, warehouse, channel_USD, channel_PLN):
description_plaintext="big orange product",
category=category,
product_type=product_type,
+ tax_class=default_tax_class,
),
Product(
name="Test product 3",
@@ -2918,6 +2911,7 @@ def product_list(product_type, category, warehouse, channel_USD, channel_PLN):
description_plaintext="small red",
category=category,
product_type=product_type,
+ tax_class=default_tax_class,
),
]
)
@@ -3023,7 +3017,7 @@ def product_list(product_type, category, warehouse, channel_USD, channel_PLN):
@pytest.fixture
def product_list_with_variants_many_channel(
- product_type, category, channel_USD, channel_PLN
+ product_type, category, channel_USD, channel_PLN, default_tax_class
):
products = list(
Product.objects.bulk_create(
@@ -3033,18 +3027,21 @@ def product_list_with_variants_many_channel(
slug="test-product-a",
category=category,
product_type=product_type,
+ tax_class=default_tax_class,
),
Product(
name="Test product 2",
slug="test-product-b",
category=category,
product_type=product_type,
+ tax_class=default_tax_class,
),
Product(
name="Test product 3",
slug="test-product-c",
category=category,
product_type=product_type,
+ tax_class=default_tax_class,
),
]
)
@@ -3192,12 +3189,13 @@ def product_with_image(product, image, media_root):
@pytest.fixture
-def unavailable_product(product_type, category, channel_USD):
+def unavailable_product(product_type, category, channel_USD, default_tax_class):
product = Product.objects.create(
name="Test product",
slug="test-product-5",
product_type=product_type,
category=category,
+ tax_class=default_tax_class,
)
ProductChannelListing.objects.create(
product=product,
@@ -3209,12 +3207,15 @@ def unavailable_product(product_type, category, channel_USD):
@pytest.fixture
-def unavailable_product_with_variant(product_type, category, warehouse, channel_USD):
+def unavailable_product_with_variant(
+ product_type, category, warehouse, channel_USD, default_tax_class
+):
product = Product.objects.create(
name="Test product",
slug="test-product-6",
product_type=product_type,
category=category,
+ tax_class=default_tax_class,
)
ProductChannelListing.objects.create(
product=product,
@@ -3244,12 +3245,15 @@ def unavailable_product_with_variant(product_type, category, warehouse, channel_
@pytest.fixture
-def product_with_images(product_type, category, media_root, channel_USD):
+def product_with_images(
+ product_type, category, media_root, channel_USD, default_tax_class
+):
product = Product.objects.create(
name="Test product",
slug="test-product-7",
product_type=product_type,
category=category,
+ tax_class=default_tax_class,
)
ProductChannelListing.objects.create(
product=product,
@@ -3835,13 +3839,20 @@ def recalculate_order(order):
@pytest.fixture
def order_with_lines(
- order, product_type, category, shipping_zone, warehouse, channel_USD
+ order,
+ product_type,
+ category,
+ shipping_zone,
+ warehouse,
+ channel_USD,
+ default_tax_class,
):
product = Product.objects.create(
name="Test product",
slug="test-product-8",
product_type=product_type,
category=category,
+ tax_class=default_tax_class,
)
ProductChannelListing.objects.create(
product=product,
@@ -3882,6 +3893,7 @@ def order_with_lines(
base_unit_price=base_price,
undiscounted_base_unit_price=base_price,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product_type.tax_class),
)
Allocation.objects.create(
order_line=line, stock=stock, quantity_allocated=line.quantity
@@ -3934,6 +3946,7 @@ def order_with_lines(
base_unit_price=base_price,
undiscounted_base_unit_price=base_price,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product_type.tax_class),
)
Allocation.objects.create(
order_line=line, stock=stock, quantity_allocated=line.quantity
@@ -3945,11 +3958,18 @@ def order_with_lines(
shipping_price = shipping_method.channel_listings.get(channel_id=channel_USD.id)
order.shipping_method_name = shipping_method.name
order.shipping_method = shipping_method
+ order.shipping_tax_class = shipping_method.tax_class
+ order.shipping_tax_class_name = shipping_method.tax_class.name
+ order.shipping_tax_class_metadata = shipping_method.tax_class.metadata
+ order.shipping_tax_class_private_metadata = (
+ shipping_method.tax_class.private_metadata
+ ) # noqa: E501
net = shipping_price.get_total()
gross = Money(amount=net.amount * Decimal(1.23), currency=net.currency)
order.shipping_price = TaxedMoney(net=net, gross=gross)
order.base_shipping_price = net
+ order.shipping_tax_rate = calculate_tax_rate(order.shipping_price)
order.save()
recalculate_order(order)
@@ -4004,6 +4024,7 @@ def order_with_lines_for_cc(
base_unit_price=unit_price.gross,
undiscounted_base_unit_price=unit_price.gross,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(variant.product.product_type.tax_class),
)
Allocation.objects.create(
order_line=line,
@@ -4154,6 +4175,7 @@ def order_with_lines_channel_PLN(
base_unit_price=unit_price.gross,
undiscounted_base_unit_price=unit_price.gross,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product_type.tax_class),
)
Allocation.objects.create(
order_line=line, stock=stock, quantity_allocated=line.quantity
@@ -4205,6 +4227,7 @@ def order_with_lines_channel_PLN(
base_unit_price=unit_price.gross,
undiscounted_base_unit_price=unit_price.gross,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product_type.tax_class),
)
Allocation.objects.create(
order_line=line, stock=stock, quantity_allocated=line.quantity
@@ -4223,6 +4246,7 @@ def order_with_lines_channel_PLN(
gross = Money(amount=net.amount * Decimal(1.23), currency=net.currency)
order.shipping_price = TaxedMoney(net=net, gross=gross)
order.base_shipping_price = net
+ order.shipping_tax_rate = calculate_tax_rate(order.shipping_price)
order.save()
recalculate_order(order)
@@ -4260,6 +4284,7 @@ def order_with_line_without_inventory_tracking(
base_unit_price=unit_price.gross,
undiscounted_base_unit_price=unit_price.gross,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product.product_type.tax_class),
)
recalculate_order(order)
@@ -4317,6 +4342,7 @@ def order_with_preorder_lines(
base_unit_price=unit_price.gross,
undiscounted_base_unit_price=unit_price.gross,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product_type.tax_class),
)
PreorderAllocation.objects.create(
order_line=line,
@@ -6026,6 +6052,7 @@ def allocations(order_list, stock, channel_USD):
unit_price=price,
total_price=price,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product.product_type.tax_class),
),
OrderLine(
order=order_list[1],
@@ -6040,6 +6067,7 @@ def allocations(order_list, stock, channel_USD):
unit_price=price,
total_price=price,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product.product_type.tax_class),
),
OrderLine(
order=order_list[2],
@@ -6054,6 +6082,7 @@ def allocations(order_list, stock, channel_USD):
unit_price=price,
total_price=price,
tax_rate=Decimal("0.23"),
+ **get_tax_class_kwargs_for_order_line(product.product_type.tax_class),
),
]
)
diff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.py
index 18f4d35f6e..f9f32bdab0 100644
--- a/saleor/webhook/payloads.py
+++ b/saleor/webhook/payloads.py
@@ -17,7 +17,6 @@ from ..checkout import base_calculations
from ..checkout.fetch import CheckoutInfo, CheckoutLineInfo
from ..checkout.models import Checkout
from ..core.prices import quantize_price, quantize_price_fields
-from ..core.taxes import include_taxes_in_prices
from ..core.utils import build_absolute_uri
from ..core.utils.anonymization import (
anonymize_checkout,
@@ -36,6 +35,8 @@ from ..plugins.webhook.utils import from_payment_app_id
from ..product import ProductMediaTypes
from ..product.models import Collection, Product
from ..shipping.interface import ShippingMethodData
+from ..tax.models import TaxClassCountryRate
+from ..tax.utils import get_charge_taxes_for_order
from ..warehouse.models import Stock, Warehouse
from . import traced_payload_generator
from .event_types import WebhookEventAsyncType
@@ -646,7 +647,6 @@ PRODUCT_FIELDS = (
"description",
"currency",
"updated_at",
- "charge_taxes",
"weight",
"publication_date",
"is_published",
@@ -677,6 +677,18 @@ def serialize_product_channel_listing_payload(channel_listings):
return channel_listing_payload
+def _get_charge_taxes_for_product(product: "Product") -> bool:
+ charge_taxes = False
+ tax_class_id = product.tax_class_id or product.product_type.tax_class_id
+ if tax_class_id:
+ charge_taxes = (
+ TaxClassCountryRate.objects.filter(tax_class_id=tax_class_id)
+ .exclude(rate=Decimal("0"))
+ .exists()
+ )
+ return charge_taxes
+
+
@traced_payload_generator
def generate_product_payload(
product: "Product", requestor: Optional["RequestorOrLazyObject"] = None
@@ -705,6 +717,7 @@ def generate_product_payload(
}
for media_obj in product.media.all()
],
+ "charge_taxes": _get_charge_taxes_for_product(product),
"channel_listings": json.loads(
serialize_product_channel_listing_payload(
product.channel_listings.all() # type: ignore
@@ -731,6 +744,7 @@ def generate_product_deleted_payload(
[product],
fields=product_fields,
extra_dict_data={
+ "charge_taxes": _get_charge_taxes_for_product(product),
"meta": generate_meta(requestor_data=generate_requestor(requestor)),
"variants": list(product_variant_ids),
},
@@ -1217,7 +1231,8 @@ def generate_checkout_payload_for_tax_calculation(
lines: Iterable["CheckoutLineInfo"],
):
checkout = checkout_info.checkout
- included_taxes_in_prices = include_taxes_in_prices()
+ tax_configuration = checkout_info.tax_configuration
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
discount_infos = fetch_active_discounts()
serializer = PayloadSerializer()
@@ -1289,7 +1304,7 @@ def generate_checkout_payload_for_tax_calculation(
extra_dict_data={
"user_id": user_id,
"user_public_metadata": user_public_metadata,
- "included_taxes_in_prices": included_taxes_in_prices,
+ "included_taxes_in_prices": prices_entered_with_tax,
"total_amount": total_amount,
"shipping_amount": shipping_method_amount,
"shipping_name": shipping_method_name,
@@ -1300,9 +1315,13 @@ def generate_checkout_payload_for_tax_calculation(
return checkout_data
-def _generate_order_lines_payload_for_tax_calculation(lines: Iterable[OrderLine]):
-
+def _generate_order_lines_payload_for_tax_calculation(lines: QuerySet[OrderLine]):
serializer = PayloadSerializer()
+
+ charge_taxes = False
+ if lines:
+ charge_taxes = get_charge_taxes_for_order(lines[0].order)
+
return serializer.serialize(
lines,
fields=("product_name", "variant_name", "quantity"),
@@ -1319,9 +1338,7 @@ def _generate_order_lines_payload_for_tax_calculation(lines: Iterable[OrderLine]
if line.variant
else {}
),
- "charge_taxes": (
- lambda line: line.variant.product.charge_taxes if line.variant else None
- ),
+ "charge_taxes": (lambda _line: charge_taxes),
"sku": (lambda line: line.product_sku),
"unit_amount": (
lambda line: quantize_price(line.base_unit_price_amount, line.currency)
@@ -1338,7 +1355,9 @@ def _generate_order_lines_payload_for_tax_calculation(lines: Iterable[OrderLine]
@traced_payload_generator
def generate_order_payload_for_tax_calculation(order: "Order"):
serializer = PayloadSerializer()
- included_taxes_in_prices = include_taxes_in_prices()
+
+ tax_configuration = order.channel.tax_configuration
+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax
# Prepare Order data
address = order.shipping_address or order.billing_address
@@ -1378,7 +1397,7 @@ def generate_order_payload_for_tax_calculation(order: "Order"):
"user_id": user_id,
"user_public_metadata": user_public_metadata,
"discounts": discounts_dict,
- "included_taxes_in_prices": included_taxes_in_prices,
+ "included_taxes_in_prices": prices_entered_with_tax,
"shipping_amount": shipping_method_amount,
"shipping_name": shipping_method_name,
"lines": json.loads(
diff --git a/saleor/webhook/serializers.py b/saleor/webhook/serializers.py
index 75d12a6d76..3e4d90e446 100644
--- a/saleor/webhook/serializers.py
+++ b/saleor/webhook/serializers.py
@@ -9,6 +9,7 @@ from ..checkout.fetch import fetch_checkout_lines
from ..core.prices import quantize_price
from ..discount import DiscountInfo
from ..product.models import Product
+from ..tax.utils import get_charge_taxes_for_checkout
if TYPE_CHECKING:
# pylint: disable=unused-import
@@ -63,7 +64,6 @@ def _get_checkout_line_payload_data(line_info: "CheckoutLineInfo") -> Dict[str,
"sku": variant.sku,
"variant_id": variant.get_global_id(),
"quantity": line_info.line.quantity,
- "charge_taxes": product.charge_taxes,
"full_name": variant.display_product(),
"product_name": product.name,
"variant_name": variant.name,
@@ -78,10 +78,11 @@ def serialize_checkout_lines_for_tax_calculation(
discounts: Optional[Iterable[DiscountInfo]] = None,
) -> List[dict]:
channel = checkout_info.channel
-
+ charge_taxes = get_charge_taxes_for_checkout(checkout_info, lines)
return [
{
**_get_checkout_line_payload_data(line_info),
+ "charge_taxes": charge_taxes,
"unit_amount": quantize_price(
base_calculations.calculate_base_line_unit_price(
line_info, channel, discounts
diff --git a/saleor/webhook/tests/test_webhook_payloads.py b/saleor/webhook/tests/test_webhook_payloads.py
index 6f395c1be7..50c6163fa1 100644
--- a/saleor/webhook/tests/test_webhook_payloads.py
+++ b/saleor/webhook/tests/test_webhook_payloads.py
@@ -53,6 +53,7 @@ from ..payloads import (
generate_order_payload,
generate_order_payload_for_tax_calculation,
generate_payment_payload,
+ generate_product_payload,
generate_product_variant_payload,
generate_product_variant_with_stock_payload,
generate_requestor,
@@ -297,17 +298,19 @@ def test_generate_order_payload(
@freeze_time()
[email protected]("taxes_included", [True, False])
[email protected]("prices_entered_with_tax", [True, False])
@mock.patch("saleor.webhook.payloads._generate_order_lines_payload_for_tax_calculation")
def test_generate_order_payload_for_tax_calculation(
mocked_order_lines,
order_for_payload,
- taxes_included,
- site_settings,
- customer_user,
+ prices_entered_with_tax,
):
- site_settings.include_taxes_in_prices = taxes_included
- site_settings.save(update_fields=["include_taxes_in_prices"])
+ order = order_for_payload
+
+ tax_configuration = order.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
order_lines = '"order_lines"'
mocked_order_lines.return_value = order_lines
@@ -345,7 +348,7 @@ def test_generate_order_payload_for_tax_calculation(
},
"user_id": graphene.Node.to_global_id("User", user.pk),
"user_public_metadata": user.metadata,
- "included_taxes_in_prices": taxes_included,
+ "included_taxes_in_prices": prices_entered_with_tax,
"currency": order.currency,
"shipping_name": order.shipping_method.name,
"shipping_amount": str(
@@ -604,15 +607,21 @@ def test_order_lines_have_all_required_fields(
}
[email protected]("taxes_included", [True]) # , False])
+ "charge_taxes, prices_entered_with_tax",
+ [(False, False), (False, True), (True, False), (True, True)],
+)
def test_order_lines_for_tax_calculation_have_all_required_fields(
order,
order_line_with_one_allocation,
- taxes_included,
- site_settings,
+ charge_taxes,
+ prices_entered_with_tax,
):
- site_settings.include_taxes_in_prices = taxes_included
- site_settings.save(update_fields=["include_taxes_in_prices"])
+ tax_configuration = order.channel.tax_configuration
+ tax_configuration.charge_taxes = charge_taxes
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
order.lines.add(order_line_with_one_allocation)
currency = order.currency
@@ -649,7 +658,7 @@ def test_order_lines_for_tax_calculation_have_all_required_fields(
"product_type_metadata": {"product_type_meta": "value"},
"quantity": line.quantity,
"sku": line.product_sku,
- "charge_taxes": variant.product.charge_taxes,
+ "charge_taxes": charge_taxes,
"unit_amount": str(quantize_price(line.base_unit_price_amount, currency)),
"total_amount": str(
quantize_price(line.base_unit_price_amount * line.quantity, currency)
@@ -657,10 +666,14 @@ def test_order_lines_for_tax_calculation_have_all_required_fields(
}
[email protected]("charge_taxes", [True, False])
def test_order_lines_for_tax_calculation_with_removed_variant(
- order,
- order_line_with_one_allocation,
+ order, order_line_with_one_allocation, charge_taxes
):
+ tax_configuration = order.channel.tax_configuration
+ tax_configuration.charge_taxes = charge_taxes
+ tax_configuration.save(update_fields=["charge_taxes"])
+ tax_configuration.country_exceptions.all().delete()
order.lines.add(order_line_with_one_allocation)
currency = order.currency
@@ -692,7 +705,7 @@ def test_order_lines_for_tax_calculation_with_removed_variant(
"product_type_metadata": {},
"quantity": line.quantity,
"sku": line.product_sku,
- "charge_taxes": None,
+ "charge_taxes": charge_taxes,
"unit_amount": str(quantize_price(line.base_unit_price_amount, currency)),
"total_amount": str(
quantize_price(line.base_unit_price_amount * line.quantity, currency)
@@ -760,6 +773,25 @@ def test_generate_collection_payload(collection):
assert payload == expected_payload
[email protected]("tax_rate", [0, 23])
+def test_generate_product_payload_charge_taxes(
+ product_with_two_variants, default_tax_class, tax_rate
+):
+ # given
+ product = product_with_two_variants
+ default_tax_class.country_rates.all().delete()
+ default_tax_class.country_rates.create(country="PL", rate=tax_rate)
+ product.tax_class = default_tax_class
+ product.save(update_fields=["tax_class"])
+
+ # when
+ payload = json.loads(generate_product_payload(product_with_two_variants))
+
+ # then
+ expected_charge_taxes = tax_rate != 0
+ assert payload[0]["charge_taxes"] == expected_charge_taxes
+
+
@freeze_time()
def test_generate_shipping_zone_metadata_updated_payload(
shipping_zone,
@@ -1054,7 +1086,7 @@ def test_generate_invoice_payload(fulfilled_order):
"collection_point_name": None,
"shipping_price_net_amount": "10.00",
"shipping_price_gross_amount": "12.30",
- "shipping_tax_rate": "0.0000",
+ "shipping_tax_rate": "0.2300",
"total_net_amount": "80.00",
"total_gross_amount": "98.40",
"weight": "0.0:g",
@@ -1593,21 +1625,22 @@ def test_generate_sale_toggle_payload(sale):
@patch("saleor.webhook.payloads.serialize_checkout_lines_for_tax_calculation")
[email protected]("taxes_included", [True, False])
[email protected]("prices_entered_with_tax", [True, False])
def test_generate_checkout_payload_for_tax_calculation(
mocked_serialize_checkout_lines_for_tax_calculation,
mocked_fetch_checkout,
checkout_with_prices,
- site_settings,
- taxes_included,
+ prices_entered_with_tax,
):
checkout = checkout_with_prices
currency = checkout.currency
discounts_info = fetch_active_discounts()
- site_settings.include_taxes_in_prices = taxes_included
- site_settings.save(update_fields=["include_taxes_in_prices"])
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
mocked_serialized_checkout_lines = {"data": "checkout_lines_data"}
mocked_serialize_checkout_lines_for_tax_calculation.return_value = (
@@ -1659,7 +1692,7 @@ def test_generate_checkout_payload_for_tax_calculation(
},
"currency": currency,
"discounts": [{"amount": "5.00", "name": "Voucher 5 USD"}],
- "included_taxes_in_prices": taxes_included,
+ "included_taxes_in_prices": prices_entered_with_tax,
"lines": mocked_serialized_checkout_lines,
"metadata": {"meta_key": "meta_value"},
"shipping_name": checkout.shipping_method.name,
@@ -1688,15 +1721,16 @@ def test_generate_checkout_payload_for_tax_calculation_digital_checkout(
mocked_serialize_checkout_lines_for_tax_calculation,
mocked_fetch_checkout,
checkout_with_digital_item,
- site_settings,
):
- taxes_included = True
+ prices_entered_with_tax = True
discounts_info = fetch_active_discounts()
checkout = checkout_with_digital_item
currency = checkout.currency
- site_settings.include_taxes_in_prices = taxes_included
- site_settings.save(update_fields=["include_taxes_in_prices"])
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
mocked_serialized_checkout_lines = {"data": "checkout_lines_data"}
mocked_serialize_checkout_lines_for_tax_calculation.return_value = (
@@ -1740,7 +1774,7 @@ def test_generate_checkout_payload_for_tax_calculation_digital_checkout(
},
"currency": currency,
"discounts": [],
- "included_taxes_in_prices": taxes_included,
+ "included_taxes_in_prices": prices_entered_with_tax,
"lines": mocked_serialized_checkout_lines,
"metadata": {},
"shipping_name": None,
@@ -1765,17 +1799,18 @@ def test_generate_checkout_payload_for_tax_calculation_digital_checkout(
@freeze_time()
[email protected]("taxes_included", [True, False])
[email protected]("prices_entered_with_tax", [True, False])
def test_generate_checkout_payload(
checkout_with_prices,
- site_settings,
- taxes_included,
+ prices_entered_with_tax,
customer_user,
):
checkout = checkout_with_prices
- site_settings.include_taxes_in_prices = taxes_included
- site_settings.save(update_fields=["include_taxes_in_prices"])
+ tax_configuration = checkout.channel.tax_configuration
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
# when
payload = json.loads(generate_checkout_payload(checkout, customer_user))[0]
diff --git a/saleor/webhook/tests/test_webhook_serializers.py b/saleor/webhook/tests/test_webhook_serializers.py
index 22a3117f60..d2cbb75274 100644
--- a/saleor/webhook/tests/test_webhook_serializers.py
+++ b/saleor/webhook/tests/test_webhook_serializers.py
@@ -117,9 +117,12 @@ def test_serialize_checkout_lines(
assert len(checkout_lines_data) == len(list(checkout_lines))
[email protected]("taxes_included", [True, False])
+ "charge_taxes, prices_entered_with_tax",
+ [(False, False), (False, True), (True, False), (True, True)],
+)
def test_serialize_checkout_lines_for_tax_calculation(
- checkout_with_prices, taxes_included, site_settings
+ checkout_with_prices, charge_taxes, prices_entered_with_tax
):
# We should be sure that we always sends base prices to tax app.
# We shouldn't use previously calculated prices because they can be
@@ -133,8 +136,12 @@ def test_serialize_checkout_lines_for_tax_calculation(
manager = get_plugins_manager()
discounts_info = fetch_active_discounts()
checkout_info = fetch_checkout_info(checkout, lines, discounts_info, manager)
- site_settings.include_taxes_in_prices = taxes_included
- site_settings.save()
+
+ tax_configuration = checkout_info.tax_configuration
+ tax_configuration.charge_taxes = charge_taxes
+ tax_configuration.prices_entered_with_tax = prices_entered_with_tax
+ tax_configuration.save(update_fields=["charge_taxes", "prices_entered_with_tax"])
+ tax_configuration.country_exceptions.all().delete()
# when
checkout_lines_data = serialize_checkout_lines_for_tax_calculation(
@@ -158,7 +165,7 @@ def test_serialize_checkout_lines_for_tax_calculation(
"id": graphene.Node.to_global_id("CheckoutLine", line.pk),
"sku": variant.sku,
"quantity": line.quantity,
- "charge_taxes": product.charge_taxes,
+ "charge_taxes": charge_taxes,
"full_name": variant.display_product(),
"product_name": product.name,
"variant_name": variant.name,
diff --git a/templates/invoices/invoice.html b/templates/invoices/invoice.html
index cbe363ea6f..ded31cbeb6 100644
--- a/templates/invoices/invoice.html
+++ b/templates/invoices/invoice.html
@@ -220,7 +220,7 @@
<div class="padded-font"></div>
<span class="header-category">Amount:</span>
<div class="padded-font-sm"></div>
- <span class="header-item">{% price order.total_gross %}</span>
+ <span class="header-item">{% price order.total_gross display_gross=order.display_gross_prices %}</span>
</div>
</div>
<div class="section-left">
@@ -305,7 +305,7 @@
</div>
<div class="content-padded">
<span class="header-title">ITEMS ORDERED</span>
- {% include "invoices/invoice_products_table.html" with products=products_first_page %}
+ {% include "invoices/invoice_products_table.html" with products=products_first_page order=order %}
{% if not rest_of_products|length %}
{% if products_first_page|length == 4 %}
<div class="page-break"></div>
@@ -314,7 +314,7 @@
{% else %}
{% for product_set in rest_of_products %}
<div class="page-break"></div>
- {% include "invoices/invoice_products_table.html" with products=product_set %}
+ {% include "invoices/invoice_products_table.html" with products=product_set order=order %}
{% if forloop.last %}
{% if product_set|length > 11 %}
<div class="page-break"></div>
diff --git a/templates/invoices/invoice_products_table.html b/templates/invoices/invoice_products_table.html
index 4adbf7fc0a..8e839ad92c 100644
--- a/templates/invoices/invoice_products_table.html
+++ b/templates/invoices/invoice_products_table.html
@@ -27,13 +27,13 @@
</span>
</td>
<td class="cell-price">
- <span class="normal-text-table cell-price-content">{% price product.unit_price.gross %}</span>
+ <span class="normal-text-table cell-price-content">{% price product.unit_price.gross display_gross=order.display_gross_prices %}</span>
</td>
<td class="cell-quantity">
<span class="normal-text-table cell-quantity-content">{{ product.quantity }}</span>
</td>
<td class="cell-total-price">
- <span class="normal-text-table">{% price product.total_price.gross %}</span>
+ <span class="normal-text-table">{% price product.total_price.gross display_gross=order.display_gross_prices %}</span>
</td>
</tr>
{% endfor %}
diff --git a/templates/invoices/invoice_summary_table.html b/templates/invoices/invoice_summary_table.html
index 1048e55bb3..7d8205094d 100644
--- a/templates/invoices/invoice_summary_table.html
+++ b/templates/invoices/invoice_summary_table.html
@@ -8,7 +8,7 @@
<td class="cell-quantity"></td>
<td class="cell-total-price">
<span class="header-item">
- {% price order.get_subtotal.gross %}
+ {% price order.get_subtotal.gross display_gross=order.display_gross_prices %}
</span>
</td>
</tr>
@@ -19,7 +19,7 @@
<td class="cell-quantity"></td>
<td class="cell-total-price">
<span class="header-item">
- {% price order.shipping_price.gross %}
+ {% price order.shipping_price.gross display_gross=order.display_gross_prices %}
</span>
</td>
</tr>
@@ -30,7 +30,7 @@
<td class="cell-quantity"></td>
<td class="cell-total-price">
<span class="header-item">
- {% price order.total.tax %}
+ {% price order.total.tax display_gross=order.display_gross_prices %}
</span>
</td>
</tr>
@@ -42,7 +42,7 @@
<td class="cell-quantity"></td>
<td class="cell-total-price">
<span class="header-item">
- -{% price gift_cards_payment %}
+ -{% price gift_cards_payment display_gross=order.display_gross_prices %}
</span>
</td>
</tr>
@@ -54,7 +54,7 @@
<td class="cell-quantity"></td>
<td class="cell-total-price">
<span class="header-item">
- {% price order.total.gross %}
+ {% price order.total.gross display_gross=order.display_gross_prices %}
</span>
</td>
</tr>