# 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:

### Steps

1. Create amount formatting methods for 2, 3 and 4 decimal places:
• `Amounts2Decimals`
• `Amounts3Decimal`
• `Amounts4Decimals`
1. Create a multi-field Script Formatter:
1. Name it `AmountsTable`.
2. Set the field data type to` Double/Amount:`
3. Add the following script to the Project Script: AmountsTable_FormatDoubleField.
2. Create a validation method for the line item:
1. Add the following script to the Project Script:
`Quantity / Unit of Quantity x Unit Price = Line Item Total Price`
LineItem_Validate
2. Create a table model
3. Create a format locator for amounts and a table locator
4. Create a field of type table

## Applies to:

Product Version Category
AXPRO 5.5 Project Builder