{"id":"invoice-totals-compute","version":"1.0.0","description":"Compute invoice line nets, tax breakdown by rate and totals with per-line or per-rate rounding, net or gross prices.","supported_operations":["calculate invoice total with VAT per line versus per invoice","invoice totals with multiple VAT rates breakdown","EN 16931 tax amount rounding per category","tax inclusive prices invoice net and VAT totals","why does my invoice VAT differ by one cent","credit note totals with negative quantity","line discount percent then VAT total","VAT breakdown by rate for an invoice"],"unsupported_operations":["looking up VAT rates or deciding which rate applies","reverse charge, exemptions, withholding or document-level allowances and charges","checking totals stated on an existing invoice (use invoice-arithmetic-check)","currency conversion or invoice formatting"],"semantics":["Each line has quantity and unit_price (signed decimals, negative for credits, any precision), optional discount_percent (0..100, default \"0\") and tax_rate_percent (0..100). Options: rounding (required, one of half_even, half_up, half_down, half_ceiling, half_floor, up, down, ceiling, floor, unnecessary), prices_include_tax (boolean, default false), tax_rounding (\"per_rate_total\" default per EN 16931 BR-CO-17, or \"per_line\"), and exactly one of currency (active ISO 4217 code) or scale (0..18).","Line arithmetic on exact rationals, rounded once per stated value: base = quantity x unit_price x (1 - discount_percent/100). Tax-exclusive: net = round(base); per_line: tax = round(net x rate/100), gross = net + tax; per_rate_total: tax and gross are null. Tax-inclusive: g = round(base) is the line gross, net = round(g x 100/(100 + rate)); per_line: tax = g - net, gross = g; per_rate_total: tax and gross are null.","Lines are grouped by the numeric tax rate (\"7.5\" and \"7.50\" are one group; rate_percent is canonical) and listed ascending by rate. Tax-exclusive per_line: taxable = sum of nets, tax = sum of line taxes. Tax-exclusive per_rate_total: tax = round(taxable x rate/100), one rounding per group. Inclusive per_line: tax = sum of (g - net). Inclusive per_rate_total: G = sum of g, tax = round(G x rate/(100 + rate)), taxable = G - tax.","total_net is the sum of taxable amounts, total_tax the sum of tax amounts and total_gross their sum, with no further rounding. Example: three lines of 1 x 1.11 at 21%: per_line taxes 0.23 each give total_gross 4.02; per_rate_total gives tax round(3.33 x 0.21) = 0.70 and total_gross 4.03.","unnecessary makes any inexact required rounding not_computable (reason rounding_necessary). Ties follow the mode; half_up is away from zero, so credit notes round symmetrically. Outputs have exactly scale fraction digits, never \"-0\", and index is the 0-based input position.","1 to 1000 lines (0 lines is invalid_input; more than 1000 is limit_exceeded before the elements are read); a decimal string over 62 characters is limit_exceeded, checked before syntax; more than 60 digits or 40 fraction digits is invalid_input. Rates above 100 are invalid_input.","Data is the pinned ISO 4217 snapshot named by data_version; no clock, locale or network. The tool holds no tax rates.","Disclaimer: arithmetic calculation only; not financial, tax, legal, or investment advice."],"limits":{"max_lines":1000,"max_decimal_chars":62,"max_decimal_digits":60,"max_fraction_digits":40,"max_scale":18},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["lines","rounding"],"properties":{"lines":{"type":"array","minItems":1,"maxItems":1000,"items":{"type":"object","additionalProperties":false,"required":["quantity","unit_price","tax_rate_percent"],"properties":{"quantity":{"type":"string","minLength":1,"maxLength":62,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Signed decimal quantity (negative for returns/credits); not precision-limited."},"unit_price":{"type":"string","minLength":1,"maxLength":62,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Signed decimal unit price (net, or gross when prices_include_tax is true); not precision-limited."},"discount_percent":{"type":"string","minLength":1,"maxLength":62,"pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Line discount in percent, 0 to 100; default \"0\".","default":"0"},"tax_rate_percent":{"type":"string","minLength":1,"maxLength":62,"pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Tax rate in percent, 0 to 100 inclusive."}}}},"currency":{"type":"string","minLength":3,"maxLength":3,"pattern":"^[A-Za-z]{3}$","description":"Active ISO 4217 alphabetic code with a minor unit (case-insensitive). Give exactly one of currency or scale."},"scale":{"type":"integer","minimum":0,"maximum":18,"description":"Fraction digits for non-ISO units. Give exactly one of currency or scale."},"rounding":{"type":"string","enum":["half_even","half_up","half_down","half_ceiling","half_floor","up","down","ceiling","floor","unnecessary"]},"prices_include_tax":{"type":"boolean","default":false,"description":"true: unit_price is a gross (tax-inclusive) price."},"tax_rounding":{"type":"string","enum":["per_line","per_rate_total"],"default":"per_rate_total","description":"per_rate_total (EN 16931 BR-CO-17, default) or per_line."}}},"output_schema":{"type":"object","additionalProperties":false,"required":["lines","tax_breakdown","total_net","total_tax","total_gross","currency","scale","data_version"],"properties":{"lines":{"type":"array","minItems":1,"maxItems":1000,"items":{"type":"object","additionalProperties":false,"required":["index","net","tax","gross"],"properties":{"index":{"type":"integer","minimum":0,"maximum":999},"net":{"type":"string","minLength":1,"maxLength":400,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Line net amount at exactly scale digits (inclusive prices: the net portion of the rounded gross line)."},"tax":{"type":["string","null"],"maxLength":400,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Line tax (per_line policy) or null (per_rate_total)."},"gross":{"type":["string","null"],"maxLength":400,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Line gross = net + tax (per_line policy) or null (per_rate_total)."}}}},"tax_breakdown":{"type":"array","minItems":1,"maxItems":1000,"items":{"type":"object","additionalProperties":false,"required":["rate_percent","taxable_amount","tax_amount"],"properties":{"rate_percent":{"type":"string","minLength":1,"maxLength":62,"pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$"},"taxable_amount":{"type":"string","minLength":1,"maxLength":400,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Taxable amount of the rate group."},"tax_amount":{"type":"string","minLength":1,"maxLength":400,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Tax amount of the rate group."}}}},"total_net":{"type":"string","minLength":1,"maxLength":400,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Sum of taxable amounts."},"total_tax":{"type":"string","minLength":1,"maxLength":400,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Sum of tax amounts."},"total_gross":{"type":"string","minLength":1,"maxLength":400,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"total_net + total_tax."},"currency":{"type":["string","null"],"pattern":"^[A-Z]{3}$"},"scale":{"type":"integer","minimum":0,"maximum":18},"data_version":{"type":"string","const":"iso4217-datasets-7cdc784-2026-07-27"}}},"examples":[{"input":{"lines":[{"quantity":"1","unit_price":"1.11","tax_rate_percent":"21"},{"quantity":"1","unit_price":"1.11","tax_rate_percent":"21"},{"quantity":"1","unit_price":"1.11","tax_rate_percent":"21"}],"currency":"EUR","rounding":"half_up"},"output":{"lines":[{"index":0,"net":"1.11","tax":null,"gross":null},{"index":1,"net":"1.11","tax":null,"gross":null},{"index":2,"net":"1.11","tax":null,"gross":null}],"tax_breakdown":[{"rate_percent":"21","taxable_amount":"3.33","tax_amount":"0.70"}],"total_net":"3.33","total_tax":"0.70","total_gross":"4.03","currency":"EUR","scale":2,"data_version":"iso4217-datasets-7cdc784-2026-07-27"}},{"input":{"lines":[{"quantity":"1","unit_price":"1.11","tax_rate_percent":"21"},{"quantity":"1","unit_price":"1.11","tax_rate_percent":"21"},{"quantity":"1","unit_price":"1.11","tax_rate_percent":"21"}],"currency":"EUR","rounding":"half_up","tax_rounding":"per_line"},"output":{"lines":[{"index":0,"net":"1.11","tax":"0.23","gross":"1.34"},{"index":1,"net":"1.11","tax":"0.23","gross":"1.34"},{"index":2,"net":"1.11","tax":"0.23","gross":"1.34"}],"tax_breakdown":[{"rate_percent":"21","taxable_amount":"3.33","tax_amount":"0.69"}],"total_net":"3.33","total_tax":"0.69","total_gross":"4.02","currency":"EUR","scale":2,"data_version":"iso4217-datasets-7cdc784-2026-07-27"}},{"input":{"lines":[{"quantity":"2","unit_price":"59.90","discount_percent":"10","tax_rate_percent":"20"},{"quantity":"1","unit_price":"12.00","tax_rate_percent":"5.5"}],"currency":"EUR","rounding":"half_even","prices_include_tax":true},"output":{"lines":[{"index":0,"net":"89.85","tax":null,"gross":null},{"index":1,"net":"11.37","tax":null,"gross":null}],"tax_breakdown":[{"rate_percent":"5.5","taxable_amount":"11.37","tax_amount":"0.63"},{"rate_percent":"20","taxable_amount":"89.85","tax_amount":"17.97"}],"total_net":"101.22","total_tax":"18.60","total_gross":"119.82","currency":"EUR","scale":2,"data_version":"iso4217-datasets-7cdc784-2026-07-27"}}],"execute_url":"/v1/tools/invoice-totals-compute/versions/1.0.0/execute"}