Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0044217
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Retail Modules] Discounts by Totalmajoralways2020-05-28 08:272020-06-11 18:55
ReporterLeyreView Statuspublic 
Assigned Toranjith_qualiantech_com 
PriorityhighResolutionfixedFixed in VersionRR20Q3
StatusclosedFix in branchFixed in SCM revision
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tomarvintm
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0044217: The "Variable Percentage Discount per Total Amount" discount is not calculated correctly.

DescriptionThe "Variable Percentage Discount per Total Amount" discount is not calculated correctly.
Steps To ReproduceBackend:
1) Configure a product:
   1.1. Grouped product = N
   2.2. Price = 149.9
   2.3. UPC/EAN = 1 (simple number, to enter the product in the POS).

2) Configure a discount:
   2.1. Type = Variable Percentage Discount per Total Amount
   2.2. Percentage = 5%

Web POS:
1) Add the previous product 123 times.
2) Add the previous discount.

Expected result:
Total of the receipt without the discount = 149.9 * 123 = 18437.7
Discount amount = 18437.7 * 0.05 = 921.89
Total of the receipt with the discount = 17515.81

Actual result:
Total of the receipt without the discount = 18437.7 see attached image step1.png
Discount amount = 922.5 see attached image step2.png
Total of the receipt with the discount = 17515.20

TagsNo tags attached.
Attached Filespng file icon step1.png [^] (242,442 bytes) 2020-05-28 08:27


png file icon step2.png [^] (526,733 bytes) 2020-05-28 08:28
png file icon problem.png [^] (206,813 bytes) 2020-06-11 13:45

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0120720)
hgbot (developer)
2020-06-08 07:55

Repository: erp/pmods/org.openbravo.retail.discounts.bytotal
Changeset: 34b16b968acd64d4fbf7eade9959c2f8bbb876d3
Author: Ranjith S R <ranjith <at> qualiantech.com>
Date: Mon Jun 08 11:25:07 2020 +0530
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.bytotal/rev/34b16b968acd64d4fbf7eade9959c2f8bbb876d3 [^]

Related to issue-44217 : Updated DiscountsBytotal Percentage calculation

* For bytotal percentage discounts, discount will be calculated on total receipt amount
  After applying discounts for each line, if sum of line discount is not same as total discount,
  then discount for last line should be adjusted.

---
M web/org.openbravo.retail.discounts.bytotal/app/model/business-logic/discounts-engine/engine/rules/by-total-percentage-discount.js
---
(0120741)
hgbot (developer)
2020-06-08 13:53

Repository: tools/automation/pi-mobile
Changeset: 5bcc0f0b2c82766b8439717a30d6b8f960c6dd60
Author: Ranjith S R <ranjith <at> qualiantech.com>
Date: Mon Jun 08 17:23:41 2020 +0530
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/5bcc0f0b2c82766b8439717a30d6b8f960c6dd60 [^]

Verifies issue 44217 : Modified ByTotal Percentage Automated tests

* Multidiscounts_ChangeLineQuantitiesWithByTotal
* Multidiscounts_FixedPercentageByTotal
* Multidiscounts_RemoveMultiDiscountsByTotal
* Multidiscounts_VariablePercentageByTotal

---
M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/multidiscounts/Multidiscounts_ChangeLineQuantitiesWithByTotals.java
M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/multidiscounts/Multidiscounts_FixedPercentageByTotal.java
M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/multidiscounts/Multidiscounts_RemoveMultiDiscountsByTotal.java
M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/multidiscounts/Multidiscounts_VariablePercentageByTotal.java
---
(0120802)
Leyre (developer)
2020-06-11 13:45

Testing in pi:
https://livebuilds.openbravo.com/retail_modules_pgsql_pi/ [^]

Web POS:
1) Add a product 149.9 € * 123 times.
2) Add a Variable Percentage Discount per Total Amount = 5%

The discount is calculated correctly, but the lines are not calculated proportionally. Please see attached image "problem.png"
(0120806)
marvintm (manager)
2020-06-11 18:55

As far as we can see, the result is correct. The discrepancy comes from the fact that, when we calculate the discounts that apply to multiple lines, we try as much as possible to calculate them proportionally to the total amount of the line.

However, the discounts need to be rounded to two decimals, and this means that some precision may be lost. As we anyway need to apply a fixed discount, we always follow the convention of applying the rounding error to the last discounted line.

In the specified case:
Discount: 18437,7*0.05=921.89

Proportional discount for each line: 921,89*149/(149*123) = 7.495, which rounded is 7.5.

Total discount would then be: 7.5*123 = 922,5

Difference with desired discount: 921.89-922,5 = -0.61

This difference is then applied to the last discounted line.

- Issue History
Date Modified Username Field Change
2020-05-28 08:27 Leyre New Issue
2020-05-28 08:27 Leyre Assigned To => Retail
2020-05-28 08:27 Leyre Resolution time => 1592431200
2020-05-28 08:27 Leyre Triggers an Emergency Pack => No
2020-05-28 08:27 Leyre File Added: step1.png
2020-05-28 08:28 Leyre File Added: step2.png
2020-06-05 10:37 ranjith_qualiantech_com Assigned To Retail => ranjith_qualiantech_com
2020-06-08 07:21 ranjith_qualiantech_com Status new => scheduled
2020-06-08 07:55 hgbot Checkin
2020-06-08 07:55 hgbot Note Added: 0120720
2020-06-08 13:53 hgbot Checkin
2020-06-08 13:53 hgbot Note Added: 0120741
2020-06-09 09:16 ranjith_qualiantech_com Status scheduled => resolved
2020-06-09 09:16 ranjith_qualiantech_com Resolution open => fixed
2020-06-09 19:06 marvintm Review Assigned To => marvintm
2020-06-09 19:06 marvintm Status resolved => closed
2020-06-09 19:06 marvintm Fixed in Version => RR20Q3
2020-06-11 13:45 Leyre Note Added: 0120802
2020-06-11 13:45 Leyre Status closed => new
2020-06-11 13:45 Leyre File Added: problem.png
2020-06-11 18:51 marvintm Status new => scheduled
2020-06-11 18:55 marvintm Note Added: 0120806
2020-06-11 18:55 marvintm Status scheduled => resolved
2020-06-11 18:55 marvintm Status resolved => closed


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker