Rounding VAT on invoice total

I had someone help me with this, so I’m documenting what solved it for us, in case it might help someone else.

In the file /modules/AOS_Products_Quotes/line_items.js we disabled line #722:

document.getElementById(key + 'vat_amt' + ln).value = format2Number(totalvat);

and replaced it with:

document.getElementById(key + 'vat_amt' + ln).value = parseFloat(totalvat).toFixed(3);
document.getElementById(key + 'vat_amt' + ln).value = document.getElementById(key + 'vat_amt' + ln).value.toString().replace(".", ",");

Then on line #793 we disabled:

product_vat_amt = unformat2Number(input[j].value);

and replaced it with:

var vat_custom = input[j].value;
var vat_custom_new =  vat_custom.replace(",", ".");
product_vat_amt =  parseFloat(vat_custom_new);

We then saved this file as an override in /custom/modules/AOS_Products_Quotes/line_items.js

This works for us with invoices, which is mainly what we use SuiteCRM for. It shows 3 decimals for line item VAT, then rounds the total VAT, giving us correct VAT and grand total.