You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Petr Pytelka (JIRA)" <ji...@apache.org> on 2013/07/25 12:11:48 UTC

[jira] [Commented] (OFBIZ-5281) BigDecimal in Minilang are not correctly converted with Czech Locale

    [ https://issues.apache.org/jira/browse/OFBIZ-5281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13719469#comment-13719469 ] 

Petr Pytelka commented on OFBIZ-5281:
-------------------------------------

Some more detail to the third proposal:

There is file framework/base/src/org/ofbiz/base/conversion/NumberConverters.java with class:

    public static abstract class AbstractNumberConverter<S, T> extends AbstractLocalizedConverter<S, T> {
        protected AbstractNumberConverter(Class<S> sourceClass, Class<T> targetClass) {
            super(sourceClass, targetClass);
        }

        public T convert(S obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException {
            return convert(obj, locale, null);
        }
    }

We could extend method convert to accept formatString with locale specification.
New method:

public T convert(S obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException {
    if(formatString.startWith("locale:")) {
        locale=Locale.forLanguageTag(formatString.substring(7));
    }
    return convert(obj, locale, null);
}

Decimal number in minilang file would be written as:

<if-compare field="trialBalanceResultMap.debitCreditDifference" operator="greater-equals" value="0.01" type="BigDecimal" format="locale:en_US">

Any comments?
                
> BigDecimal in Minilang are not correctly converted with Czech Locale
> --------------------------------------------------------------------
>
>                 Key: OFBIZ-5281
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5281
>             Project: OFBiz
>          Issue Type: Bug
>          Components: ALL COMPONENTS
>    Affects Versions: Release Branch 12.04
>         Environment: Czech locale
>            Reporter: Petr Pytelka
>            Priority: Critical
>              Labels: BigDecimal, locale, mini-lang
>
> I've found problem in accounting transactions when running Ofbiz with Czech locale. Problem is in the method:
> <simple-method method-name="postAcctgTrans" short-description="Post a AcctgTrans">
> Namely with the lines containing decimal numbers, like:
> <if-compare field="trialBalanceResultMap.debitCreditDifference" operator="greater-equals" value="0.01" type="BigDecimal" >
> When running Ofbiz with Czech locale decimal number format is like: 0,01. Minilang files are parsed according actual locale it means that number is incorectly parsed as 0.0 instead of 0.01. I see this as a critical issue for using Ofbiz with Czech locale.
> My first ideas how to solve this issue:
> 1. Refactor minilang files to contain only 0 as a decical value,e.g.:
> <if-compare field="trialBalanceResultMap.debitCreditDifference" operator="greater-equals" value="0.01" type="BigDecimal" >
> to
> <if-compare field="trialBalanceResultMap.debitCreditDifference" operator="greater" value="0" type="BigDecimal" >
> 2. Change minilang parser to have special support for parsing BigDecimal with C locale
> 3. Append attribute with number format specification for each line with
> big decimal in particular format, e.g.: format="C"
> Any help with this issue is welcomed...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira