Skip to content

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

Fixing avatax (#6035)

Maciej Korycinskibf87e6354ea8
diff --git a/saleor/plugins/avatax/__init__.py b/saleor/plugins/avatax/__init__.py
index 28bd5ecf54..9e4762bf9f 100644
--- a/saleor/plugins/avatax/__init__.py
+++ b/saleor/plugins/avatax/__init__.py
@@ -3,7 +3,7 @@ import logging
from dataclasses import dataclass
from datetime import date
from decimal import Decimal
-from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
+from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Union
from urllib.parse import urljoin
import requests
@@ -16,7 +16,7 @@ from ...checkout import base_calculations
if TYPE_CHECKING:
# flake8: noqa
- from ...checkout.models import Checkout
+ from ...checkout.models import Checkout, CheckoutLine
from ...order.models import Order
from ...product.models import Product, ProductVariant, ProductType
@@ -36,6 +36,9 @@ COMMON_CARRIER_CODE = "FR020100"
# Common discount code use to apply discount on order
COMMON_DISCOUNT_VOUCHER_CODE = "OD010000"
+# Temporary Unmapped Other SKU - taxable default
+DEFAULT_TAX_CODE = "O9999999"
+
@dataclass
class AvataxConfiguration:
@@ -73,25 +76,46 @@ def get_api_url(use_sandbox=True) -> str:
def api_post_request(
url: str, data: Dict[str, Any], config: AvataxConfiguration
) -> Dict[str, Any]:
+ response = None
try:
auth = HTTPBasicAuth(config.username_or_account, config.password_or_license)
response = requests.post(url, auth=auth, data=json.dumps(data), timeout=TIMEOUT)
logger.debug("Hit to Avatax to calculate taxes %s", url)
+ json_response = response.json()
+ if "error" in response: # type: ignore
+ logger.exception("Avatax response contains errors %s", json_response)
+ return json_response
except requests.exceptions.RequestException:
- logger.warning("Fetching taxes failed %s", url)
+ logger.error("Fetching taxes failed %s", url)
+ return {}
+ except json.JSONDecodeError:
+ content = response.content if response else "Unable to find the response"
+ logger.exception(
+ "Unable to decode the response from Avatax. Response: %s", content
+ )
return {}
- return response.json()
+ return json_response # type: ignore
def api_get_request(url: str, config: AvataxConfiguration):
+ response = None
try:
auth = HTTPBasicAuth(config.username_or_account, config.password_or_license)
response = requests.get(url, auth=auth, timeout=TIMEOUT)
+ json_response = response.json()
logger.debug("[GET] Hit to %s", url)
+ if "error" in json_response: # type: ignore
+ logger.error("Avatax response contains errors %s", json_response)
+ return json_response
except requests.exceptions.RequestException:
- logger.warning("Failed to fetch data from %s", url)
+ logger.error("Failed to fetch data from %s", url)
+ return {}
+ except json.JSONDecodeError:
+ content = response.content if response else "Unable to find the response"
+ logger.exception(
+ "Unable to decode the response from Avatax. Response: %s", content
+ )
return {}
- return response.json()
def _validate_adddress_details(
@@ -118,9 +142,9 @@ def _validate_order(order: "Order") -> bool:
)
-def _validate_checkout(checkout: "Checkout") -> bool:
+def _validate_checkout(checkout: "Checkout", lines: Iterable["CheckoutLine"]) -> bool:
"""Validate the checkout object if it is ready to generate a request to avatax."""
- if not checkout.lines.exists():
+ if not lines:
return False
shipping_address = checkout.shipping_address
@@ -137,24 +161,6 @@ def _retrieve_from_cache(token):
return cached_data
-def checkout_needs_new_fetch(data, checkout_token: str) -> bool:
- """Check if avatax's checkout response is cached or not.
-
- We store the response from avatax for checkout object for given time. If object
- doesn't exist in cache or something has changed, then we fetch data from avatax.
- """
-
- cached_checkout = _retrieve_from_cache(checkout_token)
-
- if not cached_checkout:
- return True
-
- cached_request_data, cached_response = cached_checkout
- if data != cached_request_data:
- return True
- return False
-
-
def taxes_need_new_fetch(data: Dict[str, Any], taxes_token: str) -> bool:
"""Check if Avatax's taxes data need to be refetched.
@@ -217,14 +223,12 @@ def get_checkout_lines_data(
"variant__product__category",
"variant__product__collections",
"variant__product__product_type",
- )
+ ).filter(variant__product__charge_taxes=True)
for line in lines:
- if not line.variant.product.charge_taxes:
- continue
name = line.variant.product.name
product = line.variant.product
product_type = line.variant.product.product_type
- tax_code = retrieve_tax_code_from_meta(product)
+ tax_code = retrieve_tax_code_from_meta(product, default=None)
tax_code = tax_code or retrieve_tax_code_from_meta(product_type)
append_line_to_data(
data=data,
@@ -249,18 +253,18 @@ def get_order_lines_data(
"variant__product__category",
"variant__product__collections",
"variant__product__product_type",
- )
+ ).filter(variant__product__charge_taxes=True)
for line in lines:
- if not line.variant or not line.variant.product.charge_taxes:
+ if not line.variant:
continue
product = line.variant.product
product_type = line.variant.product.product_type
- tax_code = retrieve_tax_code_from_meta(product)
+ tax_code = retrieve_tax_code_from_meta(product, default=None)
tax_code = tax_code or retrieve_tax_code_from_meta(product_type)
append_line_to_data(
data=data,
quantity=line.quantity,
- amount=line.unit_price_net_amount * line.quantity,
+ amount=line.unit_price_gross_amount * line.quantity,
tax_code=tax_code,
item_code=line.variant.sku,
name=line.variant.product.name,
@@ -284,7 +288,6 @@ def generate_request_data(
lines: List[Dict[str, Any]],
transaction_token: str,
address: Dict[str, str],
- customer_code: Optional[int],
customer_email: str,
config: AvataxConfiguration,
currency=settings.DEFAULT_CURRENCY,
@@ -305,7 +308,8 @@ def generate_request_data(
"lines": lines,
"code": transaction_token,
"date": str(date.today()),
- "customerCode": customer_code,
+ # https://developer.avalara.com/avatax/dev-guide/transactions/simple-transaction/
+ "customerCode": 0,
"addresses": {
"shipFrom": {
"line1": company_address.get("street_address_1"),
@@ -348,7 +352,6 @@ def generate_request_data_from_checkout(
lines=lines,
transaction_token=transaction_token or str(checkout.token),
address=address.as_data() if address else {},
- customer_code=checkout.user.id if checkout.user else 0,
customer_email=checkout.email,
config=config,
currency=currency,
@@ -397,9 +400,7 @@ def get_checkout_tax_data(
return get_cached_response_or_fetch(data, str(checkout.token), config)
-def get_order_tax_data(
- order: "Order", config: AvataxConfiguration, force_refresh=False
-) -> Dict[str, Any]:
+def get_order_request_data(order: "Order", config: AvataxConfiguration):
address = order.shipping_address or order.billing_address
lines = get_order_lines_data(order)
transaction = (
@@ -410,11 +411,17 @@ def get_order_tax_data(
lines=lines,
transaction_token=order.token,
address=address.as_data() if address else {},
- customer_code=order.user.id if order.user else None,
customer_email=order.user_email,
config=config,
currency=order.total.currency,
)
+ return data
+
+
+def get_order_tax_data(
+ order: "Order", config: AvataxConfiguration, force_refresh=False
+) -> Dict[str, Any]:
+ data = get_order_request_data(order, config)
response = get_cached_response_or_fetch(
data, "order_%s" % order.token, config, force_refresh
)
@@ -446,7 +453,9 @@ def get_cached_tax_codes_or_fetch(
return tax_codes
-def retrieve_tax_code_from_meta(obj: Union["Product", "ProductVariant", "ProductType"]):
- # O9999999 - "Temporary Unmapped Other SKU - taxable default"
- tax_code = obj.get_value_from_metadata(META_CODE_KEY, "O9999999")
+def retrieve_tax_code_from_meta(
+ obj: Union["Product", "ProductVariant", "ProductType"],
+ default: Optional[str] = DEFAULT_TAX_CODE,
+):
+ tax_code = obj.get_value_from_metadata(META_CODE_KEY, default)
return tax_code
diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.py
index b72b78911d..83229471c5 100644
--- a/saleor/plugins/avatax/plugin.py
+++ b/saleor/plugins/avatax/plugin.py
@@ -7,7 +7,8 @@ from urllib.parse import urljoin
from django.core.exceptions import ValidationError
from prices import Money, TaxedMoney, TaxedMoneyRange
-from ...core.taxes import TaxError, TaxType, zero_taxed_money
+from ...checkout import base_calculations
+from ...core.taxes import TaxError, TaxType, charge_taxes_on_shipping, zero_taxed_money
from ...discount import DiscountInfo
from ..base_plugin import BasePlugin, ConfigurationTypeField
from ..error_codes import PluginErrorCode
@@ -24,6 +25,7 @@ from . import (
get_api_url,
get_cached_tax_codes_or_fetch,
get_checkout_tax_data,
+ get_order_request_data,
get_order_tax_data,
)
from .tasks import api_post_request_task
@@ -112,6 +114,20 @@ class AvataxPlugin(BasePlugin):
return previous_value.net != previous_value.gross
return False
+ def _append_prices_of_not_taxed_lines(
+ self,
+ price: TaxedMoney,
+ lines: Iterable["CheckoutLine"],
+ discounts: Iterable[DiscountInfo],
+ ):
+ for line in lines:
+ if line.variant.product.charge_taxes:
+ continue
+ line_price = base_calculations.base_checkout_line_total(line, discounts)
+ price.gross.amount += line_price.gross.amount
+ price.net.amount += line_price.net.amount
+ return price
+
def calculate_checkout_total(
self,
checkout: "Checkout",
@@ -124,37 +140,46 @@ class AvataxPlugin(BasePlugin):
checkout_total = previous_value
- if not _validate_checkout(checkout):
+ if not _validate_checkout(checkout, lines):
return checkout_total
response = get_checkout_tax_data(checkout, discounts, self.config)
if not response or "error" in response:
return checkout_total
-
currency = response.get("currencyCode")
tax = Decimal(response.get("totalTax", 0.0))
total_net = Decimal(response.get("totalAmount", 0.0))
total_gross = Money(amount=total_net + tax, currency=currency)
total_net = Money(amount=total_net, currency=currency)
- total = TaxedMoney(net=total_net, gross=total_gross)
+ taxed_total = TaxedMoney(net=total_net, gross=total_gross)
+ total = self._append_prices_of_not_taxed_lines(taxed_total, lines, discounts)
voucher_value = checkout.discount
if voucher_value:
total -= voucher_value
return max(total, zero_taxed_money(total.currency))
def _calculate_checkout_subtotal(
- self, currency: str, lines: List[Dict]
+ self,
+ checkout,
+ lines: Iterable["CheckoutLine"],
+ discounts: Iterable[DiscountInfo],
+ base_subtotal: TaxedMoney,
) -> TaxedMoney:
+ currency = checkout.currency
+ response = get_checkout_tax_data(checkout, discounts, self.config)
+ if not response or "error" in response:
+ return base_subtotal
+
sub_tax = Decimal(0.0)
sub_net = Decimal(0.0)
- for line in lines:
+ for line in response.get("lines", []):
if line["itemCode"] == "Shipping":
continue
sub_tax += Decimal(line["tax"])
sub_net += Decimal(line.get("lineAmount", 0.0))
sub_total_gross = Money(sub_net + sub_tax, currency)
sub_total_net = Money(sub_net, currency)
-
- return TaxedMoney(net=sub_total_net, gross=sub_total_gross)
+ taxed_subtotal = TaxedMoney(net=sub_total_net, gross=sub_total_gross)
+ return self._append_prices_of_not_taxed_lines(taxed_subtotal, lines, discounts)
def calculate_checkout_subtotal(
self,
@@ -167,14 +192,15 @@ class AvataxPlugin(BasePlugin):
return previous_value
base_subtotal = previous_value
- if not _validate_checkout(checkout):
+ if not _validate_checkout(checkout, lines):
return base_subtotal
response = get_checkout_tax_data(checkout, discounts, self.config)
if not response or "error" in response:
return base_subtotal
- currency = str(response.get("currencyCode"))
- return self._calculate_checkout_subtotal(currency, response.get("lines", []))
+ return self._calculate_checkout_subtotal(
+ checkout, lines, discounts, base_subtotal
+ )
def _calculate_checkout_shipping(
self, currency: str, lines: List[Dict], shipping_price: TaxedMoney
@@ -199,11 +225,15 @@ class AvataxPlugin(BasePlugin):
discounts: Iterable[DiscountInfo],
previous_value: TaxedMoney,
) -> TaxedMoney:
+ base_shipping_price = previous_value
+
+ if not charge_taxes_on_shipping():
+ return base_shipping_price
+
if self._skip_plugin(previous_value):
- return previous_value
+ return base_shipping_price
- base_shipping_price = previous_value
- if not _validate_checkout(checkout):
+ if not _validate_checkout(checkout, lines):
return base_shipping_price
response = get_checkout_tax_data(checkout, discounts, self.config)
@@ -256,12 +286,14 @@ class AvataxPlugin(BasePlugin):
def order_created(self, order: "Order", previous_value: Any) -> Any:
if not self.active:
return previous_value
- data = get_order_tax_data(order, self.config, force_refresh=True)
+ request_data = get_order_request_data(order, self.config)
transaction_url = urljoin(
get_api_url(self.config.use_sandbox), "transactions/createoradjust"
)
- api_post_request_task.delay(transaction_url, data, asdict(self.config))
+ api_post_request_task.delay(
+ transaction_url, request_data, asdict(self.config), order.id
+ )
return previous_value
def calculate_checkout_line_total(
@@ -273,13 +305,18 @@ class AvataxPlugin(BasePlugin):
if self._skip_plugin(previous_value):
return previous_value
- checkout = checkout_line.checkout
base_total = previous_value
+ if not checkout_line.variant.product.charge_taxes:
+ return base_total
- if not _validate_checkout(checkout):
+ checkout = checkout_line.checkout
+ if not _validate_checkout(checkout, [checkout_line]):
return base_total
taxes_data = get_checkout_tax_data(checkout, discounts, self.config)
+ if not taxes_data or "error" in taxes_data:
+ return base_total
+
currency = taxes_data.get("currencyCode")
for line in taxes_data.get("lines", []):
if line.get("itemCode") == checkout_line.variant.sku:
@@ -309,7 +346,8 @@ class AvataxPlugin(BasePlugin):
) -> TaxedMoney:
if self._skip_plugin(previous_value):
return previous_value
-
+ if order_line.variant and not order_line.variant.product.charge_taxes: # type: ignore
+ return previous_value
if _validate_order(order_line.order):
return self._calculate_order_line_unit(order_line)
return order_line.unit_price
@@ -320,6 +358,9 @@ class AvataxPlugin(BasePlugin):
if self._skip_plugin(previous_value):
return previous_value
+ if not charge_taxes_on_shipping():
+ return previous_value
+
if not _validate_order(order):
return zero_taxed_money(order.total.currency)
taxes_data = get_order_tax_data(order, self.config, False)
diff --git a/saleor/plugins/avatax/tasks.py b/saleor/plugins/avatax/tasks.py
index bccb493e49..bf348ca870 100644
--- a/saleor/plugins/avatax/tasks.py
+++ b/saleor/plugins/avatax/tasks.py
@@ -1,8 +1,31 @@
+import logging
+
from ...celeryconf import app
+from ...core.taxes import TaxError
+from ...order.events import external_notification_event
+from ...order.models import Order
from . import AvataxConfiguration, api_post_request
+logger = logging.getLogger(__name__)
+
-def api_post_request_task(transaction_url, data, config):
+ autoretry_for=(TaxError,), retry_backoff=60, retry_kwargs={"max_retries": 5},
+)
+def api_post_request_task(transaction_url, data, config, order_id):
config = AvataxConfiguration(**config)
- api_post_request(transaction_url, data, config)
+ order = Order.objects.filter(id=order_id).first()
+ if not order:
+ logger.error(
+ "Unable to send the order %s to Avatax. Order doesn't exist.", order_id
+ )
+ return
+ response = api_post_request(transaction_url, data, config)
+
+ msg = f"Order sent to Avatax. Order ID: {order.token}"
+ if not response or "error" in response:
+ msg = "Unable to send order to Avatax."
+
+ external_notification_event(order=order, user=None, message=msg, parameters=None)
+ if not response:
+ raise TaxError
diff --git a/saleor/plugins/avatax/tests/cassettes/test_api_post_request_task_creates_order_event.yaml b/saleor/plugins/avatax/tests/cassettes/test_api_post_request_task_creates_order_event.yaml
new file mode 100644
index 0000000000..086eac2b14
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_api_post_request_task_creates_order_event.yaml
@@ -0,0 +1,67 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "36.90", "taxCode": "O9999999", "taxIncluded":
+ true, "itemCode": "SKU_A", "description": "Test product"}, {"quantity": 2, "amount":
+ "49.20", "taxCode": "O9999999", "taxIncluded": true, "itemCode": "SKU_B", "description":
+ "Test product 2"}, {"quantity": 1, "amount": "10.00", "taxCode": "FR020100",
+ "taxIncluded": true, "itemCode": "Shipping", "description": null}], "code":
+ "9cfe9695-f1db-40ba-90aa-e1539fda12f7", "date": "2020-08-24", "customerCode":
+ 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2": "", "city":
+ "Irvine", "region": "CA", "country": "US", "postalCode": "92614"}, "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
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '914'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":1000806342096,"code":"9cfe9695-f1db-40ba-90aa-e1539fda12f7","companyId":242975,"date":"2020-08-24","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":78.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":17.9700,"totalTaxable":78.13,"totalTaxCalculated":17.9700,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"20.8.0.9","originAddressId":3001586652614,"destinationAddressId":2001586652614,"exchangeRateEffectiveDate":"2020-08-24","exchangeRate":1.0,"isSellerImporterOfRecord":true,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2020-08-24T07:47:36.3333522Z","modifiedUserId":283192,"taxDate":"2020-08-24T00:00:00Z","lines":[{"id":2002547288862,"transactionId":1000806342096,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":2001586652614,"originAddressId":3001586652614,"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":"2020-08-24","revAccount":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0,"taxCalculated":6.9000,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2020-08-24","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":10001474842630,"transactionLineId":2002547288862,"transactionId":1000806342096,"addressId":2001586652614,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"PL","exemptAmount":0.0,"exemptReasonId":4,"inState":false,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":410972,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0,"nonTaxableUnits":0.0,"exemptUnits":0.0,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":6002351241906,"documentLineId":2002547288862,"documentAddressId":3001586652614,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":7001372545282,"documentLineId":2002547288862,"documentAddressId":2001586652614,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-2300O--US","vatNumberTypeId":0},{"id":3002547288861,"transactionId":1000806342096,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product 2","destinationAddressId":2001586652614,"originAddressId":3001586652614,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_B","lineAmount":40.0,"quantity":2.0,"ref1":"","ref2":"","reportingDate":"2020-08-24","revAccount":"","sourcing":"Destination","tax":9.2000,"taxableAmount":40.0,"taxCalculated":9.2000,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2020-08-24","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":11001474842630,"transactionLineId":3002547288861,"transactionId":1000806342096,"addressId":2001586652614,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"PL","exemptAmount":0.0,"exemptReasonId":4,"inState":false,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":410972,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":9.2000,"taxableAmount":40.0,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":9.2000,"taxOverride":0.0,"rateType":"Standard","rateTypeCode":"S","taxableUnits":40.0,"nonTaxableUnits":0.0,"exemptUnits":0.0,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":8001372545283,"documentLineId":3002547288861,"documentAddressId":3001586652614,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":9001372545283,"documentLineId":3002547288861,"documentAddressId":2001586652614,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-2300O--US","vatNumberTypeId":0},{"id":4002547288863,"transactionId":1000806342096,"lineNumber":"3","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":2001586652614,"originAddressId":3001586652614,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.13,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2020-08-24","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR020100","taxCodeId":4784,"taxDate":"2020-08-24","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":12001474842630,"transactionLineId":4002547288863,"transactionId":1000806342096,"addressId":2001586652614,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"PL","exemptAmount":0.0,"exemptReasonId":4,"inState":false,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":410972,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.87,"taxOverride":0.0,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.13,"nonTaxableUnits":0.0,"exemptUnits":0.0,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":10001372545283,"documentLineId":4002547288863,"documentAddressId":3001586652614,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":11001372545283,"documentLineId":4002547288863,"documentAddressId":2001586652614,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-2300F--US","vatNumberTypeId":0}],"addresses":[{"id":2001586652614,"transactionId":1000806342096,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":3001586652614,"transactionId":1000806342096,"boundaryLevel":"Address","line1":"2000
+ Main St","line2":"","line3":"","city":"Irvine","region":"CA","postalCode":"92614-7202","country":"US","taxRegionId":4017409,"latitude":"33.684716","longitude":"-117.851489"}],"locationTypes":[{"documentLocationTypeId":0,"documentId":1000806342096,"documentAddressId":3001586652614,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":0,"documentId":1000806342096,"documentAddressId":2001586652614,"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":78.13,"rate":0.230000,"tax":17.97,"taxCalculated":17.97,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '8460'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '1'
+ DatabaseDuration:
+ - '00:00:00.0010000'
+ Date:
+ - Mon, 24 Aug 2020 07:47:36 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/1000806342096
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.1346619'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_api_post_request_task_sends_request.yaml b/saleor/plugins/avatax/tests/cassettes/test_api_post_request_task_sends_request.yaml
new file mode 100644
index 0000000000..2e4b22b6cb
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_api_post_request_task_sends_request.yaml
@@ -0,0 +1,67 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesInvoice",
+ "lines": [{"quantity": 3, "amount": "36.90", "taxCode": "O9999999", "taxIncluded":
+ true, "itemCode": "SKU_A", "description": "Test product"}, {"quantity": 2, "amount":
+ "49.20", "taxCode": "O9999999", "taxIncluded": true, "itemCode": "SKU_B", "description":
+ "Test product 2"}, {"quantity": 1, "amount": "10.00", "taxCode": "FR020100",
+ "taxIncluded": true, "itemCode": "Shipping", "description": null}], "code":
+ "8e1ac801-46f9-4905-941d-b6879afb3ba1", "date": "2020-08-24", "customerCode":
+ 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2": "", "city":
+ "Irvine", "region": "CA", "country": "US", "postalCode": "92614"}, "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
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '914'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: '{"id":4000806339434,"code":"8e1ac801-46f9-4905-941d-b6879afb3ba1","companyId":242975,"date":"2020-08-24","status":"Saved","type":"SalesInvoice","batchCode":"","currencyCode":"USD","customerUsageType":"","entityUseCode":"","customerVendorCode":"0","customerCode":"0","exemptNo":"","reconciled":false,"locationCode":"","reportingLocationCode":"","purchaseOrderNo":"","referenceCode":"","salespersonCode":"","taxOverrideType":"None","taxOverrideAmount":0.0,"taxOverrideReason":"","totalAmount":78.13,"totalExempt":0.0,"totalDiscount":0.0,"totalTax":17.9700,"totalTaxable":78.13,"totalTaxCalculated":17.9700,"adjustmentReason":"NotAdjusted","adjustmentDescription":"","locked":false,"region":"","country":"PL","version":1,"softwareVersion":"20.7.1.3","originAddressId":3001586647962,"destinationAddressId":2001586647962,"exchangeRateEffectiveDate":"2020-08-24","exchangeRate":1.0,"isSellerImporterOfRecord":true,"description":"","email":"[email protected]","businessIdentificationNo":"","modifiedDate":"2020-08-24T07:43:33.4264769Z","modifiedUserId":283192,"taxDate":"2020-08-24T00:00:00Z","lines":[{"id":6001743135120,"transactionId":4000806339434,"lineNumber":"1","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product","destinationAddressId":2001586647962,"originAddressId":3001586647962,"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":"2020-08-24","revAccount":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0,"taxCalculated":6.9000,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2020-08-24","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":8001474834334,"transactionLineId":6001743135120,"transactionId":4000806339434,"addressId":2001586647962,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"PL","exemptAmount":0.0,"exemptReasonId":4,"inState":false,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":410972,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":6.9000,"taxableAmount":30.0,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":6.9000,"taxOverride":0.0,"rateType":"Standard","rateTypeCode":"S","taxableUnits":30.0,"nonTaxableUnits":0.0,"exemptUnits":0.0,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":11001372536966,"documentLineId":6001743135120,"documentAddressId":3001586647962,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":12001372536965,"documentLineId":6001743135120,"documentAddressId":2001586647962,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-2300O--US","vatNumberTypeId":0},{"id":1002547281257,"transactionId":4000806339434,"lineNumber":"2","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"Test
+ product 2","destinationAddressId":2001586647962,"originAddressId":3001586647962,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"SKU_B","lineAmount":40.0,"quantity":2.0,"ref1":"","ref2":"","reportingDate":"2020-08-24","revAccount":"","sourcing":"Destination","tax":9.2000,"taxableAmount":40.0,"taxCalculated":9.2000,"taxCode":"O9999999","taxCodeId":5340,"taxDate":"2020-08-24","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":11001474834335,"transactionLineId":1002547281257,"transactionId":4000806339434,"addressId":2001586647962,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"PL","exemptAmount":0.0,"exemptReasonId":4,"inState":false,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":410972,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":9.2000,"taxableAmount":40.0,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":9.2000,"taxOverride":0.0,"rateType":"Standard","rateTypeCode":"S","taxableUnits":40.0,"nonTaxableUnits":0.0,"exemptUnits":0.0,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":1004071305231,"documentLineId":1002547281257,"documentAddressId":3001586647962,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":3004071305228,"documentLineId":1002547281257,"documentAddressId":2001586647962,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-2300O--US","vatNumberTypeId":0},{"id":2002547281258,"transactionId":4000806339434,"lineNumber":"3","boundaryOverrideId":0,"customerUsageType":"","entityUseCode":"","description":"","destinationAddressId":2001586647962,"originAddressId":3001586647962,"discountAmount":0.0,"discountTypeId":0,"exemptAmount":0.0,"exemptCertId":0,"exemptNo":"","isItemTaxable":true,"isSSTP":false,"itemCode":"Shipping","lineAmount":8.13,"quantity":1.0,"ref1":"","ref2":"","reportingDate":"2020-08-24","revAccount":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxCalculated":1.87,"taxCode":"FR020100","taxCodeId":4784,"taxDate":"2020-08-24","taxEngine":"","taxOverrideType":"None","businessIdentificationNo":"","taxOverrideAmount":0.0,"taxOverrideReason":"","taxIncluded":true,"details":[{"id":2002552069712,"transactionLineId":2002547281258,"transactionId":4000806339434,"addressId":2001586647962,"country":"PL","region":"PL","countyFIPS":"","stateFIPS":"PL","exemptAmount":0.0,"exemptReasonId":4,"inState":false,"jurisCode":"PL","jurisName":"POLAND","jurisdictionId":200102,"signatureCode":"","stateAssignedNo":"","jurisType":"CNT","jurisdictionType":"Country","nonTaxableAmount":0.0,"nonTaxableRuleId":0,"nonTaxableType":"RateRule","rate":0.230000,"rateRuleId":410972,"rateSourceId":0,"serCode":"","sourcing":"Destination","tax":1.87,"taxableAmount":8.13,"taxType":"Output","taxSubTypeId":"O","taxTypeGroupId":"InputAndOutput","taxName":"Standard
+ Rate","taxAuthorityTypeId":45,"taxRegionId":205102,"taxCalculated":1.87,"taxOverride":0.0,"rateType":"Standard","rateTypeCode":"S","taxableUnits":8.13,"nonTaxableUnits":0.0,"exemptUnits":0.0,"unitOfBasis":"PerCurrencyUnit","isNonPassThru":false,"isFee":false}],"nonPassthroughDetails":[],"lineLocationTypes":[{"documentLineLocationTypeId":5002351233590,"documentLineId":2002547281258,"documentAddressId":3001586647962,"locationTypeCode":"ShipFrom"},{"documentLineLocationTypeId":6002351233590,"documentLineId":2002547281258,"documentAddressId":2001586647962,"locationTypeCode":"ShipTo"}],"hsCode":"","costInsuranceFreight":0.0,"vatCode":"PLS-2300F--US","vatNumberTypeId":0}],"addresses":[{"id":2001586647962,"transactionId":4000806339434,"boundaryLevel":"Zip5","line1":"Teczowa
+ 7","line2":"","line3":"","city":"WROCLAW","region":"","postalCode":"53-601","country":"PL","taxRegionId":205102},{"id":3001586647962,"transactionId":4000806339434,"boundaryLevel":"Address","line1":"2000
+ Main St","line2":"","line3":"","city":"Irvine","region":"CA","postalCode":"92614-7202","country":"US","taxRegionId":4017409,"latitude":"33.684716","longitude":"-117.851489"}],"locationTypes":[{"documentLocationTypeId":0,"documentId":4000806339434,"documentAddressId":3001586647962,"locationTypeCode":"ShipFrom"},{"documentLocationTypeId":0,"documentId":4000806339434,"documentAddressId":2001586647962,"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":78.13,"rate":0.230000,"tax":17.97,"taxCalculated":17.97,"nonTaxable":0.0,"exemption":0.0}]}'
+ headers:
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '8458'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '1'
+ DatabaseDuration:
+ - '00:00:00.0010000'
+ Date:
+ - Mon, 24 Aug 2020 07:43:36 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/4000806339434
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.1365235'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-29.52-37.00-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-29.52-37.00-3.0-True].yaml
deleted file mode 100644
index fdc29e7e5d..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-29.52-37.00-3.0-True].yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
- true, "itemCode": "123", "description": ""}, {"quantity": 1, "amount": "10.00",
- "taxCode": "FR020100", "taxIncluded": true, "itemCode": "Shipping", "description":
- ""}], "code": "8c1f745b-dd3f-4169-baaf-30c8cac73f10", "date": "2019-06-26",
- "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2":
- "", "city": "Irvine", "region": "CA", "country": "US", "postalCode": "92614"},
- "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
- "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
- "USD", "email": ""}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '746'
- User-Agent:
- - python-requests/2.22.0
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: "{\"id\":0,\"code\":\"8c1f745b-dd3f-4169-baaf-30c8cac73f10\",\"companyId\"\
- :242975,\"date\":\"2019-06-26\",\"paymentDate\":\"2019-06-26\",\"status\"\
- :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
- :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2019-06-26\"\
- ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2019-06-26T10:14:55.6685415Z\"\
- ,\"modifiedUserId\":283192,\"taxDate\":\"2019-06-26T00:00:00\",\"lines\":[{\"\
- id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"\",\"discountAmount\"\
- :0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\"\
- :\"123\",\"lineAmount\":24.39,\"quantity\":3.0,\"reportingDate\":\"2019-06-26\"\
- ,\"tax\":5.61,\"taxableAmount\":24.39,\"taxCalculated\":5.61,\"taxCode\":\"\
- O9999999\",\"taxCodeId\":5340,\"taxDate\":\"2019-06-26\",\"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\",\"isNonPassThru\":false}],\"nonPassthroughDetails\"\
- :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300O--US\"\
- ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
- ,\"description\":\"\",\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\"\
- :0,\"isItemTaxable\":true,\"itemCode\":\"Shipping\",\"lineAmount\":8.13,\"\
- quantity\":1.0,\"reportingDate\":\"2019-06-26\",\"tax\":1.87,\"taxableAmount\"\
- :8.13,\"taxCalculated\":1.87,\"taxCode\":\"FR020100\",\"taxCodeId\":4784,\"\
- taxDate\":\"2019-06-26\",\"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\"\
- ,\"isNonPassThru\":false}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"\
- costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\"\
- :0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\"\
- ,\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\"\
- ,\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\"\
- :205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\"\
- :0,\"boundaryLevel\":\"Zip5\",\"line1\":\"2000 Main Street\",\"line2\":\"\"\
- ,\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\"\
- ,\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"0\",\"longitude\"\
- :\"0\"}],\"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}]}"
- headers:
- Connection:
- - keep-alive
- Content-Type:
- - application/json; charset=utf-8
- Date:
- - Wed, 26 Jun 2019 10:14:54 GMT
- Location:
- - /api/v2/companies/242975/transactions/0
- Server:
- - Kestrel
- ServerDuration:
- - '00:00:00.0904801'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- X-Powered-By:
- - ASP.NET
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-31.51-38.99-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-31.51-38.99-3.0-True].yaml
new file mode 100644
index 0000000000..dc501368ca
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-31.51-38.99-3.0-True].yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
+ true, "itemCode": "123", "description": "Test product"}, {"quantity": 1, "amount":
+ "10.00", "taxCode": "FR020100", "taxIncluded": true, "itemCode": "Shipping",
+ "description": null}], "code": "7dba2600-52f5-4e46-abb5-2f3cf4a046ce", "date":
+ "2020-08-21", "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main
+ Street", "line2": "", "city": "Irvine", "region": "CA", "country": "US", "postalCode":
+ "92614"}, "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW",
+ "region": "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": ""}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '760'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: "{\"id\":0,\"code\":\"7dba2600-52f5-4e46-abb5-2f3cf4a046ce\",\"companyId\"\
+ :242975,\"date\":\"2020-08-21\",\"paymentDate\":\"2020-08-21\",\"status\"\
+ :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
+ :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2020-08-21\"\
+ ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2020-08-21T09:53:04.8002245Z\"\
+ ,\"modifiedUserId\":283192,\"taxDate\":\"2020-08-21T00:00:00\",\"lines\":[{\"\
+ id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"Test product\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"123\",\"lineAmount\":24.39,\"quantity\":3.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":5.61,\"taxableAmount\":24.39,\"taxCalculated\":5.61,\"\
+ taxCode\":\"PC040156\",\"taxCodeId\":6622,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\"\
+ :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300P--US\"\
+ ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"Shipping\",\"lineAmount\":8.13,\"quantity\":1.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":1.87,\"taxableAmount\":8.13,\"taxCalculated\":1.87,\"\
+ taxCode\":\"FR020100\",\"taxCodeId\":4784,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\"\
+ :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\"\
+ ,\"vatNumberTypeId\":0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
+ :\"Zip5\",\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\"\
+ :\"WROCLAW\",\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\"\
+ ,\"taxRegionId\":205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"\
+ transactionId\":0,\"boundaryLevel\":\"Address\",\"line1\":\"2000 Main Street\"\
+ ,\"line2\":\"\",\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\"\
+ :\"92614\",\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"33.684716\"\
+ ,\"longitude\":\"-117.851489\"}],\"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}]}"
+ headers:
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '3337'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '0'
+ DatabaseDuration:
+ - 00:00:00
+ Date:
+ - Fri, 21 Aug 2020 09:53:04 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.0817576'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-37.00-37.00-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-37.00-37.00-3.0-True].yaml
deleted file mode 100644
index 9bd8a3cf79..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-37.00-37.00-3.0-True].yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
- true, "itemCode": "123", "description": ""}, {"quantity": 1, "amount": "10.00",
- "taxCode": "FR020100", "taxIncluded": true, "itemCode": "Shipping", "description":
- ""}], "code": "8522a3b1-6d24-4e2a-81fd-11d4c517c2a4", "date": "2019-06-26",
- "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2":
- "", "city": "Irvine", "region": "CA", "country": "US", "postalCode": "92614"},
- "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
- "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
- "USD", "email": ""}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '746'
- User-Agent:
- - python-requests/2.22.0
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: "{\"id\":0,\"code\":\"8522a3b1-6d24-4e2a-81fd-11d4c517c2a4\",\"companyId\"\
- :242975,\"date\":\"2019-06-26\",\"paymentDate\":\"2019-06-26\",\"status\"\
- :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
- :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2019-06-26\"\
- ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2019-06-26T10:14:00.7968405Z\"\
- ,\"modifiedUserId\":283192,\"taxDate\":\"2019-06-26T00:00:00\",\"lines\":[{\"\
- id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"\",\"discountAmount\"\
- :0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\"\
- :\"123\",\"lineAmount\":24.39,\"quantity\":3.0,\"reportingDate\":\"2019-06-26\"\
- ,\"tax\":5.61,\"taxableAmount\":24.39,\"taxCalculated\":5.61,\"taxCode\":\"\
- O9999999\",\"taxCodeId\":5340,\"taxDate\":\"2019-06-26\",\"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\",\"isNonPassThru\":false}],\"nonPassthroughDetails\"\
- :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300O--US\"\
- ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
- ,\"description\":\"\",\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\"\
- :0,\"isItemTaxable\":true,\"itemCode\":\"Shipping\",\"lineAmount\":8.13,\"\
- quantity\":1.0,\"reportingDate\":\"2019-06-26\",\"tax\":1.87,\"taxableAmount\"\
- :8.13,\"taxCalculated\":1.87,\"taxCode\":\"FR020100\",\"taxCodeId\":4784,\"\
- taxDate\":\"2019-06-26\",\"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\"\
- ,\"isNonPassThru\":false}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"\
- costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\"\
- :0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\"\
- ,\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\"\
- ,\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\"\
- :205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\"\
- :0,\"boundaryLevel\":\"Zip5\",\"line1\":\"2000 Main Street\",\"line2\":\"\"\
- ,\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\"\
- ,\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"0\",\"longitude\"\
- :\"0\"}],\"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}]}"
- headers:
- Connection:
- - keep-alive
- Content-Type:
- - application/json; charset=utf-8
- Date:
- - Wed, 26 Jun 2019 10:14:19 GMT
- Location:
- - /api/v2/companies/242975/transactions/0
- Server:
- - Kestrel
- ServerDuration:
- - '00:00:00.0921649'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- X-Powered-By:
- - ASP.NET
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-40.00-40.00-0.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-40.00-40.00-0.0-False].yaml
deleted file mode 100644
index 2308d58309..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-40.00-40.00-0.0-False].yaml
+++ /dev/null
@@ -1,100 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
- false, "itemCode": "123", "description": ""}, {"quantity": 1, "amount": "10.00",
- "taxCode": "FR020100", "taxIncluded": false, "itemCode": "Shipping", "description":
- ""}], "code": "5800f60f-eaad-4c3c-8fe4-a50fbc58b185", "date": "2019-06-26",
- "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2":
- "", "city": "Irvine", "region": "CA", "country": "US", "postalCode": "92614"},
- "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
- "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
- "USD", "email": ""}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '748'
- User-Agent:
- - python-requests/2.22.0
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: "{\"id\":0,\"code\":\"5800f60f-eaad-4c3c-8fe4-a50fbc58b185\",\"companyId\"\
- :242975,\"date\":\"2019-06-26\",\"paymentDate\":\"2019-06-26\",\"status\"\
- :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
- :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2019-06-26\",\"exchangeRate\"\
- :1.0,\"email\":\"\",\"modifiedDate\":\"2019-06-26T10:14:19.00325Z\",\"modifiedUserId\"\
- :283192,\"taxDate\":\"2019-06-26T00:00:00\",\"lines\":[{\"id\":0,\"transactionId\"\
- :0,\"lineNumber\":\"1\",\"description\":\"\",\"discountAmount\":0.0,\"exemptAmount\"\
- :0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\":\"123\",\"lineAmount\"\
- :30.0,\"quantity\":3.0,\"reportingDate\":\"2019-06-26\",\"tax\":6.9,\"taxableAmount\"\
- :30.0,\"taxCalculated\":6.9,\"taxCode\":\"O9999999\",\"taxCodeId\":5340,\"\
- taxDate\":\"2019-06-26\",\"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\"\
- ,\"isNonPassThru\":false}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"\
- costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300O--US\",\"vatNumberTypeId\"\
- :0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\",\"description\":\"\"\
- ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
- :true,\"itemCode\":\"Shipping\",\"lineAmount\":10.0,\"quantity\":1.0,\"reportingDate\"\
- :\"2019-06-26\",\"tax\":2.3,\"taxableAmount\":10.0,\"taxCalculated\":2.3,\"\
- taxCode\":\"FR020100\",\"taxCodeId\":4784,\"taxDate\":\"2019-06-26\",\"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\",\"isNonPassThru\":false}],\"\
- nonPassthroughDetails\":[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"\
- vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\":0}],\"addresses\":[{\"id\"\
- :0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\",\"line1\":\"T\u0119czowa\
- \ 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\",\"region\":\"\",\"\
- postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\":205102,\"latitude\"\
- :\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
- :\"Zip5\",\"line1\":\"2000 Main Street\",\"line2\":\"\",\"line3\":\"\",\"\
- city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\",\"country\":\"\
- US\",\"taxRegionId\":4017409,\"latitude\":\"0\",\"longitude\":\"0\"}],\"summary\"\
- :[{\"country\":\"PL\",\"region\":\"PL\",\"jurisType\":\"Country\",\"jurisCode\"\
- :\"PL\",\"jurisName\":\"POLAND\",\"taxAuthorityType\":45,\"stateAssignedNo\"\
- :\"\",\"taxType\":\"Output\",\"taxSubType\":\"O\",\"taxName\":\"Standard Rate\"\
- ,\"rateType\":\"Standard\",\"taxable\":40.0,\"rate\":0.230000,\"tax\":9.2,\"\
- taxCalculated\":9.2,\"nonTaxable\":0.0,\"exemption\":0.0}]}"
- headers:
- Connection:
- - keep-alive
- Content-Type:
- - application/json; charset=utf-8
- Date:
- - Wed, 26 Jun 2019 10:14:18 GMT
- Location:
- - /api/v2/companies/242975/transactions/0
- Server:
- - Kestrel
- ServerDuration:
- - '00:00:00.1088685'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- X-Powered-By:
- - ASP.NET
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-40.00-49.20-0.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-40.00-49.20-0.0-False].yaml
deleted file mode 100644
index 534eb04496..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-40.00-49.20-0.0-False].yaml
+++ /dev/null
@@ -1,100 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "O9999999", "taxIncluded":
- false, "itemCode": "123", "description": ""}, {"quantity": 1, "amount": "10.00",
- "taxCode": "FR020100", "taxIncluded": false, "itemCode": "Shipping", "description":
- ""}], "code": "3a100b96-0554-423d-8c19-39f3e1536763", "date": "2019-06-26",
- "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2":
- "", "city": "Irvine", "region": "CA", "country": "US", "postalCode": "92614"},
- "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
- "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
- "USD", "email": ""}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '748'
- User-Agent:
- - python-requests/2.22.0
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: "{\"id\":0,\"code\":\"3a100b96-0554-423d-8c19-39f3e1536763\",\"companyId\"\
- :242975,\"date\":\"2019-06-26\",\"paymentDate\":\"2019-06-26\",\"status\"\
- :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
- :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2019-06-26\",\"exchangeRate\"\
- :1.0,\"email\":\"\",\"modifiedDate\":\"2019-06-26T10:14:49.6389136Z\",\"modifiedUserId\"\
- :283192,\"taxDate\":\"2019-06-26T00:00:00\",\"lines\":[{\"id\":0,\"transactionId\"\
- :0,\"lineNumber\":\"1\",\"description\":\"\",\"discountAmount\":0.0,\"exemptAmount\"\
- :0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\":\"123\",\"lineAmount\"\
- :30.0,\"quantity\":3.0,\"reportingDate\":\"2019-06-26\",\"tax\":6.9,\"taxableAmount\"\
- :30.0,\"taxCalculated\":6.9,\"taxCode\":\"O9999999\",\"taxCodeId\":5340,\"\
- taxDate\":\"2019-06-26\",\"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\"\
- ,\"isNonPassThru\":false}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"\
- costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300O--US\",\"vatNumberTypeId\"\
- :0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\",\"description\":\"\"\
- ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
- :true,\"itemCode\":\"Shipping\",\"lineAmount\":10.0,\"quantity\":1.0,\"reportingDate\"\
- :\"2019-06-26\",\"tax\":2.3,\"taxableAmount\":10.0,\"taxCalculated\":2.3,\"\
- taxCode\":\"FR020100\",\"taxCodeId\":4784,\"taxDate\":\"2019-06-26\",\"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\",\"isNonPassThru\":false}],\"\
- nonPassthroughDetails\":[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"\
- vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\":0}],\"addresses\":[{\"id\"\
- :0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\",\"line1\":\"T\u0119czowa\
- \ 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\",\"region\":\"\",\"\
- postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\":205102,\"latitude\"\
- :\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
- :\"Zip5\",\"line1\":\"2000 Main Street\",\"line2\":\"\",\"line3\":\"\",\"\
- city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\",\"country\":\"\
- US\",\"taxRegionId\":4017409,\"latitude\":\"0\",\"longitude\":\"0\"}],\"summary\"\
- :[{\"country\":\"PL\",\"region\":\"PL\",\"jurisType\":\"Country\",\"jurisCode\"\
- :\"PL\",\"jurisName\":\"POLAND\",\"taxAuthorityType\":45,\"stateAssignedNo\"\
- :\"\",\"taxType\":\"Output\",\"taxSubType\":\"O\",\"taxName\":\"Standard Rate\"\
- ,\"rateType\":\"Standard\",\"taxable\":40.0,\"rate\":0.230000,\"tax\":9.2,\"\
- taxCalculated\":9.2,\"nonTaxable\":0.0,\"exemption\":0.0}]}"
- headers:
- Connection:
- - keep-alive
- Content-Type:
- - application/json; charset=utf-8
- Date:
- - Wed, 26 Jun 2019 10:14:53 GMT
- Location:
- - /api/v2/companies/242975/transactions/0
- Server:
- - Kestrel
- ServerDuration:
- - '00:00:00.0888919'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- X-Powered-By:
- - ASP.NET
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-41.99-51.19-0.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-41.99-51.19-0.0-False].yaml
new file mode 100644
index 0000000000..eb5cc92c25
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[False-41.99-51.19-0.0-False].yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
+ false, "itemCode": "123", "description": "Test product"}, {"quantity": 1, "amount":
+ "10.00", "taxCode": "FR020100", "taxIncluded": false, "itemCode": "Shipping",
+ "description": null}], "code": "9720e6ff-44c6-4c92-97b0-7020b9360f2c", "date":
+ "2020-08-21", "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main
+ Street", "line2": "", "city": "Irvine", "region": "CA", "country": "US", "postalCode":
+ "92614"}, "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW",
+ "region": "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": ""}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '762'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: "{\"id\":0,\"code\":\"9720e6ff-44c6-4c92-97b0-7020b9360f2c\",\"companyId\"\
+ :242975,\"date\":\"2020-08-21\",\"paymentDate\":\"2020-08-21\",\"status\"\
+ :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
+ :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2020-08-21\",\"exchangeRate\"\
+ :1.0,\"email\":\"\",\"modifiedDate\":\"2020-08-21T09:53:03.4882536Z\",\"modifiedUserId\"\
+ :283192,\"taxDate\":\"2020-08-21T00:00:00\",\"lines\":[{\"id\":0,\"transactionId\"\
+ :0,\"lineNumber\":\"1\",\"description\":\"Test product\",\"discountAmount\"\
+ :0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\"\
+ :\"123\",\"lineAmount\":30.00,\"quantity\":3.0,\"reportingDate\":\"2020-08-21\"\
+ ,\"tax\":6.9,\"taxableAmount\":30.0,\"taxCalculated\":6.9,\"taxCode\":\"PC040156\"\
+ ,\"taxCodeId\":6622,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"costInsuranceFreight\"\
+ :0.0,\"vatCode\":\"PLS-2300P--US\",\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\"\
+ :0,\"lineNumber\":\"2\",\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\"\
+ :0,\"isItemTaxable\":true,\"itemCode\":\"Shipping\",\"lineAmount\":10.00,\"\
+ quantity\":1.0,\"reportingDate\":\"2020-08-21\",\"tax\":2.3,\"taxableAmount\"\
+ :10.0,\"taxCalculated\":2.3,\"taxCode\":\"FR020100\",\"taxCodeId\":4784,\"\
+ taxDate\":\"2020-08-21\",\"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}],\"\
+ nonPassthroughDetails\":[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"\
+ vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\":0}],\"addresses\":[{\"id\"\
+ :0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\",\"line1\":\"T\u0119czowa\
+ \ 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\",\"region\":\"\",\"\
+ postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\":205102,\"latitude\"\
+ :\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
+ :\"Address\",\"line1\":\"2000 Main Street\",\"line2\":\"\",\"line3\":\"\"\
+ ,\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\",\"country\"\
+ :\"US\",\"taxRegionId\":4017409,\"latitude\":\"33.684716\",\"longitude\":\"\
+ -117.851489\"}],\"summary\":[{\"country\":\"PL\",\"region\":\"PL\",\"jurisType\"\
+ :\"Country\",\"jurisCode\":\"PL\",\"jurisName\":\"POLAND\",\"taxAuthorityType\"\
+ :45,\"stateAssignedNo\":\"\",\"taxType\":\"Output\",\"taxSubType\":\"O\",\"\
+ taxName\":\"Standard Rate\",\"rateType\":\"Standard\",\"taxable\":40.0,\"\
+ rate\":0.230000,\"tax\":9.2,\"taxCalculated\":9.2,\"nonTaxable\":0.0,\"exemption\"\
+ :0.0}]}"
+ headers:
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '3323'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '0'
+ DatabaseDuration:
+ - 00:00:00
+ Date:
+ - Fri, 21 Aug 2020 09:53:03 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.0861759'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.00-20.00-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.00-20.00-5.0-False].yaml
deleted file mode 100644
index fa3b097859..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.00-20.00-5.0-False].yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "O9999999", "taxIncluded":
- false, "itemCode": "123", "description": ""}, {"quantity": 1, "amount": "10.00",
- "taxCode": "FR020100", "taxIncluded": false, "itemCode": "Shipping", "description":
- ""}], "code": "c391cd80-d11b-4098-8e56-35ca056a9d99", "date": "2019-06-26",
- "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2":
- "", "city": "Irvine", "region": "CA", "country": "US", "postalCode": "92614"},
- "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
- "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
- "USD", "email": ""}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '748'
- User-Agent:
- - python-requests/2.22.0
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: "{\"id\":0,\"code\":\"c391cd80-d11b-4098-8e56-35ca056a9d99\",\"companyId\"\
- :242975,\"date\":\"2019-06-26\",\"paymentDate\":\"2019-06-26\",\"status\"\
- :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
- :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2019-06-26\"\
- ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2019-06-26T10:13:15.1448397Z\"\
- ,\"modifiedUserId\":283192,\"taxDate\":\"2019-06-26T00:00:00\",\"lines\":[{\"\
- id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"\",\"discountAmount\"\
- :0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\"\
- :\"123\",\"lineAmount\":15.0,\"quantity\":3.0,\"reportingDate\":\"2019-06-26\"\
- ,\"tax\":3.45,\"taxableAmount\":15.0,\"taxCalculated\":3.45,\"taxCode\":\"\
- O9999999\",\"taxCodeId\":5340,\"taxDate\":\"2019-06-26\",\"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\",\"isNonPassThru\":false}],\"nonPassthroughDetails\"\
- :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300O--US\"\
- ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
- ,\"description\":\"\",\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\"\
- :0,\"isItemTaxable\":true,\"itemCode\":\"Shipping\",\"lineAmount\":10.0,\"\
- quantity\":1.0,\"reportingDate\":\"2019-06-26\",\"tax\":2.3,\"taxableAmount\"\
- :10.0,\"taxCalculated\":2.3,\"taxCode\":\"FR020100\",\"taxCodeId\":4784,\"\
- taxDate\":\"2019-06-26\",\"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\"\
- ,\"isNonPassThru\":false}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"\
- costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\"\
- :0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\"\
- ,\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\"\
- ,\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\"\
- :205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\"\
- :0,\"boundaryLevel\":\"Zip5\",\"line1\":\"2000 Main Street\",\"line2\":\"\"\
- ,\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\"\
- ,\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"0\",\"longitude\"\
- :\"0\"}],\"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:
- - Wed, 26 Jun 2019 10:13:18 GMT
- Location:
- - /api/v2/companies/242975/transactions/0
- Server:
- - Kestrel
- ServerDuration:
- - '00:00:00.0897601'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- X-Powered-By:
- - ASP.NET
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.00-25.75-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.00-25.75-5.0-False].yaml
deleted file mode 100644
index 2d56ca376f..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.00-25.75-5.0-False].yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "O9999999", "taxIncluded":
- false, "itemCode": "123", "description": ""}, {"quantity": 1, "amount": "10.00",
- "taxCode": "FR020100", "taxIncluded": false, "itemCode": "Shipping", "description":
- ""}], "code": "9ea835c0-b750-4d10-ad56-aa5eb75ffa51", "date": "2019-06-26",
- "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2":
- "", "city": "Irvine", "region": "CA", "country": "US", "postalCode": "92614"},
- "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
- "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
- "USD", "email": ""}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '748'
- User-Agent:
- - python-requests/2.22.0
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: "{\"id\":0,\"code\":\"9ea835c0-b750-4d10-ad56-aa5eb75ffa51\",\"companyId\"\
- :242975,\"date\":\"2019-06-26\",\"paymentDate\":\"2019-06-26\",\"status\"\
- :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
- :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2019-06-26\"\
- ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2019-06-26T10:14:12.7711371Z\"\
- ,\"modifiedUserId\":283192,\"taxDate\":\"2019-06-26T00:00:00\",\"lines\":[{\"\
- id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"\",\"discountAmount\"\
- :0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\"\
- :\"123\",\"lineAmount\":15.0,\"quantity\":3.0,\"reportingDate\":\"2019-06-26\"\
- ,\"tax\":3.45,\"taxableAmount\":15.0,\"taxCalculated\":3.45,\"taxCode\":\"\
- O9999999\",\"taxCodeId\":5340,\"taxDate\":\"2019-06-26\",\"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\",\"isNonPassThru\":false}],\"nonPassthroughDetails\"\
- :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300O--US\"\
- ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
- ,\"description\":\"\",\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\"\
- :0,\"isItemTaxable\":true,\"itemCode\":\"Shipping\",\"lineAmount\":10.0,\"\
- quantity\":1.0,\"reportingDate\":\"2019-06-26\",\"tax\":2.3,\"taxableAmount\"\
- :10.0,\"taxCalculated\":2.3,\"taxCode\":\"FR020100\",\"taxCodeId\":4784,\"\
- taxDate\":\"2019-06-26\",\"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\"\
- ,\"isNonPassThru\":false}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"\
- costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\"\
- :0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\"\
- ,\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\"\
- ,\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\"\
- :205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\"\
- :0,\"boundaryLevel\":\"Zip5\",\"line1\":\"2000 Main Street\",\"line2\":\"\"\
- ,\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\"\
- ,\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"0\",\"longitude\"\
- :\"0\"}],\"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:
- - Wed, 26 Jun 2019 10:14:17 GMT
- Location:
- - /api/v2/companies/242975/transactions/0
- Server:
- - Kestrel
- ServerDuration:
- - '00:00:00.0919139'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- X-Powered-By:
- - ASP.NET
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.33-25.00-0.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.33-25.00-0.0-True].yaml
deleted file mode 100644
index 7dc6a5466c..0000000000
--- a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-20.33-25.00-0.0-True].yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-interactions:
-- request:
- body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
- "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "O9999999", "taxIncluded":
- true, "itemCode": "123", "description": ""}, {"quantity": 1, "amount": "10.00",
- "taxCode": "FR020100", "taxIncluded": true, "itemCode": "Shipping", "description":
- ""}], "code": "a1cbe308-cb75-4a9d-aeec-00e590667ddb", "date": "2019-06-26",
- "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main Street", "line2":
- "", "city": "Irvine", "region": "CA", "country": "US", "postalCode": "92614"},
- "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW", "region":
- "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
- "USD", "email": ""}}'
- headers:
- Accept:
- - '*/*'
- Accept-Encoding:
- - gzip, deflate
- Authorization:
- - Basic Og==
- Connection:
- - keep-alive
- Content-Length:
- - '746'
- User-Agent:
- - python-requests/2.22.0
- method: POST
- uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
- response:
- body:
- string: "{\"id\":0,\"code\":\"a1cbe308-cb75-4a9d-aeec-00e590667ddb\",\"companyId\"\
- :242975,\"date\":\"2019-06-26\",\"paymentDate\":\"2019-06-26\",\"status\"\
- :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
- :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2019-06-26\"\
- ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2019-06-26T10:12:27.071586Z\"\
- ,\"modifiedUserId\":283192,\"taxDate\":\"2019-06-26T00:00:00\",\"lines\":[{\"\
- id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"\",\"discountAmount\"\
- :0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\"\
- :\"123\",\"lineAmount\":12.2,\"quantity\":3.0,\"reportingDate\":\"2019-06-26\"\
- ,\"tax\":2.8,\"taxableAmount\":12.2,\"taxCalculated\":2.8,\"taxCode\":\"O9999999\"\
- ,\"taxCodeId\":5340,\"taxDate\":\"2019-06-26\",\"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\",\"isNonPassThru\":false}],\"nonPassthroughDetails\"\
- :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300O--US\"\
- ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
- ,\"description\":\"\",\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\"\
- :0,\"isItemTaxable\":true,\"itemCode\":\"Shipping\",\"lineAmount\":8.13,\"\
- quantity\":1.0,\"reportingDate\":\"2019-06-26\",\"tax\":1.87,\"taxableAmount\"\
- :8.13,\"taxCalculated\":1.87,\"taxCode\":\"FR020100\",\"taxCodeId\":4784,\"\
- taxDate\":\"2019-06-26\",\"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\"\
- ,\"isNonPassThru\":false}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"\
- costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\"\
- :0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\"\
- ,\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\"\
- ,\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\"\
- :205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\"\
- :0,\"boundaryLevel\":\"Zip5\",\"line1\":\"2000 Main Street\",\"line2\":\"\"\
- ,\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\"\
- ,\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"0\",\"longitude\"\
- :\"0\"}],\"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.33,\"\
- rate\":0.230000,\"tax\":4.67,\"taxCalculated\":4.67,\"nonTaxable\":0.0,\"\
- exemption\":0.0}]}"
- headers:
- Connection:
- - keep-alive
- Content-Type:
- - application/json; charset=utf-8
- Date:
- - Wed, 26 Jun 2019 10:12:45 GMT
- Location:
- - /api/v2/companies/242975/transactions/0
- Server:
- - Kestrel
- ServerDuration:
- - '00:00:00.0876198'
- Transfer-Encoding:
- - chunked
- X-Content-Type-Options:
- - nosniff
- X-Powered-By:
- - ASP.NET
- status:
- code: 201
- message: Created
-version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-21.99-27.74-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-21.99-27.74-5.0-False].yaml
new file mode 100644
index 0000000000..3f94fc6bac
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-21.99-27.74-5.0-False].yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
+ false, "itemCode": "123", "description": "Test product"}, {"quantity": 1, "amount":
+ "10.00", "taxCode": "FR020100", "taxIncluded": false, "itemCode": "Shipping",
+ "description": null}], "code": "7261ba40-44a3-4e71-9497-663daa928169", "date":
+ "2020-08-21", "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main
+ Street", "line2": "", "city": "Irvine", "region": "CA", "country": "US", "postalCode":
+ "92614"}, "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW",
+ "region": "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": ""}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '762'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: "{\"id\":0,\"code\":\"7261ba40-44a3-4e71-9497-663daa928169\",\"companyId\"\
+ :242975,\"date\":\"2020-08-21\",\"paymentDate\":\"2020-08-21\",\"status\"\
+ :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
+ :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2020-08-21\"\
+ ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2020-08-21T09:53:02.2176238Z\"\
+ ,\"modifiedUserId\":283192,\"taxDate\":\"2020-08-21T00:00:00\",\"lines\":[{\"\
+ id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"Test product\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"123\",\"lineAmount\":15.00,\"quantity\":3.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":3.45,\"taxableAmount\":15.0,\"taxCalculated\":3.45,\"\
+ taxCode\":\"PC040156\",\"taxCodeId\":6622,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\"\
+ :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300P--US\"\
+ ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"Shipping\",\"lineAmount\":10.00,\"quantity\":1.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":2.3,\"taxableAmount\":10.0,\"taxCalculated\":2.3,\"\
+ taxCode\":\"FR020100\",\"taxCodeId\":4784,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\":[],\"\
+ hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\",\"\
+ vatNumberTypeId\":0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
+ :\"Zip5\",\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\"\
+ :\"WROCLAW\",\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\"\
+ ,\"taxRegionId\":205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"\
+ transactionId\":0,\"boundaryLevel\":\"Address\",\"line1\":\"2000 Main Street\"\
+ ,\"line2\":\"\",\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\"\
+ :\"92614\",\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"33.684716\"\
+ ,\"longitude\":\"-117.851489\"}],\"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-Length:
+ - '3331'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '0'
+ DatabaseDuration:
+ - 00:00:00
+ Date:
+ - Fri, 21 Aug 2020 09:53:02 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.0917739'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-22.32-26.99-0.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-22.32-26.99-0.0-True].yaml
new file mode 100644
index 0000000000..23992ab240
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total[True-22.32-26.99-0.0-True].yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
+ true, "itemCode": "123", "description": "Test product"}, {"quantity": 1, "amount":
+ "10.00", "taxCode": "FR020100", "taxIncluded": true, "itemCode": "Shipping",
+ "description": null}], "code": "302dbb02-9f03-4d28-aaf3-21bc80420ef0", "date":
+ "2020-08-21", "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main
+ Street", "line2": "", "city": "Irvine", "region": "CA", "country": "US", "postalCode":
+ "92614"}, "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW",
+ "region": "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": ""}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '760'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: "{\"id\":0,\"code\":\"302dbb02-9f03-4d28-aaf3-21bc80420ef0\",\"companyId\"\
+ :242975,\"date\":\"2020-08-21\",\"paymentDate\":\"2020-08-21\",\"status\"\
+ :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
+ :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2020-08-21\"\
+ ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2020-08-21T09:53:00.8812197Z\"\
+ ,\"modifiedUserId\":283192,\"taxDate\":\"2020-08-21T00:00:00\",\"lines\":[{\"\
+ id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"Test product\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"123\",\"lineAmount\":12.2,\"quantity\":3.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":2.8,\"taxableAmount\":12.2,\"taxCalculated\":2.8,\"\
+ taxCode\":\"PC040156\",\"taxCodeId\":6622,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\":[],\"\
+ hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300P--US\",\"\
+ vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\",\"\
+ discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"Shipping\",\"lineAmount\":8.13,\"quantity\":1.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":1.87,\"taxableAmount\":8.13,\"taxCalculated\":1.87,\"\
+ taxCode\":\"FR020100\",\"taxCodeId\":4784,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\"\
+ :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\"\
+ ,\"vatNumberTypeId\":0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
+ :\"Zip5\",\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\"\
+ :\"WROCLAW\",\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\"\
+ ,\"taxRegionId\":205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"\
+ transactionId\":0,\"boundaryLevel\":\"Address\",\"line1\":\"2000 Main Street\"\
+ ,\"line2\":\"\",\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\"\
+ :\"92614\",\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"33.684716\"\
+ ,\"longitude\":\"-117.851489\"}],\"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.33,\"rate\":0.230000,\"tax\":4.67,\"taxCalculated\":4.67,\"\
+ nonTaxable\":0.0,\"exemption\":0.0}]}"
+ headers:
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '3330'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '0'
+ DatabaseDuration:
+ - 00:00:00
+ Date:
+ - Fri, 21 Aug 2020 09:53:00 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.0847127'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[False-31.51-38.99-3.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[False-31.51-38.99-3.0-True].yaml
new file mode 100644
index 0000000000..d8e8066e46
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[False-31.51-38.99-3.0-True].yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
+ true, "itemCode": "123", "description": "Test product"}, {"quantity": 1, "amount":
+ "10.00", "taxCode": "FR020100", "taxIncluded": true, "itemCode": "Shipping",
+ "description": null}], "code": "94d932d1-b54d-49a9-964a-cca05489ca69", "date":
+ "2020-08-21", "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main
+ Street", "line2": "", "city": "Irvine", "region": "CA", "country": "US", "postalCode":
+ "92614"}, "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW",
+ "region": "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": ""}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '760'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: "{\"id\":0,\"code\":\"94d932d1-b54d-49a9-964a-cca05489ca69\",\"companyId\"\
+ :242975,\"date\":\"2020-08-21\",\"paymentDate\":\"2020-08-21\",\"status\"\
+ :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
+ :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2020-08-21\"\
+ ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2020-08-21T09:55:42.8885021Z\"\
+ ,\"modifiedUserId\":283192,\"taxDate\":\"2020-08-21T00:00:00\",\"lines\":[{\"\
+ id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"Test product\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"123\",\"lineAmount\":24.39,\"quantity\":3.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":5.61,\"taxableAmount\":24.39,\"taxCalculated\":5.61,\"\
+ taxCode\":\"PC040156\",\"taxCodeId\":6622,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\"\
+ :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300P--US\"\
+ ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"Shipping\",\"lineAmount\":8.13,\"quantity\":1.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":1.87,\"taxableAmount\":8.13,\"taxCalculated\":1.87,\"\
+ taxCode\":\"FR020100\",\"taxCodeId\":4784,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\"\
+ :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\"\
+ ,\"vatNumberTypeId\":0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
+ :\"Zip5\",\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\"\
+ :\"WROCLAW\",\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\"\
+ ,\"taxRegionId\":205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"\
+ transactionId\":0,\"boundaryLevel\":\"Address\",\"line1\":\"2000 Main Street\"\
+ ,\"line2\":\"\",\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\"\
+ :\"92614\",\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"33.684716\"\
+ ,\"longitude\":\"-117.851489\"}],\"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}]}"
+ headers:
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '3337'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '0'
+ DatabaseDuration:
+ - 00:00:00
+ Date:
+ - Fri, 21 Aug 2020 09:55:42 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.1078321'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[False-41.99-51.19-0.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[False-41.99-51.19-0.0-False].yaml
new file mode 100644
index 0000000000..39deb20545
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[False-41.99-51.19-0.0-False].yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "30.00", "taxCode": "PC040156", "taxIncluded":
+ false, "itemCode": "123", "description": "Test product"}, {"quantity": 1, "amount":
+ "10.00", "taxCode": "FR020100", "taxIncluded": false, "itemCode": "Shipping",
+ "description": null}], "code": "183d964e-0a28-47c3-a16a-4a71af2fd83e", "date":
+ "2020-08-21", "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main
+ Street", "line2": "", "city": "Irvine", "region": "CA", "country": "US", "postalCode":
+ "92614"}, "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW",
+ "region": "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": ""}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '762'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: "{\"id\":0,\"code\":\"183d964e-0a28-47c3-a16a-4a71af2fd83e\",\"companyId\"\
+ :242975,\"date\":\"2020-08-21\",\"paymentDate\":\"2020-08-21\",\"status\"\
+ :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
+ :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2020-08-21\",\"exchangeRate\"\
+ :1.0,\"email\":\"\",\"modifiedDate\":\"2020-08-21T09:55:41.5981021Z\",\"modifiedUserId\"\
+ :283192,\"taxDate\":\"2020-08-21T00:00:00\",\"lines\":[{\"id\":0,\"transactionId\"\
+ :0,\"lineNumber\":\"1\",\"description\":\"Test product\",\"discountAmount\"\
+ :0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\":true,\"itemCode\"\
+ :\"123\",\"lineAmount\":30.00,\"quantity\":3.0,\"reportingDate\":\"2020-08-21\"\
+ ,\"tax\":6.9,\"taxableAmount\":30.0,\"taxCalculated\":6.9,\"taxCode\":\"PC040156\"\
+ ,\"taxCodeId\":6622,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\":[],\"hsCode\":\"\",\"costInsuranceFreight\"\
+ :0.0,\"vatCode\":\"PLS-2300P--US\",\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\"\
+ :0,\"lineNumber\":\"2\",\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\"\
+ :0,\"isItemTaxable\":true,\"itemCode\":\"Shipping\",\"lineAmount\":10.00,\"\
+ quantity\":1.0,\"reportingDate\":\"2020-08-21\",\"tax\":2.3,\"taxableAmount\"\
+ :10.0,\"taxCalculated\":2.3,\"taxCode\":\"FR020100\",\"taxCodeId\":4784,\"\
+ taxDate\":\"2020-08-21\",\"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}],\"\
+ nonPassthroughDetails\":[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"\
+ vatCode\":\"PLS-2300F--US\",\"vatNumberTypeId\":0}],\"addresses\":[{\"id\"\
+ :0,\"transactionId\":0,\"boundaryLevel\":\"Zip5\",\"line1\":\"T\u0119czowa\
+ \ 7\",\"line2\":\"\",\"line3\":\"\",\"city\":\"WROCLAW\",\"region\":\"\",\"\
+ postalCode\":\"53-601\",\"country\":\"PL\",\"taxRegionId\":205102,\"latitude\"\
+ :\"0\",\"longitude\":\"0\"},{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
+ :\"Address\",\"line1\":\"2000 Main Street\",\"line2\":\"\",\"line3\":\"\"\
+ ,\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\":\"92614\",\"country\"\
+ :\"US\",\"taxRegionId\":4017409,\"latitude\":\"33.684716\",\"longitude\":\"\
+ -117.851489\"}],\"summary\":[{\"country\":\"PL\",\"region\":\"PL\",\"jurisType\"\
+ :\"Country\",\"jurisCode\":\"PL\",\"jurisName\":\"POLAND\",\"taxAuthorityType\"\
+ :45,\"stateAssignedNo\":\"\",\"taxType\":\"Output\",\"taxSubType\":\"O\",\"\
+ taxName\":\"Standard Rate\",\"rateType\":\"Standard\",\"taxable\":40.0,\"\
+ rate\":0.230000,\"tax\":9.2,\"taxCalculated\":9.2,\"nonTaxable\":0.0,\"exemption\"\
+ :0.0}]}"
+ headers:
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '3323'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '0'
+ DatabaseDuration:
+ - 00:00:00
+ Date:
+ - Fri, 21 Aug 2020 09:55:41 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.0843004'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[True-21.99-27.74-5.0-False].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[True-21.99-27.74-5.0-False].yaml
new file mode 100644
index 0000000000..a50e2a0fb4
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[True-21.99-27.74-5.0-False].yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
+ false, "itemCode": "123", "description": "Test product"}, {"quantity": 1, "amount":
+ "10.00", "taxCode": "FR020100", "taxIncluded": false, "itemCode": "Shipping",
+ "description": null}], "code": "fc9542c5-03eb-436c-a0fb-7ae54461f1b4", "date":
+ "2020-08-21", "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main
+ Street", "line2": "", "city": "Irvine", "region": "CA", "country": "US", "postalCode":
+ "92614"}, "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW",
+ "region": "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": ""}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '762'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: "{\"id\":0,\"code\":\"fc9542c5-03eb-436c-a0fb-7ae54461f1b4\",\"companyId\"\
+ :242975,\"date\":\"2020-08-21\",\"paymentDate\":\"2020-08-21\",\"status\"\
+ :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
+ :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2020-08-21\"\
+ ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2020-08-21T09:55:40.404618Z\"\
+ ,\"modifiedUserId\":283192,\"taxDate\":\"2020-08-21T00:00:00\",\"lines\":[{\"\
+ id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"Test product\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"123\",\"lineAmount\":15.00,\"quantity\":3.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":3.45,\"taxableAmount\":15.0,\"taxCalculated\":3.45,\"\
+ taxCode\":\"PC040156\",\"taxCodeId\":6622,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\"\
+ :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300P--US\"\
+ ,\"vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"Shipping\",\"lineAmount\":10.00,\"quantity\":1.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":2.3,\"taxableAmount\":10.0,\"taxCalculated\":2.3,\"\
+ taxCode\":\"FR020100\",\"taxCodeId\":4784,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\":[],\"\
+ hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\",\"\
+ vatNumberTypeId\":0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
+ :\"Zip5\",\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\"\
+ :\"WROCLAW\",\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\"\
+ ,\"taxRegionId\":205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"\
+ transactionId\":0,\"boundaryLevel\":\"Address\",\"line1\":\"2000 Main Street\"\
+ ,\"line2\":\"\",\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\"\
+ :\"92614\",\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"33.684716\"\
+ ,\"longitude\":\"-117.851489\"}],\"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-Length:
+ - '3330'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '0'
+ DatabaseDuration:
+ - 00:00:00
+ Date:
+ - Fri, 21 Aug 2020 09:55:40 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.0883820'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ status:
+ code: 201
+ message: Created
+version: 1
diff --git a/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[True-22.32-26.99-0.0-True].yaml b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[True-22.32-26.99-0.0-True].yaml
new file mode 100644
index 0000000000..b6384457c2
--- /dev/null
+++ b/saleor/plugins/avatax/tests/cassettes/test_calculate_checkout_total_uses_default_calculation[True-22.32-26.99-0.0-True].yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: '{"createTransactionModel": {"companyCode": "DEFAULT", "type": "SalesOrder",
+ "lines": [{"quantity": 3, "amount": "15.00", "taxCode": "PC040156", "taxIncluded":
+ true, "itemCode": "123", "description": "Test product"}, {"quantity": 1, "amount":
+ "10.00", "taxCode": "FR020100", "taxIncluded": true, "itemCode": "Shipping",
+ "description": null}], "code": "6d781c9c-baeb-4f8b-b0bc-a9003c0ae92b", "date":
+ "2020-08-21", "customerCode": 0, "addresses": {"shipFrom": {"line1": "2000 Main
+ Street", "line2": "", "city": "Irvine", "region": "CA", "country": "US", "postalCode":
+ "92614"}, "shipTo": {"line1": "T\u0119czowa 7", "line2": "", "city": "WROC\u0141AW",
+ "region": "", "country": "PL", "postalCode": "53-601"}}, "commit": false, "currencyCode":
+ "USD", "email": ""}}'
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Authorization:
+ - Basic Og==
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '760'
+ User-Agent:
+ - python-requests/2.24.0
+ method: POST
+ uri: https://sandbox-rest.avatax.com/api/v2/transactions/createoradjust
+ response:
+ body:
+ string: "{\"id\":0,\"code\":\"6d781c9c-baeb-4f8b-b0bc-a9003c0ae92b\",\"companyId\"\
+ :242975,\"date\":\"2020-08-21\",\"paymentDate\":\"2020-08-21\",\"status\"\
+ :\"Temporary\",\"type\":\"SalesOrder\",\"currencyCode\":\"USD\",\"customerVendorCode\"\
+ :\"0\",\"customerCode\":\"0\",\"reconciled\":false,\"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\":\"2020-08-21\"\
+ ,\"exchangeRate\":1.0,\"email\":\"\",\"modifiedDate\":\"2020-08-21T09:55:39.12401Z\"\
+ ,\"modifiedUserId\":283192,\"taxDate\":\"2020-08-21T00:00:00\",\"lines\":[{\"\
+ id\":0,\"transactionId\":0,\"lineNumber\":\"1\",\"description\":\"Test product\"\
+ ,\"discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"123\",\"lineAmount\":12.2,\"quantity\":3.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":2.8,\"taxableAmount\":12.2,\"taxCalculated\":2.8,\"\
+ taxCode\":\"PC040156\",\"taxCodeId\":6622,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\":[],\"\
+ hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300P--US\",\"\
+ vatNumberTypeId\":0},{\"id\":0,\"transactionId\":0,\"lineNumber\":\"2\",\"\
+ discountAmount\":0.0,\"exemptAmount\":0.0,\"exemptCertId\":0,\"isItemTaxable\"\
+ :true,\"itemCode\":\"Shipping\",\"lineAmount\":8.13,\"quantity\":1.0,\"reportingDate\"\
+ :\"2020-08-21\",\"tax\":1.87,\"taxableAmount\":8.13,\"taxCalculated\":1.87,\"\
+ taxCode\":\"FR020100\",\"taxCodeId\":4784,\"taxDate\":\"2020-08-21\",\"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}],\"nonPassthroughDetails\"\
+ :[],\"hsCode\":\"\",\"costInsuranceFreight\":0.0,\"vatCode\":\"PLS-2300F--US\"\
+ ,\"vatNumberTypeId\":0}],\"addresses\":[{\"id\":0,\"transactionId\":0,\"boundaryLevel\"\
+ :\"Zip5\",\"line1\":\"T\u0119czowa 7\",\"line2\":\"\",\"line3\":\"\",\"city\"\
+ :\"WROCLAW\",\"region\":\"\",\"postalCode\":\"53-601\",\"country\":\"PL\"\
+ ,\"taxRegionId\":205102,\"latitude\":\"0\",\"longitude\":\"0\"},{\"id\":0,\"\
+ transactionId\":0,\"boundaryLevel\":\"Address\",\"line1\":\"2000 Main Street\"\
+ ,\"line2\":\"\",\"line3\":\"\",\"city\":\"Irvine\",\"region\":\"CA\",\"postalCode\"\
+ :\"92614\",\"country\":\"US\",\"taxRegionId\":4017409,\"latitude\":\"33.684716\"\
+ ,\"longitude\":\"-117.851489\"}],\"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.33,\"rate\":0.230000,\"tax\":4.67,\"taxCalculated\":4.67,\"\
+ nonTaxable\":0.0,\"exemption\":0.0}]}"
+ headers:
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '3328'
+ Content-Type:
+ - application/json; charset=utf-8
+ DatabaseCalls:
+ - '0'
+ DatabaseDuration:
+ - 00:00:00
+ Date:
+ - Fri, 21 Aug 2020 09:55:39 GMT
+ Location:
+ - /api/v2/companies/242975/transactions/0
+ Server:
+ - Kestrel
+ ServerDuration:
+ - '00:00:00.0844088'
+ ServiceDuration:
+ - 00:00:00
+ X-Content-Type-Options:
+ - nosniff
+ 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 7ccdfabba3..d01c01fc42 100644
--- a/saleor/plugins/avatax/tests/test_avatax.py
+++ b/saleor/plugins/avatax/tests/test_avatax.py
@@ -1,19 +1,25 @@
+from json import JSONDecodeError
from unittest.mock import Mock
import pytest
from django.core.exceptions import ValidationError
from prices import Money, TaxedMoney
+from requests import RequestException
from ....checkout.utils import add_variant_to_checkout
from ....core.prices import quantize_price
-from ....core.taxes import TaxError
+from ....core.taxes import TaxError, TaxType
from ...manager import get_plugins_manager
from ...models import PluginConfiguration
from .. import (
+ META_CODE_KEY,
+ META_DESCRIPTION_KEY,
AvataxConfiguration,
- checkout_needs_new_fetch,
+ api_get_request,
+ api_post_request,
generate_request_data_from_checkout,
get_cached_tax_codes_or_fetch,
+ taxes_need_new_fetch,
)
from ..plugin import AvataxPlugin
@@ -93,10 +99,75 @@ def test_calculate_checkout_line_total(
@pytest.mark.parametrize(
"with_discount, expected_net, expected_gross, voucher_amount, taxes_in_prices",
[
- (True, "20.33", "25.00", "0.0", True),
- (True, "20.00", "25.75", "5.0", False),
- (False, "40.00", "49.20", "0.0", False),
- (False, "29.52", "37.00", "3.0", True),
+ (True, "22.32", "26.99", "0.0", True),
+ (True, "21.99", "27.74", "5.0", False),
+ (False, "41.99", "51.19", "0.0", False),
+ (False, "31.51", "38.99", "3.0", True),
+ ],
+)
+def test_calculate_checkout_total_uses_default_calculation(
+ with_discount,
+ expected_net,
+ expected_gross,
+ voucher_amount,
+ taxes_in_prices,
+ checkout_with_item,
+ product_with_single_variant,
+ discount_info,
+ shipping_zone,
+ address,
+ address_usa,
+ site_settings,
+ monkeypatch,
+ plugin_configuration,
+ non_default_category,
+):
+ plugin_configuration()
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
+ lambda _: {"PC040156": "desc"},
+ )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
+ checkout_with_item.shipping_address = address
+ checkout_with_item.save()
+ site_settings.company_address = address_usa
+ site_settings.include_taxes_in_prices = taxes_in_prices
+ site_settings.save()
+
+ voucher_amount = Money(voucher_amount, "USD")
+ checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
+ 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, "PC040156")
+ product.save()
+
+ product_with_single_variant.charge_taxes = False
+ product_with_single_variant.category = non_default_category
+ product_with_single_variant.save()
+ add_variant_to_checkout(
+ checkout_with_item, product_with_single_variant.variants.get()
+ )
+
+ discounts = [discount_info] if with_discount else None
+ total = manager.calculate_checkout_total(
+ checkout_with_item, list(checkout_with_item), discounts
+ )
+ 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, "22.32", "26.99", "0.0", True),
+ (True, "21.99", "27.74", "5.0", False),
+ (False, "41.99", "51.19", "0.0", False),
+ (False, "31.51", "38.99", "3.0", True),
],
)
def test_calculate_checkout_total(
@@ -106,6 +177,7 @@ def test_calculate_checkout_total(
voucher_amount,
taxes_in_prices,
checkout_with_item,
+ product_with_single_variant,
discount_info,
shipping_zone,
address,
@@ -113,17 +185,22 @@ def test_calculate_checkout_total(
site_settings,
monkeypatch,
plugin_configuration,
+ non_default_category,
):
plugin_configuration()
monkeypatch.setattr(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
lambda _: {"PC040156": "desc"},
)
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.plugin.AvataxPlugin._skip_plugin", lambda *_: False
+ )
manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
checkout_with_item.shipping_address = address
checkout_with_item.save()
site_settings.company_address = address_usa
site_settings.include_taxes_in_prices = taxes_in_prices
+ site_settings.save()
voucher_amount = Money(voucher_amount, "USD")
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
@@ -134,6 +211,13 @@ def test_calculate_checkout_total(
manager.assign_tax_code_to_object_meta(product, "PC040156")
product.save()
+ product_with_single_variant.charge_taxes = False
+ product_with_single_variant.category = non_default_category
+ product_with_single_variant.save()
+ add_variant_to_checkout(
+ checkout_with_item, product_with_single_variant.variants.get()
+ )
+
discounts = [discount_info] if with_discount else None
total = manager.calculate_checkout_total(
checkout_with_item, list(checkout_with_item), discounts
@@ -348,14 +432,29 @@ def test_get_cached_tax_codes_or_fetch_wrong_response(monkeypatch):
assert len(tax_codes) == 0
-def test_checkout_needs_new_fetch(monkeypatch, checkout_with_item, address):
+def test_taxes_need_new_fetch(monkeypatch, checkout_with_item, address):
monkeypatch.setattr("saleor.plugins.avatax.cache.get", lambda x: None)
checkout_with_item.shipping_address = address
config = AvataxConfiguration(
username_or_account="wrong_data", password_or_license="wrong_data"
)
checkout_data = generate_request_data_from_checkout(checkout_with_item, config)
- assert checkout_needs_new_fetch(checkout_data, str(checkout_with_item.token))
+ assert taxes_need_new_fetch(checkout_data, str(checkout_with_item.token))
+
+
+def test_taxes_need_new_fetch_uses_cached_data(
+ monkeypatch, checkout_with_item, address
+):
+
+ checkout_with_item.shipping_address = address
+ config = AvataxConfiguration(
+ username_or_account="wrong_data", password_or_license="wrong_data"
+ )
+ checkout_data = generate_request_data_from_checkout(checkout_with_item, config)
+ monkeypatch.setattr(
+ "saleor.plugins.avatax.cache.get", lambda x: [checkout_data, None]
+ )
+ assert not taxes_need_new_fetch(checkout_data, str(checkout_with_item.token))
def test_get_plugin_configuration(settings):
@@ -479,3 +578,77 @@ def test_skip_disabled_plugin(settings, plugin_configuration):
)
is True
)
+
+
+def test_get_tax_code_from_object_meta(product, settings, plugin_configuration):
+ product.store_value_in_metadata(
+ {META_CODE_KEY: "KEY", META_DESCRIPTION_KEY: "DESC"}
+ )
+ plugin_configuration(username=None, password=None)
+ settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
+ manager = get_plugins_manager()
+ tax_type = manager.get_tax_code_from_object_meta(product)
+
+ assert isinstance(tax_type, TaxType)
+ assert tax_type.code == "KEY"
+ assert tax_type.description == "DESC"
+
+
+def test_api_get_request_handles_request_errors(product, monkeypatch):
+ mocked_response = Mock(side_effect=RequestException())
+ monkeypatch.setattr("saleor.plugins.avatax.requests.get", mocked_response)
+
+ config = AvataxConfiguration(
+ username_or_account="test", password_or_license="test", use_sandbox=False,
+ )
+ url = "https://www.avatax.api.com/some-get-path"
+
+ response = api_get_request(url, config)
+
+ assert response == {}
+ assert mocked_response.called
+
+
+def test_api_get_request_handles_json_errors(product, monkeypatch):
+ mocked_response = Mock(side_effect=JSONDecodeError("", "", 0))
+ monkeypatch.setattr("saleor.plugins.avatax.requests.get", mocked_response)
+
+ config = AvataxConfiguration(
+ username_or_account="test", password_or_license="test", use_sandbox=False,
+ )
+ url = "https://www.avatax.api.com/some-get-path"
+
+ response = api_get_request(url, config)
+
+ assert response == {}
+ assert mocked_response.called
+
+
+def test_api_post_request_handles_request_errors(product, monkeypatch):
+ mocked_response = Mock(side_effect=RequestException())
+ monkeypatch.setattr("saleor.plugins.avatax.requests.post", mocked_response)
+
+ config = AvataxConfiguration(
+ username_or_account="test", password_or_license="test", use_sandbox=False,
+ )
+ url = "https://www.avatax.api.com/some-get-path"
+
+ response = api_post_request(url, {}, config)
+
+ assert mocked_response.called
+ assert response == {}
+
+
+def test_api_post_request_handles_json_errors(product, monkeypatch):
+ mocked_response = Mock(side_effect=JSONDecodeError("", "", 0))
+ monkeypatch.setattr("saleor.plugins.avatax.requests.post", mocked_response)
+
+ config = AvataxConfiguration(
+ username_or_account="test", password_or_license="test", use_sandbox=False,
+ )
+ url = "https://www.avatax.api.com/some-get-path"
+
+ response = api_post_request(url, {}, config)
+
+ assert mocked_response.called
+ assert response == {}
diff --git a/saleor/plugins/avatax/tests/test_tasks.py b/saleor/plugins/avatax/tests/test_tasks.py
new file mode 100644
index 0000000000..b613694392
--- /dev/null
+++ b/saleor/plugins/avatax/tests/test_tasks.py
@@ -0,0 +1,91 @@
+from dataclasses import asdict
+from urllib.parse import urljoin
+
+import pytest
+
+from ....core.taxes import TaxError
+from ....order import OrderEvents
+from .. import AvataxConfiguration, get_api_url, get_order_request_data
+from ..tasks import api_post_request_task
+
+
+def test_api_post_request_task_sends_request(
+ order_with_lines, address_usa, shipping_zone, site_settings
+):
+ method = shipping_zone.shipping_methods.get()
+ 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.save()
+
+ site_settings.company_address = address_usa
+ site_settings.save()
+
+ config = AvataxConfiguration(
+ username_or_account="", password_or_license="", use_sandbox=False,
+ )
+ request_data = get_order_request_data(order_with_lines, config)
+
+ transaction_url = urljoin(
+ get_api_url(config.use_sandbox), "transactions/createoradjust"
+ )
+ api_post_request_task(
+ transaction_url, request_data, asdict(config), order_with_lines.id
+ )
+
+
+def test_api_post_request_task_creates_order_event(
+ order_with_lines, address_usa, shipping_zone, site_settings
+):
+ method = shipping_zone.shipping_methods.get()
+ 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.save()
+
+ site_settings.company_address = address_usa
+ site_settings.save()
+
+ config = AvataxConfiguration(
+ username_or_account="", password_or_license="", use_sandbox=False,
+ )
+ request_data = get_order_request_data(order_with_lines, config)
+
+ transaction_url = urljoin(
+ get_api_url(config.use_sandbox), "transactions/createoradjust"
+ )
+ api_post_request_task(
+ transaction_url, request_data, asdict(config), order_with_lines.id
+ )
+
+ expected_event_msg = f"Order sent to Avatax. Order ID: {order_with_lines.token}"
+ assert order_with_lines.events.count() == 1
+ event = order_with_lines.events.get()
+ assert event.type == OrderEvents.EXTERNAL_SERVICE_NOTIFICATION
+ assert event.parameters["message"] == expected_event_msg
+
+
+def test_api_post_request_task_missing_response(
+ order_with_lines, shipping_zone, monkeypatch
+):
+ monkeypatch.setattr("saleor.plugins.avatax.tasks.api_post_request", lambda *_: {})
+
+ config = AvataxConfiguration(
+ username_or_account="test", password_or_license="test", use_sandbox=False,
+ )
+ request_data = {}
+
+ transaction_url = urljoin(
+ get_api_url(config.use_sandbox), "transactions/createoradjust"
+ )
+ with pytest.raises(TaxError):
+ api_post_request_task(
+ transaction_url, request_data, asdict(config), order_with_lines.pk
+ )
+
+ assert order_with_lines.events.count() == 1
+ event = order_with_lines.events.get()
+ assert event.type == OrderEvents.EXTERNAL_SERVICE_NOTIFICATION
+ assert event.parameters["message"] == "Unable to send order to Avatax."
diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.py
index 51aa9d68c2..bf23525cd8 100644
--- a/saleor/plugins/manager.py
+++ b/saleor/plugins/manager.py
@@ -110,8 +110,11 @@ class PluginsManager(PaymentInterface):
discount=checkout.discount,
currency=checkout.currency,
)
- return self.__run_method_on_plugins(
- "calculate_checkout_total", default_value, checkout, lines, discounts
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "calculate_checkout_total", default_value, checkout, lines, discounts
+ ),
+ checkout.currency,
)
def calculate_checkout_subtotal(
@@ -126,8 +129,11 @@ class PluginsManager(PaymentInterface):
default_value = base_calculations.base_checkout_subtotal(
line_totals, checkout.currency
)
- return self.__run_method_on_plugins(
- "calculate_checkout_subtotal", default_value, checkout, lines, discounts
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "calculate_checkout_subtotal", default_value, checkout, lines, discounts
+ ),
+ checkout.currency,
)
def calculate_checkout_shipping(
@@ -137,8 +143,11 @@ class PluginsManager(PaymentInterface):
discounts: Iterable[DiscountInfo],
) -> TaxedMoney:
default_value = base_calculations.base_checkout_shipping_price(checkout, lines)
- return self.__run_method_on_plugins(
- "calculate_checkout_shipping", default_value, checkout, lines, discounts
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "calculate_checkout_shipping", default_value, checkout, lines, discounts
+ ),
+ checkout.currency,
)
def calculate_order_shipping(self, order: "Order") -> TaxedMoney:
@@ -149,8 +158,11 @@ class PluginsManager(PaymentInterface):
TaxedMoney(net=shipping_price, gross=shipping_price),
shipping_price.currency,
)
- return self.__run_method_on_plugins(
- "calculate_order_shipping", default_value, order
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "calculate_order_shipping", default_value, order
+ ),
+ order.currency,
)
def calculate_checkout_line_total(
@@ -159,15 +171,21 @@ class PluginsManager(PaymentInterface):
default_value = base_calculations.base_checkout_line_total(
checkout_line, discounts
)
- return self.__run_method_on_plugins(
- "calculate_checkout_line_total", default_value, checkout_line, discounts
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "calculate_checkout_line_total", default_value, checkout_line, discounts
+ ),
+ checkout_line.checkout.currency,
)
def calculate_order_line_unit(self, order_line: "OrderLine") -> TaxedMoney:
unit_price = order_line.unit_price
default_value = quantize_price(unit_price, unit_price.currency)
- return self.__run_method_on_plugins(
- "calculate_order_line_unit", default_value, order_line
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "calculate_order_line_unit", default_value, order_line
+ ),
+ order_line.currency,
)
def get_tax_rate_type_choices(self) -> List[TaxType]:
@@ -184,8 +202,11 @@ class PluginsManager(PaymentInterface):
default_value = quantize_price(
TaxedMoney(net=price, gross=price), price.currency
)
- return self.__run_method_on_plugins(
- "apply_taxes_to_product", default_value, product, price, country
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "apply_taxes_to_product", default_value, product, price, country
+ ),
+ price.currency,
)
def apply_taxes_to_shipping(
@@ -194,8 +215,11 @@ class PluginsManager(PaymentInterface):
default_value = quantize_price(
TaxedMoney(net=price, gross=price), price.currency
)
- return self.__run_method_on_plugins(
- "apply_taxes_to_shipping", default_value, price, shipping_address
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "apply_taxes_to_shipping", default_value, price, shipping_address
+ ),
+ price.currency,
)
def apply_taxes_to_shipping_price_range(self, prices: MoneyRange, country: Country):
@@ -204,8 +228,11 @@ class PluginsManager(PaymentInterface):
default_value = quantize_price(
TaxedMoneyRange(start=start, stop=stop), start.currency
)
- return self.__run_method_on_plugins(
- "apply_taxes_to_shipping_price_range", default_value, prices, country
+ return quantize_price(
+ self.__run_method_on_plugins(
+ "apply_taxes_to_shipping_price_range", default_value, prices, country
+ ),
+ start.currency,
)
def preprocess_order_creation(