Openbravo Issue Tracking System - Retail Modules
View Issue Details
0039392Retail ModulesDiscounts and Promotionspublic2018-10-02 17:012018-11-22 10:27
lbressan 
ranjith_qualiantech_com 
highmajoralways
closedfixed 
5
RR18Q1.1 
RR19Q1 
marvintm
No
0039392: Division by zero error when several products are included in both a pack discount and another discount.
When products that belong to a pack discount, are also included in a higher priority discount, a "division by zero" error may occur.
Define a Pack discount with more than 1 product:
    Pack discount:
        - Apply next discount = Yes
        - Priority = 2
        - Product A
        - Product B

Define a Price Adjustment discount with the same products
    Price Adjustment discount:
        - Apply next discount = Yes
        - Priority = 1
        - Product A
        - Product B

Create a Sales Order and press the "Add Pack" button.
Select the "Pack discount" just created.
A division by zero error should display, while executing OBDISC_Pack function.

The same error is visible if manually adding pack products and then Booking the Sales Order.

The issue is in the OBDISC_Pack, with a variable v_totalAmount. This variable starts as 0 and gets filled in a loop, but if this loops is not executed, then a division by zero will occur.
With the above configuration, for one specific orderline, the loop won't be executed and then the error happens.
No tags attached.
png Screen Shot 2018-10-04 at 16.14.38.png (439,310) 2018-10-04 21:17
https://issues.openbravo.com/file_download.php?file_id=12239&type=bug
png Screen Shot 2018-10-04 at 16.14.52.png (425,516) 2018-10-04 21:17
https://issues.openbravo.com/file_download.php?file_id=12240&type=bug
png Screen Shot 2018-10-04 at 16.15.13.png (289,826) 2018-10-04 21:18
https://issues.openbravo.com/file_download.php?file_id=12241&type=bug
png Screen Shot 2018-10-04 at 16.15.26.png (302,334) 2018-10-04 21:18
https://issues.openbravo.com/file_download.php?file_id=12242&type=bug
Issue History
2018-10-02 17:01lbressanNew Issue
2018-10-02 17:01lbressanAssigned To => Retail
2018-10-02 17:01lbressanResolution time => 1540245600
2018-10-02 17:01lbressanTriggers an Emergency Pack => No
2018-10-03 08:56ranjith_qualiantech_comAssigned ToRetail => ranjith_qualiantech_com
2018-10-03 08:56ranjith_qualiantech_comStatusnew => scheduled
2018-10-03 12:31jorge-garciaNote Added: 0107135
2018-10-03 12:31jorge-garciaAssigned Toranjith_qualiantech_com => lbressan
2018-10-03 12:32jorge-garciaStatusscheduled => feedback
2018-10-03 12:32jorge-garciaNote Edited: 0107135bug_revision_view_page.php?bugnote_id=0107135#r17734
2018-10-04 21:17lbressanFile Added: Screen Shot 2018-10-04 at 16.14.38.png
2018-10-04 21:17lbressanFile Added: Screen Shot 2018-10-04 at 16.14.52.png
2018-10-04 21:18lbressanFile Added: Screen Shot 2018-10-04 at 16.15.13.png
2018-10-04 21:18lbressanFile Added: Screen Shot 2018-10-04 at 16.15.26.png
2018-10-04 21:22lbressanNote Added: 0107163
2018-10-04 21:22lbressanAssigned Tolbressan => jorge-garcia
2018-10-04 21:23lbressanStatusfeedback => new
2018-10-04 21:23lbressanNote Edited: 0107163bug_revision_view_page.php?bugnote_id=0107163#r17743
2018-10-16 08:39jorge-garciaAssigned Tojorge-garcia => Retail
2018-10-16 11:36ranjith_qualiantech_comAssigned ToRetail => ranjith_qualiantech_com
2018-10-16 11:36ranjith_qualiantech_comStatusnew => scheduled
2018-11-12 13:15mgonzalezhIssue Monitored: mgonzalezh
2018-11-13 07:37hgbotCheckin
2018-11-13 07:37hgbotNote Added: 0107866
2018-11-13 07:37hgbotStatusscheduled => resolved
2018-11-13 07:37hgbotResolutionopen => fixed
2018-11-13 07:37hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts/rev/816f4f4497b14682e2029d6c603d72e7870e7c48 [^]
2018-11-13 10:59hgbotCheckin
2018-11-13 10:59hgbotNote Added: 0107877
2018-11-14 11:16ranjith_qualiantech_comNote Added: 0107902
2018-11-14 11:16ranjith_qualiantech_comStatusresolved => new
2018-11-14 11:16ranjith_qualiantech_comResolutionfixed => open
2018-11-14 11:16ranjith_qualiantech_comStatusnew => scheduled
2018-11-16 13:01hgbotCheckin
2018-11-16 13:01hgbotNote Added: 0107948
2018-11-16 13:01hgbotStatusscheduled => resolved
2018-11-16 13:01hgbotResolutionopen => fixed
2018-11-16 13:01hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts/rev/816f4f4497b14682e2029d6c603d72e7870e7c48 [^] => http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts/rev/2e5923e545dfca37a1d8f043614d95bf72f28203 [^]
2018-11-16 13:50marvintmReview Assigned To => marvintm
2018-11-16 13:50marvintmStatusresolved => closed
2018-11-16 13:50marvintmFixed in Version => RR19Q1
2018-11-22 10:27hgbotCheckin
2018-11-22 10:27hgbotNote Added: 0108052

