from .finance_tax_add_vat_types import VatBreakdown from .finance_tax_vat_rate import vat_rate from .money_add import add_money from .money_amount import Money from .money_apply_rate import apply_rate def add_vat(net: Money, jurisdiction: str, category: str, on_date: str) -> VatBreakdown: """Add VAT to a net amount at the rate in force on the date of supply. Returns the whole breakdown rather than just the tax: an invoice needs net, tax and gross together, and deriving the third from the other two in caller code is where rounding bugs are born. """ rate = vat_rate(jurisdiction, category, on_date) tax = apply_rate(net, rate.basis_points, "half-up") return VatBreakdown( net=net, tax=tax, gross=add_money(net, tax), basis_points=rate.basis_points, )