diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py index fac9be7bdb1..4d28d106604 100644 --- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py +++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py @@ -34,8 +34,8 @@ pricing_rule_fields = [ other_fields = [ "min_qty", "max_qty", - "min_amt", - "max_amt", + "min_amount", + "max_amount", "priority", "warehouse", "threshold_percentage", @@ -246,7 +246,11 @@ def prepare_pricing_rule( def set_args(args, pr, doc, child_doc, discount_fields, child_doc_fields): pr.update(args) for field in other_fields + discount_fields: - pr.set(field, child_doc_fields.get(field)) + target_field = field + if target_field in ["min_amount", "max_amount"]: + target_field = "min_amt" if field == "min_amount" else "max_amt" + + pr.set(target_field, child_doc_fields.get(field)) pr.promotional_scheme_id = child_doc_fields.name pr.promotional_scheme = doc.name diff --git a/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py index b3b9d7b2086..9e576fb8775 100644 --- a/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py +++ b/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py @@ -90,6 +90,23 @@ class TestPromotionalScheme(unittest.TestCase): price_rules = frappe.get_all("Pricing Rule", filters={"promotional_scheme": ps.name}) self.assertEqual(price_rules, []) + def test_min_max_amount_configuration(self): + ps = make_promotional_scheme() + ps.price_discount_slabs[0].min_amount = 10 + ps.price_discount_slabs[0].max_amount = 1000 + ps.save() + + price_rules_data = frappe.db.get_value( + "Pricing Rule", {"promotional_scheme": ps.name}, ["min_amt", "max_amt"], as_dict=1 + ) + + self.assertEqual(price_rules_data.min_amt, 10) + self.assertEqual(price_rules_data.max_amt, 1000) + + frappe.delete_doc("Promotional Scheme", ps.name) + price_rules = frappe.get_all("Pricing Rule", filters={"promotional_scheme": ps.name}) + self.assertEqual(price_rules, []) + def make_promotional_scheme(**args): args = frappe._dict(args)