2

I have been working on ADempiere these past few days and I am confused about something.

I created a new column on my database table named Other_Number with the reference type Quantity. Max length is 20.

On my Java source, I used BigDecimal.

Now every time I try to input exactly 20 digits on the Other_Number field, the last 4 digits gets rounded. Say if I input 12345678901234567891. When I try to save it, it becomes 12345678901234567000.

Other than that. All the records that gets saved on the database (PSQL) gets appended with ".000000000000" (that's 12 zeros).

Now I need to do something so that when I input 20 digits, the last 4 digits don't get rounded.

Also I need to get rid of that ".000000000000"

Can you please tell me why this is happening?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
RhanCandia
  • 21
  • 2

4 Answers4

2

If it's not actually a number you want but rather some kind of reference field that contains only numeric digits, change the definition in the Application Dictionary to be:

Reference: String 
Length: 20 
Value Format: 00000000000000000000 (i.e. 20 Zeros!)

This will force the input be numeric only (i.e. alpha characters will be ignored!) and because it is a String there will be no roundingString with 20 numeric digits

Colin Rooney
  • 439
  • 7
  • 15
2

ADempiere as a financials ERP software is crucial in how it deals with financial amounts. In the database the exact BigDecimal value has to maintain its data integrity. Precision and rounding has been done as perfect as possible in code. Been part of the established famous project Compiere ERP, where iDempiere and Openbravo are also forks from, such financial amount management is already well defined and solved. Perhaps you need to set precision in its appropriate window http://wiki.idempiere.org/en/Currency_%28Window_ID-115%29 enter image description here

red1
  • 120
  • 5
1

Adempiere will support upto 14(+5) digits (trillions) amount/quantity of business (USD currency).

What currency you are using, is it possible to use this much amount/quantity in ERP system ?

If you want to change the logic, then you can change logic at the getNumberFormat method of DispalyType.java class.

What was the business scenario?

Giri
  • 507
  • 6
  • 23
1

In Adempiere java code "setScale" Method is used to rounded the value

Example:

    BigDecimal len= value           
    len= len.setScale(2,4);
    setLength(len);
Silviaa
  • 475
  • 8
  • 35