Amount Script Formatter 2, 3 and 4 Decimals
17761
QAID # 17761 Published
Question / Problem:
Amount Script Formatter 2, 3 and 4 Decimals
Answer / Solution:
- €12.34
- €12.345
- €12.3456
Use Case
- The formatting of the cells of an inherited table cannot be altered, due to the KTM inheritance design.
This article describes a work around for the problem - a work around which is actually a best practice. - Vendors sometimes print a line item unit price with more than just two decimal places, for example, €12.345 or €12.3456.
The unit price is often printed in this way when the unit is very small, for example, screws.
Example
In this case, the line item unit price needs to be formatted differently than the standard amount, which has 2 decimal places:
Download
Click this link to download the zipped example project: Formatter_Script_TableAmount.zip (Created with V5.0 Build 3223).
Example Results
Steps
- Create amount formatting methods for 2, 3 and 4 decimal places:
Amounts2Decimals
Amounts3Decimal
Amounts4Decimals
- Create a multi-field Script Formatter:
- Name it
AmountsTable
. - Set the field data type to
Double/Amount:
- Add the following script to the Project Script: AmountsTable_FormatDoubleField.
- Name it
- Create a validation method for the line item:
- Add the following script to the Project Script:
Quantity / Unit of Quantity x Unit Price = Line Item Total Price
LineItem_Validate - Create a table model
- Create a format locator for amounts and a table locator
- Create a field of type table
- Add the following script to the Project Script:
Applies to:
Product | Version | Category |
---|---|---|
AXPRO | 5.5 | Project Builder |