This topic contains 2 replies, has 0 voices, and was last updated by mmarchant77 9 years ago.

  • Author
    Posts
  • #2973

    mmarchant77

    I’m working on an invoice printout with advanced pdf/html, and I’m seeing issues with rounding.

    I have custom column fields of type decimal number and they may contain numbers with more than 2 numbers after the decimal, yet on the printout they’re always rounded to 2 numbers after the decimal and there’s no html code that explains this behaviour.

    Has anyone every noticed this and found a way to get around it?

    Another issue I’m facing is that rounding of the rate column is inconsistent: it rounds when printing in another language with “print in customer’s locale” but not when printing in the company language. Has anyone every see this?
    This is a cached copy. Click here to see the original post.

  • #2974

    michoel

    The way I ensure consistent rounding of all fields is to first convert all fields to a number and then format with FTL:

    PHP Code:

        
            
        
            
        
     

    ${toNumber(item.grossamt)?string[“0.00”]} 

    See here for formatting options:

    http://freemarker.org/docs/ref_built…ing_for_number

    http://docs.oracle.com/javase/7/docs…malFormat.html

  • #2975

    mmarchant77

    Thanks very much for your response.

    I have tried your PHP function, yet the issue still remains with the decimal numbers. They are rounded before the PHP function has the chance to do the formatting.

    However, for the rate field, the function does indeed work and solves the issue I was seeing with the multi-language.

You must be logged in to reply to this topic.