Merge pull request #43649 from frappe/mergify/bp/version-14-hotfix/pr-43614

fix: ignore free item when qty is zero (backport #43614)
This commit is contained in:
ruthra kumar
2024-10-15 06:01:44 +05:30
committed by GitHub
2 changed files with 9 additions and 0 deletions

View File

@@ -981,6 +981,12 @@ class TestPricingRule(FrappeTestCase):
self.assertEqual(so.items[1].item_code, "_Test Item")
self.assertEqual(so.items[1].qty, 3)
so = make_sales_order(item_code="_Test Item", qty=5, do_not_submit=1)
so.items[0].qty = 1
del so.items[-1]
so.save()
self.assertEqual(len(so.items), 1)
def test_apply_multiple_pricing_rules_for_discount_percentage_and_amount(self):
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 1")
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")

View File

@@ -644,6 +644,9 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
if pricing_rule.round_free_qty:
qty = math.floor(qty)
if not qty:
return
free_item_data_args = {
"item_code": free_item,
"qty": qty,