Closed challengee closed 9 years ago
@mohawke this should be ready, what do you think?
does this fix an issue?
Maybe just calculate the VAT amount and Discount based on the given data?
A = invoice amount (given)
Vr = VAT rate (given)
T = invoice total (given)
D = discount
V = VAT amount
1) A - D + V = T
2) (A - D)*Vr = V
This leads to:
D = [ A*( 1 + Vr ) - T ] / ( 1 + Vr )
Then you can use the rounded D
here ( we'll call it Dr
):
V = (A - Dr)*Vr
Then round this V
to Vr
and put Vr
and Dr
on the invoice. This should be correct according to VAT regulations.
@challengee : what do you think?
Seems like a good idea, I'll give this a try
Looks correct now!
Fixes #59 and fixes #44