Today I would like to share my approach to provide flexible precision in numeric display type. As you know there are several numeric display types in Adempiere / Idempiere. You can find them in the list of Reference Type in Table & Column window. You can see you can have either Number, Amount, Cost+Price, Quantity or Integer. While Integer is obviously for whole number, there is confusion to know the difference between the rest.
The differences are easily tracked down in DisplayType class which you can find in org.compiere.util. It is the minimum number of digits allowed in the fraction portion of a number. So there you have:
Integer : None
Quantity : None
Amount : 2
Number : 1
As you can see Cost+Price is having the same number of digits as Amount. You can not tell the difference between the two. So let’s make some difference. My workaround is to modify one line in DisplayType class. I would change the code so the minimum fraction digits for Cost+Price is taken from System Configuration that I can manage later. It even gives me better flexibility!
else if (displayType == CostPrice)
MSysConfig.getIntValue(“DISPLAY_TYPE_COSTPRICE_FRACTION”, AMOUNT_FRACTION, Env.getAD_Client_ID(Env.getCtx())));
In implementation you would probably need to have a numeric display type where it can support more than 2 number of digits in the fraction portion. I hope the modification I share with you today can help you in this situation.
Goodwill Consulting is a long time Adempiere / Idempiere supporter since their inception. We are offering software-as-a-service solution on the cloud based on Adempiere / Idempiere. For more information, you can drop us a visit at www.goodwillerp.com