Notes
(0107135)
jorge-garcia   
2018-10-03 12:31   
(edited on: 2018-10-03 12:32)
Issue is not reproducible neither PI nor 3.0RR18Q1.1

(0107163)
lbressan   
2018-10-04 21:22   
(edited on: 2018-10-04 21:23)
I added some screentshots that contain some examples in order to reproduce the error, and the error itself. These are in 3.0RR18Q3.1, but I also reproduced it in 18Q1.1.
I apologize if I missed any detail in the issue description that is present on these screenshot.

Let me know if you still cant reproduce the error.

(0107866)
hgbot   
2018-11-13 07:37   
Repository: erp/pmods/org.openbravo.retail.discounts
Changeset: 816f4f4497b14682e2029d6c603d72e7870e7c48
Author: Ranjith S R <ranjith <at> qualiantech.com>
Date: Tue Nov 13 12:06:48 2018 +0530
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts/rev/816f4f4497b14682e2029d6c603d72e7870e7c48 [^]

Fixed issue 39392 : Refactored Discount pack calculation

* Previous applied discounts must be consider for pack discount calculation
* Pack discount should be applied for recently added pack products
* Refactored Discount pack calculation changes
  * While iterating order lines, pack discout will be calculated for pack's last product line.
    For previous line iteration, calculation is prevented. Because for pack discount calculation, all lines "gross amount" is needed including discount amount.
    So in the last line iteration, its possible to fetch all the pack lines information
  * If Products added manually which are from Pack, and we are trying to add new pack, pack discount will be calculated for newly added products not for maunally added products

---
M src-db/database/model/functions/OBDISC_PACK.xml
M src/org/openbravo/retail/discounts/AddPack.java
---
(0107877)
hgbot   
2018-11-13 10:59   
Repository: erp/pmods/org.openbravo.retail.discounts
Changeset: 72ebc6f003bd7741547f3f705e1773566dc386f5
Author: Ranjith S R <ranjith <at> qualiantech.com>
Date: Tue Nov 13 15:29:31 2018 +0530
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts/rev/72ebc6f003bd7741547f3f705e1773566dc386f5 [^]

Related to issue 39392 : Backed out changeset: 816f4f4497b1

* Backed out due to error in dbcons-oracle

---
M src-db/database/model/functions/OBDISC_PACK.xml
M src/org/openbravo/retail/discounts/AddPack.java
---
(0107902)
ranjith_qualiantech_com   
2018-11-14 11:16   
Function OBDISC_PACK failing in oracle
(0107948)
hgbot   
2018-11-16 13:01   
Repository: erp/pmods/org.openbravo.retail.discounts
Changeset: 2e5923e545dfca37a1d8f043614d95bf72f28203
Author: Ranjith S R <ranjith <at> qualiantech.com>
Date: Thu Nov 15 14:37:31 2018 +0530
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts/rev/2e5923e545dfca37a1d8f043614d95bf72f28203 [^]

Fixed issue 39392 : Refactored Discount pack calculation

* Previous applied discounts must be consider for pack discount calculation
* Pack discount should be applied for recently added pack products
* Refactored Discount pack calculation changes
  * While iterating order lines, pack discout will be calculated for pack's last product line.
    For previous line iteration, calculation is prevented. Because for pack discount calculation, all lines "gross amount" is needed including discount amount.
    So in the last line iteration, its possible to fetch all the pack lines information
  * If Products added manually which are from Pack, and we are trying to add new pack, pack discount will be calculated for newly added products not for maunally added products

---
M src-db/database/model/functions/OBDISC_PACK.xml
M src/org/openbravo/retail/discounts/AddPack.java
---
(0108052)
hgbot   
2018-11-22 10:27   
Repository: erp/pmods/org.openbravo.retail.discounts
Changeset: 87de3847adea1e274c3d45d96a678e0b2c0a9729
Author: Ranjith S R <ranjith <at> qualiantech.com>
Date: Thu Nov 22 12:11:00 2018 +0530
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts/rev/87de3847adea1e274c3d45d96a678e0b2c0a9729 [^]

Related to issue 39392 : Removed unused variables in obdisc_pack function

---
M src-db/database/model/functions/OBDISC_PACK.xml
---