From b93828cd337be9c6b71903f1a9cfc54fec956b9f Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 2 May 2024 09:37:24 +0530 Subject: [PATCH] fix: pricing rule rounding Consider a pricing rule of 20:1 with recursion enabled, free items should follow the below progression | Qty | Free item qty | |-------+---------------| | 0-19 | 0 | | 20-39 | 1 | | 40-59 | 2 | (cherry picked from commit 9bf37426c13d6a92db46a49d58b4d36faef048f2) --- erpnext/accounts/doctype/pricing_rule/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index f1d4d2be458c..44f7f33a3191 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -6,6 +6,7 @@ import copy import json +import math import frappe from frappe import _, bold @@ -653,7 +654,7 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None): if transaction_qty: qty = flt(transaction_qty) * qty / pricing_rule.recurse_for if pricing_rule.round_free_qty: - qty = round(qty) + qty = math.floor(qty) free_item_data_args = { "item_code": free_item,