Hi,

I noticed some weird behaviour with IN when inputting monetary values with a comma as a decimal separator. There are also some discrepancies between the invoice table in the admin panel and displayed values on the generated PDF.

Let’s start with a new line:

The total is obviously wrong, it should be 41,475 rounded to 41,48.

The same line on the PDF shows this:

For some unknown reason, 0,75 is now 0,70, but the total is right this time.

Let’s try another line. I input the same numbers, but now with periods instead of commas:

Now the total is almost right, but there is a rounding error (it should be 41,48, not 41,47).

The PDF however does the rounding properly and shows the correct total:

Now if I save this invoice and reopen it, the line with the periods is converted to the use of commas as decimal separators (as per my currency settings), and the calculation is right this time in the admin panel, minus the rounding error:

The PDF is unchanged from the previous step.

Now if I change a number on the line that had periods converted to commas (55,3 → 55,3), the calculation is working properly (with a rounding error once again):

If I now try tho replicate that exact same combination on a new line, it just works on the first try:

I really can’t figure the logic here!

One last thing (I am still trying to find how to replicate it), sometimes the commas simply disappear and the numbers are calculated as integers. For instance, on an invoice I charged my client 27,7 km of travel expenses, and on the invoice it ended up being 277 km… I then had an unpleasant chat with him

The same thing happened a few other times too.

So basically the calculations are inconsistent and I am for now forced to double check (and manually calculate) everything. Here is a summary of the issues:

- The admin panel does not round numbers correctly but the PDF does;
- Numbers with commas as decimal separators are sometimes misinterpreted as totally different numbers - replacing commas with periods fixes the problem, and upon saving and reloading the periods are now commas and work properly ;
- Sometimes commas as decimal separators are simply removed from the input numbers, creating a much bigger integer;

I can work around the weird commas bug for now, but I cannot fix the rounding errors, which end up creating different totals in the PDFs that what is calculated in the admin panel, leading to wrong client balances:

Admin total:

PDF total:

Not a big difference, but still, those should match!

Thanks in advance for looking into that.