Money masks on input type cost price doesn't work when logged as portuguese (br) on adaxa plugin

27 views
Skip to first unread message

leonard...@devcoffee.com.br

unread,
Aug 30, 2016, 8:23:59 AM8/30/16
to iDempiere
Hi,

The cost price fields works great when i'm logged in english language on adaxa plugin. But the same doesn't happen when i'm logged in portuguese (br) language. For example:

When a I create a sales order / order line, the mask money works with a decimal point ($ 240.53). We have a flag on language window on idempiere called decimal point, if this flag are not ticked, the system use a comma as decimal separator (R$ 240,53), this is the default format in brazil and the conversion works fine on idempiere webui. but the follow problem occurs in adaxa plugin:

When I create a order line and select a product, first the price will be displayed as "240.53". If I change the quantity, the application will reload the fields on the form, and the price will be changed for "24053". Debbuging the application, i get the following code responsable for the conversion:


 if (DisplayType.isNumeric(dt))
 
{
 
BigDecimal bd = null;
 
try
 
{
 
Number nn = null;
 
if (dt == DisplayType.Amount)
 nn
= wsc.amountFormat.parse(value);
 
else if (dt == DisplayType.Quantity)
 nn
= wsc.quantityFormat.parse(value);
 
else // DisplayType.CostPrice
 nn
= wsc.numberFormat.parse(value);
 
if (nn instanceof BigDecimal)
 bd
= (BigDecimal)nn;
 
else
 bd
= new BigDecimal(nn.toString());
 
}
 
catch (Exception e)
 
{
 log
.warning("BigDecimal: " + columnName + "=" + value + ERROR);
 
return ERROR;
 
}
 log
.fine("BigDecimal: " + columnName + "=" + value + " -> " + bd);
 
return bd;
 
}

As we can see, the code gets the context of the application (including the language selected on the login), and do the parse. If we track back this line 
nn = wsc.numberFormat.parse(value);

we will get a DecimalFormat.parse() method, and i can't figure out how the context can interfere on this method.

I developed atemporary solution, the value will not be changed like before (240.53 to 24053)  but the user have to deal with the decimal point, like in english ($ 240.25 for example)

            BigDecimal bd = null;
            try
            {
                Number nn = null;
                if (dt == DisplayType.Amount)
                    nn = Double.parseDouble(value);
                else if (dt == DisplayType.Quantity)
                    nn = Double.parseDouble(value);
                else    //     DisplayType.CostPrice
                    nn = Double.parseDouble(value);
                if (nn instanceof BigDecimal)
                    bd = (BigDecimal)nn;
                else
                    bd = new BigDecimal(nn.toString());
            }
            catch (Exception e)
            {
                log.warning("BigDecimal: " + columnName + "=" + value + ERROR);
                return ERROR;
            }
            log.fine("BigDecimal: " + columnName + "=" + value + " -> " + bd);
            return bd;

But this is not good. I'm working on this problem for days and have no idea how solve this, any help will be greatful!
Reply all
Reply to author
Forward
0 new messages