+2

Round numbers - open PDF templates

Ineke0333 11 months ago in Home Portal / Smart Projects with CAT integration updated by Thomas Mosley 11 months ago 5

Anyone has any idea to round numbers in the open PDF templates in XTRF? 

Our quotes include totals with 3 decimals -> €120,025

Thanks for sharing your thoughts

Hey, is this only a problem in open PDF templates?

You could try and check General configuration - Settings - Number and Date formatting - quantity and currency format 

+1

Thank you, this is not an option I'm afraid since we use 3 decimals for pricing matters on other levels. So ideally I want to manage this only within the open PDF templates in the document templates. Any suggestions? 

Hi, 

As I remember there was an issue with the default way they were handling this when they first launched the new templates. They were going to fix it at some point but I am not sure if that has happened. 

Our workaround is:

$utils.getXtrfDecimalFormattingUtils().formatCurrency(YOUR_VARIABLE_HERE)

Provided you have set up your currency format to only be 2 digits, this will show only 2 digits. If you also want to show the currency symbol, you need to add that before, i.e.:


${quote.currency.symbol} $utils.getXtrfDecimalFormattingUtils().formatCurrency($totalAgreed)

+1

This is the code we are using for our quote templates that include half cent pricing....

#set($decimalSeparator = '.')
#set($decimalSeparator = $decimalSeparator.toCharArray().get(0))
#set($groupSeparator = ",")
#set($groupSeparator = $groupSeparator.toCharArray().get(0))
#set($myFormat = $utils.getXtrfDecimalFormattingUtils().getDecimalFormat('#,##0.000', $decimalSeparator, $groupSeparator, true)) .... #set($unitRate = $myFormat.format($receivable.getRate())) #set($output = ${currencySymbol} + ${unitRate} + " per " + ${receivable.calculationUnit.displayName}) ${output}
+1

This is the answer I got a few months ago from the Helpdesk, similar to MikevG's when I needed to display 4 digits after the decimal:

You can define custom number formats by using:

#set($decimalSeparator = ',')
#set($decimalSeparator = $decimalSeparator.toCharArray().get(0))
#set($groupingSeparator = '.')
#set($groupingSeparator = $groupingSeparator.toCharArray().get(0))
#set($myFormat = $utils.getXtrfDecimalFormattingUtils().getDecimalFormat('#,##0.0000', $decimalSeparator, $groupingSeparator, true))

$myFormat.format($valueToFormat)
$myFormat.format(10.01) ➝ 10,0100