Openbravo Issue Tracking System - POS2
View Issue Details
0057672POS2POSpublic2025-01-17 06:362025-02-06 14:45
prakashmurugesan88 
prakashmurugesan88 
highmajoralways
closedfixed 
5
 
25Q125Q1 
No
No
0057672: Problem with “Maximum discount per role” functionality, does not work correctly.
We apply the changes but there is an error in the way decimals and rounding are handled, resulting in inconsistencies when validating the maximum discounts allowed. This allows the system to accept final prices that are below the calculated limits for both the Unit Price and the List Price.
Navigate to role and configure the detailed actions and the maximum discount as below.
In the terminal, add a product and to the line, add a manual discount as below.
You can notice following Rounding issue.


Initial Context:

Product with List Price: 5.90€.
Product with Unit Price (price already reduced): 4.90€.
Observed Behavior:

The system warns that the maximum discount allowed is 16%, based on the Unit Price.

Calculated discount: 4.90€ × 0.16 = 0.784€ ≈ 0.78€ (rounding).
Expected minimum allowed price: €4.90 - €0.78 = €4.12.
However, the POS allows to apply a price of €4.11, which is below the expected limit of €4.12.

Extended Case:

If the original List Price of €5.90 is considered, a maximum discount of 30% would imply:

Minimum price allowed: €5.90 × 0.70 = €4.13.
But the system allows applying a discount that results in a final price of 4.11€, equivalent to a discount of 30.33%, exceeding the established limit.
No tags attached.
blocks defect 0057671 closed prakashmurugesan88 Problem with “Maximum discount per role” functionality, does not work correctly. 
Issue History
2025-01-17 06:36prakashmurugesan88New Issue
2025-01-17 06:36prakashmurugesan88Assigned To => prakashmurugesan88
2025-01-17 06:36prakashmurugesan88OBNetwork customer => No
2025-01-17 06:36prakashmurugesan88Triggers an Emergency Pack => No
2025-01-17 06:36prakashmurugesan88Issue generated from0057671
2025-01-17 06:37prakashmurugesan88Typedefect => backport
2025-01-17 06:37prakashmurugesan88Target Version => 25Q1
2025-01-17 06:38prakashmurugesan88Statusnew => scheduled
2025-01-17 06:40prakashmurugesan88Relationship addedblocks 0057671
2025-01-17 07:55prakashmurugesan88Note Added: 0174258
2025-02-06 14:45hgbotResolutionopen => fixed
2025-02-06 14:45hgbotStatusscheduled => resolved
2025-02-06 14:45hgbotFixed in Version => 25Q1
2025-02-06 14:45hgbotNote Added: 0175229
2025-02-06 14:45marvintmStatusresolved => closed

Notes
(0174258)
prakashmurugesan88   
2025-01-17 07:55   
https://gitlab.com/openbravo/product/pmods/org.openbravo.pos2/-/merge_requests/3358 [^]
(0175229)
hgbot   
2025-02-06 14:45   
Repository: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.pos2 [^]
Changeset: 6e026c1f1f2d27982117fe905254e63f414ac7d0
Author: Prakash Murugesan <p.murugesan@external.orisha.com>
Date: 06-02-2025 13:44:51
URL: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.pos2/-/commit/6e026c1f1f2d27982117fe905254e63f414ac7d0 [^]

Fixes ISSUE-57672: Fixed percentage calculation rounding issue

---
M src-db/database/sourcedata/AD_MESSAGE.xml
M web-jspack/org.openbravo.pos2/src/model/ticket/user-actions/discounts/ApplyHigherDiscountThanAllowedForRole.js
M web-jspack/org.openbravo.pos2/src/model/ticket/user-actions/discounts/__test__/areDiscountsExceedingMaximumAllowedByRole.test.js
---