In the backend (Node.js) I save my prices in cents (*100) and always excluding VAT.
However, on the frontend we would like the user to be able to define their prices including VAT.
So what we do is as follows:
Price incl VAT: 10,00
Formula to incl VAT: (10*100)/1.21
which gives 826.4462809917355
Math.round it to: 826
The 826
is the price excl VAT which we save in the database.
But when we add the VAT (21%) to it, then it becomes this:
(826/100)*1.21
Which will become 999.4599999999999
.
Math.round makes 999 of it.
So when our users filling in 10,00 as price incl VAT. It will end up being 9,99