Skip to content

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

Merge branch 'master' into fix-none-reaching-quantize-price

IKarbowiak4c8ee3fe5a24
diff --cc CHANGELOG.md
index 0573429ec0,b4af403968..8ca7224312
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -48,8 -49,8 +49,9 @@@ All notable, unreleased changes to thi
- Do not allow negative product price - #6091 by @IKarbowiak
- Handle None as attribute value - #6092 by @IKarbowiak
- Fix for calling order_created before the order was saved - #6095 by @korycins
+ - Update default decimal places - #6098 by @IKarbowiak
- Avoid assigning the same pictures twice to a variant - #6112 by @IKarbowiak
+- Fix crashing system when avalara is improperly configured - #6117 by @IKarbowiak
## 2.10.2
diff --cc saleor/graphql/order/tests/test_order.py
index 258e430027,079a2e7640..f2b3dd3dca
--- a/saleor/graphql/order/tests/test_order.py
+++ b/saleor/graphql/order/tests/test_order.py
@@@ -558,42 -558,6 +558,42 @@@ def test_query_order_as_app(app_api_cli
assert order_data["token"] == order.token
+DRAFT_ORDER_CREATE_MUTATION = """
+mutation draftCreate(
- $user: ID, $discount: Decimal, $lines: [OrderLineCreateInput],
++ $user: ID, $discount: PositiveDecimal, $lines: [OrderLineCreateInput],
+ $shippingAddress: AddressInput, $shippingMethod: ID, $voucher: ID,
+ $customerNote: String) {
+ draftOrderCreate(
+ input: {user: $user, discount: $discount,
+ lines: $lines, shippingAddress: $shippingAddress,
+ shippingMethod: $shippingMethod, voucher: $voucher,
+ customerNote: $customerNote}) {
+ orderErrors {
+ field
+ message
+ code
+ }
+ order {
+ discount {
+ amount
+ }
+ discountName
+ lines {
+ productName
+ productSku
+ quantity
+ }
+ status
+ voucher {
+ code
+ }
+ customerNote
+ }
+ }
+ }
+"""
+
+
def test_draft_order_create(
staff_api_client,
permission_manage_orders,
diff --cc saleor/plugins/avatax/tests/test_avatax.py
index 8fce5065d4,8d5693d96e..62118d976e
--- a/saleor/plugins/avatax/tests/test_avatax.py
+++ b/saleor/plugins/avatax/tests/test_avatax.py
@@@ -763,53 -704,8 +790,54 @@@ def test_get_order_request_data_checks_
request_data = get_order_request_data(order_with_lines, config)
lines_data = request_data["createTransactionModel"]["lines"]
line_without_taxes = [line for line in lines_data if line["taxIncluded"] is False]
+ # if order line has different .net and .gross we already added tax to it
lines_with_taxes = [line for line in lines_data if line["taxIncluded"] is True]
- assert len(line_without_taxes) == 1
- assert len(lines_with_taxes) == 2
+ assert len(line_without_taxes) == 2
+ assert len(lines_with_taxes) == 1
+
+ assert line_without_taxes[0]["itemCode"] == line.product_sku
+
+
+@patch("saleor.plugins.avatax.get_order_request_data")
+@patch("saleor.plugins.avatax.get_cached_response_or_fetch")
+def test_get_order_tax_data(
+ get_cached_response_or_fetch_mock,
+ get_order_request_data_mock,
+ order,
+ plugin_configuration,
+):
+ # given
+ conf = plugin_configuration()
+
+ return_value = {"id": 0, "code": "3d4893da", "companyId": 123}
+ get_cached_response_or_fetch_mock.return_value = return_value
+
+ # when
+ response = get_order_tax_data(order, conf)
+
+ # then
+ get_order_request_data_mock.assert_called_once_with(order, conf)
+ assert response == return_value
+
+
+@patch("saleor.plugins.avatax.get_order_request_data")
+@patch("saleor.plugins.avatax.get_cached_response_or_fetch")
+def test_get_order_tax_data_raised_error(
+ get_cached_response_or_fetch_mock,
+ get_order_request_data_mock,
+ order,
+ plugin_configuration,
+):
+ # given
+ conf = plugin_configuration()
+
+ return_value = {"error": {"message": "test error"}}
+ get_cached_response_or_fetch_mock.return_value = return_value
+
+ # when
+ with pytest.raises(TaxError) as e:
+ get_order_tax_data(order, conf)
+
+ # then
+ assert e._excinfo[1].args[0] == return_value["error"]