Openbravo Issue Tracking System - Retail Modules
View Issue Details
0045405Retail ModulesDiscounts and Promotionspublic2020-11-10 14:332020-12-09 06:37
gsuarez 
ranjith_qualiantech_com 
highmajoralways
closedfixed 
30
RR19Q1 
 
No
0045405: Error applying coupon. The last line is negative.
When applying a coupon for 71.49, the last line is negative.
This coupon was generated by OTF. The rule is 50% off the next purchase, that is, a sale was made for 142.98.
I attach a ZIP with two images, one of POS and the other of the backoffice.
1. Generate a new Variable Amount Coupons promotion. Check Is OTF Coupon and Uses coupon codes. In the field Included Product Categories, select the option "Only those defined". Add Lighting & Electronics product category in Product Category tab.
2. Generate a new OTF rule with 50% of discount and associate the discount created in step 1. I used OTF_10_PER rule, but I change 10% to 50%.
3. Generate a sales for 142.98 for products that being to Ski category.
4. Check that a coupon is generated in the promotion created in step 1. The amount of the coupon will be 71.49.
5. Change the price of 8 products to:
   a) WVG/L0001 to 19.99.
   b) WVG/L0002 to 10.
   c) WVG/L0003 to 18.99.
   d) WVG/L0004 to 12.50.
   e) WVG/L0005 to 2.99.
   f) WVG/L0006 to 2.99.
   g) WVG/L0007 to 1.
   h) WVG/L0008 to 0.10.
The list price will be The White Valley Group Purchase Price List Version.
6. Refresh POS and check that the prices has been changed.
7. In the new ticket, add the products in order. First WVG/L0001, second WVG/L0002 and so.
8. For the product WVG/L0006 check that quantity are 2.
9. Apply the coupon.
10. Check that the line with price 0.10 has a discount of 0.11.
No tags attached.
related to defect 0047265 closed migueldejuana Combos with higher discount than line amount, generate negative lines 
related to defect 0047365 closed migueldejuana Coupons with higher discount than line amount, generate negative lines 
zip Images.zip (300,904) 2020-11-10 14:33
https://issues.openbravo.com/file_download.php?file_id=15075&type=bug
diff 45405_19Q1_discountcouponotf.diff (3,364) 2020-12-09 06:37
https://issues.openbravo.com/file_download.php?file_id=15145&type=bug
Issue History
2020-11-10 14:33gsuarezNew Issue
2020-11-10 14:33gsuarezAssigned To => Retail
2020-11-10 14:33gsuarezFile Added: Images.zip
2020-11-10 14:33gsuarezResolution time => 1606777200
2020-11-10 14:33gsuarezTriggers an Emergency Pack => No
2020-11-24 03:26ranjith_qualiantech_comAssigned ToRetail => ranjith_qualiantech_com
2020-11-24 03:26ranjith_qualiantech_comStatusnew => scheduled
2020-11-24 10:51hgbotNote Added: 0124580
2020-11-25 07:52hgbotResolutionopen => fixed
2020-11-25 07:52hgbotStatusscheduled => closed
2020-11-25 07:52hgbotNote Added: 0124606
2020-11-25 07:52hgbotNote Added: 0124607
2020-12-09 06:37ranjith_qualiantech_comFile Added: 45405_19Q1_discountcouponotf.diff
2021-06-28 16:28migueldejuanaRelationship addedrelated to 0047265
2021-07-08 14:34migueldejuanaRelationship addedrelated to 0047365

Notes
(0124580)
hgbot   
2020-11-24 10:51   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.discounts.coupons.otf/-/merge_requests/2 [^]
(0124606)
hgbot   
2020-11-25 07:52   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.discounts.coupons.otf [^]
Changeset: e47123efa5527b3208acd00e8210ba193f857533
Author: Ranjith S R <ranjith@qualiantech.com>
Date: 2020-11-24T15:15:20+05:30
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.discounts.coupons.otf/-/commit/e47123efa5527b3208acd00e8210ba193f857533 [^]

Fixed ISSUE-45405: Updated discount calculation by sorting lines
To avoid decimal problem, difference of accumulated discount and total discount will be applied for last line.
Sometimes discount amount will be higher than last line price which leads to negative line. To avoid this, Line should be sorted ascending by price, so last line will have higher amount, discount will be applied withput any problem

---
M web/org.openbravo.retail.discounts.coupons.otf/app/model/business-logic/discounts-engine/engine/rules/variable-amount-coupons-discount.js
---
(0124607)
hgbot   
2020-11-25 07:52   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.discounts.coupons.otf/-/merge_requests/2 [^]