fix: tests

(cherry picked from commit 366ae85d85)
This commit is contained in:
Mihir Kandoi
2025-02-05 19:18:01 +05:30
committed by Mergify
parent 8fb9228871
commit f63a9dbf9b
3 changed files with 7 additions and 1 deletions

View File

@@ -646,7 +646,7 @@ def remove_pricing_rule_for_item(pricing_rules, item_details, item_code=None, ra
if pricing_rule.margin_type in ["Percentage", "Amount"]:
item_details.margin_rate_or_amount = 0.0
item_details.margin_type = None
elif pricing_rule.get("free_item"):
elif pricing_rule.get("free_item") and pricing_rule.get("enforce_free_item_qty"):
item_details.remove_free_item = (
item_code if pricing_rule.get("same_item") else pricing_rule.get("free_item")
)

View File

@@ -386,6 +386,7 @@ class TestPricingRule(FrappeTestCase):
"price_or_product_discount": "Product",
"same_item": 1,
"free_qty": 1,
"enforce_free_item_qty": 1,
"company": "_Test Company",
}
frappe.get_doc(test_record.copy()).insert()
@@ -418,6 +419,7 @@ class TestPricingRule(FrappeTestCase):
"same_item": 0,
"free_item": "_Test Item 2",
"free_qty": 1,
"enforce_free_item_qty": 1,
"company": "_Test Company",
}
frappe.get_doc(test_record.copy()).insert()
@@ -1111,6 +1113,7 @@ class TestPricingRule(FrappeTestCase):
"price_or_product_discount": "Product",
"same_item": 1,
"free_qty": 1,
"enforce_free_item_qty": 1,
"round_free_qty": 1,
"is_recursive": 1,
"recurse_for": 2,
@@ -1156,6 +1159,7 @@ class TestPricingRule(FrappeTestCase):
"price_or_product_discount": "Product",
"same_item": 1,
"free_qty": 10,
"enforce_free_item_qty": 1,
"round_free_qty": 1,
"is_recursive": 1,
"recurse_for": 100,
@@ -1451,6 +1455,7 @@ def make_pricing_rule(**args):
"discount_amount": args.discount_amount or 0.0,
"apply_multiple_pricing_rules": args.apply_multiple_pricing_rules or 0,
"has_priority": args.has_priority or 0,
"enforce_free_item_qty": args.enforce_free_item_qty or 1,
}
)

View File

@@ -1242,6 +1242,7 @@ class TestPickList(FrappeTestCase):
"is_recursive": 1,
"recurse_for": 2,
"free_qty": 1,
"enforce_free_item_qty": 1,
"company": "_Test Company",
"customer": "_Test Customer",
}