PDF generation, balance_due_raw containing int instead of float


I noticed a problem today on my invoice generation, the amount in the variable “$balance_due_raw” is an int and not a float. I use it for the swiss QR invoice generation and it is required for the amount field to be in the following numerical format, with two decimals (%01.2f) : 123456.00

It seems this has been introduced by a somewhat recent update. I installed the latest update available on github (v5.7.45-W125), but the problem remains. Is there maybe another variable i can use ?



@david can you please advise?

Nothing has changed around this part of the app for a while. is the number correct?

ie. 123456

But you are expecting

123456.00 ?

Thanks for your quick replies

It may have changed a few month ago, I’m not updating too often. The number is correct but it used to print out as a 2 decimal float and now it prints effectively raw (int when full number, one decimal when there are decimal).

What I want (and used to have in $balance_due_raw) : 10.00, 12345.00, 1.50, 0.10
What I get now : 10, 12345, 1.5, 0.1

Maybe is there a trick to format the number in the pdf invoice generator ? Or another variable I could use ? $balance_due doesn’t work since it includes the monetary symbol.

With my digging in, I think it used to work that way in the previous version I was using, v5.5.110. The thing changed for me when I updated to v5.7.29. Some change has happend in between those IMO.

I added a new variable called $balance_due_dec containing the formatted value I need. I made a pull request (#8950) containing the addition.

I have v5.7.54-C125 installed now, but $balance_due_dec is still unknown?

Oh sorry, it seems like I did the pull request on the wrong branch (v5-stable instead of v5-develop). I fixed it now and it should merge and be available in the next release :slight_smile:

1 Like