fix: tests

This commit is contained in:
Mihir Kandoi
2025-02-05 19:18:01 +05:30
parent 19c01b1457
commit 366ae85d85
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

@@ -396,6 +396,7 @@ class TestPricingRule(IntegrationTestCase):
"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()
@@ -428,6 +429,7 @@ class TestPricingRule(IntegrationTestCase):
"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()
@@ -1121,6 +1123,7 @@ class TestPricingRule(IntegrationTestCase):
"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,
@@ -1166,6 +1169,7 @@ class TestPricingRule(IntegrationTestCase):
"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,
@@ -1461,6 +1465,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

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