Formatting 'unit price'

Hi,

after installing a self hosted system and being able to connect to the system
with the api, I found one minor issue.

In the invoices (pdf) the field ‘unit cost’ is displayed with 4 decimal places, the field ‘line total’ with 2 decimal places.

how can i please get the field ‘unit cost’ displayed with 2 decimal places in the pdf version, too?

Thanks in advance!

What value are you using for the unit cost? The PDF should match the input.

Thanks! The value is a php-float with 5 decimal places handed over with an api call:

The (partial) json-string is
invoice_items":[{“product_key”:“PKey1”,“note”:“xxx”,“cost”:“44.53782”,“qty”:“1”},{“PKey2”:“pk2”,“notes”:“note”,“cost”:2.47899,“qty”:1}]

The PDF shows Unit Cost QTY Line Total 44.5378 1 44.54 2.479 1 2,48

To show it as 2 decimals on the PDF you’d need to round the values before sending the API request or change the source code.

Thanks, ‘rounding on sender-side’ is something that i had already tried resulting in rounding errors in the total of the invoice.
Do you have any pointer where to look at the source-code exactly?

BTW: great piece of software anyway :wink:

https://github.com/invoiceninja/invoiceninja/blob/master/resources/assets/js/pdf.pdfmake.js

https://invoice-ninja.readthedocs.io/en/latest/developer_guide.html#code

Good luck!!