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:
@@ -981,6 +981,12 @@ class TestPricingRule(FrappeTestCase):
|
|||||||
self.assertEqual(so.items[1].item_code, "_Test Item")
|
self.assertEqual(so.items[1].item_code, "_Test Item")
|
||||||
self.assertEqual(so.items[1].qty, 3)
|
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):
|
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 1")
|
||||||
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")
|
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")
|
||||||
|
|||||||
@@ -644,6 +644,9 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
|
|||||||
if pricing_rule.round_free_qty:
|
if pricing_rule.round_free_qty:
|
||||||
qty = math.floor(qty)
|
qty = math.floor(qty)
|
||||||
|
|
||||||
|
if not qty:
|
||||||
|
return
|
||||||
|
|
||||||
free_item_data_args = {
|
free_item_data_args = {
|
||||||
"item_code": free_item,
|
"item_code": free_item,
|
||||||
"qty": qty,
|
"qty": qty,
|
||||||
|
|||||||
Reference in New Issue
Block a user