test: pricing rule for product discounts

This commit is contained in:
Gursheen Anand
2024-03-12 13:55:43 +05:30
parent 7075c50b85
commit 0ffc5cf012

View File

@@ -107,6 +107,28 @@ class TestPromotionalScheme(unittest.TestCase):
price_rules = frappe.get_all("Pricing Rule", filters={"promotional_scheme": ps.name})
self.assertEqual(price_rules, [])
def test_pricing_rule_for_product_discount_slabs(self):
ps = make_promotional_scheme()
ps.set("price_discount_slabs", [])
ps.set(
"product_discount_slabs",
[
{
"rule_description": "12+1",
"min_qty": 12,
"free_item": "_Test Item 2",
"free_qty": 1,
"is_recursive": 1,
"recurse_for": 12,
}
],
)
ps.save()
pr = frappe.get_doc("Pricing Rule", {"promotional_scheme_id": ps.product_discount_slabs[0].name})
self.assertSequenceEqual(
[pr.min_qty, pr.free_item, pr.free_qty, pr.recurse_for], [12, "_Test Item 2", 1, 12]
)
def make_promotional_scheme(**args):
args = frappe._dict(args)