Skip to content

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

Rename flag to useLegacyLineDiscountPropagation (#17637)

Maciej Korycinski5535108c2b59
diff --git a/saleor/channel/migrations/0021_rename_use_legacy_line_voucher_propagation_for_order_channel_use_legacy_line_discount_propagation_fo.py b/saleor/channel/migrations/0021_rename_use_legacy_line_voucher_propagation_for_order_channel_use_legacy_line_discount_propagation_fo.py
new file mode 100644
index 0000000000..f8ce53c59a
--- /dev/null
+++ b/saleor/channel/migrations/0021_rename_use_legacy_line_voucher_propagation_for_order_channel_use_legacy_line_discount_propagation_fo.py
@@ -0,0 +1,17 @@
+# Generated by Django 4.2.20 on 2025-04-23 09:32
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("channel", "0020_channel_use_legacy_line_voucher_propagation_for_order"),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name="channel",
+ old_name="use_legacy_line_voucher_propagation_for_order",
+ new_name="use_legacy_line_discount_propagation_for_order",
+ ),
+ ]
diff --git a/saleor/channel/models.py b/saleor/channel/models.py
index 2a55f3390d..207eaebcec 100644
--- a/saleor/channel/models.py
+++ b/saleor/channel/models.py
@@ -56,7 +56,7 @@ class Channel(ModelWithMetadata):
# line lvl discounts for orders created from checkout are stored as
# OrderLineDiscount. This flag controls how we should return it via API.
- use_legacy_line_voucher_propagation_for_order = models.BooleanField(default=True)
+ use_legacy_line_discount_propagation_for_order = models.BooleanField(default=True)
class Meta(ModelWithMetadata.Meta):
ordering = ("slug",)
diff --git a/saleor/checkout/complete_checkout.py b/saleor/checkout/complete_checkout.py
index 1e10fdd32a..34d2683945 100644
--- a/saleor/checkout/complete_checkout.py
+++ b/saleor/checkout/complete_checkout.py
@@ -361,7 +361,7 @@ def _create_line_for_order(
undiscounted_unit_price=undiscounted_unit_price,
base_unit_price=base_unit_price,
undiscounted_base_unit_price=undiscounted_base_unit_price,
- use_legacy_voucher_propagation=checkout_info.channel.use_legacy_line_voucher_propagation_for_order,
+ use_legacy_discount_propagation=checkout_info.channel.use_legacy_line_discount_propagation_for_order,
prices_entered_with_tax=prices_entered_with_tax,
)
@@ -405,7 +405,7 @@ def _create_line_for_order(
if checkout_info.voucher and is_order_level_voucher(checkout_info.voucher)
else None
),
- use_legacy_voucher_propagation=checkout_info.channel.use_legacy_line_voucher_propagation_for_order,
+ use_legacy_discount_propagation=checkout_info.channel.use_legacy_line_discount_propagation_for_order,
)
if line_discounts:
@@ -433,20 +433,20 @@ def _get_unit_discount(
undiscounted_unit_price: TaxedMoney,
base_unit_price: Money,
undiscounted_base_unit_price: Money,
- use_legacy_voucher_propagation: bool,
+ use_legacy_discount_propagation: bool,
prices_entered_with_tax: bool,
) -> Money:
"""Returng the discount applicable on single line.
- When `use_legacy_voucher_propagation` is `True`, the discount
- amount includes the `ENTIRE_ORDER` voucher discount. This is
- already reflected in the order-level discounts, but to maintain
+ When `use_legacy_discount_propagation` is `True`, the discount
+ amount includes the `ENTIRE_ORDER` voucher discount, and OrderPromotion discount.
+ This is already reflected in the order-level discounts, but to maintain
backward compatibility, the legacy flow behaves as before.
- When `use_legacy_voucher_propagation` is `False`, the
+ When `use_legacy_discount_propagation` is `False`, the
`unit_discount` includes only the order-line level discounts.
"""
- if use_legacy_voucher_propagation:
+ if use_legacy_discount_propagation:
discount_price = undiscounted_unit_price - unit_price
if prices_entered_with_tax:
return discount_price.gross
@@ -457,10 +457,10 @@ def _get_unit_discount(
def _get_unit_discount_reason(
line_discounts: list[OrderLineDiscount],
order_lvl_voucher_code: str | None,
- use_legacy_voucher_propagation: bool,
+ use_legacy_discount_propagation: bool,
) -> str | None:
include_entire_order_lvl_reason = (
- order_lvl_voucher_code and use_legacy_voucher_propagation
+ order_lvl_voucher_code and use_legacy_discount_propagation
)
if not include_entire_order_lvl_reason and not line_discounts:
return None
@@ -493,7 +493,7 @@ def _create_order_line_discount_object_for_voucher(
code = checkout_line_info.voucher_code
discount_reason = f"Voucher code: {code}"
- if channel.use_legacy_line_voucher_propagation_for_order:
+ if channel.use_legacy_line_discount_propagation_for_order:
# Previously voucher discount was always set as fixed value. To keep it in the
# same way as previously we force the fixed type when legacy flow is used
value_type = DiscountValueType.FIXED
diff --git a/saleor/graphql/channel/mutations/channel_create.py b/saleor/graphql/channel/mutations/channel_create.py
index 7d42270a7f..423d069b26 100644
--- a/saleor/graphql/channel/mutations/channel_create.py
+++ b/saleor/graphql/channel/mutations/channel_create.py
@@ -150,7 +150,7 @@ class OrderSettingsInput(BaseInputObjectType):
),
)
- use_legacy_line_voucher_propagation = graphene.Boolean(
+ use_legacy_line_discount_propagation = graphene.Boolean(
required=False,
description=(
"This flag only affects orders created from checkout and applies "
diff --git a/saleor/graphql/channel/mutations/utils.py b/saleor/graphql/channel/mutations/utils.py
index 5e23ab400c..877a55ecdb 100644
--- a/saleor/graphql/channel/mutations/utils.py
+++ b/saleor/graphql/channel/mutations/utils.py
@@ -84,12 +84,12 @@ def clean_input_order_settings(
# For newly created channels, by default use new discount propagation flow
if instance.pk is None:
- cleaned_input["use_legacy_line_voucher_propagation_for_order"] = False
+ cleaned_input["use_legacy_line_discount_propagation_for_order"] = False
- if order_settings.get("use_legacy_line_voucher_propagation") is not None:
- cleaned_input["use_legacy_line_voucher_propagation_for_order"] = order_settings[
- "use_legacy_line_voucher_propagation"
- ]
+ if order_settings.get("use_legacy_line_discount_propagation") is not None:
+ cleaned_input["use_legacy_line_discount_propagation_for_order"] = (
+ order_settings["use_legacy_line_discount_propagation"]
+ )
def clean_input_checkout_settings(checkout_settings: dict, cleaned_input: dict):
diff --git a/saleor/graphql/channel/tests/mutations/test_channel_create.py b/saleor/graphql/channel/tests/mutations/test_channel_create.py
index d7f6636895..61e21ab68a 100644
--- a/saleor/graphql/channel/tests/mutations/test_channel_create.py
+++ b/saleor/graphql/channel/tests/mutations/test_channel_create.py
@@ -48,7 +48,7 @@ CHANNEL_CREATE_MUTATION = """
allowUnpaidOrders
includeDraftOrderInVoucherUsage
draftOrderLinePriceFreezePeriod
- useLegacyLineVoucherPropagation
+ useLegacyLineDiscountPropagation
}
checkoutSettings {
useLegacyErrorFlow
@@ -901,7 +901,7 @@ def test_channel_create_set_allow_unpaid_orders(
("use_legacy_input", "expected_result"),
[(True, True), (False, False), (None, False)],
)
-def test_channel_create_set_use_legacy_line_voucher_propagation(
+def test_channel_create_set_use_legacy_line_discount_propagation(
use_legacy_input,
expected_result,
permission_manage_channels,
@@ -918,7 +918,7 @@ def test_channel_create_set_use_legacy_line_voucher_propagation(
"slug": slug,
"currencyCode": currency_code,
"defaultCountry": default_country,
- "orderSettings": {"useLegacyLineVoucherPropagation": use_legacy_input},
+ "orderSettings": {"useLegacyLineDiscountPropagation": use_legacy_input},
}
}
@@ -936,7 +936,7 @@ def test_channel_create_set_use_legacy_line_voucher_propagation(
channel_data = data["channel"]
channel = Channel.objects.get()
assert (
- channel_data["orderSettings"]["useLegacyLineVoucherPropagation"]
+ channel_data["orderSettings"]["useLegacyLineDiscountPropagation"]
== expected_result
)
- assert channel.use_legacy_line_voucher_propagation_for_order == expected_result
+ assert channel.use_legacy_line_discount_propagation_for_order == expected_result
diff --git a/saleor/graphql/channel/tests/mutations/test_channel_update.py b/saleor/graphql/channel/tests/mutations/test_channel_update.py
index 899ef37103..c1f69ae704 100644
--- a/saleor/graphql/channel/tests/mutations/test_channel_update.py
+++ b/saleor/graphql/channel/tests/mutations/test_channel_update.py
@@ -48,7 +48,7 @@ CHANNEL_UPDATE_MUTATION = """
allowUnpaidOrders
includeDraftOrderInVoucherUsage
draftOrderLinePriceFreezePeriod
- useLegacyLineVoucherPropagation
+ useLegacyLineDiscountPropagation
}
}
errors{
@@ -1643,7 +1643,7 @@ def test_channel_update_default_transaction_flow_strategy_with_payment_permissio
(None, False, False),
],
)
-def test_channel_update_set_use_legacy_line_voucher_propagation(
+def test_channel_update_set_use_legacy_line_discount_propagation(
use_legacy_input,
expected_result,
current_value_on_db,
@@ -1652,14 +1652,14 @@ def test_channel_update_set_use_legacy_line_voucher_propagation(
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = current_value_on_db
+ channel_USD.use_legacy_line_discount_propagation_for_order = current_value_on_db
channel_USD.save()
channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)
variables = {
"id": channel_id,
"input": {
- "orderSettings": {"useLegacyLineVoucherPropagation": use_legacy_input},
+ "orderSettings": {"useLegacyLineDiscountPropagation": use_legacy_input},
},
}
@@ -1677,7 +1677,7 @@ def test_channel_update_set_use_legacy_line_voucher_propagation(
channel_data = data["channel"]
channel_USD.refresh_from_db()
assert (
- channel_data["orderSettings"]["useLegacyLineVoucherPropagation"]
+ channel_data["orderSettings"]["useLegacyLineDiscountPropagation"]
== expected_result
)
- assert channel_USD.use_legacy_line_voucher_propagation_for_order == expected_result
+ assert channel_USD.use_legacy_line_discount_propagation_for_order == expected_result
diff --git a/saleor/graphql/channel/tests/queries/test_channel.py b/saleor/graphql/channel/tests/queries/test_channel.py
index ba2da86afa..906f0f05fb 100644
--- a/saleor/graphql/channel/tests/queries/test_channel.py
+++ b/saleor/graphql/channel/tests/queries/test_channel.py
@@ -312,7 +312,7 @@ QUERY_CHANNEL_ORDER_SETTINGS = """
allowUnpaidOrders
includeDraftOrderInVoucherUsage
draftOrderLinePriceFreezePeriod
- useLegacyLineVoucherPropagation
+ useLegacyLineDiscountPropagation
}
}
}
@@ -375,8 +375,8 @@ def test_query_channel_order_settings_as_staff_user(
)
assert (
- channel_data["orderSettings"]["useLegacyLineVoucherPropagation"]
- == channel_USD.use_legacy_line_voucher_propagation_for_order
+ channel_data["orderSettings"]["useLegacyLineDiscountPropagation"]
+ == channel_USD.use_legacy_line_discount_propagation_for_order
)
@@ -429,8 +429,8 @@ def test_query_channel_order_settings_as_app(
== channel_USD.draft_order_line_price_freeze_period
)
assert (
- channel_data["orderSettings"]["useLegacyLineVoucherPropagation"]
- == channel_USD.use_legacy_line_voucher_propagation_for_order
+ channel_data["orderSettings"]["useLegacyLineDiscountPropagation"]
+ == channel_USD.use_legacy_line_discount_propagation_for_order
)
diff --git a/saleor/graphql/channel/types.py b/saleor/graphql/channel/types.py
index e28c2b9c2a..970d4dafc0 100644
--- a/saleor/graphql/channel/types.py
+++ b/saleor/graphql/channel/types.py
@@ -211,7 +211,7 @@ class OrderSettings(ObjectType):
),
)
- use_legacy_line_voucher_propagation = graphene.Boolean(
+ use_legacy_line_discount_propagation = graphene.Boolean(
required=True,
description=(
"This flag only affects orders created from checkout and applies "
@@ -530,8 +530,8 @@ class Channel(ModelObjectType):
draft_order_line_price_freeze_period=(
root.draft_order_line_price_freeze_period
),
- use_legacy_line_voucher_propagation=(
- root.use_legacy_line_voucher_propagation_for_order
+ use_legacy_line_discount_propagation=(
+ root.use_legacy_line_discount_propagation_for_order
),
)
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py b/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py
index 74612092b5..4748b9804b 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py
@@ -911,7 +911,7 @@ def test_checkout_complete_requires_confirmation(
@pytest.mark.parametrize(
(
- "legacy_voucher_propagation",
+ "legacy_discount_propagation",
"expected_unit_discount_amount",
"expected_unit_discount_reason",
),
@@ -922,7 +922,7 @@ def test_checkout_complete_requires_confirmation(
)
@pytest.mark.integration
def test_checkout_with_voucher_complete(
- legacy_voucher_propagation,
+ legacy_discount_propagation,
expected_unit_discount_amount,
expected_unit_discount_reason,
user_api_client,
@@ -934,7 +934,7 @@ def test_checkout_with_voucher_complete(
):
# given
channel = checkout_with_voucher_percentage.channel
- channel.use_legacy_line_voucher_propagation_for_order = legacy_voucher_propagation
+ channel.use_legacy_line_discount_propagation_for_order = legacy_discount_propagation
channel.save()
code = voucher_percentage.codes.first()
@@ -1057,7 +1057,7 @@ def test_checkout_with_order_promotion_complete(
checkout = checkout_with_item_and_order_discount
channel = checkout.channel
- channel.use_legacy_line_voucher_propagation_for_order = legacy_propagation
+ channel.use_legacy_line_discount_propagation_for_order = legacy_propagation
channel.save()
checkout.shipping_address = address
@@ -1139,7 +1139,7 @@ def test_checkout_with_order_promotion_complete(
@pytest.mark.parametrize(
(
- "use_legacy_voucher_propagation",
+ "use_legacy_discount_propagation",
"expected_voucher_discount_value_type",
"expected_voucher_discount_value",
),
@@ -1150,7 +1150,7 @@ def test_checkout_with_order_promotion_complete(
)
@pytest.mark.integration
def test_checkout_complete_with_voucher_apply_once_per_order(
- use_legacy_voucher_propagation,
+ use_legacy_discount_propagation,
expected_voucher_discount_value_type,
expected_voucher_discount_value,
user_api_client,
@@ -1162,8 +1162,8 @@ def test_checkout_complete_with_voucher_apply_once_per_order(
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = (
- use_legacy_voucher_propagation
+ channel_USD.use_legacy_line_discount_propagation_for_order = (
+ use_legacy_discount_propagation
)
channel_USD.save()
@@ -1428,7 +1428,7 @@ def test_checkout_with_voucher_complete_product_on_promotion(
@pytest.mark.parametrize(
(
- "use_legacy_voucher_propagation",
+ "use_legacy_discount_propagation",
"expected_voucher_discount_value_type",
"expected_voucher_discount_value",
),
@@ -1438,7 +1438,7 @@ def test_checkout_with_voucher_complete_product_on_promotion(
],
)
def test_checkout_with_voucher_on_specific_product_complete(
- use_legacy_voucher_propagation,
+ use_legacy_discount_propagation,
expected_voucher_discount_value_type,
expected_voucher_discount_value,
user_api_client,
@@ -1450,8 +1450,8 @@ def test_checkout_with_voucher_on_specific_product_complete(
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = (
- use_legacy_voucher_propagation
+ channel_USD.use_legacy_line_discount_propagation_for_order = (
+ use_legacy_discount_propagation
)
channel_USD.save()
@@ -2532,7 +2532,7 @@ def test_checkout_complete_product_on_old_sale(
@pytest.mark.parametrize(
(
- "use_legacy_voucher_propagation",
+ "use_legacy_discount_propagation",
"expected_voucher_discount_value_type",
"expected_voucher_discount_value",
),
@@ -2542,7 +2542,7 @@ def test_checkout_complete_product_on_old_sale(
],
)
def test_checkout_with_voucher_on_specific_product_complete_with_product_on_promotion(
- use_legacy_voucher_propagation,
+ use_legacy_discount_propagation,
expected_voucher_discount_value_type,
expected_voucher_discount_value,
user_api_client,
@@ -2555,8 +2555,8 @@ def test_checkout_with_voucher_on_specific_product_complete_with_product_on_prom
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = (
- use_legacy_voucher_propagation
+ channel_USD.use_legacy_line_discount_propagation_for_order = (
+ use_legacy_discount_propagation
)
channel_USD.save()
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py b/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py
index b4e3ff50e8..2dd74025ec 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py
@@ -1945,7 +1945,7 @@ def test_checkout_complete_with_variant_without_sku(
@pytest.mark.parametrize(
(
- "legacy_voucher_propagation",
+ "legacy_discount_propagation",
"expected_unit_discount_amount",
"expected_unit_discount_reason",
),
@@ -1956,7 +1956,7 @@ def test_checkout_complete_with_variant_without_sku(
)
@pytest.mark.integration
def test_checkout_with_voucher_complete(
- legacy_voucher_propagation,
+ legacy_discount_propagation,
expected_unit_discount_amount,
expected_unit_discount_reason,
user_api_client,
@@ -1969,7 +1969,7 @@ def test_checkout_with_voucher_complete(
):
# given
channel = checkout_with_voucher_percentage.channel
- channel.use_legacy_line_voucher_propagation_for_order = legacy_voucher_propagation
+ channel.use_legacy_line_discount_propagation_for_order = legacy_discount_propagation
channel.save()
code = voucher_percentage.codes.first()
@@ -2075,7 +2075,7 @@ def test_checkout_with_order_promotion_complete(
checkout = checkout_with_item_and_order_discount
channel = checkout.channel
- channel.use_legacy_line_voucher_propagation_for_order = legacy_propagation
+ channel.use_legacy_line_discount_propagation_for_order = legacy_propagation
channel.save()
checkout = prepare_checkout_for_test(
@@ -2354,7 +2354,7 @@ def test_checkout_complete_with_voucher_paid_with_gift_card(
@pytest.mark.parametrize(
(
- "use_legacy_voucher_propagation",
+ "use_legacy_discount_propagation",
"expected_voucher_discount_value_type",
"expected_voucher_discount_value",
),
@@ -2365,7 +2365,7 @@ def test_checkout_complete_with_voucher_paid_with_gift_card(
)
@pytest.mark.integration
def test_checkout_complete_with_voucher_apply_once_per_order(
- use_legacy_voucher_propagation,
+ use_legacy_discount_propagation,
expected_voucher_discount_value_type,
expected_voucher_discount_value,
user_api_client,
@@ -2378,8 +2378,8 @@ def test_checkout_complete_with_voucher_apply_once_per_order(
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = (
- use_legacy_voucher_propagation
+ channel_USD.use_legacy_line_discount_propagation_for_order = (
+ use_legacy_discount_propagation
)
channel_USD.save()
@@ -2908,7 +2908,7 @@ def test_checkout_with_voucher_complete_product_on_sale(
@pytest.mark.parametrize(
(
- "use_legacy_voucher_propagation",
+ "use_legacy_discount_propagation",
"expected_voucher_discount_value_type",
"expected_voucher_discount_value",
),
@@ -2918,7 +2918,7 @@ def test_checkout_with_voucher_complete_product_on_sale(
],
)
def test_checkout_with_voucher_on_specific_product_complete(
- use_legacy_voucher_propagation,
+ use_legacy_discount_propagation,
expected_voucher_discount_value_type,
expected_voucher_discount_value,
user_api_client,
@@ -2931,8 +2931,8 @@ def test_checkout_with_voucher_on_specific_product_complete(
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = (
- use_legacy_voucher_propagation
+ channel_USD.use_legacy_line_discount_propagation_for_order = (
+ use_legacy_discount_propagation
)
channel_USD.save()
@@ -3386,7 +3386,7 @@ def test_checkout_complete_multiple_rules_applied(
@pytest.mark.parametrize(
(
- "use_legacy_voucher_propagation",
+ "use_legacy_discount_propagation",
"expected_voucher_discount_value_type",
"expected_voucher_discount_value",
),
@@ -3396,7 +3396,7 @@ def test_checkout_complete_multiple_rules_applied(
],
)
def test_checkout_with_voucher_on_specific_product_complete_with_product_on_promotion(
- use_legacy_voucher_propagation,
+ use_legacy_discount_propagation,
expected_voucher_discount_value_type,
expected_voucher_discount_value,
user_api_client,
@@ -3410,8 +3410,8 @@ def test_checkout_with_voucher_on_specific_product_complete_with_product_on_prom
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = (
- use_legacy_voucher_propagation
+ channel_USD.use_legacy_line_discount_propagation_for_order = (
+ use_legacy_discount_propagation
)
channel_USD.save()
diff --git a/saleor/graphql/order/tests/queries/test_order.py b/saleor/graphql/order/tests/queries/test_order.py
index 856ec6cd0c..2d4349d52f 100644
--- a/saleor/graphql/order/tests/queries/test_order.py
+++ b/saleor/graphql/order/tests/queries/test_order.py
@@ -998,7 +998,7 @@ def test_order_discounts_with_line_lvl_voucher_discount_from_checkout_and_legacy
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = True
+ channel_USD.use_legacy_line_discount_propagation_for_order = True
channel_USD.save()
order = order_with_lines
@@ -1072,7 +1072,7 @@ def test_order_discounts_with_line_lvl_voucher_discount_from_checkout(
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = False
+ channel_USD.use_legacy_line_discount_propagation_for_order = False
channel_USD.save()
order = order_with_lines
diff --git a/saleor/graphql/order/tests/queries/test_order_line.py b/saleor/graphql/order/tests/queries/test_order_line.py
index ffa5de6b3a..b77a71819f 100644
--- a/saleor/graphql/order/tests/queries/test_order_line.py
+++ b/saleor/graphql/order/tests/queries/test_order_line.py
@@ -833,7 +833,7 @@ def test_order_line_skips_voucher_discount_object_when_checkout_origin_and_legac
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = True
+ channel_USD.use_legacy_line_discount_propagation_for_order = True
channel_USD.save()
expected_amount = Decimal("6")
@@ -874,7 +874,7 @@ def test_order_line_skips_voucher_discount_object_when_checkout_origin(
channel_USD,
):
# given
- channel_USD.use_legacy_line_voucher_propagation_for_order = False
+ channel_USD.use_legacy_line_discount_propagation_for_order = False
channel_USD.save()
expected_amount = Decimal("6")
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
index e6be80a475..184efda2fe 100644
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@ -1443,7 +1443,7 @@ class OrderLine(
# when legacy is disabled, return the voucher discount as
# OrderLineDiscount. It is a temporary solution to provide a grace
# period for migration
- use_legacy = channel.use_legacy_line_voucher_propagation_for_order
+ use_legacy = channel.use_legacy_line_discount_propagation_for_order
if order.origin != OrderOrigin.CHECKOUT or not use_legacy:
return line_discounts
@@ -1876,7 +1876,7 @@ class Order(SyncWebhookControlContextModelObjectType[ModelObjectType[models.Orde
# for backward compatibility, when legacy propagation is enabled
# we convert the order-line-discounts into single OrderDiscount
# It is a temporary solution to provide a grace period for migration
- if not channel.use_legacy_line_voucher_propagation_for_order:
+ if not channel.use_legacy_line_discount_propagation_for_order:
return order_discounts
def wrap_order_line(order_lines):
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index a207edc134..25be1211aa 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -5189,7 +5189,7 @@ type OrderSettings {
Added in Saleor 3.21.
"""
- useLegacyLineVoucherPropagation: Boolean!
+ useLegacyLineDiscountPropagation: Boolean!
}
"""
@@ -27551,7 +27551,7 @@ input OrderSettingsInput @doc(category: "Orders") {
Added in Saleor 3.21.
"""
- useLegacyLineVoucherPropagation: Boolean
+ useLegacyLineDiscountPropagation: Boolean
}
input CheckoutSettingsInput @doc(category: "Checkout") {
diff --git a/saleor/tests/e2e/checkout/discounts/test_checkout_calculate_correct_discount_for_sale_and_voucher.py b/saleor/tests/e2e/checkout/discounts/test_checkout_calculate_correct_discount_for_sale_and_voucher.py
index 5b22768811..ff60ebda1b 100644
--- a/saleor/tests/e2e/checkout/discounts/test_checkout_calculate_correct_discount_for_sale_and_voucher.py
+++ b/saleor/tests/e2e/checkout/discounts/test_checkout_calculate_correct_discount_for_sale_and_voucher.py
@@ -2,11 +2,7 @@ import pytest
from .....product.tasks import recalculate_discounted_price_for_products_task
from ...product.utils.preparing_product import prepare_products
-from ...sales.utils import (
- create_sale,
- create_sale_channel_listing,
- sale_catalogues_add,
-)
+from ...sales.utils import create_sale, create_sale_channel_listing, sale_catalogues_add
from ...shop.utils import prepare_default_shop
from ...utils import assign_permissions
from ...vouchers.utils import create_voucher, create_voucher_channel_listing
@@ -88,12 +84,12 @@ def prepare_voucher(
@pytest.mark.parametrize(
- ("legacy_voucher_propagation", "entire_voucher_discount_reason"),
+ ("legacy_discount_propagation", "entire_voucher_discount_reason"),
[(True, "Entire order voucher code: VOUCHER001"), (False, "")],
)
@pytest.mark.e2e
def test_checkout_calculate_discount_for_percentage_sale_and_percentage_voucher_CORE_0114(
- legacy_voucher_propagation,
+ legacy_discount_propagation,
entire_voucher_discount_reason,
e2e_not_logged_api_client,
e2e_staff_api_client,
@@ -112,7 +108,7 @@ def test_checkout_calculate_discount_for_percentage_sale_and_percentage_voucher_
shop_data = prepare_default_shop(
e2e_staff_api_client,
channel_order_settings={
- "useLegacyLineVoucherPropagation": legacy_voucher_propagation
+ "useLegacyLineDiscountPropagation": legacy_discount_propagation
},
)
channel_id = shop_data["channel"]["id"]
@@ -485,7 +481,7 @@ def test_checkout_calculate_discount_for_percentage_sale_and_percentage_voucher_
unit_discount1 = line1_discount
unit_discount1 += (
calculated_line1_discount / product2_new_quantity
- if legacy_voucher_propagation
+ if legacy_discount_propagation
else 0
)
assert order_line1["unitDiscount"]["amount"] == round(unit_discount1, 2)
@@ -506,7 +502,7 @@ def test_checkout_calculate_discount_for_percentage_sale_and_percentage_voucher_
unit_discount2 = line2_discount
unit_discount2 += (
calculated_line2_discount / product3_new_quantity
- if legacy_voucher_propagation
+ if legacy_discount_propagation
else 0
)
assert order_line2["unitPrice"]["gross"]["amount"] == round(
@@ -527,17 +523,17 @@ def test_checkout_calculate_discount_for_percentage_sale_and_percentage_voucher_
calculated_line3_total / product4_quantity, 2
)
unit_discount3 = 0
- unit_discount3 += calculated_line3_discount if legacy_voucher_propagation else 0
+ unit_discount3 += calculated_line3_discount if legacy_discount_propagation else 0
assert order_line3["unitDiscount"]["amount"] == unit_discount3
@pytest.mark.parametrize(
- ("legacy_voucher_propagation", "entire_voucher_discount_reason"),
+ ("legacy_discount_propagation", "entire_voucher_discount_reason"),
[(True, "Entire order voucher code: VOUCHER002"), (False, "")],
)
@pytest.mark.e2e
def test_checkout_calculate_discount_for_fixed_sale_and_fixed_voucher_CORE_0114(
- legacy_voucher_propagation,
+ legacy_discount_propagation,
entire_voucher_discount_reason,
e2e_not_logged_api_client,
e2e_staff_api_client,
@@ -556,7 +552,7 @@ def test_checkout_calculate_discount_for_fixed_sale_and_fixed_voucher_CORE_0114(
shop_data = prepare_default_shop(
e2e_staff_api_client,
channel_order_settings={
- "useLegacyLineVoucherPropagation": legacy_voucher_propagation
+ "useLegacyLineDiscountPropagation": legacy_discount_propagation
},
)
channel_id = shop_data["channel"]["id"]
@@ -931,7 +927,7 @@ def test_checkout_calculate_discount_for_fixed_sale_and_fixed_voucher_CORE_0114(
unit_discount1 = line1_discount
unit_discount1 += (
calculated_line1_discount / product2_new_quantity
- if legacy_voucher_propagation
+ if legacy_discount_propagation
else 0
)
assert order_line1["unitDiscount"]["amount"] == round(unit_discount1, 2)
@@ -952,7 +948,7 @@ def test_checkout_calculate_discount_for_fixed_sale_and_fixed_voucher_CORE_0114(
unit_discount2 = line2_discount
unit_discount2 += (
calculated_line2_discount / product3_new_quantity
- if legacy_voucher_propagation
+ if legacy_discount_propagation
else 0
)
assert order_line2["unitDiscount"]["amount"] == round(unit_discount2, 2)
@@ -971,17 +967,17 @@ def test_checkout_calculate_discount_for_fixed_sale_and_fixed_voucher_CORE_0114(
calculated_line3_total / product4_quantity, 2
)
unit_discount3 = 0
- unit_discount3 += calculated_line3_discount if legacy_voucher_propagation else 0
+ unit_discount3 += calculated_line3_discount if legacy_discount_propagation else 0
assert order_line3["unitDiscount"]["amount"] == unit_discount3
@pytest.mark.parametrize(
- ("legacy_voucher_propagation", "entire_voucher_discount_reason"),
+ ("legacy_discount_propagation", "entire_voucher_discount_reason"),
[(True, "Entire order voucher code: VOUCHER003"), (False, "")],
)
@pytest.mark.e2e
def test_checkout_calculate_discount_for_fixed_sale_and_percentage_voucher_CORE_0114(
- legacy_voucher_propagation,
+ legacy_discount_propagation,
entire_voucher_discount_reason,
e2e_not_logged_api_client,
e2e_staff_api_client,
@@ -1000,7 +996,7 @@ def test_checkout_calculate_discount_for_fixed_sale_and_percentage_voucher_CORE_
shop_data = prepare_default_shop(
e2e_staff_api_client,
channel_order_settings={
- "useLegacyLineVoucherPropagation": legacy_voucher_propagation
+ "useLegacyLineDiscountPropagation": legacy_discount_propagation
},
)
channel_id = shop_data["channel"]["id"]
@@ -1373,7 +1369,7 @@ def test_checkout_calculate_discount_for_fixed_sale_and_percentage_voucher_CORE_
unit_discount1 = line1_discount
unit_discount1 += (
calculated_line1_discount / product2_new_quantity
- if legacy_voucher_propagation
+ if legacy_discount_propagation
else 0
)
assert order_line1["unitDiscount"]["amount"] == round(unit_discount1, 2)
@@ -1394,7 +1390,7 @@ def test_checkout_calculate_discount_for_fixed_sale_and_percentage_voucher_CORE_
unit_discount2 = line2_discount
unit_discount2 += (
calculated_line2_discount / product3_new_quantity
- if legacy_voucher_propagation
+ if legacy_discount_propagation
else 0
)
assert order_line2["unitDiscount"]["amount"] == round(unit_discount2, 2)
@@ -1412,17 +1408,17 @@ def test_checkout_calculate_discount_for_fixed_sale_and_percentage_voucher_CORE_
calculated_line3_total / product4_quantity, 2
)
unit_discount3 = 0
- unit_discount3 += calculated_line3_discount if legacy_voucher_propagation else 0
+ unit_discount3 += calculated_line3_discount if legacy_discount_propagation else 0
assert order_line3["unitDiscount"]["amount"] == unit_discount3
@pytest.mark.parametrize(
- ("legacy_voucher_propagation", "entire_voucher_discount_reason"),
+ ("legacy_discount_propagation", "entire_voucher_discount_reason"),
[(True, "Entire order voucher code: VOUCHER004"), (False, "")],
)
@pytest.mark.e2e
def test_checkout_calculate_discount_for_percentage_sale_and_fixed_voucher_CORE_0114(
- legacy_voucher_propagation,
+ legacy_discount_propagation,
entire_voucher_discount_reason,
e2e_not_logged_api_client,
e2e_staff_api_client,
@@ -1441,7 +1437,7 @@ def test_checkout_calculate_discount_for_percentage_sale_and_fixed_voucher_CORE_
shop_data = prepare_default_shop(
e2e_staff_api_client,
channel_order_settings={
- "useLegacyLineVoucherPropagation": legacy_voucher_propagation
+ "useLegacyLineDiscountPropagation": legacy_discount_propagation
},
)
channel_id = shop_data["channel"]["id"]
@@ -1815,7 +1811,7 @@ def test_checkout_calculate_discount_for_percentage_sale_and_fixed_voucher_CORE_
unit_discount1 = line1_discount
unit_discount1 += (
calculated_line1_discount / product2_new_quantity
- if legacy_voucher_propagation
+ if legacy_discount_propagation
else 0
)
assert order_line1["unitDiscount"]["amount"] == round(unit_discount1, 2)
@@ -1836,7 +1832,7 @@ def test_checkout_calculate_discount_for_percentage_sale_and_fixed_voucher_CORE_
unit_discount2 = line2_discount
unit_discount2 += (
calculated_line2_discount / product3_new_quantity
- if legacy_voucher_propagation
+ if legacy_discount_propagation
else 0
)
assert order_line2["unitDiscount"]["amount"] == round(unit_discount2, 2)
@@ -1855,5 +1851,5 @@ def test_checkout_calculate_discount_for_percentage_sale_and_fixed_voucher_CORE_
calculated_line3_total / product4_quantity, 2
)
unit_discount3 = 0
- unit_discount3 += calculated_line3_discount if legacy_voucher_propagation else 0
+ unit_discount3 += calculated_line3_discount if legacy_discount_propagation else 0
assert order_line3["unitDiscount"]["amount"] == unit_discount3
diff --git a/saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.py b/saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.py
index b4d938088e..f64fecc41d 100644
--- a/saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.py
+++ b/saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.py
@@ -148,7 +148,7 @@ def test_checkout_with_promotion_and_voucher_legacy_propagation_CORE_2107(
shop_data = prepare_default_shop(
e2e_staff_api_client,
- channel_order_settings={"useLegacyLineVoucherPropagation": True},
+ channel_order_settings={"useLegacyLineDiscountPropagation": True},
)
channel_id = shop_data["channel"]["id"]
channel_slug = shop_data["channel"]["slug"]
@@ -313,7 +313,7 @@ def test_checkout_with_promotion_and_voucher_CORE_2107(
shop_data = prepare_default_shop(
e2e_staff_api_client,
- channel_order_settings={"useLegacyLineVoucherPropagation": False},
+ channel_order_settings={"useLegacyLineDiscountPropagation": False},
)
channel_id = shop_data["channel"]["id"]
channel_slug = shop_data["channel"]["slug"]