From 8624aeca54eacf4b32e86b8d1d82245fcef65355 Mon Sep 17 00:00:00 2001 From: Lakshit Jain <108322669+ljain112@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:19:54 +0530 Subject: [PATCH] fix: promotional scheme doctype fields in consitency with pricing rule (#42432) * fix: add "round_free_qty" check box in promotional scheme * fix: add `add_for_price_list` field * fix: set_query in setup for promotional scheme --------- --- .../doctype/promotional_scheme/promotional_scheme.js | 12 ++++++++++++ .../doctype/promotional_scheme/promotional_scheme.py | 2 ++ .../promotional_scheme_price_discount.json | 10 +++++++++- .../promotional_scheme_price_discount.py | 1 + .../promotional_scheme_product_discount.json | 11 +++++++++-- .../promotional_scheme_product_discount.py | 1 + 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.js b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.js index 7a26c07d01f1..43261e4080a2 100644 --- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.js +++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.js @@ -2,6 +2,18 @@ // For license information, please see license.txt frappe.ui.form.on("Promotional Scheme", { + setup: function (frm) { + frm.set_query("for_price_list", "price_discount_slabs", (doc) => { + return { + filters: { + selling: doc.selling, + buying: doc.buying, + currency: doc.currency, + }, + }; + }); + }, + refresh: function (frm) { frm.trigger("set_options_for_applicable_for"); frm.trigger("toggle_reqd_apply_on"); diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py index 71fe156dd7ad..86bd21355153 100644 --- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py +++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py @@ -51,6 +51,7 @@ "discount_percentage", "validate_applied_rule", "apply_multiple_pricing_rules", + "for_price_list", ] product_discount_fields = [ @@ -63,6 +64,7 @@ "recurse_for", "apply_recursion_over", "apply_multiple_pricing_rules", + "round_free_qty", ] diff --git a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json index f0bb30e6a02a..b21b351ea554 100644 --- a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json +++ b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.json @@ -21,6 +21,7 @@ "rate", "discount_amount", "discount_percentage", + "for_price_list", "section_break_11", "warehouse", "threshold_percentage", @@ -120,6 +121,13 @@ "fieldtype": "Float", "label": "Discount Percentage" }, + { + "depends_on": "eval:doc.rate_or_discount!=\"Rate\"", + "fieldname": "for_price_list", + "fieldtype": "Link", + "label": "For Price List", + "options": "Price List" + }, { "fieldname": "section_break_11", "fieldtype": "Section Break" @@ -169,7 +177,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:10:22.448265", + "modified": "2024-07-23 12:33:46.574950", "modified_by": "Administrator", "module": "Accounts", "name": "Promotional Scheme Price Discount", diff --git a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py index 545c17dda890..3e07309dca5d 100644 --- a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py +++ b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py @@ -19,6 +19,7 @@ class PromotionalSchemePriceDiscount(Document): disable: DF.Check discount_amount: DF.Currency discount_percentage: DF.Float + for_price_list: DF.Link | None max_amount: DF.Currency max_qty: DF.Float min_amount: DF.Currency 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 5b3944046b08..ad4b44b6f7cf 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 @@ -22,6 +22,7 @@ "column_break_9", "free_item_uom", "free_item_rate", + "round_free_qty", "section_break_12", "warehouse", "threshold_percentage", @@ -181,12 +182,18 @@ "fieldtype": "Float", "label": "Apply Recursion Over (As Per Transaction UOM)", "mandatory_depends_on": "is_recursive" + }, + { + "default": "0", + "fieldname": "round_free_qty", + "fieldtype": "Check", + "label": "Round Free Qty" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:10:22.605892", + "modified": "2024-07-22 17:25:07.880984", "modified_by": "Administrator", "module": "Accounts", "name": "Promotional Scheme Product Discount", @@ -195,4 +202,4 @@ "sort_field": "creation", "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 1463a7b93a4f..b071d658cb48 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 @@ -53,6 +53,7 @@ class PromotionalSchemeProductDiscount(Document): "20", ] recurse_for: DF.Float + round_free_qty: DF.Check rule_description: DF.SmallText same_item: DF.Check threshold_percentage: DF.Percent