Openbravo Issue Tracking System - Retail Modules
View Issue Details
0043202Retail ModulesWeb POSpublic2020-02-12 17:582020-02-24 12:21
guilleaer 
Retail 
normalminoralways
newopen 
5
 
 
No
0043202: grossListPrice & priceList properties of order line model (client side) are not behaving as expected according to ERP behavior
In backend
-> Using price including taxes
GrossPriceList field of orderline stores the price of a product in the price list when the order line was created

-> Using price not including taxes
priceList field of orderline stores the price of a product in the price list when the order line was created

The above fields are static and should not change during the different processes.

All the facts explained above are true and correct. However, in the frontend side (client-side) we have properties that suggest the same behavior but they are behaving differently

priceList => seems to match with OB.MobileApp.model.receipt.get('lines').at(0).get('priceList') but the behavior is not the same

GrossPriceList => seems to match with OB.MobileApp.model.receipt.get('lines').at(0).get('grossListPrice') but the behavior is not the same

Error 1:
names of these properties are confusing

Error 2:
Front end does not offer a model property that represents the same concept stored in GrossPriceList, priceList which is the original price in the price list used when the order was created


Update:

Also the property discountPercentage is wrongly set for a layaway with manually modified price. This property is used for the column "discount" in the DB orderline (it is a percentage)

When a layaway is loaded in order to pay it, if you type:
OB.MobileApp.model.receipt.get('lines').at(0).get('discountPercentage')
The value is right. It's the same than when first synchronized the layaway, but when you completely pay the layaway, this code is executed:
discountPercentage = OB.DEC.toBigDecimal(grossListPrice)
              .subtract(grossUnitPrice)
              .multiply(new BigDecimal('100'))
              .divide(
                OB.DEC.toBigDecimal(grossListPrice),
                2,
                BigDecimal.prototype.ROUND_HALF_UP
              );

Since the property grossListPrice is wrong (based on grossListPrice or priceList depending on including/excluding taxes), the discountPercentage is wrongly calculated and sent.

Since this only happens for completed layaways, the orderloader doesn't put this wrong values in the DB, but they could be used by custom processes.
[scenario 1 -> including taxes]


- Go to web POS (VBS-1) which uses price including taxes)
- Mark the order as layaway
- add Headlamp ultralight (price in the price list = 18.90)
- Manually modify that line price (click price and enter 6)
- In developer tools check that

OB.MobileApp.model.receipt.get('lines').at(0).get('priceList')
18.9
OB.MobileApp.model.receipt.get('lines').at(0).get('grossListPrice')
18.9

Error 1: Since we are working with the price including taxes priceList should be 0 and grossPriceList = 18.90. However, when order is synchronized values are OK in the backend

- layaway the ticket without adding any payment

[ticket saved]

- Open the menu and open recently created receipt using "Open receipt"
- When the ticket is loaded using developer tools check that

OB.MobileApp.model.receipt.get('lines').at(0).get('priceList')
6
OB.MobileApp.model.receipt.get('lines').at(0).get('grossListPrice')
18.9

Error 2: Since we are working with the price including taxes priceList should be 0 and grossPriceList = 18.90. However, when payments are added or layaway is completed values are still correct in the backend

[scenario 2 -> Not including taxes]


- Go to web POS (PS-1) which uses price NOT including taxes)
- Mark the order as layaway
- add Headlamp ultralight (price in the price list = 18.90)
- Manually modify that line price (click price and enter 6)
- In developer tools check that

OB.MobileApp.model.receipt.get('lines').at(0).get('priceList')
18.9
OB.MobileApp.model.receipt.get('lines').at(0).get('grossListPrice')
18.9

Error 3: Since we are working with the price NOT including taxes priceList should be 18.90 and grossPriceList = 0. However, when order is synchronized values are OK in the backend

- layaway the ticket without adding any payment

[ticket saved]

- Open the menu and open recently created receipt using "Open receipt"
- When the ticket is loaded using developer tools check that

OB.MobileApp.model.receipt.get('lines').at(0).get('grossListPrice')
6
OB.MobileApp.model.receipt.get('lines').at(0).get('priceList')
6

Error 4: Since we are working with the price including taxes priceList should be 18.90 and grossPriceList = 0. However, when payments are added or layaway is completed values are still correct in the backend

Error 5: If for any reason someone needs to check the original price list of the product included in the order line when order line was created, there is no way in the front end to do that.



Update:

- Go to web POS (PS-1) which uses price NOT including taxes)
- Mark the order as layaway
- add Headlamp ultralight (price in the price list = 18.90)
- Manually modify that line price (click price and enter 6)
- In developer tools check that
OB.MobileApp.model.receipt.get('lines').at(0).get('discountPercentage') is still not set (it's set when synchronizing the order)
- Layaway the order
- Load it with open receipt option
- In developer tools check that
OB.MobileApp.model.receipt.get('lines').at(0).get('discountPercentage') is 68.25%
- Completely pay the layaway
- If you put a breakpoint in the previous code:
discountPercentage = OB.DEC.toBigDecimal(grossListPrice)
              .subtract(grossUnitPrice)
              .multiply(new BigDecimal('100'))
              .divide(
                OB.DEC.toBigDecimal(grossListPrice),
                2,
                BigDecimal.prototype.ROUND_HALF_UP
              );

- You can check the discountPercentage is calculated based on a previously wrongly calculated grossListPrice. It is always 0.
-> Rename current properties to avoid confusion since they are not working as expected
-> Create properties priceList && grossListPrice which should work in the same way that they work in backend. They will just store the original price in the pricelist. This value should be loaded from backend when an order is loaded and it MUST never change


Update:

-> Calculate the discountPercentage based on new property officialListPrice, created in issue 43226 (only if the property exists, that is, for loaded receipts)
-> In the orderloader, in the case of "ismodified", put there some exceptions that don't need to be updated i.e listPrice. Set the officialListPrice into the JSON
No tags attached.
related to defect 0043226 closed prakashmurugesan88 Wrong List price in order line when returning a product whose list price has changed in backoffice (price not including taxes) 
Issue History
2020-02-12 17:58guilleaerNew Issue
2020-02-12 17:58guilleaerAssigned To => Retail
2020-02-12 17:58guilleaerTriggers an Emergency Pack => No
2020-02-12 18:05guilleaerSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20365#r20365
2020-02-12 22:12PracticsIssue Monitored: Practics
2020-02-14 13:10joniturralde93Relationship addedrelated to 0043226
2020-02-19 13:31joniturralde93Description Updatedbug_revision_view_page.php?rev_id=20408#r20408
2020-02-19 13:31joniturralde93Steps to Reproduce Updatedbug_revision_view_page.php?rev_id=20409#r20409
2020-02-19 13:31joniturralde93Proposed Solution updated
2020-02-24 12:21hgbotCheckin
2020-02-24 12:21hgbotNote Added: 0118047

Notes
(0118047)
hgbot   
2020-02-24 12:21   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: a4c5442ca9f7c6717144b005be86c8ced4a1f063
Author: Prakash M <prakash <at> qualiantech.com>
Date: Mon Feb 24 16:49:22 2020 +0530
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/a4c5442ca9f7c6717144b005be86c8ced4a1f063 [^]

related to ISSUE-43202 : Fixed discountPercentage calculation issue

---
M web/org.openbravo.retail.posterminal/js/model/order.js
---