Openbravo Issue Tracking System - Retail Modules
View Issue Details
0035858Retail ModulesWeb POSpublic2017-04-27 13:262017-05-08 09:29
jorgewederago 
jorge-garcia 
urgentmajoralways
closedfixed 
5
pi 
piRR17Q3 
marvintm
No
0035858: When applying more than 2 discounts to the same line the information about them is generated wrongly.
If you apply more than 2 discounts to the same line and finish the transaction, if you go to the ERP and check the information related to them you will see that the values are not correctly generated so the information stored in the database is not correct.
1.- In the ERP go to discounts and promotions and generate (for eg) 4 Discretionary Fixed Amount discounts.
2.- In WebPOS buy something and apply all the discounts to it.
3.- Finish the transaction
4.- Go to the ERP to the Sales order window, select the order and line and check the values in Base Gross Unit Price displayed in discounts and promotions.
The following code seems wrong since it applies twice the discounts due accumulators.

base = line.get('price');
        _.forEach(line.get('promotions') || [], function (discount) {
          var discountAmt = discount.actualAmt || discount.amt || 0;
          discount.basePrice = base;
          discount.unitDiscount = OB.DEC.div(discountAmt, line.get('qtyToApplyDisc') || line.get('qty'));
          totalDiscount = OB.DEC.add(totalDiscount, discountAmt);
          base = OB.DEC.sub(base, totalDiscount);
        }, this);
No tags attached.
depends on backport 0035861RR17Q2.1 closed jorge-garcia When applying more than 2 discounts to the same line the information about them is generated wrongly. 
depends on backport 0035862RR17Q1.2 closed jorge-garcia When applying more than 2 discounts to the same line the information about them is generated wrongly. 
Issue History
2017-04-27 13:26jorgewederagoNew Issue
2017-04-27 13:26jorgewederagoAssigned To => Retail
2017-04-27 13:26jorgewederagoResolution time => 1491170400
2017-04-27 13:26jorgewederagoTriggers an Emergency Pack => No
2017-04-27 13:26jorgewederagoResolution time1491170400 => 1493762400
2017-04-27 13:42marvintmSeveritycritical => major
2017-04-27 13:45marvintmStatusnew => scheduled
2017-04-27 13:45marvintmAssigned ToRetail => jorge-garcia
2017-05-02 13:01hgbotCheckin
2017-05-02 13:01hgbotNote Added: 0096306
2017-05-02 13:01hgbotStatusscheduled => resolved
2017-05-02 13:01hgbotResolutionopen => fixed
2017-05-02 13:01hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/e063519daf9d714912cd76fd82e1f54da0e6d798 [^]
2017-05-02 13:02hgbotCheckin
2017-05-02 13:02hgbotNote Added: 0096307
2017-05-02 13:03hgbotCheckin
2017-05-02 13:03hgbotNote Added: 0096308
2017-05-08 09:29marvintmReview Assigned To => marvintm
2017-05-08 09:29marvintmStatusresolved => closed
2017-05-08 09:29marvintmFixed in Version => RR17Q3

Notes
(0096306)
hgbot   
2017-05-02 13:01   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: e063519daf9d714912cd76fd82e1f54da0e6d798
Author: Jorge Garcia <jorge.garcia <at> openbravo.com>
Date: Fri Apr 28 14:15:13 2017 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/e063519daf9d714912cd76fd82e1f54da0e6d798 [^]

Fixed issue 35858: When applying more than 2 discounts to the same line the
information about them is generated wrongly.

The solution is to used the discounted amount per product instead of the
discount accumulated to calculate the base price in each promotion.o

---
M web/org.openbravo.retail.posterminal/js/model/order.js
---
(0096307)
hgbot   
2017-05-02 13:02   
Repository: erp/pmods/org.openbravo.retail.sampledata
Changeset: 6d9d35117c6f80976ca8cdbb39068affc9d99450
Author: Jorge Garcia <jorge.garcia <at> openbravo.com>
Date: Fri Apr 28 14:14:40 2017 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.sampledata/rev/6d9d35117c6f80976ca8cdbb39068affc9d99450 [^]

Related issue 35858: When applying more than 2 discounts to the same line the
information about them is generated wrongly.

Create some new manual discounts to test the functionality.

Those new discounts are by default inactive and are activated by the test.

---
M referencedata/sampledata/The_White_Valley_Group/M_OFFER.xml
---
(0096308)
hgbot   
2017-05-02 13:03   
Repository: tools/automation/pi-mobile
Changeset: 6e3656dcf7428ed627ec21743982c78a3f30bd07
Author: Jorge Garcia <jorge.garcia <at> openbravo.com>
Date: Tue May 02 10:27:54 2017 +0200
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/6e3656dcf7428ed627ec21743982c78a3f30bd07 [^]

Verifies issue 35858: When applying more than 2 discounts to the same line the
information about them is generated wrongly.

Added test I35858_CorrectDataInBackendWithSeveralManualPromotions.

---
A src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/I35858_CorrectDataInBackendWithSeveralManualPromotions.java
---