Numbers format in invoice design

I want to change the Quantity number format in invoices from for example 1.663,00 to simply 1663. Any advice would be appreciated. Thanks.

Hi,

I’m not sure if it’s supported, it may require adding a new variable.

@ben any thoughts?

If you do this also please do the quantity column format: instead of 1.00 to have 1.

It can be like for Excel formats: #,###,00 or ###.00 or whatever. And default is what it is now so it does not break for current users.

I found a not so elegant way to make it work:

Settings > Invoice Design > Customize > Body
After the body tag <div id="body"> ... </div>
I added this script:

<script language="javascript">
  var productQuantities = document.querySelectorAll('[data-ref="product_table-product.quantity-td"]');
  [].forEach.call(productQuantities, function(productQuantity) {
    productQuantity.innerHTML = parseFloat(productQuantity.innerHTML).toString().replace(".", "");
  });
</script>
1 Like

It’d be awesome if this lands into official docs! Thanks!

https://invoiceninja.github.io/docs/custom-fields/#snippets

@Samsal Thanks bro!

But let us note that script is nice but not a good long term solution. It assumes the DOM will be like that forever, but that is not guaranteed. If there are changes, not only the script can not work, but it can cause other problems.

So it’s good, for now. Still should be a better/safe way.

1 Like

Is there already an official solution to adjust the decimal places for the quantity?

@david any thoughts on this? I think the behavior may be slightly different than v4.

@hillel

I think the tricky part is handle multi-regions where the separator could be comma or decimal hence why the default to a full number format.

I think the difference is in v4 we only show up to the precision for amount fields. ie,

1.11 => 1.11
1.10 => 1.1
1.00 => 1
1 => 1