Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0047780Openbravo ERP07. Sales managementpublic2021-09-29 19:572021-10-06 16:25
lbressan 
vmromanos 
highmajoralways
closedinvalid 
5
PR20Q4.4 
 
vmromanos
Core
2021-10-13
No
0047780: Application of discount in cascade
Application of discounts in cascade, for a sales order in ERP
1) Add an order in the "Sales order" window

2) Add 3 discounts in the tab "Basic Discounts", the first two with the check deactivated "Cascade" and the other active, in the last discount with the active checks

3) Select "Book" to pay

4) Verify that there have been discounts but only two discounts apply
No tags attached.
? Openbravo - Sale.mp4 (3,216,432) 2021-09-29 19:57
https://issues.openbravo.com/file_download.php?file_id=16233&type=bug
Issue History
2021-09-29 19:57lbressanNew Issue
2021-09-29 19:57lbressanAssigned To => Triage Finance
2021-09-29 19:57lbressanFile Added: Openbravo - Sale.mp4
2021-09-29 19:57lbressanModules => Core
2021-09-29 19:57lbressanRegression date => 2021-10-13
2021-09-29 19:57lbressanTriggers an Emergency Pack => No
2021-10-01 11:01PracticsIssue Monitored: Practics
2021-10-06 15:56vmromanosStatusnew => scheduled
2021-10-06 15:56vmromanosAssigned ToTriage Finance => vmromanos
2021-10-06 16:25vmromanosReview Assigned To => vmromanos
2021-10-06 16:25vmromanosNote Added: 0132211
2021-10-06 16:25vmromanosStatusscheduled => closed
2021-10-06 16:25vmromanosResolutionopen => invalid

Notes
(0132211)
vmromanos   
2021-10-06 16:25   
This is working as expected.

Cascade means to apply this discount and any other previous discount in cascade.
http://wiki.openbravo.com/wiki/Discount [^]

Example: Let's imagine we have a line net amount of 100€.
In the first scenario we declare 3 discounts as:
* 10% Cascade=Yes
* 10% Cascade=Yes
* 10% Cascade=Yes

The calculated discounts are:
 100
- 10 [10% of 100]
- 9 [10% of 100 - 10]
- 8.10 [10% of 100 - 10 - 9]


Now let's define these 3 discounts (like in the bug description) as:
* 10% Cascade=No
* 10% Cascade=No
* 10% Cascade=Yes

The calculated discounts are:
 100
- 10 [10% of 100]
- 10 [10% of 100]
- 8.10 [10% of 100 - 10 - 9]

So the system is applying the Non-cascade discounts (first two discounts), and then it calculates the cascade discount considering the previous ones as if they were declared as cascade.

Implementation details can be found at: https://gitlab.com/openbravo/product/openbravo/-/blob/master/src-db/database/model/functions/C_ORDER_POST1.xml#L1025 [^]