Display Amount as comma separated format in Advanced PDF template

Display the amount as a comma-separated value without rounding into fixed number of digits.

<#function toCurrency value showSymbol=false>
     <#assign decimalVal = value?string?split(".")[1]?length>
       <#assign decimalCountValue = value?string?split(".")[1]>
         
       <#assign addChar =''>
         <#if decimalCountValue == "00"><#assign addChar ="00">
           <#else>
       <#list 1..decimalVal as i><#assign addChar +="#"></#list></#if>
        <#if value?is_number>
          
        <#local retval = 0>
        <#local retval = value?string["#,##0."+addChar]>
       
        <#return retval>
        <#else>
        <#return value>
    </#if>
</#function>


<table>
<tr><td>${toCurrency(record.total)}</td></tr>
</table>

Leave a comment

Your email address will not be published. Required fields are marked *