-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added option to enforce free item qty in pricing rule #45750
base: develop
Are you sure you want to change the base?
Conversation
@rohitwaghchaure please note some things:
|
@@ -645,7 +646,7 @@ def remove_pricing_rule_for_item(pricing_rules, item_details, item_code=None, ra | |||
if pricing_rule.margin_type in ["Percentage", "Amount"]: | |||
item_details.margin_rate_or_amount = 0.0 | |||
item_details.margin_type = None | |||
elif pricing_rule.get("free_item"): | |||
elif pricing_rule.get("free_item") and pricing_rule.get("enforce_free_item_qty"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is called only on the frontend. It prevents free item being deleted on change of qty of that free item.
@@ -713,7 +713,8 @@ def apply_pricing_rule_for_free_items(doc, pricing_rule_args): | |||
args.pop((item.item_code, item.pricing_rules)) | |||
|
|||
for free_item in args.values(): | |||
doc.append("items", free_item) | |||
if frappe.get_value("Pricing Rule", free_item["pricing_rules"], "enforce_free_item_qty"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
condition will prevent free items being fetched on document save if enforcement is off
@rohitwaghchaure Can we create a whitelisted functions that will fetch free items? User can call that function through REST API right? |
Reference support ticket 20447
Currently ERPNext forces user to mandatorily supply free items from pricing rule. This is done by fetching free items and adding it into child table whenever a document with pricing rule is saved. Normally, free items are at discretion of seller.
This PR adds a new option in Pricing Rule called
Enforce Free Item Qty
which will keep the behaviour same as before. However, upon disabling this checkbox, free items won't be fetched when document is saved.Free items will now only be fetched when user adds an item with a free items pricing rule in the child table, not when document is saved, allowing the user to delete the free item as they wish.
This PR is incomplete. DO NOT MERGE.