I want to include the VAT in the price of a line item.
My solution is to:
Set the price of the item to its actual price ($2990) divided by 1.06.
Add an object to the "taxes" array and set its rate to 6.
import { invoices } from 'wix-billing-backend';
export function create() {
invoices.createInvoice({
...
lineItems: [{
id: '0',
name: "Line Item",
quantity: 1,
price: 2990 / 1.06,
taxes: [{
name: "VAT",
rate: 6,
code "VAT"
}]
}]
});
This works sometimes, with some prices. However, in this case, I get this error:
balance USD -0.01 must be non negative
How do I approach rounding in Velo and JS?
For posterity: It is not possible to include VAT in the price.
If I set the price to $2820.76 and apply the tax, the total will be 2990.01.
If I set the price to $2820.75 and apply the tax, the total will be 2989.99.
It is not possible to pick an intermediary price (changes that are < $0.01 are ignored).
The solution will be to use Stripe's receipt handling.