Skip to content

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

Fix inaccurate tax calculations (#9799)

Iga Karbowiakced3a2249a18
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a697753a3..26d6807cf4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ All notable, unreleased changes to this project will be documented in this file.
# 3.5.0 [Unreleased]
### Other changes
+- Fix inaccurate tax calculations - #9799 by @IKarbowiak
#### Saleor Apps
- Add webhooks `PAGE_TYPE_CREATED`, `PAGE_TYPE_UPDATED` and `PAGE_TYPE_DELETED` - #9859 by @SzymJ
diff --git a/saleor/checkout/base_calculations.py b/saleor/checkout/base_calculations.py
index be0c616658..165b8eeadc 100644
--- a/saleor/checkout/base_calculations.py
+++ b/saleor/checkout/base_calculations.py
@@ -7,7 +7,7 @@ manager.
from decimal import Decimal
from typing import TYPE_CHECKING, Iterable, Optional
-from prices import Money, TaxedMoney
+from prices import TaxedMoney
from ..core.prices import quantize_price
from ..core.taxes import zero_money, zero_taxed_money
@@ -205,12 +205,25 @@ def calculate_base_price_for_shipping_method(
def base_checkout_total(
- subtotal: TaxedMoney,
- shipping_price: TaxedMoney,
- discount: Money,
- currency: str,
+ checkout_info: "CheckoutInfo",
+ discounts: Iterable[DiscountInfo],
+ lines: Iterable["CheckoutLineInfo"],
) -> TaxedMoney:
"""Return the total cost of the checkout."""
+ currency = checkout_info.checkout.currency
+ line_totals = [
+ base_checkout_line_total(
+ line_info,
+ checkout_info.channel,
+ discounts,
+ ).price_with_discounts
+ for line_info in lines
+ ]
+ subtotal = sum(line_totals, zero_taxed_money(currency))
+
+ shipping_price = base_checkout_delivery_price(checkout_info, lines)
+ discount = checkout_info.checkout.discount
+
zero = zero_taxed_money(currency)
total = subtotal + shipping_price - discount
# Discount is subtracted from both gross and net values, which may cause negative
diff --git a/saleor/checkout/tests/test_base_calculations.py b/saleor/checkout/tests/test_base_calculations.py
index 08c9d10d74..6df7b46783 100644
--- a/saleor/checkout/tests/test_base_calculations.py
+++ b/saleor/checkout/tests/test_base_calculations.py
@@ -2,15 +2,17 @@ from decimal import Decimal
from prices import Money, TaxedMoney
+from ...core.taxes import zero_taxed_money
from ...discount import DiscountValueType, VoucherType
from ...discount.utils import get_product_discount_on_sale
+from ...plugins.manager import get_plugins_manager
from ..base_calculations import (
base_checkout_total,
base_tax_rate,
calculate_base_line_total_price,
calculate_base_line_unit_price,
)
-from ..fetch import fetch_checkout_lines
+from ..fetch import fetch_checkout_info, fetch_checkout_lines
def test_calculate_base_line_unit_price(checkout_with_single_item):
@@ -794,32 +796,52 @@ def test_base_tax_rate_gross_price_zero():
assert base_tax_rate(price) == Decimal("0.0")
-def test_base_checkout_total():
+def test_base_checkout_total(checkout_with_item, shipping_method, voucher_percentage):
# given
- currency = "USD"
- taxed_money = TaxedMoney(net=Money(10, currency), gross=Money(10, currency))
- subtotal = taxed_money
- shipping_price = taxed_money
- discount = Money(5, currency)
+ manager = get_plugins_manager()
+ channel = checkout_with_item.channel
+ currency = checkout_with_item.currency
+ discount_amount = Money(5, currency)
+ checkout_with_item.shipping_method = shipping_method
+ checkout_with_item.voucher_code = voucher_percentage.code
+ checkout_with_item.discount = discount_amount
+ checkout_with_item.save()
+ checkout_lines, _ = fetch_checkout_lines(checkout_with_item)
+ checkout_info = fetch_checkout_info(checkout_with_item, checkout_lines, [], manager)
# when
- total = base_checkout_total(subtotal, shipping_price, discount, currency)
- expected = subtotal + shipping_price - discount
+ total = base_checkout_total(checkout_info, [], checkout_lines)
# then
- assert total == expected
+ variant = checkout_with_item.lines.first().variant
+ channel_listing = variant.channel_listings.get(channel=channel)
+ net = variant.get_price(variant.product, [], channel, channel_listing)
+ shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
+ expected_price = (
+ net * checkout_with_item.lines.first().quantity
+ + shipping_channel_listings.price
+ - discount_amount
+ )
+ assert total == TaxedMoney(net=expected_price, gross=expected_price)
-def test_base_checkout_total_high_discount():
+def test_base_checkout_total_high_discount(
+ checkout_with_item, shipping_method, voucher_percentage
+):
# given
- currency = "USD"
- zero_taxed_money = TaxedMoney(net=Money(0, currency), gross=Money(0, currency))
- subtotal = TaxedMoney(net=Money(10, currency), gross=Money(12, currency))
- shipping_price = zero_taxed_money
- discount = Money(20, currency)
+ manager = get_plugins_manager()
+ checkout_lines, _ = fetch_checkout_lines(checkout_with_item)
+ checkout_info = fetch_checkout_info(checkout_with_item, checkout_lines, [], manager)
+
+ currency = checkout_with_item.currency
+ discount_amount = Money(100, currency)
+ checkout_with_item.shipping_method = shipping_method
+ checkout_with_item.voucher_code = voucher_percentage.code
+ checkout_with_item.discount = discount_amount
+ checkout_with_item.save()
# when
- total = base_checkout_total(subtotal, shipping_price, discount, currency)
+ total = base_checkout_total(checkout_info, [], checkout_lines)
# then
- assert total == zero_taxed_money
+ assert total == zero_taxed_money(currency)
diff --git a/saleor/checkout/tests/test_checkout.py b/saleor/checkout/tests/test_checkout.py
index a6b7ed10d2..1b0fc56bfc 100644
--- a/saleor/checkout/tests/test_checkout.py
+++ b/saleor/checkout/tests/test_checkout.py
@@ -203,12 +203,8 @@ def test_get_discount_for_checkout_value_voucher(
checkout = Mock(spec=checkout_with_items, channel=channel_USD)
subtotal = TaxedMoney(Money(total, "USD"), Money(total, "USD"))
monkeypatch.setattr(
- "saleor.checkout.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
- )
- monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: subtotal,
)
checkout_info = CheckoutInfo(
checkout=checkout,
@@ -297,12 +293,8 @@ def test_get_discount_for_checkout_entire_order_voucher_not_applicable(
checkout = Mock(spec=Checkout, channel=channel_USD)
subtotal = TaxedMoney(Money(total, "USD"), Money(total, "USD"))
monkeypatch.setattr(
- "saleor.checkout.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
- )
- monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: subtotal,
)
checkout_info = CheckoutInfo(
checkout=checkout,
@@ -458,14 +450,8 @@ def test_get_discount_for_checkout_specific_products_voucher_not_applicable(
lambda _: TaxedMoney(Money(0, "USD"), Money(0, "USD")),
)
monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: TaxedMoney(
- Money(total, "USD"), Money(total, "USD")
- ),
- )
- monkeypatch.setattr(
- "saleor.checkout.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: TaxedMoney(
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: TaxedMoney(
Money(total, "USD"), Money(total, "USD")
),
)
@@ -525,12 +511,8 @@ def test_get_discount_for_checkout_shipping_voucher(
manager = get_plugins_manager()
subtotal = TaxedMoney(Money(100, "USD"), Money(100, "USD"))
monkeypatch.setattr(
- "saleor.checkout.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
- )
- monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: subtotal,
)
monkeypatch.setattr(
"saleor.checkout.utils.is_shipping_required", lambda lines: True
@@ -581,12 +563,8 @@ def test_get_discount_for_checkout_shipping_voucher_all_countries(
):
subtotal = TaxedMoney(Money(100, "USD"), Money(100, "USD"))
monkeypatch.setattr(
- "saleor.checkout.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
- )
- monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: subtotal,
)
monkeypatch.setattr(
"saleor.checkout.utils.is_shipping_required", lambda lines: True
@@ -641,8 +619,8 @@ def test_get_discount_for_checkout_shipping_voucher_limited_countries(
subtotal = TaxedMoney(net=Money(100, "USD"), gross=Money(100, "USD"))
shipping_total = TaxedMoney(net=Money(10, "USD"), gross=Money(10, "USD"))
monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: subtotal,
)
checkout = Mock(
get_subtotal=Mock(return_value=subtotal),
@@ -773,12 +751,8 @@ def test_get_discount_for_checkout_shipping_voucher_not_applicable(
channel_USD,
):
monkeypatch.setattr(
- "saleor.checkout.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
- )
- monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: subtotal,
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: subtotal,
)
monkeypatch.setattr(
"saleor.checkout.utils.is_shipping_required", lambda lines: is_shipping_required
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.py
index f51710347c..9b2a2f1926 100644
--- a/saleor/checkout/utils.py
+++ b/saleor/checkout/utils.py
@@ -36,7 +36,7 @@ from ..warehouse.availability import (
)
from ..warehouse.models import Warehouse
from ..warehouse.reservations import reserve_stocks_and_preorders
-from . import AddressType, calculations
+from . import AddressType, base_calculations, calculations
from .error_codes import CheckoutErrorCode
from .fetch import (
update_checkout_info_delivery_method,
@@ -324,12 +324,10 @@ def change_shipping_address_in_checkout(
def _get_shipping_voucher_discount_for_checkout(
- manager: PluginsManager,
voucher: Voucher,
checkout_info: "CheckoutInfo",
lines: Iterable["CheckoutLineInfo"],
address: Optional["Address"],
- discounts: Optional[Iterable[DiscountInfo]] = None,
):
"""Calculate discount value for a voucher of shipping type."""
if not is_shipping_required(lines):
@@ -346,12 +344,9 @@ def _get_shipping_voucher_discount_for_checkout(
msg = "This offer is not valid in your country."
raise NotApplicable(msg)
- shipping_price = calculations.checkout_shipping_price(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=address,
- discounts=discounts,
+ # the gross is taken, as net and gross are the same for base calculations
+ shipping_price = base_calculations.base_checkout_delivery_price(
+ checkout_info=checkout_info, lines=lines
).gross
return voucher.get_discount_amount_for(shipping_price, checkout_info.channel)
@@ -457,17 +452,17 @@ def get_voucher_discount_for_checkout(
"""
validate_voucher_for_checkout(manager, voucher, checkout_info, lines, discounts)
if voucher.type == VoucherType.ENTIRE_ORDER:
- subtotal = calculations.checkout_subtotal(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=address,
- discounts=discounts,
+ # the gross is taken, as net and gross are the same for base calculations
+ subtotal = base_calculations.base_checkout_lines_total(
+ lines,
+ checkout_info.channel,
+ checkout_info.checkout.currency,
+ discounts,
).gross
return voucher.get_discount_amount_for(subtotal, checkout_info.channel)
if voucher.type == VoucherType.SHIPPING:
return _get_shipping_voucher_discount_for_checkout(
- manager, voucher, checkout_info, lines, address, discounts
+ voucher, checkout_info, lines, address
)
if voucher.type == VoucherType.SPECIFIC_PRODUCT:
# The specific product voucher is propagated on specific line's prices
@@ -537,12 +532,12 @@ def recalculate_checkout_discount(
remove_voucher_from_checkout(checkout)
checkout_info.voucher = None
else:
- subtotal = calculations.checkout_subtotal(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=address,
- discounts=discounts,
+ # the gross is taken, as net and gross are the same for base calculations
+ subtotal = base_calculations.base_checkout_lines_total(
+ lines,
+ checkout_info.channel,
+ checkout_info.checkout.currency,
+ discounts,
).gross
checkout.discount = (
min(discount, subtotal)
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 5252842529..53427ab943 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -638,6 +638,7 @@ 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,
[
@@ -698,6 +699,7 @@ 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(
diff --git a/saleor/discount/utils.py b/saleor/discount/utils.py
index ba24a1bb46..bd5a6650c6 100644
--- a/saleor/discount/utils.py
+++ b/saleor/discount/utils.py
@@ -19,7 +19,6 @@ from django.utils import timezone
from prices import Money, TaxedMoney
from ..channel.models import Channel
-from ..checkout import calculations
from ..core.taxes import zero_money
from . import DiscountInfo
from .models import NotApplicable, Sale, SaleChannelListing, VoucherCustomer
@@ -195,16 +194,15 @@ def validate_voucher_for_checkout(
lines: Iterable["CheckoutLineInfo"],
discounts: Optional[Iterable[DiscountInfo]],
):
+ from ..checkout import base_calculations
from ..checkout.utils import calculate_checkout_quantity
quantity = calculate_checkout_quantity(lines)
- address = checkout_info.shipping_address or checkout_info.billing_address
- subtotal = calculations.checkout_subtotal(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=address,
- discounts=discounts,
+ subtotal = base_calculations.base_checkout_lines_total(
+ lines,
+ checkout_info.channel,
+ checkout_info.checkout.currency,
+ discounts,
)
customer_email = cast(str, checkout_info.get_customer_email())
diff --git a/saleor/graphql/checkout/tests/test_checkout_lines.py b/saleor/graphql/checkout/tests/test_checkout_lines.py
index dcc275cca7..618f8d6c5f 100644
--- a/saleor/graphql/checkout/tests/test_checkout_lines.py
+++ b/saleor/graphql/checkout/tests/test_checkout_lines.py
@@ -758,6 +758,17 @@ MUTATION_CHECKOUT_LINES_UPDATE = """
id
}
}
+ totalPrice {
+ gross {
+ amount
+ }
+ net {
+ amount
+ }
+ }
+ discount {
+ amount
+ }
}
errors {
field
@@ -813,6 +824,53 @@ def test_checkout_lines_update(
assert checkout.last_change != previous_last_change
+def test_checkout_lines_update_checkout_with_voucher(
+ user_api_client, checkout_with_item, voucher_percentage
+):
+ """Ensure that discount is correct calculated when updating the checkout with
+ already applied discount."""
+ # given
+ channel = checkout_with_item.channel
+ line = checkout_with_item.lines.first()
+ variant = line.variant
+
+ channel_listing = variant.channel_listings.get(channel=channel)
+ unit_price = variant.get_price(
+ variant.product, [], checkout_with_item.channel, channel_listing
+ )
+
+ voucher_channel_listing = voucher_percentage.channel_listings.get(channel=channel)
+ voucher_channel_listing.discount_value = 100
+ voucher_channel_listing.save(update_fields=["discount_value"])
+
+ checkout_with_item.voucher_code = voucher_percentage.code
+ checkout_with_item.discount_amount = (unit_price * line.quantity).amount
+ checkout_with_item.save()
+
+ variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
+
+ variables = {
+ "id": to_global_id_or_none(checkout_with_item),
+ "lines": [{"variantId": variant_id, "quantity": 1}],
+ }
+
+ # when
+ response = user_api_client.post_graphql(MUTATION_CHECKOUT_LINES_UPDATE, variables)
+
+ # then
+ content = get_graphql_content(response)
+
+ data = content["data"]["checkoutLinesUpdate"]
+ assert not data["errors"]
+ checkout_data = data["checkout"]
+ total_price_gross_amount = checkout_data["totalPrice"]["gross"]["amount"]
+ assert total_price_gross_amount == 0
+ assert checkout_data["discount"]["amount"] == unit_price.amount
+
+ checkout_with_item.refresh_from_db()
+ assert checkout_with_item.discount_amount == unit_price.amount
+
+
def test_checkout_lines_update_with_new_reservations(
site_settings_with_reservations,
user_api_client,
diff --git a/saleor/graphql/checkout/tests/test_checkout_promo_codes.py b/saleor/graphql/checkout/tests/test_checkout_promo_codes.py
index 2934aa71b6..f94433140b 100644
--- a/saleor/graphql/checkout/tests/test_checkout_promo_codes.py
+++ b/saleor/graphql/checkout/tests/test_checkout_promo_codes.py
@@ -245,6 +245,9 @@ MUTATION_CHECKOUT_ADD_PROMO_CODE = """
id
token
voucherCode
+ discount {
+ amount
+ }
giftCards {
id
last4CodeChars
@@ -322,6 +325,46 @@ def test_checkout_add_voucher_code_by_token(api_client, checkout_with_item, vouc
assert data["checkout"]["voucherCode"] == voucher.code
+def test_checkout_add_already_applied_voucher_for_entire_order(
+ api_client, checkout_with_item, voucher
+):
+ # given
+ variant = checkout_with_item.lines.first().variant
+ channel = checkout_with_item.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
+ net = (
+ variant.get_price(
+ variant.product, [], checkout_with_item.channel, channel_listing
+ )
+ * checkout_with_item.lines.first().quantity
+ )
+
+ voucher_channel_listing = voucher.channel_listings.get(channel=channel)
+ voucher_channel_listing.discount_value = net.amount
+ voucher_channel_listing.save(update_fields=["discount_value"])
+
+ checkout_with_item.voucher_code = voucher.code
+ checkout_with_item.discount_amount = net.amount
+ checkout_with_item.save()
+
+ variables = {
+ "id": to_global_id_or_none(checkout_with_item),
+ "promoCode": voucher.code,
+ }
+ assert voucher.type == VoucherType.ENTIRE_ORDER
+
+ # when
+ data = _mutate_checkout_add_promo_code(api_client, variables)
+
+ # then
+ checkout_with_item.refresh_from_db()
+ assert not data["errors"]
+ checkout_data = data["checkout"]
+ total_price_gross_amount = checkout_data["totalPrice"]["gross"]["amount"]
+ assert total_price_gross_amount == 0
+ assert checkout_data["discount"]["amount"] == net.amount
+
+
@mock.patch("saleor.plugins.webhook.tasks.send_webhook_request_sync")
def test_checkout_add_voucher_code_by_token_with_external_shipment(
mock_send_request,
@@ -380,8 +423,8 @@ def test_checkout_add_voucher_code_with_display_gross_prices(
voucher_channel_listing.save()
monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: TaxedMoney(
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: TaxedMoney(
Money(95, "USD"), Money(100, "USD")
),
)
@@ -413,8 +456,8 @@ def test_checkout_add_voucher_code_without_display_gross_prices(
voucher_channel_listing.save()
monkeypatch.setattr(
- "saleor.discount.utils.calculations.checkout_subtotal",
- lambda manager, checkout_info, lines, address, discounts: TaxedMoney(
+ "saleor.checkout.utils.base_calculations.base_checkout_lines_total",
+ lambda checkout_lines, channel, currency, discounts: TaxedMoney(
Money(95, "USD"), Money(100, "USD")
),
)
diff --git a/saleor/order/tests/test_order.py b/saleor/order/tests/test_order.py
index 8ca7f14925..b7a8d58a87 100644
--- a/saleor/order/tests/test_order.py
+++ b/saleor/order/tests/test_order.py
@@ -634,6 +634,7 @@ def test_update_order_prices_tax_included(order_with_lines, vatlayer, site_setti
product_1, [], channel, variant_channel_listing_1, None
)
line_1.unit_price_gross = price_1
+ line_1.base_unit_price = price_1
line_1.save()
line_2 = order_with_lines.lines.last()
@@ -644,6 +645,7 @@ def test_update_order_prices_tax_included(order_with_lines, vatlayer, site_setti
product_2, [], channel, variant_channel_listing_2, None
)
line_2.unit_price_gross = price_2
+ line_2.base_unit_price = price_2
line_2.save()
shipping_price = order_with_lines.shipping_method.channel_listings.get(
diff --git a/saleor/order/tests/test_order_utils.py b/saleor/order/tests/test_order_utils.py
index 5fb8febc21..18bd1261f4 100644
--- a/saleor/order/tests/test_order_utils.py
+++ b/saleor/order/tests/test_order_utils.py
@@ -6,6 +6,7 @@ import pytest
from prices import Money, TaxedMoney
from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines
+from ...discount import DiscountValueType, OrderDiscountType
from ...giftcard import GiftCardEvents
from ...giftcard.models import GiftCardEvent
from ...order.interface import OrderTaxedPricesData
@@ -18,6 +19,7 @@ from ..utils import (
add_gift_cards_to_order,
add_variant_to_order,
change_order_line_quantity,
+ get_total_order_discount_excluding_shipping,
get_valid_shipping_methods_for_order,
match_orders_with_new_user,
update_taxes_for_order_line,
@@ -501,3 +503,79 @@ def test_update_taxes_for_order_line_deleted_variant(order_with_lines):
assert order_line.tax_rate == order_line_unchanged_copy.tax_rate
assert order_line.undiscounted_unit_price == order_line_unchanged_copy.unit_price
assert order_line.undiscounted_total_price == order_line_unchanged_copy.total_price
+
+
+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_total_order_discount_excluding_shipping(order, voucher_shipping_type):
+ # given
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher_shipping_type.code,
+ currency="USD",
+ amount_value=Decimal("10.0"),
+ )
+ manual_discount = order.discounts.create(
+ type=OrderDiscountType.MANUAL,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher_shipping_type.code,
+ currency="USD",
+ amount_value=Decimal("10.0"),
+ )
+ currency = order.currency
+ total = TaxedMoney(Money(10, currency), Money(10, currency))
+ order.voucher = voucher_shipping_type
+ order.total = total
+ order.undiscounted_total = total
+ order.save()
+
+ # when
+ discount_amount = get_total_order_discount_excluding_shipping(order)
+
+ # then
+ assert discount_amount == Money(manual_discount.amount_value, order.currency)
+
+
+def test_get_total_order_discount_excluding_shipping_no_shipping_discounts(
+ order, voucher
+):
+ # given
+ discount_1 = order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher.code,
+ currency="USD",
+ amount_value=Decimal("10.0"),
+ )
+ discount_2 = order.discounts.create(
+ type=OrderDiscountType.MANUAL,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher.code,
+ currency="USD",
+ amount_value=Decimal("10.0"),
+ )
+ currency = order.currency
+ total = TaxedMoney(Money(30, currency), Money(30, currency))
+ order.voucher = voucher
+ order.total = total
+ order.undiscounted_total = total
+ order.save()
+
+ # when
+ discount_amount = get_total_order_discount_excluding_shipping(order)
+
+ # then
+ assert discount_amount == Money(
+ discount_1.amount_value + discount_2.amount_value, order.currency
+ )
diff --git a/saleor/order/utils.py b/saleor/order/utils.py
index f5e9b41ff4..4d1e707c20 100644
--- a/saleor/order/utils.py
+++ b/saleor/order/utils.py
@@ -235,6 +235,7 @@ def update_taxes_for_order_lines(
):
for line in lines:
update_taxes_for_order_line(line, order, manager, tax_included=tax_included)
+ manager.update_taxes_for_order_lines(order, lines)
OrderLine.objects.bulk_update(
lines,
[
@@ -426,6 +427,8 @@ def add_variant_to_order(
order, product, variant, None, unit_price
)
+ 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(
@@ -815,6 +818,22 @@ def get_total_order_discount(order: Order) -> Money:
return total_order_discount
+def get_total_order_discount_excluding_shipping(order: Order) -> Money:
+ """Return total discounts assigned to the order excluding shipping discounts."""
+ # If the order has an assigned shipping voucher we want to exclude the corresponding
+ # order discount from the calculation.
+ # The calculation is based on assumption that an order can have only one voucher.
+ all_discounts = order.discounts.all()
+ if order.voucher_id and order.voucher.type == VoucherType.SHIPPING: # type: ignore
+ all_discounts = all_discounts.exclude(type=OrderDiscountType.VOUCHER)
+ total_order_discount = Money(
+ sum([discount.amount_value for discount in all_discounts]),
+ currency=order.currency,
+ )
+ total_order_discount = min(total_order_discount, order.undiscounted_total_gross)
+ return total_order_discount
+
+
def get_order_discounts(order: Order) -> List[OrderDiscount]:
"""Return all discounts applied to the order by staff user."""
return list(order.discounts.filter(type=OrderDiscountType.MANUAL))
diff --git a/saleor/plugins/avatax/__init__.py b/saleor/plugins/avatax/__init__.py
index 9018935cb0..230e70ae2e 100644
--- a/saleor/plugins/avatax/__init__.py
+++ b/saleor/plugins/avatax/__init__.py
@@ -16,7 +16,11 @@ from requests.auth import HTTPBasicAuth
from ...checkout import base_calculations
from ...checkout.utils import is_shipping_required
from ...core.taxes import TaxError
-from ...order.utils import get_total_order_discount
+from ...discount import VoucherType
+from ...order.utils import (
+ get_total_order_discount_excluding_shipping,
+ get_voucher_discount_assigned_to_order,
+)
from ...shipping.models import ShippingMethodChannelListing
if TYPE_CHECKING:
@@ -204,6 +208,8 @@ def append_line_to_data(
item_code: str,
name: str = None,
tax_included: Optional[bool] = None,
+ discounted: Optional[bool] = False,
+ tax_override_data: Optional[dict] = None,
ref1: Optional[str] = None,
ref2: Optional[str] = None,
):
@@ -215,9 +221,12 @@ def append_line_to_data(
"taxCode": tax_code,
"taxIncluded": tax_included,
"itemCode": item_code,
+ "discounted": discounted,
"description": name,
}
+ if tax_override_data:
+ line_data["taxOverride"] = tax_override_data
if ref1:
line_data["ref1"] = ref1
if ref2:
@@ -229,17 +238,19 @@ def append_shipping_to_data(
data: List[Dict],
shipping_price_amount: Optional[Decimal],
shipping_tax_code: str,
+ 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:
+ if charge_taxes_on_shipping and 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",
+ discounted=discounted,
)
@@ -252,9 +263,25 @@ def get_checkout_lines_data(
data: List[Dict[str, Union[str, int, bool, None]]] = []
channel = checkout_info.channel
tax_included = Site.objects.get_current().settings.include_taxes_in_prices
+ 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:
+ tax_override_data = {}
if not line_info.product.charge_taxes:
- continue
+ if not is_entire_order_discount:
+ continue
+ # if there is a voucher for the entire order we need to attach this line
+ # with 0 tax to propagate discount through all lines
+ tax_override_data = {
+ "type": "taxAmount",
+ "taxAmount": 0,
+ "reason": "Charge taxes for this product are turned off.",
+ }
+
product = line_info.product
name = product.name
product_type = line_info.product_type
@@ -286,6 +313,8 @@ def get_checkout_lines_data(
"item_code": item_code,
"name": name,
"tax_included": tax_included,
+ "discounted": is_entire_order_discount,
+ "tax_override_data": tax_override_data,
}
append_line_to_data(
@@ -297,17 +326,21 @@ def get_checkout_lines_data(
delivery_method = checkout_info.delivery_method_info.delivery_method
if delivery_method:
price = getattr(delivery_method, "price", None)
+ 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,
+ is_shipping_discount,
)
return data
def get_order_lines_data(
- order: "Order", config: AvataxConfiguration, invoice_transaction_type: bool = False
+ 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(
@@ -344,31 +377,32 @@ def get_order_lines_data(
"item_code": line.variant.sku or line.variant.get_global_id(),
"name": line.variant.product.name,
"tax_included": tax_included,
+ "discounted": discounted,
}
append_line_to_data(
**append_line_to_data_kwargs,
amount=price_with_discounts_amount,
)
- discount_amount = get_total_order_discount(order)
- if discount_amount:
- append_line_to_data(
- data=data,
- quantity=1,
- amount=discount_amount.amount * -1,
- tax_code=COMMON_DISCOUNT_VOUCHER_CODE,
- item_code="Voucher",
- name="Order discount",
- tax_included=True, # Voucher should be always applied as a gross amount
- )
-
shipping_method_channel_listing = ShippingMethodChannelListing.objects.filter(
shipping_method=order.shipping_method_id, channel=order.channel_id
).first()
if shipping_method_channel_listing:
+ shipping_discount_amount = Decimal("0")
+ if (
+ order.voucher_id
+ and order.voucher.type == VoucherType.SHIPPING # type: ignore
+ ):
+ shipping_discount = get_voucher_discount_assigned_to_order(order)
+ if shipping_discount:
+ shipping_discount_amount = shipping_discount.amount_value
+ shipping_price = max(
+ shipping_method_channel_listing.price.amount - shipping_discount_amount,
+ Decimal("0"),
+ )
append_shipping_to_data(
data,
- shipping_method_channel_listing.price.amount,
+ shipping_price,
config.shipping_tax_code,
)
return data
@@ -382,6 +416,7 @@ def generate_request_data(
customer_email: str,
config: AvataxConfiguration,
currency: str,
+ discount: Optional[Decimal] = None,
):
data = {
"companyCode": config.company_name,
@@ -391,6 +426,8 @@ def generate_request_data(
"date": str(date.today()),
# https://developer.avalara.com/avatax/dev-guide/transactions/simple-transaction/
"customerCode": 0,
+ # https://developer.avalara.com/avatax/dev-guide/discounts-and-overrides/discounts/
+ "discount": str(discount) if discount else None,
"addresses": {
"shipFrom": {
"line1": config.from_street_address,
@@ -424,7 +461,6 @@ def generate_request_data_from_checkout(
transaction_type=TransactionType.ORDER,
discounts=None,
):
-
address = checkout_info.shipping_address or checkout_info.billing_address
lines = get_checkout_lines_data(checkout_info, lines_info, config, discounts)
@@ -436,6 +472,7 @@ def generate_request_data_from_checkout(
transaction_token=transaction_token or str(checkout_info.checkout.token),
address=address.as_data() if address else {},
customer_email=customer_email,
+ discount=checkout_info.checkout.discount.amount,
config=config,
currency=currency,
)
@@ -501,8 +538,9 @@ def get_order_request_data(order: "Order", config: AvataxConfiguration):
if not (order.is_draft() or order.is_unconfirmed())
else TransactionType.ORDER
)
- is_invoice_transaction = transaction == TransactionType.INVOICE
- lines = get_order_lines_data(order, config, is_invoice_transaction)
+ discount_amount = get_total_order_discount_excluding_shipping(order).amount
+ discounted_lines = discount_amount != Decimal("0")
+ lines = get_order_lines_data(order, config, discounted=discounted_lines)
data = generate_request_data(
transaction_type=transaction,
lines=lines,
@@ -511,6 +549,7 @@ def get_order_request_data(order: "Order", config: AvataxConfiguration):
customer_email=order.user_email,
config=config,
currency=order.currency,
+ discount=discount_amount,
)
return data
diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.py
index 48b72cd730..e3f0a14ccb 100644
--- a/saleor/plugins/avatax/plugin.py
+++ b/saleor/plugins/avatax/plugin.py
@@ -240,14 +240,6 @@ class AvataxPlugin(BasePlugin):
taxed_total.price_with_sale += shipping_price
taxed_total.price_with_discounts += shipping_price
- voucher_value = checkout_info.checkout.discount
- # if price with voucher and without is the same it means that we didn't apply
- # any voucher for specifc product. The rest of the vouchers is applied to total
- if (
- voucher_value
- and taxed_total.price_with_sale == taxed_total.price_with_discounts
- ):
- taxed_total.price_with_discounts -= voucher_value
return max(
taxed_total.price_with_discounts,
zero_taxed_money(taxed_total.price_with_discounts.currency),
@@ -256,11 +248,16 @@ class AvataxPlugin(BasePlugin):
def _calculate_checkout_shipping(
self, currency: str, lines: List[Dict], shipping_price: TaxedMoney
) -> TaxedMoney:
+ discount_amount = Decimal(0.0)
shipping_tax = Decimal(0.0)
shipping_net = shipping_price.net.amount
for line in lines:
if line["itemCode"] == "Shipping":
+ # The lineAmount does not include the discountAmount,
+ # but tax is calculated for discounted net price, that
+ # take into account provided discount.
shipping_net = Decimal(line["lineAmount"])
+ discount_amount = Decimal(line.get("discountAmount", 0.0))
shipping_tax = Decimal(line["tax"])
break
@@ -269,12 +266,13 @@ class AvataxPlugin(BasePlugin):
)
if currency == "JPY" and tax_included():
shipping_gross = Money(
- amount=shipping_price.gross.amount, currency=currency
+ amount=shipping_price.gross.amount - discount_amount, currency=currency
)
shipping_net = Money(
amount=shipping_gross.amount - shipping_tax, currency=currency
)
else:
+ shipping_net -= discount_amount
shipping_gross = Money(
amount=shipping_net + shipping_tax, currency=currency
)
@@ -431,13 +429,19 @@ class AvataxPlugin(BasePlugin):
if line.get("itemCode") != item_code:
continue
+ # The lineAmount does not include the discountAmount, but tax is calculated
+ # for discounted net price, that take into account provided discount.
tax = Decimal(line.get("tax", 0.0))
+ discount_amount = Decimal(line.get("discountAmount", 0.0))
net = Decimal(line["lineAmount"])
if currency == "JPY" and tax_included():
- line_gross = base_value.price_with_sale.gross
+ line_gross = Money(
+ base_value.price_with_sale.gross.amount - discount_amount, currency
+ )
line_net = Money(amount=line_gross.amount - tax, currency=currency)
else:
+ net -= discount_amount
line_gross = Money(amount=net + tax, currency=currency)
line_net = Money(amount=net, currency=currency)
@@ -498,13 +502,20 @@ class AvataxPlugin(BasePlugin):
if line.get("itemCode") != item_code:
continue
+ # The lineAmount does not include the discountAmount, but tax is calculated
+ # for discounted net price, that take into account provided discount.
tax = Decimal(line.get("tax", 0.0))
+ discount_amount = Decimal(line.get("discountAmount", 0.0))
net = Decimal(line["lineAmount"])
if currency == "JPY" and tax_included():
- line_gross = base_value.price_with_discounts.gross
+ line_gross = Money(
+ base_value.price_with_discounts.gross.amount - discount_amount,
+ currency,
+ )
line_net = Money(amount=line_gross.amount - tax, currency=currency)
else:
+ net -= discount_amount
line_gross = Money(amount=net + tax, currency=currency)
line_net = Money(amount=net, currency=currency)
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
new file mode 100644
index 0000000000..c3425518e4
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[False].yaml
@@ -0,0 +1,70 @@
+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",
+ "ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
+ false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
+ "0af4e820-220b-45eb-8810-70fd02db1d76", "date": "2022-05-16", "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",
+ "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:
+ - '851'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"0af4e820-220b-45eb-8810-70fd02db1d76","companyId":242975,"date":"2022-05-16","paymentDate":"2022-05-16","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-05-16","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-16T13:07:37.6906528Z","modifiedUserId":283192,"taxDate":"2022-05-16","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-05-16","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-16","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-230CPL","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-05-16","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-16","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-230FPL","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}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Mon, 16 May 2022 13:07:37 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0175036'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - cf64e248-1341-4c8d-9880-1f65ecdaef67
+ x-correlation-id:
+ - cf64e248-1341-4c8d-9880-1f65ecdaef67
+ 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_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
new file mode 100644
index 0000000000..dc6c54dd40
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_entire_order[True].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "fefea9b8-3d85-4f74-aa5c-bdba69ba1475", "date": "2022-05-16", "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",
+ "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:
+ - '849'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"fefea9b8-3d85-4f74-aa5c-bdba69ba1475","companyId":242975,"date":"2022-05-16","paymentDate":"2022-05-16","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-05-16","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-16T13:07:37.6518444Z","modifiedUserId":283192,"taxDate":"2022-05-16","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-05-16","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-16","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-230CPL","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-05-16","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-16","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-230FPL","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":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:
+ - Mon, 16 May 2022 13:07:37 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0176611'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - ed3e2c8c-660a-47ec-be12-58d86f990992
+ x-correlation-id:
+ - ed3e2c8c-660a-47ec-be12-58d86f990992
+ 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_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
new file mode 100644
index 0000000000..12d775ea3a
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[24.39-30.00-True].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ 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.000", "taxCode": "FR000000", "taxIncluded":
+ true, "itemCode": "Shipping", "discounted": true, "description": null}], "code":
+ "8415f3fc-a3fe-4c18-a0fe-24045d6bdec1", "date": "2022-05-13", "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",
+ "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:
+ - '849'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"8415f3fc-a3fe-4c18-a0fe-24045d6bdec1","companyId":242975,"date":"2022-05-13","paymentDate":"2022-05-13","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-05-13","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-13T08:41:59.0456706Z","modifiedUserId":283192,"taxDate":"2022-05-13","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-05-13","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-13","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-230CPL","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-05-13","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-13","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-230FPL","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":24.39,"rate":0.230000,"tax":5.61,"taxCalculated":5.61,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Fri, 13 May 2022 08:41:59 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0157535'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - ca45a481-f167-4b19-92e9-e4e20982fd1a
+ x-correlation-id:
+ - ca45a481-f167-4b19-92e9-e4e20982fd1a
+ 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_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
new file mode 100644
index 0000000000..cfbedbb5ec
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_subtotal_voucher_on_shipping[30.00-36.90-False].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "52dea757-d13d-452e-91fa-f2918a71921e", "date": "2022-05-13", "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",
+ "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:
+ - '851'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"52dea757-d13d-452e-91fa-f2918a71921e","companyId":242975,"date":"2022-05-13","paymentDate":"2022-05-13","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-05-13","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-13T08:42:02.1813523Z","modifiedUserId":283192,"taxDate":"2022-05-13","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-05-13","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-13","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-230CPL","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-05-13","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-13","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-230FPL","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":30.0,"rate":0.230000,"tax":6.9,"taxCalculated":6.9,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Fri, 13 May 2022 08:42:02 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0159616'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 6494ecd8-24c8-46be-b9fa-2bfa5cbee2cd
+ x-correlation-id:
+ - 6494ecd8-24c8-46be-b9fa-2bfa5cbee2cd
+ 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-31.51-38.99-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-32.07-38.99-3.0-True].yaml
similarity index 62%
rename from saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-31.51-38.99-3.0-True].yaml
rename to saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-32.07-38.99-3.0-True].yaml
index eb277b7762..4979674df2 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-31.51-38.99-3.0-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[False-32.07-38.99-3.0-True].yaml
@@ -2,14 +2,15 @@ interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PS081282", "taxIncluded":
- true, "itemCode": "123", "description": "Test product", "ref1": "123"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true, "itemCode":
- "Shipping", "description": null}], "code": "80b201c7-d9da-41f6-bcbc-f7da9e492fe4",
- "date": "2022-05-05", "customerCode": 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]"}}'
+ 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":
+ "1df436e1-037f-4615-b171-0917186233b2", "date": "2022-05-12", "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",
+ "region": "", "country": "PL", "postalCode": "53-105"}}, "commit": false, "currencyCode":
+ "USD", "email": "[email protected]"}}'
headers:
Accept:
- '*/*'
@@ -20,31 +21,31 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '786'
+ - '846'
User-Agent:
- python-requests/2.27.1
method: POST
uri: https://rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"80b201c7-d9da-41f6-bcbc-f7da9e492fe4","companyId":242975,"date":"2022-05-05","paymentDate":"2022-05-05","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-05-05","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-05T09:28:09.1217097Z","modifiedUserId":283192,"taxDate":"2022-05-05","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-05-05","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"PS081282","taxCodeId":28918,"taxDate":"2022-05-05","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-230CPL","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-05-05","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-05","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":"1df436e1-037f-4615-b171-0917186233b2","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":33.08,"totalExempt":0.0,"totalDiscount":3.0,"totalTax":6.92,"totalTaxable":30.08,"totalTaxCalculated":6.92,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:04:28.4924809Z","modifiedUserId":283192,"taxDate":"2022-05-12","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":3.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.9500,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-05-12","tax":5.05,"taxableAmount":21.95,"taxCalculated":5.05,"taxCode":"PS081282","taxCodeId":28918,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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":32.52,"rate":0.230000,"tax":7.48,"taxCalculated":7.48,"nonTaxable":0.0,"exemption":0.0}]}'
+ Rate","rateType":"Standard","taxable":30.08,"rate":0.230000,"tax":6.92,"taxCalculated":6.92,"nonTaxable":0.0,"exemption":0.0}]}'
headers:
Connection:
- keep-alive
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 05 May 2022 09:28:09 GMT
+ - Thu, 12 May 2022 13:04:28 GMT
Location:
- /api/v2/companies/242975/transactions/0
ServerDuration:
- - '00:00:00.0166993'
+ - '00:00:00.0172522'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -54,9 +55,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - b97b75f6-dec7-4b2c-abac-cf1e3453c239
+ - bd7deed2-4b51-454c-bd9a-322d202dce39
x-correlation-id:
- - b97b75f6-dec7-4b2c-abac-cf1e3453c239
+ - bd7deed2-4b51-454c-bd9a-322d202dce39
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.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 d87be18a9b..7fcc6a884d 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
@@ -2,14 +2,15 @@ interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PS081282", "taxIncluded":
- false, "itemCode": "123", "description": "Test product", "ref1": "123"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false, "itemCode":
- "Shipping", "description": null}], "code": "61a9094c-272c-4844-9ea4-a504e0cdde93",
- "date": "2022-05-05", "customerCode": 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]"}}'
+ 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":
+ "d00b6a8f-0208-4b05-80ed-d93695ce8cc2", "date": "2022-05-12", "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:
- '*/*'
@@ -20,16 +21,16 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '788'
+ - '847'
User-Agent:
- python-requests/2.27.1
method: POST
uri: https://rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"61a9094c-272c-4844-9ea4-a504e0cdde93","companyId":242975,"date":"2022-05-05","paymentDate":"2022-05-05","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-05-05","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-05T09:28:09.7031909Z","modifiedUserId":283192,"taxDate":"2022-05-05","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-05-05","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"PS081282","taxCodeId":28918,"taxDate":"2022-05-05","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-230CPL","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-05-05","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-05","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":"d00b6a8f-0208-4b05-80ed-d93695ce8cc2","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","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-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:04:28.6730516Z","modifiedUserId":283192,"taxDate":"2022-05-12","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-05-12","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"PS081282","taxCodeId":28918,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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
@@ -40,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 05 May 2022 09:28:09 GMT
+ - Thu, 12 May 2022 13:04:28 GMT
Location:
- /api/v2/companies/242975/transactions/0
ServerDuration:
- - '00:00:00.0161581'
+ - '00:00:00.0177066'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -54,9 +55,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - bdcee0cd-5bca-43c5-ad84-84d3be528cd6
+ - d5cbe8bb-d02b-475c-91d7-6fc2c6c3efd5
x-correlation-id:
- - bdcee0cd-5bca-43c5-ad84-84d3be528cd6
+ - d5cbe8bb-d02b-475c-91d7-6fc2c6c3efd5
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.59-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.59-5.0-False].yaml
new file mode 100644
index 0000000000..0b15a9de64
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-26.59-5.0-False].yaml
@@ -0,0 +1,70 @@
+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": "10.000", "taxCode": "FR000000", "taxIncluded":
+ false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
+ "5d49ca70-1198-49e3-b917-aede71892d55", "date": "2022-05-12", "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:
+ - '848'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"5d49ca70-1198-49e3-b917-aede71892d55","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","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":5.0,"totalTax":4.6,"totalTaxable":20.0,"totalTaxCalculated":4.6,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:04:28.5460544Z","modifiedUserId":283192,"taxDate":"2022-05-12","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":5.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-05-12","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"PS081282","taxCodeId":28918,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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.0,"rate":0.230000,"tax":4.6,"taxCalculated":4.6,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Thu, 12 May 2022 13:04:28 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0163220'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 6ea9a2f2-be1e-4e08-a96f-8e2c975c6036
+ x-correlation-id:
+ - 6ea9a2f2-be1e-4e08-a96f-8e2c975c6036
+ 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-27.74-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-27.74-5.0-False].yaml
deleted file mode 100644
index 7a8552088e..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total[True-21.99-27.74-5.0-False].yaml
+++ /dev/null
@@ -1,69 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PS081282", "taxIncluded":
- false, "itemCode": "123", "description": "Test product", "ref1": "123"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false, "itemCode":
- "Shipping", "description": null}], "code": "b4248223-99b7-4f3a-b8dd-539bb494d493",
- "date": "2022-05-05", "customerCode": 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:
- - '788'
- User-Agent:
- - python-requests/2.27.1
- method: POST
- uri: https://rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: '{"id":0,"code":"b4248223-99b7-4f3a-b8dd-539bb494d493","companyId":242975,"date":"2022-05-05","paymentDate":"2022-05-05","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-05-05","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-05T09:28:09.7067776Z","modifiedUserId":283192,"taxDate":"2022-05-05","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-05-05","tax":3.45,"taxableAmount":15.0,"taxCalculated":3.45,"taxCode":"PS081282","taxCodeId":28918,"taxDate":"2022-05-05","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-230CPL","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-05-05","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-05","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-230FPL","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":25.0,"rate":0.230000,"tax":5.75,"taxCalculated":5.75,"nonTaxable":0.0,"exemption":0.0}]}'
- headers:
- Connection:
- - keep-alive
- Content-Type:
- - application/json; charset=utf-8
- Date:
- - Thu, 05 May 2022 09:28:09 GMT
- Location:
- - /api/v2/companies/242975/transactions/0
- ServerDuration:
- - '00:00:00.0183188'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- referrer-policy:
- - same-origin
- strict-transport-security:
- - max-age=31536000; includeSubdomains
- x-avalara-uid:
- - 2e68529f-5c77-42a4-bd28-8d2f106a05ad
- x-correlation-id:
- - 2e68529f-5c77-42a4-bd28-8d2f106a05ad
- 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-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 289ec0f815..96117e2840 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
@@ -2,14 +2,15 @@ interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PS081282", "taxIncluded":
- true, "itemCode": "123", "description": "Test product", "ref1": "123"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true, "itemCode":
- "Shipping", "description": null}], "code": "e706611e-e66b-4c0a-b52e-9bfd4ac6adff",
- "date": "2022-05-05", "customerCode": 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]"}}'
+ 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":
+ "f8feb0c8-98b9-4f59-ab40-616ffb9be1af", "date": "2022-05-12", "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:
- '*/*'
@@ -20,16 +21,16 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '786'
+ - '845'
User-Agent:
- python-requests/2.27.1
method: POST
uri: https://rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"e706611e-e66b-4c0a-b52e-9bfd4ac6adff","companyId":242975,"date":"2022-05-05","paymentDate":"2022-05-05","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-05-05","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-05T09:28:09.1105424Z","modifiedUserId":283192,"taxDate":"2022-05-05","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-05-05","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"PS081282","taxCodeId":28918,"taxDate":"2022-05-05","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-230CPL","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-05-05","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-05","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":"f8feb0c8-98b9-4f59-ab40-616ffb9be1af","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","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-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:04:28.4620862Z","modifiedUserId":283192,"taxDate":"2022-05-12","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-05-12","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"PS081282","taxCodeId":28918,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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
@@ -40,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 05 May 2022 09:28:09 GMT
+ - Thu, 12 May 2022 13:04:28 GMT
Location:
- /api/v2/companies/242975/transactions/0
ServerDuration:
- - '00:00:00.0157280'
+ - '00:00:00.0172576'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -54,9 +55,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 4814167b-f263-4db5-b6a7-1a3631d4fe10
+ - 0d850c32-99bc-428f-a797-7551af81a6e8
x-correlation-id:
- - 4814167b-f263-4db5-b6a7-1a3631d4fe10
+ - 0d850c32-99bc-428f-a797-7551af81a6e8
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-31.51-38.99-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-31.51-38.99-3.0-True].yaml
index 218d7330b3..9a49b23563 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-31.51-38.99-3.0-True].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-31.51-38.99-3.0-True].yaml
@@ -2,14 +2,15 @@ interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
- true, "itemCode": "123", "description": "Test product", "ref1": "123"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true, "itemCode":
- "Shipping", "description": null}], "code": "5bbf426a-2948-450b-97f5-b4d9d84d76a5",
- "date": "2022-05-05", "customerCode": 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]"}}'
+ 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":
+ "07e54beb-13fc-4ec8-964c-a152686d0eb4", "date": "2022-05-12", "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",
+ "region": "", "country": "PL", "postalCode": "53-105"}}, "commit": false, "currencyCode":
+ "USD", "email": "[email protected]"}}'
headers:
Accept:
- '*/*'
@@ -20,31 +21,31 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '786'
+ - '846'
User-Agent:
- python-requests/2.27.1
method: POST
uri: https://rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"5bbf426a-2948-450b-97f5-b4d9d84d76a5","companyId":242975,"date":"2022-05-05","paymentDate":"2022-05-05","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-05-05","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-05T09:28:09.104104Z","modifiedUserId":283192,"taxDate":"2022-05-05","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-05-05","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-05","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-230CPL","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-05-05","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-05","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":"07e54beb-13fc-4ec8-964c-a152686d0eb4","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":33.08,"totalExempt":0.0,"totalDiscount":3.0,"totalTax":6.92,"totalTaxable":30.08,"totalTaxCalculated":6.92,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:24:09.4777666Z","modifiedUserId":283192,"taxDate":"2022-05-12","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":3.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.9500,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-05-12","tax":5.05,"taxableAmount":21.95,"taxCalculated":5.05,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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":32.52,"rate":0.230000,"tax":7.48,"taxCalculated":7.48,"nonTaxable":0.0,"exemption":0.0}]}'
+ Rate","rateType":"Standard","taxable":30.08,"rate":0.230000,"tax":6.92,"taxCalculated":6.92,"nonTaxable":0.0,"exemption":0.0}]}'
headers:
Connection:
- keep-alive
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 05 May 2022 09:28:09 GMT
+ - Thu, 12 May 2022 13:24:09 GMT
Location:
- /api/v2/companies/242975/transactions/0
ServerDuration:
- - '00:00:00.0160004'
+ - '00:00:00.0167349'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -54,9 +55,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 341efb6c-6147-422a-bb56-e4fb9dc4b3a3
+ - c61652fb-fc61-415c-a20b-5df12599e627
x-correlation-id:
- - 341efb6c-6147-422a-bb56-e4fb9dc4b3a3
+ - c61652fb-fc61-415c-a20b-5df12599e627
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.07-38.99-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-32.07-38.99-3.0-True].yaml
new file mode 100644
index 0000000000..51e5e600c1
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[False-32.07-38.99-3.0-True].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
+ 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":
+ "e33c5050-9458-4544-bd66-0f1ce5ba489a", "date": "2022-05-12", "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",
+ "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:
+ - '846'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"e33c5050-9458-4544-bd66-0f1ce5ba489a","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","status":"Temporary","type":"SalesOrder","batchCode":"","currencyCode":"USD","exchangeRateCurrencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","totalAmount":33.08,"totalExempt":0.0,"totalDiscount":3.0,"totalTax":6.92,"totalTaxable":30.08,"totalTaxCalculated":6.92,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:26:03.2858297Z","modifiedUserId":283192,"taxDate":"2022-05-12","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":3.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":24.9500,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-05-12","tax":5.05,"taxableAmount":21.95,"taxCalculated":5.05,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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":30.08,"rate":0.230000,"tax":6.92,"taxCalculated":6.92,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Thu, 12 May 2022 13:26:03 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0165708'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - ef6bcd4e-866a-4ec4-8fc5-751e6e34fbab
+ x-correlation-id:
+ - ef6bcd4e-866a-4ec4-8fc5-751e6e34fbab
+ 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_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 ace6582596..a48f3b70b2 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
@@ -2,14 +2,15 @@ interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
- false, "itemCode": "123", "description": "Test product", "ref1": "123"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false, "itemCode":
- "Shipping", "description": null}], "code": "4045b50f-96d6-486b-aeae-0902853e4483",
- "date": "2022-05-05", "customerCode": 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]"}}'
+ 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":
+ "e376ef5e-dc9a-41a8-998c-1ed702080049", "date": "2022-05-12", "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:
- '*/*'
@@ -20,16 +21,16 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '788'
+ - '847'
User-Agent:
- python-requests/2.27.1
method: POST
uri: https://rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"4045b50f-96d6-486b-aeae-0902853e4483","companyId":242975,"date":"2022-05-05","paymentDate":"2022-05-05","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-05-05","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-05T09:28:09.5596739Z","modifiedUserId":283192,"taxDate":"2022-05-05","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-05-05","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-05","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-230CPL","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-05-05","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-05","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":"e376ef5e-dc9a-41a8-998c-1ed702080049","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","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-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:24:09.5228594Z","modifiedUserId":283192,"taxDate":"2022-05-12","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-05-12","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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
@@ -40,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 05 May 2022 09:28:09 GMT
+ - Thu, 12 May 2022 13:24:09 GMT
Location:
- /api/v2/companies/242975/transactions/0
ServerDuration:
- - '00:00:00.0201749'
+ - '00:00:00.0173252'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -54,9 +55,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - 8d68b458-6c0a-4492-9fb9-044f13e15d36
+ - dbd5dd4f-c875-483e-ab36-36b960826b83
x-correlation-id:
- - 8d68b458-6c0a-4492-9fb9-044f13e15d36
+ - dbd5dd4f-c875-483e-ab36-36b960826b83
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.59-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-26.59-5.0-False].yaml
new file mode 100644
index 0000000000..6453d72ac8
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-26.59-5.0-False].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
+ 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":
+ "2bf6455b-c3bb-43d7-9d08-6023aef24dd0", "date": "2022-05-12", "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:
+ - '848'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"2bf6455b-c3bb-43d7-9d08-6023aef24dd0","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","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":5.0,"totalTax":4.6,"totalTaxable":20.0,"totalTaxCalculated":4.6,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:26:03.0987901Z","modifiedUserId":283192,"taxDate":"2022-05-12","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":5.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-05-12","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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.0,"rate":0.230000,"tax":4.6,"taxCalculated":4.6,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Thu, 12 May 2022 13:26:03 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0166500'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 1d61e08a-d88e-4f50-9dd7-d178d447a12a
+ x-correlation-id:
+ - 1d61e08a-d88e-4f50-9dd7-d178d447a12a
+ 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_uses_default_calculation[True-21.99-27.74-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-27.74-5.0-False].yaml
index 749c1a1cf7..6d970221f0 100644
--- a/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-27.74-5.0-False].yaml
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_uses_default_calculation[True-21.99-27.74-5.0-False].yaml
@@ -2,14 +2,15 @@ interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
- false, "itemCode": "123", "description": "Test product", "ref1": "123"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": false, "itemCode":
- "Shipping", "description": null}], "code": "34e4f7a5-ae1d-46aa-af23-957ca2a32497",
- "date": "2022-05-05", "customerCode": 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]"}}'
+ 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":
+ "5808de90-aff0-42fa-a643-880174ffcec4", "date": "2022-05-12", "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:
- '*/*'
@@ -20,31 +21,31 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '788'
+ - '848'
User-Agent:
- python-requests/2.27.1
method: POST
uri: https://rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"34e4f7a5-ae1d-46aa-af23-957ca2a32497","companyId":242975,"date":"2022-05-05","paymentDate":"2022-05-05","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-05-05","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-05T09:28:09.4684849Z","modifiedUserId":283192,"taxDate":"2022-05-05","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-05-05","tax":3.45,"taxableAmount":15.0,"taxCalculated":3.45,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-05","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-230CPL","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-05-05","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-05","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":"5808de90-aff0-42fa-a643-880174ffcec4","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","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":5.0,"totalTax":4.6,"totalTaxable":20.0,"totalTaxCalculated":4.6,"adjustmentReason":"NotAdjusted","locked":false,"version":1,"exchangeRateEffectiveDate":"2022-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:24:09.51892Z","modifiedUserId":283192,"taxDate":"2022-05-12","lines":[{"id":0,"transactionId":0,"lineNumber":"1","customerUsageType":"","entityUseCode":"","description":"Test
+ product","discountAmount":5.0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"itemCode":"123","lineAmount":15.0,"quantity":3.0,"ref1":"123","ref2":"","reportingDate":"2022-05-12","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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":25.0,"rate":0.230000,"tax":5.75,"taxCalculated":5.75,"nonTaxable":0.0,"exemption":0.0}]}'
+ Rate","rateType":"Standard","taxable":20.0,"rate":0.230000,"tax":4.6,"taxCalculated":4.6,"nonTaxable":0.0,"exemption":0.0}]}'
headers:
Connection:
- keep-alive
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 05 May 2022 09:28:09 GMT
+ - Thu, 12 May 2022 13:24:09 GMT
Location:
- /api/v2/companies/242975/transactions/0
ServerDuration:
- - '00:00:00.0156792'
+ - '00:00:00.0186480'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -54,9 +55,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - d6f17537-e22d-4910-8488-12d3df8b6e35
+ - ef3b9e76-8667-49b1-9555-f1535e3c0d39
x-correlation-id:
- - d6f17537-e22d-4910-8488-12d3df8b6e35
+ - ef3b9e76-8667-49b1-9555-f1535e3c0d39
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 5d476ec862..38e9d67639 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
@@ -2,14 +2,15 @@ interactions:
- request:
body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
"lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
- true, "itemCode": "123", "description": "Test product", "ref1": "123"}, {"quantity":
- 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded": true, "itemCode":
- "Shipping", "description": null}], "code": "99a94f17-64da-4071-9822-35e6c40b826b",
- "date": "2022-05-05", "customerCode": 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]"}}'
+ 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":
+ "ad906e36-4827-40bc-99b8-1b96ca5d68ce", "date": "2022-05-12", "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:
- '*/*'
@@ -20,16 +21,16 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '786'
+ - '845'
User-Agent:
- python-requests/2.27.1
method: POST
uri: https://rest.avatax.com/api/v2/transactions/createoradjust
response:
body:
- string: '{"id":0,"code":"99a94f17-64da-4071-9822-35e6c40b826b","companyId":242975,"date":"2022-05-05","paymentDate":"2022-05-05","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-05-05","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-05T09:28:09.0763452Z","modifiedUserId":283192,"taxDate":"2022-05-05","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-05-05","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-05","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-230CPL","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-05-05","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-05","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":"ad906e36-4827-40bc-99b8-1b96ca5d68ce","companyId":242975,"date":"2022-05-12","paymentDate":"2022-05-12","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-05-12","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-12T13:24:09.5057381Z","modifiedUserId":283192,"taxDate":"2022-05-12","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-05-12","tax":2.8,"taxableAmount":12.2,"taxCalculated":2.8,"taxCode":"PC040156","taxCodeId":6622,"taxDate":"2022-05-12","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-230CPL","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-05-12","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-12","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-230FPL","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
@@ -40,11 +41,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- - Thu, 05 May 2022 09:28:09 GMT
+ - Thu, 12 May 2022 13:24:09 GMT
Location:
- /api/v2/companies/242975/transactions/0
ServerDuration:
- - '00:00:00.0183416'
+ - '00:00:00.0199536'
Transfer-Encoding:
- chunked
X-Content-Type-Options:
@@ -54,9 +55,9 @@ interactions:
strict-transport-security:
- max-age=31536000; includeSubdomains
x-avalara-uid:
- - fe96c83f-ee47-403a-aa0d-0e846538ac8a
+ - 77d675f6-0e3d-41c1-a2ab-dc409f62995d
x-correlation-id:
- - fe96c83f-ee47-403a-aa0d-0e846538ac8a
+ - 77d675f6-0e3d-41c1-a2ab-dc409f62995d
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
new file mode 100644
index 0000000000..60e37f1f0e
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[10.00-12.30-False].yaml
@@ -0,0 +1,70 @@
+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",
+ "ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
+ false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
+ "e9fc372d-7d2f-45fc-ba50-bf26dee97547", "date": "2022-05-13", "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",
+ "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:
+ - '851'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"e9fc372d-7d2f-45fc-ba50-bf26dee97547","companyId":242975,"date":"2022-05-13","paymentDate":"2022-05-13","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-05-13","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-13T09:18:13.5692766Z","modifiedUserId":283192,"taxDate":"2022-05-13","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-05-13","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-13","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-230CPL","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-05-13","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-13","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-230FPL","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}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Fri, 13 May 2022 09:18:13 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0159573'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - c41dcaba-39f8-4ac1-bcc1-13f11f2db6a4
+ x-correlation-id:
+ - c41dcaba-39f8-4ac1-bcc1-13f11f2db6a4
+ 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_voucher_on_entire_order[24.39-30.00-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[24.39-30.00-True].yaml
new file mode 100644
index 0000000000..c376459bcf
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[24.39-30.00-True].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "0d4ecac2-5025-4aed-ab9d-2b512c228375", "date": "2022-05-13", "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",
+ "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:
+ - '849'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"0d4ecac2-5025-4aed-ab9d-2b512c228375","companyId":242975,"date":"2022-05-13","paymentDate":"2022-05-13","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-05-13","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-13T09:05:45.9637919Z","modifiedUserId":283192,"taxDate":"2022-05-13","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-05-13","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-13","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-230CPL","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-05-13","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-13","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-230FPL","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":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:
+ - Fri, 13 May 2022 09:05:45 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0200972'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - ad575c83-947a-4993-ac18-29e7f03bcb9e
+ x-correlation-id:
+ - ad575c83-947a-4993-ac18-29e7f03bcb9e
+ 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_voucher_on_entire_order[30.00-36.90-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[30.00-36.90-False].yaml
new file mode 100644
index 0000000000..0246bdbcff
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[30.00-36.90-False].yaml
@@ -0,0 +1,70 @@
+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",
+ "ref1": "123"}, {"quantity": 1, "amount": "10.000", "taxCode": "FR000000", "taxIncluded":
+ false, "itemCode": "Shipping", "discounted": false, "description": null}], "code":
+ "5c47f4d1-da74-47d6-8ffb-eff76323b4cb", "date": "2022-05-13", "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",
+ "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:
+ - '851'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"5c47f4d1-da74-47d6-8ffb-eff76323b4cb","companyId":242975,"date":"2022-05-13","paymentDate":"2022-05-13","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-05-13","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-13T09:05:48.1001733Z","modifiedUserId":283192,"taxDate":"2022-05-13","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-05-13","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-13","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-230CPL","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-05-13","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-13","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-230FPL","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}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Fri, 13 May 2022 09:05:48 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0174934'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - de869976-f116-405d-a198-b7c5b62e91d5
+ x-correlation-id:
+ - de869976-f116-405d-a198-b7c5b62e91d5
+ 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_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
new file mode 100644
index 0000000000..d1ebbf700a
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order[8.13-10.00-True].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "7acb6056-92e8-4022-8591-013559f8b835", "date": "2022-05-13", "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",
+ "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:
+ - '849'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"7acb6056-92e8-4022-8591-013559f8b835","companyId":242975,"date":"2022-05-13","paymentDate":"2022-05-13","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-05-13","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-13T09:18:11.6968879Z","modifiedUserId":283192,"taxDate":"2022-05-13","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-05-13","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-13","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-230CPL","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-05-13","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-13","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-230FPL","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":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:
+ - Fri, 13 May 2022 09:18:11 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0236105'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 4d433fb6-a579-4985-b5a6-7a0af8d354e0
+ x-correlation-id:
+ - 4d433fb6-a579-4985-b5a6-7a0af8d354e0
+ 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_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
new file mode 100644
index 0000000000..2b238ffc40
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes.yaml
@@ -0,0 +1,74 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
+ true, "itemCode": "123", "discounted": true, "description": "Test product",
+ "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": "4596776d-deba-46ab-9e5c-84948a2f201d",
+ "date": "2022-05-31", "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"}},
+ "commit": false, "currencyCode": "USD", "email": "[email protected]"}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate, br
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '959'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"4596776d-deba-46ab-9e5c-84948a2f201d","companyId":242975,"date":"2022-05-31","paymentDate":"2022-05-31","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-05-31","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-31T12:22:06.6383944Z","modifiedUserId":283192,"taxDate":"2022-05-31","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-05-31","tax":0.0,"taxableAmount":0.0,"taxCalculated":6.44,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-31","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-230CPL","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-05-31","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-31","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-230FPL","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":8.13,"rate":0.230000,"tax":1.87,"taxCalculated":8.31,"nonTaxable":28.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Tue, 31 May 2022 12:22:06 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0143473'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ cache-control:
+ - private, no-cache, no-store
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 3d7ba6d9-126b-4091-9dc2-df41e4484010
+ x-correlation-id:
+ - 3d7ba6d9-126b-4091-9dc2-df41e4484010
+ 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_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
new file mode 100644
index 0000000000..8f7b0dcc16
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[24.39-30.00-True].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ 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.000", "taxCode": "FR000000", "taxIncluded":
+ true, "itemCode": "Shipping", "discounted": true, "description": null}], "code":
+ "4cf89126-f0c2-41a7-8cd3-22f7c45a3981", "date": "2022-05-13", "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",
+ "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:
+ - '849'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"4cf89126-f0c2-41a7-8cd3-22f7c45a3981","companyId":242975,"date":"2022-05-13","paymentDate":"2022-05-13","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-05-13","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-13T08:45:57.9444209Z","modifiedUserId":283192,"taxDate":"2022-05-13","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-05-13","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-13","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-230CPL","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-05-13","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-13","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-230FPL","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":24.39,"rate":0.230000,"tax":5.61,"taxCalculated":5.61,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Fri, 13 May 2022 08:45:57 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0171240'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 3850b795-df67-470a-a038-fb86c8004f0f
+ x-correlation-id:
+ - 3850b795-df67-470a-a038-fb86c8004f0f
+ 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_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
new file mode 100644
index 0000000000..6efd5fe7d9
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_checkout_total_voucher_on_shipping[30.00-36.90-False].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "5bb6b0a6-3211-4021-9350-7c01dbd208e0", "date": "2022-05-13", "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",
+ "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:
+ - '851'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":0,"code":"5bb6b0a6-3211-4021-9350-7c01dbd208e0","companyId":242975,"date":"2022-05-13","paymentDate":"2022-05-13","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-05-13","exchangeRate":1.0,"email":"[email protected]","modifiedDate":"2022-05-13T08:46:00.5961952Z","modifiedUserId":283192,"taxDate":"2022-05-13","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-05-13","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-13","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-230CPL","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-05-13","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-13","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-230FPL","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":30.0,"rate":0.230000,"tax":6.9,"taxCalculated":6.9,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Fri, 13 May 2022 08:46:00 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ ServerDuration:
+ - '00:00:00.0208480'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 7703c268-fbcc-4650-9bdd-c68af9863ba1
+ x-correlation-id:
+ - 7703c268-fbcc-4650-9bdd-c68af9863ba1
+ 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_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
new file mode 100644
index 0000000000..c8bed865e9
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[16.26-20.00-True].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "30.000", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "87e8d8ea-306e-4e45-87ed-ecc7a8edeed3", "date": "2022-05-17", "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",
+ "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:
+ - '841'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":85025119543287,"code":"87e8d8ea-306e-4e45-87ed-ecc7a8edeed3","companyId":242975,"date":"2022-05-17","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.4.1.0","originAddressId":85025119543289,"destinationAddressId":85025119543288,"exchangeRateEffectiveDate":"2022-05-17","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-05-17T07:23:13.5109874Z","modifiedUserId":283192,"taxDate":"2022-05-17","lines":[{"id":85025119543293,"transactionId":85025119543287,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85025119543288,"originAddressId":85025119543289,"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-05-17","revAccount":"","sourcing":"Destination","tax":3.74,"taxableAmount":16.26,"taxCalculated":3.74,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025119543298,"transactionLineId":85025119543293,"transactionId":85025119543287,"addressId":85025119543288,"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":410972,"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":85025119543296,"documentLineId":85025119543293,"documentAddressId":85025119543289,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025119543297,"documentLineId":85025119543293,"documentAddressId":85025119543288,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230CPL","vatNumberTypeId":0},{"id":85025119543294,"transactionId":85025119543287,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85025119543288,"originAddressId":85025119543289,"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-05-17","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025119543302,"transactionLineId":85025119543294,"transactionId":85025119543287,"addressId":85025119543288,"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":410972,"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":85025119543300,"documentLineId":85025119543294,"documentAddressId":85025119543289,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025119543301,"documentLineId":85025119543294,"documentAddressId":85025119543288,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230FPL","vatNumberTypeId":0}],"addresses":[{"id":85025119543288,"transactionId":85025119543287,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85025119543289,"transactionId":85025119543287,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85025119543291,"documentId":85025119543287,"documentAddressId":85025119543289,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85025119543292,"documentId":85025119543287,"documentAddressId":85025119543288,"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:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Tue, 17 May 2022 07:23:13 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/85025119543287
+ ServerDuration:
+ - '00:00:00.1183026'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - d780071f-c3bc-47bd-ab15-ffa0d3098b86
+ x-correlation-id:
+ - d780071f-c3bc-47bd-ab15-ffa0d3098b86
+ 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_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
new file mode 100644
index 0000000000..6007a788da
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_entire_order_voucher[20.00-24.60-False].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "30.000", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "a222526e-1343-481a-8405-f664ef080f6b", "date": "2022-05-17", "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",
+ "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:
+ - '843'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":85025119938187,"code":"a222526e-1343-481a-8405-f664ef080f6b","companyId":242975,"date":"2022-05-17","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.4.1.0","originAddressId":85025119938189,"destinationAddressId":85025119938188,"exchangeRateEffectiveDate":"2022-05-17","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-05-17T07:23:14.976804Z","modifiedUserId":283192,"taxDate":"2022-05-17","lines":[{"id":85025119938193,"transactionId":85025119938187,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85025119938188,"originAddressId":85025119938189,"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-05-17","revAccount":"","sourcing":"Destination","tax":4.6,"taxableAmount":20.0,"taxCalculated":4.6,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85025119938198,"transactionLineId":85025119938193,"transactionId":85025119938187,"addressId":85025119938188,"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":410972,"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":85025119938196,"documentLineId":85025119938193,"documentAddressId":85025119938189,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025119938197,"documentLineId":85025119938193,"documentAddressId":85025119938188,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230CPL","vatNumberTypeId":0},{"id":85025119938194,"transactionId":85025119938187,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85025119938188,"originAddressId":85025119938189,"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-05-17","revAccount":"","sourcing":"Destination","tax":2.3,"taxableAmount":10.0,"taxCalculated":2.3,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85025119938202,"transactionLineId":85025119938194,"transactionId":85025119938187,"addressId":85025119938188,"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":410972,"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":85025119938200,"documentLineId":85025119938194,"documentAddressId":85025119938189,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025119938201,"documentLineId":85025119938194,"documentAddressId":85025119938188,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230FPL","vatNumberTypeId":0}],"addresses":[{"id":85025119938188,"transactionId":85025119938187,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85025119938189,"transactionId":85025119938187,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85025119938191,"documentId":85025119938187,"documentAddressId":85025119938189,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85025119938192,"documentId":85025119938187,"documentAddressId":85025119938188,"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:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Tue, 17 May 2022 07:23:15 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/85025119938187
+ ServerDuration:
+ - '00:00:00.1189926'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 1166e2e3-203c-48ff-9fb7-c776da45ab05
+ x-correlation-id:
+ - 1166e2e3-203c-48ff-9fb7-c776da45ab05
+ 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_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
new file mode 100644
index 0000000000..56998c311f
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[24.39-30.00-True].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "30.000", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "b7e092ee-6bb7-48ab-8031-853eb702c909", "date": "2022-05-17", "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:
+ - '837'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":85025118455378,"code":"b7e092ee-6bb7-48ab-8031-853eb702c909","companyId":242975,"date":"2022-05-17","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.4.1.0","originAddressId":85025118455380,"destinationAddressId":85025118455379,"exchangeRateEffectiveDate":"2022-05-17","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-05-17T07:25:00.5971153Z","modifiedUserId":283192,"taxDate":"2022-05-17","lines":[{"id":85025118455384,"transactionId":85025118455378,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85025118455379,"originAddressId":85025118455380,"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-05-17","revAccount":"","sourcing":"Destination","tax":5.61,"taxableAmount":24.39,"taxCalculated":5.61,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025118455389,"transactionLineId":85025118455384,"transactionId":85025118455378,"addressId":85025118455379,"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":410972,"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":85025118455387,"documentLineId":85025118455384,"documentAddressId":85025118455380,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025118455388,"documentLineId":85025118455384,"documentAddressId":85025118455379,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230CPL","vatNumberTypeId":0},{"id":85025118455385,"transactionId":85025118455378,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85025118455379,"originAddressId":85025118455380,"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-05-17","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025118455393,"transactionLineId":85025118455385,"transactionId":85025118455378,"addressId":85025118455379,"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":410972,"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":85025118455391,"documentLineId":85025118455385,"documentAddressId":85025118455380,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025118455392,"documentLineId":85025118455385,"documentAddressId":85025118455379,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230FPL","vatNumberTypeId":0}],"addresses":[{"id":85025118455379,"transactionId":85025118455378,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85025118455380,"transactionId":85025118455378,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85025118455382,"documentId":85025118455378,"documentAddressId":85025118455380,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85025118455383,"documentId":85025118455378,"documentAddressId":85025118455379,"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:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Tue, 17 May 2022 07:25:00 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/85025118455378
+ ServerDuration:
+ - '00:00:00.0959429'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - b16a49db-18d7-41f2-9225-8c75ef0570b1
+ x-correlation-id:
+ - b16a49db-18d7-41f2-9225-8c75ef0570b1
+ 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_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
new file mode 100644
index 0000000000..ce79eb6f1c
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_line_total_shipping_voucher[30.00-36.90-False].yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "30.000", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "a9c8f708-9d06-4312-8b5f-577acbf27406", "date": "2022-05-17", "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:
+ - '839'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":85025119350025,"code":"a9c8f708-9d06-4312-8b5f-577acbf27406","companyId":242975,"date":"2022-05-17","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.4.1.0","originAddressId":85025119350027,"destinationAddressId":85025119350026,"exchangeRateEffectiveDate":"2022-05-17","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-05-17T07:25:02.1545113Z","modifiedUserId":283192,"taxDate":"2022-05-17","lines":[{"id":85025119350031,"transactionId":85025119350025,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85025119350026,"originAddressId":85025119350027,"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-05-17","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85025119350036,"transactionLineId":85025119350031,"transactionId":85025119350025,"addressId":85025119350026,"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":410972,"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":85025119350034,"documentLineId":85025119350031,"documentAddressId":85025119350027,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025119350035,"documentLineId":85025119350031,"documentAddressId":85025119350026,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230CPL","vatNumberTypeId":0},{"id":85025119350032,"transactionId":85025119350025,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85025119350026,"originAddressId":85025119350027,"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-05-17","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":false,"details":[{"id":85025119350040,"transactionLineId":85025119350032,"transactionId":85025119350025,"addressId":85025119350026,"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":410972,"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":85025119350038,"documentLineId":85025119350032,"documentAddressId":85025119350027,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025119350039,"documentLineId":85025119350032,"documentAddressId":85025119350026,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230FPL","vatNumberTypeId":0}],"addresses":[{"id":85025119350026,"transactionId":85025119350025,"boundaryLevel":"Zip5","line1":"Olawska
+ 10","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-105","country":"PL","taxRegionId":205102},{"id":85025119350027,"transactionId":85025119350025,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85025119350029,"documentId":85025119350025,"documentAddressId":85025119350027,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85025119350030,"documentId":85025119350025,"documentAddressId":85025119350026,"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:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Tue, 17 May 2022 07:25:02 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/85025119350025
+ ServerDuration:
+ - '00:00:00.0977534'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - ac814507-423f-4703-968a-755bcc7e026c
+ x-correlation-id:
+ - ac814507-423f-4703-968a-755bcc7e026c
+ 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_order_shipping_entire_order_voucher.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_entire_order_voucher.yaml
new file mode 100644
index 0000000000..fa4e49263e
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_entire_order_voucher.yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "36.900", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "b6625112-df5f-4032-bc2f-127384d39ee0", "date": "2022-05-17", "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":
+ "", "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:
+ - '840'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":85025131417259,"code":"b6625112-df5f-4032-bc2f-127384d39ee0","companyId":242975,"date":"2022-05-17","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.4.1.0","originAddressId":85025131417261,"destinationAddressId":85025131417260,"exchangeRateEffectiveDate":"2022-05-17","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-05-17T08:23:23.5827096Z","modifiedUserId":283192,"taxDate":"2022-05-17","lines":[{"id":85025131417265,"transactionId":85025131417259,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85025131417260,"originAddressId":85025131417261,"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-05-17","revAccount":"","sourcing":"Destination","tax":5.03,"taxableAmount":21.87,"taxCalculated":5.03,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025131417270,"transactionLineId":85025131417265,"transactionId":85025131417259,"addressId":85025131417260,"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":410972,"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":85025131417268,"documentLineId":85025131417265,"documentAddressId":85025131417261,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025131417269,"documentLineId":85025131417265,"documentAddressId":85025131417260,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230CPL","vatNumberTypeId":0},{"id":85025131417266,"transactionId":85025131417259,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85025131417260,"originAddressId":85025131417261,"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-05-17","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025131417274,"transactionLineId":85025131417266,"transactionId":85025131417259,"addressId":85025131417260,"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":410972,"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":85025131417272,"documentLineId":85025131417266,"documentAddressId":85025131417261,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025131417273,"documentLineId":85025131417266,"documentAddressId":85025131417260,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230FPL","vatNumberTypeId":0}],"addresses":[{"id":85025131417260,"transactionId":85025131417259,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85025131417261,"transactionId":85025131417259,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85025131417263,"documentId":85025131417259,"documentAddressId":85025131417261,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85025131417264,"documentId":85025131417259,"documentAddressId":85025131417260,"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:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Tue, 17 May 2022 08:23:23 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/85025131417259
+ ServerDuration:
+ - '00:00:00.1135452'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - cfc14005-58f0-4c74-a132-8f15635c89e4
+ x-correlation-id:
+ - cfc14005-58f0-4c74-a132-8f15635c89e4
+ 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_order_shipping_free_shipping_voucher.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_free_shipping_voucher.yaml
new file mode 100644
index 0000000000..81705571d9
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_free_shipping_voucher.yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "36.900", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "1156dc9b-f00f-4f62-bc0e-3c2db6f59e9e", "date": "2022-05-17", "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:
+ - '836'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":85025129569135,"code":"1156dc9b-f00f-4f62-bc0e-3c2db6f59e9e","companyId":242975,"date":"2022-05-17","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.4.1.0","originAddressId":85025129569137,"destinationAddressId":85025129569136,"exchangeRateEffectiveDate":"2022-05-17","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-05-17T08:26:08.2848183Z","modifiedUserId":283192,"taxDate":"2022-05-17","lines":[{"id":85025129569141,"transactionId":85025129569135,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85025129569136,"originAddressId":85025129569137,"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-05-17","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025129569146,"transactionLineId":85025129569141,"transactionId":85025129569135,"addressId":85025129569136,"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":410972,"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":85025129569144,"documentLineId":85025129569141,"documentAddressId":85025129569137,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025129569145,"documentLineId":85025129569141,"documentAddressId":85025129569136,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230CPL","vatNumberTypeId":0},{"id":85025129569142,"transactionId":85025129569135,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85025129569136,"originAddressId":85025129569137,"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-05-17","revAccount":"","sourcing":"Destination","tax":0.0,"taxableAmount":0.0,"taxCalculated":0.0,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025129569150,"transactionLineId":85025129569142,"transactionId":85025129569135,"addressId":85025129569136,"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":410972,"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":85025129569148,"documentLineId":85025129569142,"documentAddressId":85025129569137,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025129569149,"documentLineId":85025129569142,"documentAddressId":85025129569136,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230FPL","vatNumberTypeId":0}],"addresses":[{"id":85025129569136,"transactionId":85025129569135,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85025129569137,"transactionId":85025129569135,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85025129569139,"documentId":85025129569135,"documentAddressId":85025129569137,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85025129569140,"documentId":85025129569135,"documentAddressId":85025129569136,"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:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Tue, 17 May 2022 08:26:08 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/85025129569135
+ ServerDuration:
+ - '00:00:00.0967904'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - b0595f94-8c25-45d2-918e-040c1209f715
+ x-correlation-id:
+ - b0595f94-8c25-45d2-918e-040c1209f715
+ 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_order_shipping_voucher_on_shipping.yaml b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_voucher_on_shipping.yaml
new file mode 100644
index 0000000000..ba525757d3
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_avatax/test_calculate_order_shipping_voucher_on_shipping.yaml
@@ -0,0 +1,70 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "36.900", "taxCode": "O9999999", "taxIncluded":
+ 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":
+ "e3cf0e38-a6db-43a5-a716-fd1bf9524f67", "date": "2022-05-17", "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:
+ - '836'
+ User-Agent:
+ - python-requests/2.27.1
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":85025131932312,"code":"e3cf0e38-a6db-43a5-a716-fd1bf9524f67","companyId":242975,"date":"2022-05-17","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.4.1.0","originAddressId":85025131932314,"destinationAddressId":85025131932313,"exchangeRateEffectiveDate":"2022-05-17","exchangeRate":1.0,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2022-05-17T08:29:58.0184339Z","modifiedUserId":283192,"taxDate":"2022-05-17","lines":[{"id":85025131932318,"transactionId":85025131932312,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":85025131932313,"originAddressId":85025131932314,"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-05-17","revAccount":"","sourcing":"Destination","tax":6.9,"taxableAmount":30.0,"taxCalculated":6.9,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025131932323,"transactionLineId":85025131932318,"transactionId":85025131932312,"addressId":85025131932313,"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":410972,"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":85025131932321,"documentLineId":85025131932318,"documentAddressId":85025131932314,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025131932322,"documentLineId":85025131932318,"documentAddressId":85025131932313,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230CPL","vatNumberTypeId":0},{"id":85025131932319,"transactionId":85025131932312,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":85025131932313,"originAddressId":85025131932314,"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-05-17","revAccount":"","sourcing":"Destination","tax":0.93,"taxableAmount":4.07,"taxCalculated":0.93,"taxCode":"FR000000","taxCodeId":4779,"taxDate":"2022-05-17","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":85025131932327,"transactionLineId":85025131932319,"transactionId":85025131932312,"addressId":85025131932313,"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":410972,"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":85025131932325,"documentLineId":85025131932319,"documentAddressId":85025131932314,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":85025131932326,"documentLineId":85025131932319,"documentAddressId":85025131932313,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-230FPL","vatNumberTypeId":0}],"addresses":[{"id":85025131932313,"transactionId":85025131932312,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":85025131932314,"transactionId":85025131932312,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"Wroclaw","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102}],"locationTypes":[{"documentLocationTypeId":85025131932316,"documentId":85025131932312,"documentAddressId":85025131932314,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":85025131932317,"documentId":85025131932312,"documentAddressId":85025131932313,"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:
+ - keep-alive
+ Content-Type:
+ - application/json; charset=utf-8
+ Date:
+ - Tue, 17 May 2022 08:29:58 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/85025131932312
+ ServerDuration:
+ - '00:00:00.0951020'
+ Transfer-Encoding:
+ - chunked
+ X-Content-Type-Options:
+ - nosniff
+ referrer-policy:
+ - same-origin
+ strict-transport-security:
+ - max-age=31536000; includeSubdomains
+ x-avalara-uid:
+ - 69e18b7f-9900-4d00-a08e-9b294479b3e4
+ x-correlation-id:
+ - 69e18b7f-9900-4d00-a08e-9b294479b3e4
+ 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/test_avatax.py b/saleor/plugins/avatax/tests/test_avatax.py
index 466307043f..027990aaca 100644
--- a/saleor/plugins/avatax/tests/test_avatax.py
+++ b/saleor/plugins/avatax/tests/test_avatax.py
@@ -680,6 +680,188 @@ def test_calculate_order_line_total_with_discount(
)
+ "expected_net, expected_gross, taxes_in_prices",
+ [
+ ("16.26", "20.00", True),
+ ("20.00", "24.60", False),
+ ],
+)
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_order_line_total_entire_order_voucher(
+ expected_net,
+ expected_gross,
+ taxes_in_prices,
+ order_line,
+ address,
+ ship_to_pl_address,
+ shipping_zone,
+ voucher,
+ site_settings,
+ monkeypatch,
+ plugin_configuration,
+):
+ # given
+ 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
+ order.shipping_address = ship_to_pl_address
+ order.shipping_method = shipping_zone.shipping_methods.get()
+ order.save(update_fields=["shipping_address", "shipping_method"])
+
+ 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)
+ unit_price = TaxedMoney(net=net, gross=net)
+ order_line.unit_price = unit_price
+ total_price = unit_price * order_line.quantity
+ order_line.total_price = total_price
+ order_line.base_unit_price = unit_price.gross
+ order_line.save()
+
+ order = order_line.order
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher.code,
+ currency="USD",
+ amount_value=Decimal("10.0"),
+ )
+ order.voucher = voucher
+ total = total_price * order.lines.count()
+ order.total = total
+ order.undiscounted_total = total
+ order.save(
+ update_fields=[
+ "voucher",
+ "undiscounted_total_gross_amount",
+ "undiscounted_total_net_amount",
+ "total_net_amount",
+ "total_gross_amount",
+ ]
+ )
+
+ # when
+ total = manager.calculate_order_line_total(
+ order_line.order,
+ order_line,
+ variant,
+ product,
+ ).price_with_discounts
+
+ # then
+ total = quantize_price(total, total.currency)
+ assert total == TaxedMoney(
+ net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
+ )
+
+
+ "expected_net, expected_gross, taxes_in_prices",
+ [
+ ("24.39", "30.00", True),
+ ("30.00", "36.90", False),
+ ],
+)
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_order_line_total_shipping_voucher(
+ expected_net,
+ expected_gross,
+ taxes_in_prices,
+ order_line,
+ address,
+ ship_to_pl_address,
+ shipping_zone,
+ voucher_free_shipping,
+ site_settings,
+ monkeypatch,
+ plugin_configuration,
+):
+ # given
+ 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
+ order.shipping_address = ship_to_pl_address
+ order.shipping_method = shipping_zone.shipping_methods.get()
+ order.save(update_fields=["shipping_address", "shipping_method"])
+
+ 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)
+ unit_price = TaxedMoney(net=net, gross=net)
+ order_line.unit_price = unit_price
+ total_price = unit_price * order_line.quantity
+ order_line.total_price = total_price
+ order_line.base_unit_price = unit_price.gross
+ order_line.save()
+
+ order = order_line.order
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher_free_shipping.code,
+ currency="USD",
+ amount_value=Decimal("10.0"),
+ )
+ order.voucher = voucher_free_shipping
+ total = total_price * order.lines.count()
+ order.total = total
+ order.undiscounted_total = total
+ order.save(
+ update_fields=[
+ "voucher",
+ "undiscounted_total_gross_amount",
+ "undiscounted_total_net_amount",
+ "total_net_amount",
+ "total_gross_amount",
+ ]
+ )
+
+ # when
+ total = manager.calculate_order_line_total(
+ order_line.order,
+ order_line,
+ variant,
+ product,
+ ).price_with_discounts
+
+ # then
+ total = quantize_price(total, total.currency)
+ assert total == TaxedMoney(
+ net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
+ )
+
+
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
def test_calculate_order_line_total_order_not_valid(
order_line,
@@ -775,9 +957,9 @@ def test_calculate_order_shipping_order_not_valid(
"with_discount, expected_net, expected_gross, voucher_amount, taxes_in_prices",
[
(True, "22.32", "26.99", "0.0", True),
- (True, "21.99", "27.74", "5.0", False),
+ (True, "21.99", "26.59", "5.0", False),
(False, "41.99", "51.19", "0.0", False),
- (False, "31.51", "38.99", "3.0", True),
+ (False, "32.07", "38.99", "3.0", True),
],
)
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
@@ -790,6 +972,7 @@ def test_calculate_checkout_total_uses_default_calculation(
checkout_with_item,
product_with_single_variant,
discount_info,
+ voucher_percentage,
shipping_zone,
address,
ship_to_pl_address,
@@ -813,6 +996,8 @@ def test_calculate_checkout_total_uses_default_calculation(
voucher_amount = Money(voucher_amount, "USD")
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
checkout_with_item.discount = voucher_amount
+ if voucher_amount != "0.0":
+ checkout_with_item.voucher_code = voucher_percentage.code
checkout_with_item.save()
line = checkout_with_item.lines.first()
product = line.variant.product
@@ -840,9 +1025,9 @@ def test_calculate_checkout_total_uses_default_calculation(
"with_discount, expected_net, expected_gross, voucher_amount, taxes_in_prices",
[
(True, "22.32", "26.99", "0.0", True),
- (True, "21.99", "27.74", "5.0", False),
+ (True, "21.99", "26.59", "5.0", False),
(False, "41.99", "51.19", "0.0", False),
- (False, "31.51", "38.99", "3.0", True),
+ (False, "32.07", "38.99", "3.0", True),
],
)
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
@@ -855,6 +1040,7 @@ def test_calculate_checkout_total(
checkout_with_item,
product_with_single_variant,
discount_info,
+ voucher_percentage,
shipping_zone,
address,
ship_to_pl_address,
@@ -881,6 +1067,8 @@ def test_calculate_checkout_total(
voucher_amount = Money(voucher_amount, "USD")
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
checkout_with_item.discount = voucher_amount
+ if voucher_amount != "0.0":
+ checkout_with_item.voucher_code = voucher_percentage.code
checkout_with_item.save()
line = checkout_with_item.lines.first()
product = line.variant.product
@@ -905,6 +1093,208 @@ def test_calculate_checkout_total(
)
+ "expected_net, expected_gross, taxes_in_prices",
+ [
+ ("8.13", "10.00", True),
+ ("10.00", "12.30", False),
+ ],
+)
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_checkout_total_voucher_on_entire_order(
+ expected_net,
+ expected_gross,
+ taxes_in_prices,
+ checkout_with_item,
+ voucher_percentage,
+ stock,
+ monkeypatch,
+ site_settings,
+ ship_to_pl_address,
+ shipping_zone,
+ address,
+ plugin_configuration,
+):
+ """Ensure that the voucher is applied to entire order the total
+ is equal to the shipping price."""
+ # given
+ plugin_configuration()
+ variant = stock.product_variant
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
+ 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
+ channel_listing = variant.channel_listings.get(channel=channel)
+ net = (
+ variant.get_price(
+ variant.product, [], checkout_with_item.channel, channel_listing
+ )
+ * checkout_with_item.lines.first().quantity
+ )
+
+ checkout_with_item.shipping_address = ship_to_pl_address
+ checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
+ checkout_with_item.voucher_code = voucher_percentage.code
+ checkout_with_item.discount_amount = net.amount
+ checkout_with_item.save()
+
+ discounts = None
+ checkout_info = fetch_checkout_info(checkout_with_item, [], discounts, manager)
+ lines, _ = fetch_checkout_lines(checkout_with_item)
+
+ # when
+ total = manager.calculate_checkout_total(
+ checkout_info, lines, ship_to_pl_address, discounts
+ )
+
+ # then
+ total = quantize_price(total, total.currency)
+ assert total == TaxedMoney(
+ net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
+ )
+
+
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_checkout_total_voucher_on_entire_order_product_without_taxes(
+ checkout_with_item,
+ voucher_percentage,
+ stock,
+ monkeypatch,
+ site_settings,
+ ship_to_pl_address,
+ shipping_zone,
+ address,
+ plugin_configuration,
+):
+ """Ensure that the voucher is applied to entire order the total
+ is equal to the shipping price."""
+ # given
+ plugin_configuration()
+ variant = stock.product_variant
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
+ 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
+ channel_listing = variant.channel_listings.get(channel=channel)
+ net = (
+ variant.get_price(
+ variant.product, [], checkout_with_item.channel, channel_listing
+ )
+ * checkout_with_item.lines.first().quantity
+ )
+
+ discount_amount = Decimal("2.0")
+ checkout_with_item.shipping_address = ship_to_pl_address
+ shipping_method = shipping_zone.shipping_methods.get()
+ checkout_with_item.shipping_method = shipping_method
+ checkout_with_item.voucher_code = voucher_percentage.code
+ checkout_with_item.discount_amount = discount_amount
+ checkout_with_item.save()
+
+ 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)
+
+ currency = checkout_with_item.currency
+
+ # when
+ total = manager.calculate_checkout_total(
+ checkout_info, lines, ship_to_pl_address, discounts
+ )
+
+ # then
+ total = quantize_price(total, currency)
+ expected_gross = Money(net.amount - discount_amount, "USD")
+ assert total == TaxedMoney(
+ net=quantize_price(expected_gross + shipping_price / Decimal("1.23"), currency),
+ gross=expected_gross + shipping_price,
+ )
+
+
+ "expected_net, expected_gross, taxes_in_prices",
+ [
+ ("24.39", "30.00", True),
+ ("30.00", "36.90", False),
+ ],
+)
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_checkout_total_voucher_on_shipping(
+ expected_net,
+ expected_gross,
+ taxes_in_prices,
+ 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
+ is equal to subtotal price."""
+ # given
+ plugin_configuration()
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
+ 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
+ shipping_method = shipping_zone.shipping_methods.get()
+ shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
+
+ checkout_with_item.shipping_address = ship_to_pl_address
+ checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
+ checkout_with_item.voucher_code = voucher_free_shipping.code
+ checkout_with_item.discount_amount = shipping_channel_listings.price.amount
+ checkout_with_item.save()
+
+ discounts = None
+ checkout_info = fetch_checkout_info(checkout_with_item, [], discounts, manager)
+ lines, _ = fetch_checkout_lines(checkout_with_item)
+
+ # when
+ total = manager.calculate_checkout_total(
+ checkout_info, lines, ship_to_pl_address, discounts
+ )
+
+ # then
+ total = quantize_price(total, total.currency)
+ assert total == TaxedMoney(
+ net=Money(expected_net, "USD"), gross=Money(expected_gross, "USD")
+ )
+
+
@pytest.mark.vcr
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
def test_calculate_checkout_total_not_charged_product_and_shipping_with_0_price(
@@ -1028,109 +1418,387 @@ def test_calculate_checkout_subtotal(
plugin_configuration,
):
plugin_configuration()
- variant = stock.product_variant
- monkeypatch.setattr(
- "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
- lambda _: {"PC040156": "desc"},
- )
+ variant = stock.product_variant
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
+ lambda _: {"PC040156": "desc"},
+ )
+ manager = get_plugins_manager()
+ site_settings.company_address = address
+ site_settings.include_taxes_in_prices = taxes_in_prices
+ site_settings.save()
+
+ checkout_with_item.shipping_address = ship_to_pl_address
+ checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
+ checkout_with_item.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")
+ )
+
+
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_checkout_subtotal_for_product_without_tax(
+ checkout,
+ stock,
+ monkeypatch,
+ site_settings,
+ ship_to_pl_address,
+ shipping_zone,
+ address,
+ plugin_configuration,
+):
+ plugin_configuration()
+ variant = stock.product_variant
+ product = variant.product
+ product.charge_taxes = False
+ product.save(update_fields=["charge_taxes"])
+
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
+ lambda _: {"PC040156": "desc"},
+ )
+ manager = get_plugins_manager()
+ site_settings.company_address = address
+ site_settings.include_taxes_in_prices = True
+ site_settings.save()
+
+ checkout.shipping_address = ship_to_pl_address
+ checkout.shipping_method = shipping_zone.shipping_methods.get()
+ checkout.save()
+
+ quantity = 2
+ checkout_info = fetch_checkout_info(checkout, [], [], manager)
+ add_variant_to_checkout(checkout_info, variant, quantity)
+
+ lines, _ = fetch_checkout_lines(checkout)
+ assert len(lines) == 1
+ update_delivery_method_lists_for_checkout_info(
+ checkout_info,
+ checkout_info.checkout.shipping_method,
+ checkout_info.checkout.collection_point,
+ ship_to_pl_address,
+ lines,
+ [],
+ manager,
+ checkout.channel.shipping_method_listings.all(),
+ )
+
+ total = manager.calculate_checkout_subtotal(checkout_info, lines, address, [])
+ total = quantize_price(total, total.currency)
+ expected_total = variant.channel_listings.first().price_amount * quantity
+ assert total == TaxedMoney(
+ net=Money(expected_total, "USD"), gross=Money(expected_total, "USD")
+ )
+
+
[email protected]("taxes_in_prices", [True, False])
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_checkout_subtotal_voucher_on_entire_order(
+ taxes_in_prices,
+ checkout_with_item,
+ voucher_percentage,
+ stock,
+ monkeypatch,
+ site_settings,
+ ship_to_pl_address,
+ shipping_zone,
+ address,
+ plugin_configuration,
+):
+ """Ensure that the voucher is applied to entire order the subtotal price
+ is equal to zero."""
+ # given
+ plugin_configuration()
+ variant = stock.product_variant
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
+ 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
+ channel_listing = variant.channel_listings.get(channel=channel)
+ net = (
+ variant.get_price(
+ variant.product, [], checkout_with_item.channel, channel_listing
+ )
+ * checkout_with_item.lines.first().quantity
+ )
+
+ checkout_with_item.shipping_address = ship_to_pl_address
+ checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
+ checkout_with_item.voucher_code = voucher_percentage.code
+ checkout_with_item.discount_amount = net.amount
+ checkout_with_item.save()
+
+ discounts = None
+ checkout_info = fetch_checkout_info(checkout_with_item, [], discounts, manager)
+ lines, _ = fetch_checkout_lines(checkout_with_item)
+
+ # when
+ total = manager.calculate_checkout_subtotal(
+ checkout_info, lines, address, discounts
+ )
+
+ # then
+ total = quantize_price(total, total.currency)
+ assert total == TaxedMoney(net=Money(0, "USD"), gross=Money(0, "USD"))
+
+
+ "expected_net, expected_gross, taxes_in_prices",
+ [
+ ("24.39", "30.00", True),
+ ("30.00", "36.90", False),
+ ],
+)
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_checkout_subtotal_voucher_on_shipping(
+ expected_net,
+ expected_gross,
+ taxes_in_prices,
+ 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 subtotal price
+ not changed."""
+ # given
+ plugin_configuration()
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
+ 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
+ shipping_method = shipping_zone.shipping_methods.get()
+ shipping_channel_listings = shipping_method.channel_listings.get(channel=channel)
+
+ checkout_with_item.shipping_address = ship_to_pl_address
+ checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
+ checkout_with_item.voucher_code = voucher_free_shipping.code
+ checkout_with_item.discount_amount = shipping_channel_listings.price.amount
+ checkout_with_item.save()
+
+ discounts = None
+ checkout_info = fetch_checkout_info(checkout_with_item, [], discounts, manager)
+ lines, _ = fetch_checkout_lines(checkout_with_item)
+
+ # when
+ total = manager.calculate_checkout_subtotal(
+ 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")
+ )
+
+
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_order_shipping(
+ order_line, shipping_zone, site_settings, address, plugin_configuration
+):
+ plugin_configuration()
+ 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.save()
+
+ site_settings.company_address = address
+ site_settings.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"))
+
+
+@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+def test_calculate_order_shipping_entire_order_voucher(
+ order_line, shipping_zone, voucher, site_settings, address, plugin_configuration
+):
+ # given
+ plugin_configuration()
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = taxes_in_prices
- site_settings.save()
- checkout_with_item.shipping_address = ship_to_pl_address
- checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
- checkout_with_item.save()
+ variant = order_line.variant
+ channel = order_line.order.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
+ order = order_line.order
- discounts = [discount_info] if with_discount else None
+ net = variant.get_price(variant.product, [], channel, channel_listing)
+ unit_price = TaxedMoney(net=net, gross=net)
+ total_price = unit_price * order_line.quantity
+ total = total_price * order.lines.count()
- 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")
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher.code,
+ currency="USD",
+ amount_value=Decimal("10.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.total = total
+ order.undiscounted_total = total
+ order.voucher = voucher
+ order.save()
+
+ site_settings.company_address = address
+ site_settings.save()
+
+ # when
+ price = manager.calculate_order_shipping(order)
+
+ # then
+ price = quantize_price(price, price.currency)
+ assert price == TaxedMoney(net=Money("8.13", "USD"), gross=Money("10.00", "USD"))
+
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
-def test_calculate_checkout_subtotal_for_product_without_tax(
- checkout,
- stock,
- monkeypatch,
- site_settings,
- ship_to_pl_address,
+def test_calculate_order_shipping_free_shipping_voucher(
+ order_line,
shipping_zone,
+ voucher_free_shipping,
+ site_settings,
address,
plugin_configuration,
):
+ # given
plugin_configuration()
- variant = stock.product_variant
- product = variant.product
- product.charge_taxes = False
- product.save(update_fields=["charge_taxes"])
-
- monkeypatch.setattr(
- "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
- lambda _: {"PC040156": "desc"},
- )
manager = get_plugins_manager()
- site_settings.company_address = address
- site_settings.include_taxes_in_prices = True
- site_settings.save()
- checkout.shipping_address = ship_to_pl_address
- checkout.shipping_method = shipping_zone.shipping_methods.get()
- checkout.save()
+ variant = order_line.variant
+ channel = order_line.order.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
+ order = order_line.order
- quantity = 2
- checkout_info = fetch_checkout_info(checkout, [], [], manager)
- add_variant_to_checkout(checkout_info, variant, quantity)
+ net = variant.get_price(variant.product, [], channel, channel_listing)
+ unit_price = TaxedMoney(net=net, gross=net)
+ total_price = unit_price * order_line.quantity
+ total = total_price * order.lines.count()
- lines, _ = fetch_checkout_lines(checkout)
- assert len(lines) == 1
- update_delivery_method_lists_for_checkout_info(
- checkout_info,
- checkout_info.checkout.shipping_method,
- checkout_info.checkout.collection_point,
- ship_to_pl_address,
- lines,
- [],
- manager,
- checkout.channel.shipping_method_listings.all(),
- )
+ method = shipping_zone.shipping_methods.get()
+ shipping_channel_listings = method.channel_listings.get(channel=channel)
- total = manager.calculate_checkout_subtotal(checkout_info, lines, address, [])
- total = quantize_price(total, total.currency)
- expected_total = variant.channel_listings.first().price_amount * quantity
- assert total == TaxedMoney(
- net=Money(expected_total, "USD"), gross=Money(expected_total, "USD")
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher_free_shipping.code,
+ currency="USD",
+ amount_value=shipping_channel_listings.price.amount,
)
+ order.shipping_address = order.billing_address.get_copy()
+ order.shipping_method_name = method.name
+ order.shipping_method = method
+ order.total = total
+ order.undiscounted_total = total
+ order.voucher = voucher_free_shipping
+ order.save()
+
+ site_settings.company_address = address
+ site_settings.save()
+
+ # when
+ price = manager.calculate_order_shipping(order)
+
+ # then
+ price = quantize_price(price, price.currency)
+ assert price == TaxedMoney(net=Money("0", "USD"), gross=Money("0", "USD"))
+
@pytest.mark.vcr
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
-def test_calculate_order_shipping(
- order_line, shipping_zone, site_settings, address, plugin_configuration
+def test_calculate_order_shipping_voucher_on_shipping(
+ order_line,
+ shipping_zone,
+ voucher_shipping_type,
+ site_settings,
+ address,
+ plugin_configuration,
):
+ # given
plugin_configuration()
manager = get_plugins_manager()
+
+ variant = order_line.variant
+ channel = order_line.order.channel
+ channel_listing = variant.channel_listings.get(channel=channel)
order = order_line.order
+
+ net = variant.get_price(variant.product, [], channel, channel_listing)
+ unit_price = TaxedMoney(net=net, gross=net)
+ total_price = unit_price * order_line.quantity
+ total = total_price * order.lines.count()
+
method = shipping_zone.shipping_methods.get()
+ shipping_channel_listings = method.channel_listings.get(channel=channel)
+
+ order.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.FIXED,
+ value=Decimal("10.0"),
+ name=voucher_shipping_type.code,
+ currency="USD",
+ amount_value=shipping_channel_listings.price.amount - Decimal("5"),
+ )
+
order.shipping_address = order.billing_address.get_copy()
order.shipping_method_name = method.name
order.shipping_method = method
+ order.total = total
+ order.undiscounted_total = total
+ order.voucher = voucher_shipping_type
order.save()
site_settings.company_address = address
site_settings.save()
+ # when
price = manager.calculate_order_shipping(order)
+
+ # then
price = quantize_price(price, price.currency)
- assert price == TaxedMoney(net=Money("8.13", "USD"), gross=Money("10.00", "USD"))
+ assert price == TaxedMoney(net=Money("4.07", "USD"), gross=Money("5.0", "USD"))
@pytest.mark.vcr
@@ -2642,6 +3310,7 @@ def test_order_created(api_post_request_task_mock, order, plugin_configuration):
"code": str(order.id),
"date": datetime.date.today().strftime("%Y-%m-%d"),
"customerCode": 0,
+ "discount": None,
"addresses": {
"shipFrom": {
"line1": "Tęczowa 7",
@@ -2949,8 +3618,12 @@ def test_get_order_request_data_confirmed_order_with_voucher(
request_data = get_order_request_data(order_with_lines, config)
lines_data = request_data["createTransactionModel"]["lines"]
- # extra one from shipping data and from discount
- assert len(lines_data) == order_with_lines.lines.count() + 1 + 1
+ # extra one from shipping data
+ assert len(lines_data) == order_with_lines.lines.count() + 1
+ for line_data in lines_data[:-1]:
+ assert line_data["discounted"] is True
+ # shipping line shouldn't be discounted
+ assert lines_data[-1]["discounted"] is False
def test_get_order_request_data_confirmed_order_with_sale(
@@ -3048,8 +3721,143 @@ def test_get_order_request_data_draft_order_with_voucher(
# then
lines_data = request_data["createTransactionModel"]["lines"]
- # lines + shipping + discount
- assert len(lines_data) == order_with_lines.lines.count() + 2
+ # lines + shipping
+ assert len(lines_data) == order_with_lines.lines.count() + 1
+ for line_data in lines_data[:-1]:
+ assert line_data["discounted"] is True
+ # shipping line shouldn't be discounted
+ assert lines_data[-1]["discounted"] is False
+ assert Decimal(lines_data[-1]["amount"]) != Decimal("0")
+
+
+def test_get_order_request_data_draft_order_with_shipping_voucher(
+ order_with_lines, shipping_zone, site_settings, address, voucher_free_shipping
+):
+ # given
+ site_settings.include_taxes_in_prices = True
+ site_settings.company_address = address
+ site_settings.save()
+ method = shipping_zone.shipping_methods.get()
+ method_listing = method.channel_listings.get(channel=order_with_lines.channel)
+ line = order_with_lines.lines.first()
+ line.base_unit_price_amount = line.unit_price_net_amount
+ line.undiscounted_base_unit_price_amount = line.unit_price_gross_amount
+ line.save()
+
+ order_with_lines.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.PERCENTAGE,
+ value=Decimal("100.0"),
+ name=voucher_free_shipping.code,
+ currency="USD",
+ amount_value=method_listing.price.amount,
+ )
+
+ 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_with_lines.voucher = voucher_free_shipping
+ order_with_lines.save(
+ update_fields=[
+ "status",
+ "voucher",
+ "shipping_address",
+ "shipping_method_name",
+ "shipping_method",
+ ]
+ )
+
+ config = AvataxConfiguration(
+ username_or_account="",
+ password_or_license="",
+ 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
+ request_data = get_order_request_data(order_with_lines, config)
+
+ # then
+ lines_data = request_data["createTransactionModel"]["lines"]
+
+ # lines + shipping
+ assert len(lines_data) == order_with_lines.lines.count() + 1
+ for line_data in lines_data[:-1]:
+ assert line_data["discounted"] is False
+ # shipping line shouldn't be discounted
+ assert lines_data[-1]["discounted"] is False
+ assert Decimal(lines_data[-1]["amount"]) == Decimal("0")
+
+
+def test_get_order_request_data_draft_order_shipping_voucher_amount_too_high(
+ order_with_lines, shipping_zone, site_settings, address, 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.include_taxes_in_prices = True
+ site_settings.company_address = address
+ site_settings.save()
+ method = shipping_zone.shipping_methods.get()
+ method_listing = method.channel_listings.get(channel=order_with_lines.channel)
+ line = order_with_lines.lines.first()
+ line.base_unit_price_amount = line.unit_price_net_amount
+ line.undiscounted_base_unit_price_amount = line.unit_price_gross_amount
+ line.save()
+
+ order_with_lines.discounts.create(
+ type=OrderDiscountType.VOUCHER,
+ value_type=DiscountValueType.PERCENTAGE,
+ value=Decimal("100.0"),
+ name=voucher_free_shipping.code,
+ currency="USD",
+ amount_value=method_listing.price.amount + Decimal("10.0"),
+ )
+
+ 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_with_lines.voucher = voucher_free_shipping
+ order_with_lines.save(
+ update_fields=[
+ "status",
+ "voucher",
+ "shipping_address",
+ "shipping_method_name",
+ "shipping_method",
+ ]
+ )
+
+ config = AvataxConfiguration(
+ username_or_account="",
+ password_or_license="",
+ 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
+ request_data = get_order_request_data(order_with_lines, config)
+
+ # then
+ lines_data = request_data["createTransactionModel"]["lines"]
+
+ # lines + shipping
+ assert len(lines_data) == order_with_lines.lines.count() + 1
+ for line_data in lines_data[:-1]:
+ assert line_data["discounted"] is False
+ # shipping line shouldn't be discounted
+ assert lines_data[-1]["discounted"] is False
+ assert Decimal(lines_data[-1]["amount"]) == Decimal("0")
def test_get_order_request_data_draft_order_with_sale(
@@ -3355,14 +4163,14 @@ def test_get_order_lines_data_sets_different_tax_code_for_zero_amount(
)
# when
- lines_data = get_order_lines_data(order_with_lines, config)
+ lines_data = get_order_lines_data(order_with_lines, config, discounted=False)
# then
assert lines_data[0]["amount"] == "0.000"
assert lines_data[0]["taxCode"] == DEFAULT_TAX_CODE
-def test_get_order_lines_data_with_invoice_type(
+def test_get_order_lines_data_with_discounted(
settings, channel_USD, plugin_configuration, order, order_line
):
# given
@@ -3397,12 +4205,13 @@ def test_get_order_lines_data_with_invoice_type(
)
# when
- lines_data = get_order_lines_data(order, config, invoice_transaction_type=True)
+ lines_data = get_order_lines_data(order, config, discounted=True)
# then
assert len(lines_data) == 1
line_data = lines_data[0]
assert line_data["amount"] == "12.300"
+ assert line_data["discounted"] is True
def test_get_order_lines_data_sets_different_tax_code_only_for_zero_amount(
@@ -3432,7 +4241,7 @@ def test_get_order_lines_data_sets_different_tax_code_only_for_zero_amount(
config = avatax_config
# when
- lines_data = get_order_lines_data(order_with_lines, config)
+ lines_data = get_order_lines_data(order_with_lines, config, discounted=False)
# then
assert lines_data[0]["amount"] == "10.000"
diff --git a/saleor/plugins/base_plugin.py b/saleor/plugins/base_plugin.py
index 241018e7d9..2e5f136b33 100644
--- a/saleor/plugins/base_plugin.py
+++ b/saleor/plugins/base_plugin.py
@@ -197,6 +197,14 @@ 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
diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.py
index 95b51f9aaf..fb68ceb649 100644
--- a/saleor/plugins/manager.py
+++ b/saleor/plugins/manager.py
@@ -219,15 +219,11 @@ class PluginsManager(PaymentInterface):
discounts: Iterable[DiscountInfo],
) -> TaxedMoney:
currency = checkout_info.checkout.currency
+
default_value = base_calculations.base_checkout_total(
- subtotal=self.calculate_checkout_subtotal(
- checkout_info, lines, address, discounts
- ),
- shipping_price=self.calculate_checkout_shipping(
- checkout_info, lines, address, discounts
- ),
- discount=checkout_info.checkout.discount,
- currency=currency,
+ checkout_info,
+ discounts,
+ lines,
)
if default_value <= zero_taxed_money(currency):
@@ -347,6 +343,19 @@ 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,
+ )
+ return lines
+
def calculate_checkout_line_total(
self,
checkout_info: "CheckoutInfo",
diff --git a/saleor/plugins/vatlayer/__init__.py b/saleor/plugins/vatlayer/__init__.py
index 2192780c9f..f8e73004a8 100644
--- a/saleor/plugins/vatlayer/__init__.py
+++ b/saleor/plugins/vatlayer/__init__.py
@@ -1,10 +1,17 @@
from dataclasses import dataclass
-from typing import List, Optional
+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 ...core.taxes import charge_taxes_on_shipping, include_taxes_in_prices
+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"
@@ -89,3 +96,92 @@ def get_taxed_shipping_price(shipping_price, 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,
+ ).price_with_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
index c1a850fbab..6a64dad711 100644
--- a/saleor/plugins/vatlayer/plugin.py
+++ b/saleor/plugins/vatlayer/plugin.py
@@ -17,8 +17,14 @@ from prices import Money, TaxedMoney, TaxedMoneyRange
from ...checkout import base_calculations, calculations
from ...checkout.interface import CheckoutTaxedPricesData
-from ...core.taxes import TaxType
+from ...core.prices import quantize_price
+from ...core.taxes import TaxType, zero_money, zero_taxed_money
+from ...discount import VoucherType
from ...order.interface import OrderTaxedPricesData
+from ...order.utils import (
+ get_total_order_discount_excluding_shipping,
+ get_voucher_discount_assigned_to_order,
+)
from ...plugins.error_codes import PluginErrorCode
from ...product.models import ProductType
from ..base_plugin import BasePlugin, ConfigurationTypeField
@@ -26,6 +32,7 @@ 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,
@@ -174,22 +181,18 @@ class VatlayerPlugin(BasePlugin):
return previous_value
manager = get_plugins_manager()
- return (
- calculations.checkout_subtotal(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=address,
- discounts=discounts,
- )
- + calculations.checkout_shipping_price(
- manager=manager,
- checkout_info=checkout_info,
- lines=lines,
- address=address,
- discounts=discounts,
- )
- - checkout_info.checkout.discount
+ return calculations.checkout_subtotal(
+ manager=manager,
+ checkout_info=checkout_info,
+ lines=lines,
+ address=address,
+ discounts=discounts,
+ ) + calculations.checkout_shipping_price(
+ manager=manager,
+ checkout_info=checkout_info,
+ lines=lines,
+ address=address,
+ discounts=discounts,
)
def _get_taxes_for_country(self, country: Country):
@@ -245,6 +248,16 @@ class VatlayerPlugin(BasePlugin):
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(
@@ -259,11 +272,101 @@ class VatlayerPlugin(BasePlugin):
taxes = self._get_taxes_for_country(address.country)
if not order.shipping_method:
return previous_value
+
shipping_price = order.shipping_method.channel_listings.get(
channel_id=order.channel_id
).price
+
+ if (
+ order.voucher_id
+ and order.voucher.type == VoucherType.SHIPPING # type: ignore
+ ):
+ shipping_discount = get_voucher_discount_assigned_to_order(order)
+ if shipping_discount:
+ shipping_price = Money(
+ max(
+ shipping_price.amount - shipping_discount.amount_value,
+ Decimal("0"),
+ ),
+ shipping_price.currency,
+ )
return get_taxed_shipping_price(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
+ line.tax_rate = (line.unit_price.tax / line.unit_price.net).quantize(
+ Decimal(".0001")
+ )
+
def calculate_checkout_line_total(
self,
checkout_info: "CheckoutInfo",
@@ -274,6 +377,8 @@ class VatlayerPlugin(BasePlugin):
previous_value: CheckoutTaxedPricesData,
) -> CheckoutTaxedPricesData:
unit_taxed_prices_data = self.__calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
checkout_line_info,
checkout_info.channel,
discounts,
@@ -290,39 +395,18 @@ class VatlayerPlugin(BasePlugin):
undiscounted_price=unit_taxed_prices_data.undiscounted_price * quantity,
)
- def calculate_order_line_total(
- self,
- order: "Order",
- order_line: "OrderLine",
- variant: "ProductVariant",
- product: "Product",
- previous_value: OrderTaxedPricesData,
- ) -> OrderTaxedPricesData:
- unit_price_data = self.__calculate_order_line_unit(
- order,
- order_line,
- variant,
- product,
- previous_value,
- )
- if unit_price_data is None:
- return previous_value
- quantity = order_line.quantity
- return OrderTaxedPricesData(
- undiscounted_price=unit_price_data.undiscounted_price * quantity,
- price_with_discounts=unit_price_data.price_with_discounts * quantity,
- )
-
def calculate_checkout_line_unit_price(
self,
checkout_info: "CheckoutInfo",
- lines: Iterable["CheckoutLineInfo"],
+ lines: List["CheckoutLineInfo"],
checkout_line_info: "CheckoutLineInfo",
address: Optional["Address"],
discounts: Iterable["DiscountInfo"],
previous_value: CheckoutTaxedPricesData,
) -> CheckoutTaxedPricesData:
unit_taxed_prices_data = self.__calculate_checkout_line_unit_price(
+ checkout_info,
+ lines,
checkout_line_info,
checkout_info.channel,
discounts,
@@ -333,6 +417,8 @@ class VatlayerPlugin(BasePlugin):
def __calculate_checkout_line_unit_price(
self,
+ checkout_info: "CheckoutInfo",
+ lines: List["CheckoutLineInfo"],
checkout_line_info: "CheckoutLineInfo",
channel: "Channel",
discounts: Iterable["DiscountInfo"],
@@ -348,6 +434,14 @@ class VatlayerPlugin(BasePlugin):
discounts,
)
+ prices_data.price_with_discounts = apply_checkout_discount_on_checkout_line(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ discounts,
+ prices_data.price_with_discounts,
+ )
+
country = address.country if address else None
taxed_prices_data = CheckoutTaxedPricesData(
price_with_sale=self.__apply_taxes_to_product(
@@ -362,44 +456,6 @@ class VatlayerPlugin(BasePlugin):
)
return taxed_prices_data
- def calculate_order_line_unit(
- self,
- order: "Order",
- order_line: "OrderLine",
- variant: "ProductVariant",
- product: "Product",
- previous_value: OrderTaxedPricesData,
- ) -> OrderTaxedPricesData:
- unit_price_data = self.__calculate_order_line_unit(
- order, order_line, variant, product, previous_value
- )
- return unit_price_data if unit_price_data is not None else previous_value
-
- def __calculate_order_line_unit(
- self,
- order: "Order",
- order_line: "OrderLine",
- variant: "ProductVariant",
- product: "Product",
- previous_value: OrderTaxedPricesData,
- ):
- if self._skip_plugin(previous_value):
- return
-
- address = order.shipping_address or order.billing_address
- country = address.country if address else None
- if not variant:
- return
- taxed_prices_data = OrderTaxedPricesData(
- undiscounted_price=self.__apply_taxes_to_product(
- product, order_line.undiscounted_unit_price, country
- ),
- price_with_discounts=self.__apply_taxes_to_product(
- product, order_line.unit_price, country
- ),
- )
- return taxed_prices_data
-
def get_checkout_line_tax_rate(
self,
checkout_info: "CheckoutInfo",
diff --git a/saleor/plugins/vatlayer/tests/test_vatlayer.py b/saleor/plugins/vatlayer/tests/test_vatlayer.py
index 7af08f4c37..85a5bf90dd 100644
--- a/saleor/plugins/vatlayer/tests/test_vatlayer.py
+++ b/saleor/plugins/vatlayer/tests/test_vatlayer.py
@@ -12,6 +12,7 @@ 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 ....discount import DiscountValueType, OrderDiscountType
from ....product.models import Product
from ...manager import get_plugins_manager
from ...models import PluginConfiguration
@@ -187,9 +188,9 @@ def test_apply_tax_to_price_no_taxes_raise_typeerror_for_invalid_type():
"with_discount, expected_net, expected_gross, voucher_amount, taxes_in_prices",
[
(True, "20.34", "25.00", "0.0", True),
- (True, "20.00", "25.75", "5.0", False),
+ (True, "20.00", "24.60", "5.0", False),
(False, "40.00", "49.20", "0.0", False),
- (False, "29.52", "37.00", "3.0", True),
+ (False, "30.09", "37.00", "3.0", True),
],
)
@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
@@ -200,17 +201,20 @@ def test_calculate_checkout_total(
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()
@@ -224,7 +228,66 @@ def test_calculate_checkout_total(
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")
@@ -496,107 +559,126 @@ def test_calculate_order_shipping_for_order_without_shipping(
@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_order_line_unit(vatlayer, order_line, shipping_zone, site_settings):
+def test_calculate_order_shipping_voucher_on_shipping(
+ vatlayer, order_line, shipping_zone, voucher_shipping_type
+):
+ # given
manager = get_plugins_manager()
- order_line.unit_price = TaxedMoney(
- net=Money("10.00", "USD"), gross=Money("10.00", "USD")
- )
- order_line.save()
-
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.voucher = voucher_shipping_type
order.save()
- variant = order_line.variant
- product = variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
+ currency = order.currency
+ discount_amount = Decimal("5.0")
+ 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)
- line_price = manager.calculate_order_line_unit(
- order, order_line, variant, product
- ).price_with_discounts
- line_price = quantize_price(line_price, line_price.currency)
- assert line_price == TaxedMoney(
- net=Money("8.13", "USD"), gross=Money("10.00", "USD")
+ # 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),
)
-def test_calculate_order_line_unit_from_origin_country(
- vatlayer_plugin, order_line, shipping_zone, site_settings
+@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
+def test_calculate_order_shipping_free_shipping_voucher(
+ vatlayer, order_line, shipping_zone, voucher_shipping_type
):
- vatlayer_plugin(
- origin_country="DE", countries_to_calculate_taxes_from_origin="PL,FR"
- )
+ # given
manager = get_plugins_manager()
-
- order_line.unit_price = TaxedMoney(
- net=Money("10.00", "USD"), gross=Money("10.00", "USD")
- )
- order_line.save()
-
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.voucher = voucher_shipping_type
order.save()
- variant = order_line.variant
- product = variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
- product.save()
+ currency = order.currency
+ channel = order.channel
+ shipping_channel_listings = method.channel_listings.get(channel=channel)
+ shipping_price = shipping_channel_listings.price
- line_price = manager.calculate_order_line_unit(
- order, order_line, variant, product
- ).price_with_discounts
- line_price = quantize_price(line_price, line_price.currency)
-
- # make sure that we applied DE taxes (19%)
- assert line_price == TaxedMoney(
- net=Money("8.40", "USD"), gross=Money("10.00", "USD")
+ 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)
-def test_calculate_order_line_unit_with_excluded_country(
- vatlayer_plugin, order_line, shipping_zone, site_settings
+ # 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
):
- vatlayer_plugin(origin_country="DE", excluded_countries="PL,FR")
manager = get_plugins_manager()
- order_line.unit_price = TaxedMoney(
- net=Money("10.00", "USD"), gross=Money("10.00", "USD")
- )
- order_line.save()
+ line = checkout_with_item.lines.first()
+ assert line.quantity > 1
- 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.save()
+ 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 = order_line.variant
+ variant = line.variant
product = variant.product
- manager.assign_tax_code_to_object_meta(product, "standard")
+ manager.assign_tax_code_to_object_meta(variant.product, "standard")
product.save()
- line_price = manager.calculate_order_line_unit(
- order, order_line, variant, product
- ).price_with_discounts
- line_price = quantize_price(line_price, line_price.currency)
+ 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,
+ [],
+ ).price_with_sale
assert line_price == TaxedMoney(
- net=Money("10.00", "USD"), gross=Money("10.00", "USD")
+ 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(
- vatlayer, checkout_with_item, shipping_zone, address, site_settings
+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()
@@ -606,10 +688,17 @@ def test_calculate_checkout_line_total(
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()
@@ -617,17 +706,22 @@ def test_calculate_checkout_line_total(
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,
[],
- ).price_with_sale
+ ).price_with_discounts
+ # 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=Money("8.13", "USD") * line.quantity,
- gross=Money("10.00", "USD") * line.quantity,
+ net=quantize_price(unit_net * line.quantity, currency),
+ gross=quantize_price(total_gross, currency),
)
@@ -711,48 +805,382 @@ def test_calculate_checkout_line_total_with_excluded_country(
@override_settings(PLUGINS=["saleor.plugins.vatlayer.plugin.VatlayerPlugin"])
-def test_calculate_order_line_total(vatlayer, order_line, site_settings):
+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(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_unit_price(
+ checkout_info,
+ lines,
+ checkout_line_info,
+ address,
+ [],
+ ).price_with_sale
+
+ 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()
- assert order_line.quantity > 1
+ 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 = order_line.variant
+ 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()
- channel = order_line.order.channel
+ 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,
+ [],
+ ).price_with_discounts
+
+ # 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)
- net = variant.get_price(product, [], channel, channel_listing)
- unit_price = TaxedMoney(net=net, gross=net)
- order_line.unit_price = unit_price
- total_price = unit_price * order_line.quantity
- order_line.total_price = total_price
- order_line.save()
-
- line_price = manager.calculate_order_line_total(
- order_line.order,
- order_line,
- variant,
- product,
+ 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,
+ [],
).price_with_discounts
- total_price_amount = total_price.net.amount
- currency = total_price.currency
- expected_price = quantize_price(
- TaxedMoney(
- net=Money(total_price_amount / Decimal("1.23"), currency),
- gross=Money(total_price_amount, currency),
+ # 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,
)
- assert line_price == expected_price
+
+ 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,
+ [],
+ ).price_with_discounts
+
+ # 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(
- vatlayer, checkout_with_item, shipping_zone, address, site_settings
+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()
@@ -761,10 +1189,15 @@ def test_calculate_checkout_line_unit_price(
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()
@@ -772,16 +1205,19 @@ def test_calculate_checkout_line_unit_price(
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,
[],
- ).price_with_sale
+ ).price_with_discounts
+ # then
assert line_price == TaxedMoney(
- net=Money("8.13", "USD"), gross=Money("10.00", "USD")
+ net=quantize_price(unit_gross / Decimal("1.23"), checkout_with_item.currency),
+ gross=unit_gross,
)
@@ -1703,3 +2139,130 @@ def test_calculate_checkout_shipping_no_shipping_price(
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,
+ )
+ )