Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Allow proper price calculations for draft orders created in OrderBulkCreate mutation (#17583)
Iga Karbowiake5ff65b54ecd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1007b608f2..232faf58e2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -108,3 +108,4 @@ All notable, unreleased changes to this project will be documented in this file.- Allow to change Admin email plugin custom templates back to default - #17563 by @wcislo-saleor- Fixes incorrect gift card balances after covering the full order total - #17566 by @korycins- Fixes tax class not clearing when selecting a shipping method without a tax class - #17560 by @korycins+- The prices for draft orders created in `OrderBulkCreate` now are properly calculated - #17583 by @IKarbowiakdiff --git a/saleor/graphql/order/bulk_mutations/order_bulk_create.py b/saleor/graphql/order/bulk_mutations/order_bulk_create.pyindex 3a574357fe..68c003ee70 100644--- a/saleor/graphql/order/bulk_mutations/order_bulk_create.py+++ b/saleor/graphql/order/bulk_mutations/order_bulk_create.py@@ -24,7 +24,12 @@ from ....core.prices import quantize_pricefrom ....core.tracing import traced_atomic_transactionfrom ....core.utils.url import validate_storefront_urlfrom ....core.weight import zero_weight-from ....discount.models import OrderDiscount, VoucherCode+from ....discount.models import (+ DiscountType,+ OrderDiscount,+ OrderLineDiscount,+ VoucherCode,+)from ....discount.utils.manual_discount import apply_discount_to_valuefrom ....giftcard.models import GiftCardfrom ....invoice.models import Invoice@@ -44,7 +49,7 @@ from ....payment.models import TransactionEvent, TransactionItemfrom ....permission.enums import OrderPermissionsfrom ....product.models import ProductVariantfrom ....shipping.models import ShippingMethod, ShippingMethodChannelListing-from ....tax.models import TaxClass+from ....tax.models import TaxClass, TaxConfigurationfrom ....warehouse.management import stock_bulk_updatefrom ....warehouse.models import Stock, Warehousefrom ...account.i18n import I18nMixin@@ -102,6 +107,7 @@ class OrderBulkFulfillment:@dataclassclass OrderBulkOrderLine:line: OrderLine+ line_discount: OrderLineDiscount | Nonewarehouse: Warehouse@@ -125,6 +131,7 @@ class OrderBulkCreateData:user: User | None = Nonebilling_address: Address | None = Nonechannel: Channel | None = None+ tax_configuration: TaxConfiguration | None = Noneshipping_address: Address | None = Nonevoucher_code: VoucherCode | None = None# error which ignores error policy and disqualify order@@ -164,6 +171,14 @@ class OrderBulkCreateData:def all_order_lines(self) -> list[OrderLine]:return [order_line.line for order_line in self.lines]+ @property+ def all_order_line_discounts(self) -> list[OrderLineDiscount]:+ return [+ order_line.line_discount+ for order_line in self.lines+ if order_line.line_discount+ ]+@propertydef all_fulfillment_lines(self) -> list[FulfillmentLine]:return [@@ -276,6 +291,8 @@ class LineAmounts:total_net: Decimalunit_gross: Decimalunit_net: Decimal+ base_unit_price: Decimal+ undiscounted_base_unit_price: Decimalunit_discount_value: Decimalunit_discount_type: str | Noneunit_discount_reason: str | None@@ -765,6 +782,9 @@ class OrderBulkCreate(BaseMutation, I18nMixin):| Q(external_reference__in=identifiers.variant_external_references.keys))channels = Channel.objects.filter(slug__in=identifiers.channel_slugs.keys)+ tax_configurations = TaxConfiguration.objects.filter(+ channel_id__in=channels.values("id")+ )voucher_codes = VoucherCode.objects.filter(code__in=identifiers.voucher_codes.keys).select_related("voucher")@@ -803,6 +823,11 @@ class OrderBulkCreate(BaseMutation, I18nMixin):for channel in channels:object_storage[f"Channel.slug.{channel.slug}"] = channel+ for tax_configuration in tax_configurations:+ object_storage[+ f"TaxConfiguration.channel_id.{tax_configuration.channel_id}"+ ] = tax_configuration+for voucher_code in voucher_codes:object_storage[f"VoucherCode.code.{voucher_code.code}"] = voucher_code@@ -1039,6 +1064,12 @@ class OrderBulkCreate(BaseMutation, I18nMixin):object_storage=object_storage,)+ tax_configuration = None+ if channel:+ tax_configuration = object_storage.get(+ f"TaxConfiguration.channel_id.{channel.id}"+ )+billing_address: Address | None = Nonebilling_address_input = order_input["billing_address"]metadata_list: list[MetadataInput] = billing_address_input.pop("metadata", None)@@ -1125,6 +1156,7 @@ class OrderBulkCreate(BaseMutation, I18nMixin):order_data.user = userorder_data.channel = channel+ order_data.tax_configuration = tax_configurationorder_data.billing_address = billing_addressorder_data.shipping_address = shipping_addressorder_data.voucher_code = voucher_code@@ -1238,11 +1270,26 @@ class OrderBulkCreate(BaseMutation, I18nMixin):))+ prices_entered_with_tax = True+ if tax_configuration := order_data.tax_configuration:+ prices_entered_with_tax = tax_configuration.prices_entered_with_tax++ undiscounted_base_unit_price_amount = (+ undiscounted_unit_price_gross_amount+ if prices_entered_with_tax+ else undiscounted_unit_price_net_amount+ )+ base_unit_price = undiscounted_base_unit_price_amount+ if unit_discount_amount:+ base_unit_price -= unit_discount_amount+return LineAmounts(total_gross=gross_amount,total_net=net_amount,unit_gross=unit_price_gross_amount,unit_net=unit_price_net_amount,+ base_unit_price=base_unit_price,+ undiscounted_base_unit_price=undiscounted_base_unit_price_amount,unit_discount_reason=unit_discount_reason,unit_discount_type=unit_discount_type,unit_discount_value=unit_discount_value,@@ -1738,11 +1785,27 @@ class OrderBulkCreate(BaseMutation, I18nMixin):undiscounted_unit_price_gross_amount=line_amounts.undiscounted_unit_gross,undiscounted_total_price_net_amount=line_amounts.undiscounted_total_net,undiscounted_total_price_gross_amount=line_amounts.undiscounted_total_gross,+ base_unit_price_amount=line_amounts.base_unit_price,+ undiscounted_base_unit_price_amount=line_amounts.undiscounted_base_unit_price,unit_discount_amount=line_amounts.unit_discount_amount,tax_rate=line_amounts.tax_rate,tax_class=line_tax_class,tax_class_name=order_line_input.get("tax_class_name"),)+ line_discount = None+ if line_amounts.unit_discount_amount > 0:+ discount_amount = line_amounts.unit_discount_amount * line_amounts.quantity+ line_discount = OrderLineDiscount(+ line=order_line,+ unique_type=DiscountType.MANUAL,+ type=DiscountType.MANUAL,+ value_type=line_amounts.unit_discount_type+ or DiscountValueTypeEnum.FIXED.name, # type: ignore[attr-defined]+ value=line_amounts.unit_discount_value,+ amount_value=discount_amount,+ currency=order_line.currency,+ reason=line_amounts.unit_discount_reason,+ )if metadata := order_line_input.get("metadata"):cls.process_metadata(@@ -1775,7 +1838,9 @@ class OrderBulkCreate(BaseMutation, I18nMixin):field=order_line.tax_class_private_metadata,)- return OrderBulkOrderLine(line=order_line, warehouse=warehouse)+ return OrderBulkOrderLine(+ line=order_line, line_discount=line_discount, warehouse=warehouse+ )@classmethoddef create_single_fulfillment(@@ -2286,6 +2351,16 @@ class OrderBulkCreate(BaseMutation, I18nMixin):)OrderLine.objects.bulk_create(order_lines)+ order_line_discounts: list[OrderLineDiscount] = sum(+ [+ order_data.all_order_line_discounts+ for order_data in orders_data+ if order_data.order+ ],+ [],+ )+ OrderLineDiscount.objects.bulk_create(order_line_discounts)+notes = [notefor order_data in orders_datadiff --git a/saleor/graphql/order/tests/integration/test_bulk_order.py b/saleor/graphql/order/tests/integration/test_bulk_order.pyindex 58674de139..7a88586538 100644--- a/saleor/graphql/order/tests/integration/test_bulk_order.py+++ b/saleor/graphql/order/tests/integration/test_bulk_order.py@@ -6,9 +6,12 @@ import grapheneimport pytestfrom saleor.order import OrderEvents-from saleor.order.models import Order+from saleor.order.models import Order, OrderLinefrom saleor.payment.models import TransactionItem+from .....order.calculations import fetch_order_prices_if_expired+from .....plugins.manager import get_plugins_manager+from ....discount.enums import DiscountValueTypeEnumfrom ....order.enums import OrderStatusEnumfrom ....payment.enums import TransactionActionEnumfrom ....payment.tests.mutations.test_transaction_request_action import (@@ -301,3 +304,104 @@ def test_filter_imported_orders(assert data_1["edges"][0]["node"]["id"] == order_2_idassert data_2["totalCount"] == 1assert data_2["edges"][0]["node"]["id"] == order_3_id+++def test_refresh_order_prices_from_imported_draft_order_with_unit_discount(+ staff_api_client,+ permission_manage_orders_import,+ permission_group_manage_orders,+ order_bulk_input, # noqa: F811+ product,+ channel_USD,+):+ # given+ staff_api_client.user.user_permissions.add(permission_manage_orders_import)+ permission_group_manage_orders.user_set.add(staff_api_client.user)++ # when+ # import draft order from external system+ order = order_bulk_input+ order["status"] = OrderStatusEnum.DRAFT.name+ order["deliveryMethod"] = None+ order["channel"] = channel_USD.slug+ order["currency"] = "USD"+ order["fulfillments"] = []+ order["transactions"] = []+ order["invoices"] = []+ order["discounts"] = []++ discount_type = DiscountValueTypeEnum.FIXED.name+ discount_value = 10+ discount_reason = "Test discount"+ variant = product.variants.first()+ order["lines"][0]["variantId"] = graphene.Node.to_global_id(+ "ProductVariant", variant.id+ )+ order["lines"][0]["isShippingRequired"] = False+ order["lines"][0]["unitDiscountValue"] = discount_value+ order["lines"][0]["unitDiscountType"] = discount_type+ order["lines"][0]["unitDiscountReason"] = discount_reason++ line_total_price_net = 50+ line_total_price_gross = 60+ order["lines"][0]["totalPrice"]["net"] = line_total_price_net+ order["lines"][0]["totalPrice"]["gross"] = line_total_price_gross++ variables = {+ "orders": [order],+ "stockUpdatePolicy": StockUpdatePolicyEnum.UPDATE.name,+ }++ response = staff_api_client.post_graphql(ORDER_BULK_CREATE, variables)+ content = get_graphql_content(response)++ data = content["data"]["orderBulkCreate"]["results"]+ assert not data[0]["errors"]++ order_response_data = data[0]["order"]++ order_line = order_response_data["lines"][0]+ assert order_line["variant"]["id"] == graphene.Node.to_global_id(+ "ProductVariant", variant.id+ )+ assert order_line["unitDiscountType"] == discount_type+ assert order_line["unitDiscountValue"] == discount_value+ assert order_line["unitDiscountReason"] == discount_reason+ assert order_response_data["total"]["net"]["amount"] == line_total_price_net+ assert order_response_data["total"]["gross"]["amount"] == line_total_price_gross+ assert (+ order_response_data["undiscountedTotal"]["net"]["amount"]+ == order["lines"][0]["undiscountedTotalPrice"]["net"]+ )+ assert (+ order_response_data["undiscountedTotal"]["gross"]["amount"]+ == order["lines"][0]["undiscountedTotalPrice"]["gross"]+ )+ assert order_response_data["shippingPrice"]["gross"]["amount"] == 0+ assert order_response_data["shippingPrice"]["net"]["amount"] == 0++ db_order_line = OrderLine.objects.get()+ assert db_order_line.variant == variant+ assert db_order_line.unit_discount_type == discount_type.lower()+ assert db_order_line.unit_discount_value == discount_value+ assert db_order_line.unit_discount_reason == discount_reason++ assert order_response_data++ # refetch order prices+ order = Order.objects.get()+ order, lines = fetch_order_prices_if_expired(+ order, get_plugins_manager(allow_replica=True), force_update=True+ )++ # then - ensure the order prices are updated, the discount is applied+ line = lines[0]+ assert line.unit_discount_type == discount_type.lower()+ assert line.unit_discount_value == discount_value+ assert line.unit_discount_reason == discount_reason+ assert (+ line.undiscounted_total_price_net_amount - line.total_price_net_amount+ ) / line.quantity == line.unit_discount_amount+ assert order.total_net_amount == line.total_price_net_amount+ assert order.total_gross_amount == line.total_price_gross_amountdiff --git a/saleor/graphql/order/tests/mutations/test_order_bulk_create.py b/saleor/graphql/order/tests/mutations/test_order_bulk_create.pyindex b38c9fd993..5f972dbcfc 100644--- a/saleor/graphql/order/tests/mutations/test_order_bulk_create.py+++ b/saleor/graphql/order/tests/mutations/test_order_bulk_create.py@@ -110,6 +110,14 @@ ORDER_BULK_CREATE = """amount}}+ undiscountedTotalPrice{+ gross {+ amount+ }+ net {+ amount+ }+ }metadata {keyvaluediff --git a/saleor/tests/e2e/orders/test_able_to_update_draft_order_after_bulk_order_creation_with_line_discount.py b/saleor/tests/e2e/orders/test_able_to_update_draft_order_after_bulk_order_creation_with_line_discount.pynew file mode 100644index 0000000000..5d8aa1f85a--- /dev/null+++ b/saleor/tests/e2e/orders/test_able_to_update_draft_order_after_bulk_order_creation_with_line_discount.py@@ -0,0 +1,231 @@+import graphene+from django.utils import timezone++from .. import DEFAULT_ADDRESS+from ..product.utils.preparing_product import prepare_product+from ..shop.utils.preparing_shop import prepare_shop+from ..taxes.utils import update_country_tax_rates+from ..utils import assert_address_data, assign_permissions+from .utils import draft_order_update, order_bulk_create, order_query+++def prepare_order_bulk_create_input(+ customer_user,+ product_variant_id,+ warehouse_id,+ shipping_method_id,+ channel_slug,+ currency,+ tax_class_id,+ line_discount_data,+):+ user = {+ "id": graphene.Node.to_global_id("User", customer_user.id),+ "email": None,+ }+ delivery_method = {+ "shippingMethodId": shipping_method_id,+ "shippingMethodName": "Denormalized name",+ "shippingPrice": {+ "gross": 60,+ "net": 50,+ },+ "shippingTaxRate": 0.2,+ "shippingTaxClassId": tax_class_id,+ "shippingTaxClassName": "Denormalized name",+ }+ line = {+ "variantId": product_variant_id,+ "createdAt": timezone.now(),+ "productName": "Product Name",+ "variantName": "Variant Name",+ "translatedProductName": "Nazwa Produktu",+ "translatedVariantName": "Nazwa Wariantu",+ "isShippingRequired": True,+ "isGiftCard": False,+ "quantity": 5,+ "totalPrice": {+ "gross": 120,+ "net": 100,+ },+ "undiscountedTotalPrice": {+ "gross": 120,+ "net": 100,+ },+ "taxRate": 0.2,+ "taxClassId": tax_class_id,+ "warehouse": warehouse_id,+ "metadata": [{"key": "md key", "value": "md value"}],+ "privateMetadata": [{"key": "pmd key", "value": "pmd value"}],+ **line_discount_data,+ }+ return {+ "channel": channel_slug,+ "createdAt": timezone.now(),+ "status": "DRAFT",+ "user": user,+ "billingAddress": DEFAULT_ADDRESS,+ "shippingAddress": DEFAULT_ADDRESS,+ "currency": currency,+ "languageCode": "PL",+ "deliveryMethod": delivery_method,+ "lines": [line],+ "weight": "10.15",+ "redirectUrl": "https://www.example.com",+ "metadata": [{"key": "md key", "value": "md value"}],+ "privateMetadata": [{"key": "pmd key", "value": "pmd value"}],+ }+++def test_able_to_update_draft_order_after_bulk_order_creation_with_line_discount_CORE_0258(+ e2e_staff_api_client,+ e2e_logged_api_client,+ shop_permissions,+ permission_manage_product_types_and_attributes,+ permission_manage_orders,+ permission_manage_orders_import,+):+ # Before+ permissions = [+ *shop_permissions,+ permission_manage_product_types_and_attributes,+ permission_manage_orders,+ permission_manage_orders_import,+ ]+ assign_permissions(e2e_staff_api_client, permissions)++ shipping_country = "US"+ shipping_class_tax_rate = 8+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": True,+ "tax_rates": [+ {+ "type": "shipping_country",+ "name": "Shipping Country Tax Rate",+ "country_code": shipping_country,+ "rate": shipping_class_tax_rate,+ },+ ],+ }+ price = 10++ shop_data, tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {+ "add_channels": {},+ },+ {+ "name": "Another shipping method",+ "add_channels": {},+ },+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ tax_settings=tax_settings,+ )+ channel_data = shop_data[0]+ channel_id = channel_data["id"]+ channel_slug = channel_data["slug"]+ currency = channel_data["currency"]+ warehouse_id = channel_data["warehouse_id"]+ shipping_method_id = channel_data["shipping_zones"][0]["shipping_methods"][0]["id"]+ shipping_method_id_2 = channel_data["shipping_zones"][0]["shipping_methods"][1][+ "id"+ ]+ tax_class_id = tax_config[0]["shipping_country_tax_class_id"]++ update_country_tax_rates(+ e2e_staff_api_client,+ shipping_country,+ [{"rate": shipping_class_tax_rate}],+ )++ _product_id, product_variant_id, _product_variant_price = prepare_product(+ e2e_staff_api_client,+ warehouse_id,+ channel_id,+ price,+ )++ line_discount_data = {+ "unitDiscountValue": 10,+ "unitDiscountType": "FIXED",+ "unitDiscountReason": "Test discount",+ "totalPrice": {+ "net": 50,+ "gross": 60,+ },+ }+ order_input = prepare_order_bulk_create_input(+ e2e_logged_api_client.user,+ product_variant_id,+ warehouse_id,+ shipping_method_id,+ channel_slug,+ currency,+ tax_class_id,+ line_discount_data,+ )++ # Step 1 - Create order with order bulk create+ create_order_response = order_bulk_create(e2e_staff_api_client, [order_input])++ assert create_order_response["count"] == 1++ draft_order = create_order_response["results"][0]["order"]+ assert draft_order+ order_id = draft_order["id"]+ assert len(draft_order["lines"]) == 1+ line = draft_order["lines"][0]+ assert line["unitDiscountValue"] == line_discount_data["unitDiscountValue"]+ assert line["unitDiscountType"] == line_discount_data["unitDiscountType"]+ assert line["unitDiscountReason"] == line_discount_data["unitDiscountReason"]+ assert line["unitDiscount"]["amount"] == line_discount_data["unitDiscountValue"]++ # Step 2 - Update delivery method+ address = DEFAULT_ADDRESS+ address["firstName"] = "New name"+ input = {+ "shippingMethod": shipping_method_id_2,+ "billingAddress": DEFAULT_ADDRESS, # force the price recalculation+ }+ draft_order = draft_order_update(+ e2e_staff_api_client,+ order_id,+ input,+ )++ order_shipping_id = draft_order["order"]["deliveryMethod"]["id"]+ assert order_shipping_id == shipping_method_id_2+ order_billing_address = draft_order["order"]["billingAddress"]+ assert_address_data(order_billing_address, address)++ # Step 3 - Ensure that the line discount is still applied+ draft_order = order_query(e2e_staff_api_client, order_id)++ assert draft_order+ assert len(draft_order["lines"]) == 1+ line = draft_order["lines"][0]+ assert line["unitDiscountValue"] == line_discount_data["unitDiscountValue"]+ assert line["unitDiscountType"] == line_discount_data["unitDiscountType"]+ assert line["unitDiscountReason"] == line_discount_data["unitDiscountReason"]+ assert line["unitDiscount"]["amount"] == line_discount_data["unitDiscountValue"]+ assert (+ line["undiscountedUnitPrice"]["gross"]["amount"] * line["quantity"]+ - line["totalPrice"]["gross"]["amount"]+ ) / 5 == line["unitDiscount"]["amount"]+ assert (+ draft_order["subtotal"]["gross"]["amount"]+ == line["totalPrice"]["gross"]["amount"]+ )diff --git a/saleor/tests/e2e/orders/utils/__init__.py b/saleor/tests/e2e/orders/utils/__init__.pyindex c637dc63de..29d5561675 100644--- a/saleor/tests/e2e/orders/utils/__init__.py+++ b/saleor/tests/e2e/orders/utils/__init__.py@@ -3,6 +3,7 @@ from .draft_order_complete import draft_order_complete, raw_draft_order_completefrom .draft_order_create import draft_order_createfrom .draft_order_delete import draft_order_deletefrom .draft_order_update import draft_order_update, raw_draft_order_update+from .order_bulk_create import order_bulk_createfrom .order_by_checkout_id_query import order_by_checkout_id_queryfrom .order_cancel import order_cancelfrom .order_create_from_checkout import (@@ -25,6 +26,7 @@ from .order_update_shipping import order_update_shippingfrom .order_void import order_void, raw_order_void__all__ = [+ "order_bulk_create","raw_draft_order_complete","draft_order_create","order_lines_create",diff --git a/saleor/tests/e2e/orders/utils/fragments.py b/saleor/tests/e2e/orders/utils/fragments.pynew file mode 100644index 0000000000..b92cfd554c--- /dev/null+++ b/saleor/tests/e2e/orders/utils/fragments.py@@ -0,0 +1,75 @@+ORDER_LINE_FRAGMENT = """+fragment OrderLine on OrderLine {+ id+ variant {+ id+ }+ productName+ productSku+ variantName+ translatedVariantName+ translatedProductName+ productVariantId+ isShippingRequired+ quantity+ quantityFulfilled+ unitPrice {+ gross {+ amount+ }+ net {+ amount+ }+ }+ unitDiscount {+ amount+ }+ unitDiscountValue+ unitDiscountReason+ unitDiscountType+ totalPrice {+ gross {+ amount+ }+ net {+ amount+ }+ }+ undiscountedUnitPrice{+ gross {+ amount+ }+ net {+ amount+ }+ }+ undiscountedTotalPrice{+ gross {+ amount+ }+ net {+ amount+ }+ }+ metadata {+ key+ value+ }+ privateMetadata {+ key+ value+ }+ taxClass {+ id+ }+ taxClassName+ taxRate+ taxClassMetadata {+ key+ value+ }+ taxClassPrivateMetadata {+ key+ value+ }+}"""diff --git a/saleor/tests/e2e/orders/utils/order_bulk_create.py b/saleor/tests/e2e/orders/utils/order_bulk_create.pynew file mode 100644index 0000000000..246f9e3fa9--- /dev/null+++ b/saleor/tests/e2e/orders/utils/order_bulk_create.py@@ -0,0 +1,203 @@+from saleor.graphql.tests.utils import get_graphql_content++from .fragments import ORDER_LINE_FRAGMENT++ORDER_BULK_CREATE_MUTATION = (+ """+ mutation OrderBulkCreate(+ $orders: [OrderBulkCreateInput!]!,+ $errorPolicy: ErrorPolicyEnum,+ $stockUpdatePolicy: StockUpdatePolicyEnum+) {+ orderBulkCreate(+ orders: $orders,+ errorPolicy: $errorPolicy,+ stockUpdatePolicy: $stockUpdatePolicy+ ) {+ count+ results {+ order {+ id+ user {+ id+ }+ metadata {+ key+ value+ }+ privateMetadata {+ key+ value+ }+ lines {+ ...OrderLine+ }+ billingAddress{+ postalCode+ metadata{+ key+ value+ }+ }+ shippingAddress{+ postalCode+ metadata{+ key+ value+ }+ }+ shippingMethodName+ shippingTaxClass{+ name+ }+ shippingTaxClassName+ shippingTaxClassMetadata {+ key+ value+ }+ shippingTaxClassPrivateMetadata {+ key+ value+ }+ shippingPrice {+ gross {+ amount+ }+ net {+ amount+ }+ }+ subtotal{+ gross {+ amount+ }+ net {+ amount+ }+ }+ total{+ gross {+ amount+ }+ net {+ amount+ }+ }+ undiscountedTotal{+ gross {+ amount+ }+ net {+ amount+ }+ }+ events {+ message+ user {+ id+ }+ app {+ id+ }+ }+ weight {+ value+ }+ externalReference+ trackingClientId+ displayGrossPrices+ channel {+ slug+ }+ status+ created+ languageCode+ collectionPointName+ redirectUrl+ origin+ fulfillments {+ lines {+ id+ quantity+ orderLine {+ id+ }+ }+ trackingNumber+ fulfillmentOrder+ status+ }+ transactions {+ id+ pspReference+ message+ name+ authorizedAmount {+ amount+ currency+ }+ canceledAmount{+ currency+ amount+ }+ chargedAmount{+ currency+ amount+ }+ refundedAmount{+ currency+ amount+ }+ events {+ amount {+ amount+ }+ type+ }+ }+ invoices {+ number+ url+ }+ discounts {+ type+ valueType+ value+ reason+ }+ voucher {+ id+ code+ }+ voucherCode+ }+ errors {+ path+ message+ code+ }+ }+ errors {+ message+ code+ }+ }+}+"""+ + ORDER_LINE_FRAGMENT+)+++def order_bulk_create(api_client, orders):+ variables = {"orders": orders}++ response = api_client.post_graphql(+ ORDER_BULK_CREATE_MUTATION,+ variables=variables,+ )+ content = get_graphql_content(response)++ data = content["data"]["orderBulkCreate"]++ return datadiff --git a/saleor/tests/e2e/orders/utils/order_query.py b/saleor/tests/e2e/orders/utils/order_query.pyindex 95c9226258..c9a290d304 100644--- a/saleor/tests/e2e/orders/utils/order_query.py+++ b/saleor/tests/e2e/orders/utils/order_query.py@@ -1,5 +1,6 @@from ...account.utils.fragments import ADDRESS_FRAGMENTfrom ...utils import get_graphql_content+from .fragments import ORDER_LINE_FRAGMENTORDER_QUERY = ("""@@ -59,10 +60,38 @@ query OrderDetails($id: ID!) {keyvalue}+ lines {+ ...OrderLine+ }+ subtotal{+ gross {+ amount+ }+ net {+ amount+ }+ }+ total{+ gross {+ amount+ }+ net {+ amount+ }+ }+ undiscountedTotal{+ gross {+ amount+ }+ net {+ amount+ }+ }}}"""+ ADDRESS_FRAGMENT+ + ORDER_LINE_FRAGMENT)diff --git a/saleor/tests/e2e/shop/utils/preparing_shop.py b/saleor/tests/e2e/shop/utils/preparing_shop.pyindex 7861559a4d..99d8ec3859 100644--- a/saleor/tests/e2e/shop/utils/preparing_shop.py+++ b/saleor/tests/e2e/shop/utils/preparing_shop.py@@ -75,6 +75,7 @@ def prepare_shop("id": channel_id,"warehouse_id": warehouse_id,"slug": created_channel["slug"],+ "currency": created_channel["currencyCode"],"shipping_zones": [],"order_settings": created_channel["orderSettings"],"checkout_settings": created_channel["checkoutSettings"],