View source | View content page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Show collection (0 pages)
Collections help

Search

Projects:Allow comma separator/Technical Documentation

Contents

Allow comma ',' as decimal separator for numbers - Technical Documentation

Overview

There should be a decimal separator defined in Openbravo.properties, and widgets should take it into account to do its validation.

Open discussion

1. Decimal separator ',' and others formats like date are related to language selected by user in preferences. It's not unique for all user's executing a Openbravo ERP instance. Example: In a installation that have users using English, Spanish and Portuguese the configurations are different.

Current status

Currently Openbravo ERP has this configuration of decimal and grouping separators:


Javascript level

There is a custom function (not a dojo function) which validates the input number format, this function only admit decimal separator (grouping separator is not implemented)

Use a dojo validation base on "dojo/widget/RealNumberValidation.js" and always take the dot "." as decimal separator.

Currently opnebravo has an "openbravo/widget/RealNumberValidation.js" which has a method "postMixInProperties" to obtain the element properties.


Java level

There is no transformation of input values, for output values (presentation) there is a "format.xml" config file that especifies the format. This format.xml defines many formats that principal utility is for reports, all the generated windows use the "qtyEdition" format.

For example, to obtain 1.500,23 a posible config can be:

  <Number name="qtyEdition"
      decimal="," grouping="." formatOutput="#,##0.###" formatInternal="#,##0.###" />

In 'formatOutput' and 'formatInternal' always the decimal separator is '.' and the grouping separator is ',', to change the separators is necesary to especify the separator character in 'decimal' and 'grouping' atributtes, for example: decimal="," grouping="."


Database level

The format for introducing numbers is defined in a session variable in the openbravo.properties:

bbdd.sessionConfig=ALTER SESSION SET NLS_DATE_FORMAT='DD-MM-YYYY' NLS_NUMERIC_CHARACTERS='.,'

In NLS_NUMERIC_CHARACTERS variable the fist character especifies the decimal separator and the second the grouping separator. ORACLE only acepts numbers with the format expecied in this variable, but if this variable isn't especified takes the default for the database language. This variable also affects the format of the outgoing numbers in the database.

Postgres doesn't have grouping separator, and takes the first ocurrence of comma ',' or dot '.' as decimal separator. If there is more than one separator takes the first as decimal separator and from the second to the end discard it, for example : 1.500,23 -> 1.5 Or 1,500.23 -> 1.5


Changes needed

Configuration files

In openbravo.properties or format.xml especify the decimal separator.


Servlet level

The HttpSecureAppServlet need to read it and declare as global variable.


Java & XML level

The java servlets of each window needs to read the global variable and pass it to the xml.


HTML level

In html is need to add an attribute to the input real number:

<INPUT dojoType="openbravo:RealNumberTextbox" type="text" ... decimal="," ... >


Javascript level

Read the "decimal" attribute in "openbravo/widget/RealNumberValidation.js" and override the dojo separator

postMixInProperties: function(localProperties, frag) {
 ...
	if(localProperties.decimal){ 
		this.flags.decimal = localProperties.decimal;
	}
 ...
}

Change the default/ValidationIntegerBox.js to validate against the defined separator in the "decimal" attribute.

Retrieved from "http://wiki.openbravo.com/wiki/Projects:Allow_comma_separator/Technical_Documentation"

This page has been accessed 5,548 times. This page was last modified on 8 June 2012, at 05:26. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.