Skip to content

Commit

Permalink
fix: pricing rule rounding
Browse files Browse the repository at this point in the history
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 9bf3742)
  • Loading branch information
ruthra-kumar authored and mergify[bot] committed May 7, 2024
1 parent cd3ca1e commit b93828c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion erpnext/accounts/doctype/pricing_rule/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import copy
import json
import math

import frappe
from frappe import _, bold
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b93828c

Please sign in to comment.