From 5f4b23d4afedeb76ad239f15212e0469366f2e49 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 12 Mar 2024 13:16:39 +0530 Subject: [PATCH] feat: add recursion qty field in promotional scheme (cherry picked from commit 7075c50b85a5eddf72b9466cff8c2ec3a064c0ad) --- .../promotional_scheme/promotional_scheme.py | 2 ++ .../promotional_scheme_product_discount.json | 27 ++++++++++++++++--- .../promotional_scheme_product_discount.py | 2 ++ erpnext/public/js/controllers/transaction.js | 4 +-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py index 0bb8d3a4578..a9c1900bdec 100644 --- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py +++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py @@ -60,6 +60,8 @@ product_discount_fields = [ "free_item_rate", "same_item", "is_recursive", + "recurse_for", + "apply_recursion_over", "apply_multiple_pricing_rules", ] diff --git a/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.json b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.json index 3eab51510db..4e61d04ad21 100644 --- a/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.json +++ b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.json @@ -27,7 +27,9 @@ "threshold_percentage", "column_break_15", "priority", - "is_recursive" + "is_recursive", + "recurse_for", + "apply_recursion_over" ], "fields": [ { @@ -161,17 +163,36 @@ "fieldname": "is_recursive", "fieldtype": "Check", "label": "Is Recursive" + }, + { + "default": "0", + "depends_on": "is_recursive", + "description": "Give free item for every N quantity", + "fieldname": "recurse_for", + "fieldtype": "Float", + "label": "Recurse Every (As Per Transaction UOM)", + "mandatory_depends_on": "is_recursive" + }, + { + "default": "0", + "depends_on": "is_recursive", + "description": "Qty for which recursion isn't applicable.", + "fieldname": "apply_recursion_over", + "fieldtype": "Float", + "label": "Apply Recursion Over (As Per Transaction UOM)", + "mandatory_depends_on": "is_recursive" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-03-06 21:58:18.162346", + "modified": "2024-03-12 12:53:58.199108", "modified_by": "Administrator", "module": "Accounts", "name": "Promotional Scheme Product Discount", "owner": "Administrator", "permissions": [], "sort_field": "modified", - "sort_order": "DESC" + "sort_order": "DESC", + "states": [] } \ No newline at end of file diff --git a/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py index 7dd5fea373e..1463a7b93a4 100644 --- a/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py +++ b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py @@ -15,6 +15,7 @@ class PromotionalSchemeProductDiscount(Document): from frappe.types import DF apply_multiple_pricing_rules: DF.Check + apply_recursion_over: DF.Float disable: DF.Check free_item: DF.Link | None free_item_rate: DF.Currency @@ -51,6 +52,7 @@ class PromotionalSchemeProductDiscount(Document): "19", "20", ] + recurse_for: DF.Float rule_description: DF.SmallText same_item: DF.Check threshold_percentage: DF.Percent diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 7f6bc7f14dc..0b642b48cf7 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1816,8 +1816,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe let items = []; me.frm.doc.items.forEach(d => { - // if same item was added a free item through a different pricing rule, keep it - if(d.item_code != item.remove_free_item || !d.is_free_item || removed_pricing_rule?.includes(d.pricing_rules)) { + // if same item was added as free item through a different pricing rule, keep it + if(d.item_code != item.remove_free_item || !d.is_free_item || !removed_pricing_rule?.includes(d.pricing_rules)) { items.push(d); } });