Decimal number VS pdf

in my custom module I have a decimal field. Here is the screenshot.

The problem is that in the pdf model, it is printed with too many decimals.
While the currency fields are limited according to the settings, here I can’t format it with only 2 decimals.
Can anyone give me a suggestion?

Thank you all.

Where is that PDF being generated from?

  • where do you define it?

  • where do you trigger its actual generation from?

Hi pgr,
it is a pdf from listview, standad, which uses formLetter.php

I had a look at the code but unfortunately I couldn’t get to the spot that is producing that output, I’d have to spend more time on it, which I am afraid I don’t have… :frowning:

Are you using a debugger? Can you step through the code until you get there?

In the file

you see the field types being handled, like enum, radio. you can add decimal here and change the format or strip the extra zeros. In order to make it upgrade safe, you have to move the generatePDF.php to custom directory first and then the templateParser.php

1 Like

If this can be fixed in templateParser.php and the fix is to respect the decimals specified in the field definition, then we should just fix this for everyone and make the fix in core. That way you wouldn’t have to worry about being upgrade-safe.

Hello and thank you both.
Next week, right after the Christmas break, I will try and let you know.

1 Like

if ($ field_def ['type'] == 'decimal') {
in templateParser is correct and the pdf is formatted as desired.

However, to make safe changes in custom it is not enough to edit the generatepdf file here
require_once ('custom / modules / AOS_PDF_Templates / templateParser.php');

Evidently it is called in other places in the code and therefore it is necessary to make more changes to make it work.

At the moment I don’t know where else is called.

@2di7 can you explain in more detail what you added, and where?

Maybe you can also start a PR so this gets fixed in core. I can help you with that, if necessary. Thanks