Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0048662Openbravo ERPA. Platformpublic2022-02-23 16:492022-02-23 16:49
vmromanos 
Triage Platform Base 
normalminoralways
newopen 
5
 
 
Core
No
0048662: FilterExpression class receives number with thousand separator
A class that implements the org.openbravo.client.application.FilterExpression java interface receives as parameter a "context", which is a json object with some properties.

In case of a property that represents a number, the property is sent as a String and it includes the thousand separator. Example:
"inpexpectedQty":"2,000"
(the number represents two thousand)

Usually you want to parse this number into a BigDecimal using the BigDecimal(String) constructor. The problem is that this thousand separator is not allowed for the BigDecimal constructor and it fails.


Note that in the case of callouts we have the similar need of parsing a number, but in that case there is an API to properly do it [CalloutInfo.getBigDecimalParameter()].

In the case of FilterExpression we don't have such an API.
Login in Backend to the AWO-QA client
Create a Purchase Order for
 - US West Coast
 - Be Soft Drinker, Inc.
 - US West Coast warehouse
Enter a line for 2000 units of Ale beer
Book the order.

Now press Receive button and Done.
Go to the Task tab just below Order Line, select the task and set Confirmed Quantity = 1.
Press Confirm button.
Notice that the Delta Response mandatory field is empty, because the DeltaResponseDefaultExpression (https://gitlab.com/openbravo/product/pmods/org.openbravo.warehouse.advancedwarehouseoperations/-/blob/master/src/org/openbravo/warehouse/advancedwarehouseoperations/filterexpression/DeltaResponseDefaultExpression.java#L67 [^]) has thrown an exception trying to parse the number.

java.lang.NumberFormatException: Character , is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
    at java.math.BigDecimal.<init>(BigDecimal.java:518) ~[?:?]
    at java.math.BigDecimal.<init>(BigDecimal.java:401) ~[?:?]
    at java.math.BigDecimal.<init>(BigDecimal.java:834) ~[?:?]
    at org.openbravo.warehouse.advancedwarehouseoperations.filterexpression.DeltaResponseDefaultExpression.isExpectedQtyEqualOrLowerThanConfirmedQty(DeltaResponseDefaultExpression.java:67) ~[classes/:?]
Several possibilities I see:
- To send numbers as numbers in the JSON (not as String). That would represent an API change.
- To keep on sending numbers as Strings, but making sure we don't have thousand separator, and that the decimal separator is a fixed parameter (dot)
- To have an API in java to easily parse a number in FilterExpression (and any other related class), like we have in callouts, which is able to remove the thousand separator and to set the decimal separator to a dot.
No tags attached.
Issue History
2022-02-23 16:49vmromanosNew Issue
2022-02-23 16:49vmromanosAssigned To => Triage Platform Base
2022-02-23 16:49vmromanosModules => Core
2022-02-23 16:49vmromanosTriggers an Emergency Pack => No

There are no notes attached to this issue.