Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
from .finance_tax_add_vat_types import VatBreakdown
from .finance_tax_vat_rate import vat_rate ← from finance.tax.vat-rate ^1.0.0 · built alongside by fune
from .money_add import add_money ← from money.add ^1.0.0 · built alongside by fune
from .money_amount import Money ← from money.amount ^1.0.0 · built alongside by fune
from .money_apply_rate import apply_rate ← from money.apply-rate ^1.0.0 · built alongside by fune
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,
)