Functional Weave
Code in Rust

finance.credit-note.calculate@1.0.0

vectors.json

18,819 bytes · view raw

[
  {"name": "all three days of consultancy credited", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 3, "net": null}], "GB", "2026-09-16"], "expect": {"currency": "GBP", "lines": [{"description": "Consultancy, 3 days", "net": {"minor": -150000, "currency": "GBP"}, "tax": {"minor": -30000, "currency": "GBP"}, "gross": {"minor": -180000, "currency": "GBP"}, "basisPoints": 2000}], "subtotal": {"minor": -150000, "currency": "GBP"}, "taxTotal": {"minor": -30000, "currency": "GBP"}, "total": {"minor": -180000, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 2000, "taxable": {"minor": -150000, "currency": "GBP"}, "tax": {"minor": -30000, "currency": "GBP"}}]}},
  {"name": "a 2010 invoice credited today gets 2010's 17.5%, not today's 20%", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 1, "net": null}], "GB", "2010-06-01"], "expect": {"currency": "GBP", "lines": [{"description": "Consultancy, 3 days", "net": {"minor": -50000, "currency": "GBP"}, "tax": {"minor": -8750, "currency": "GBP"}, "gross": {"minor": -58750, "currency": "GBP"}, "basisPoints": 1750}], "subtotal": {"minor": -50000, "currency": "GBP"}, "taxTotal": {"minor": -8750, "currency": "GBP"}, "total": {"minor": -58750, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 1750, "taxable": {"minor": -50000, "currency": "GBP"}, "tax": {"minor": -8750, "currency": "GBP"}}]}},
  {"name": "units from two lines at two rates, grouped by rate", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 1, "net": null}, {"line": 2, "quantity": 2, "net": null}], "GB", "2026-09-16"], "expect": {"currency": "GBP", "lines": [{"description": "Consultancy, 3 days", "net": {"minor": -50000, "currency": "GBP"}, "tax": {"minor": -10000, "currency": "GBP"}, "gross": {"minor": -60000, "currency": "GBP"}, "basisPoints": 2000}, {"description": "Printed report", "net": {"minor": -2500, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}, "gross": {"minor": -2500, "currency": "GBP"}, "basisPoints": 0}], "subtotal": {"minor": -52500, "currency": "GBP"}, "taxTotal": {"minor": -10000, "currency": "GBP"}, "total": {"minor": -62500, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 0, "taxable": {"minor": -2500, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, {"basisPoints": 2000, "taxable": {"minor": -50000, "currency": "GBP"}, "tax": {"minor": -10000, "currency": "GBP"}}]}},
  {"name": "a price reduction credited by amount, VAT added at the line's category", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 3, "quantity": null, "net": {"minor": 1000, "currency": "GBP"}}], "GB", "2026-09-16"], "expect": {"currency": "GBP", "lines": [{"description": "Software licence", "net": {"minor": -1000, "currency": "GBP"}, "tax": {"minor": -200, "currency": "GBP"}, "gross": {"minor": -1200, "currency": "GBP"}, "basisPoints": 2000}], "subtotal": {"minor": -1000, "currency": "GBP"}, "taxTotal": {"minor": -200, "currency": "GBP"}, "total": {"minor": -1200, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 2000, "taxable": {"minor": -1000, "currency": "GBP"}, "tax": {"minor": -200, "currency": "GBP"}}]}},
  {"name": "a discounted line credited by units keeps its discount and mirrors the invoice exactly", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 3, "quantity": 1, "net": null}], "GB", "2026-09-16"], "expect": {"currency": "GBP", "lines": [{"description": "Software licence", "net": {"minor": -8999, "currency": "GBP"}, "tax": {"minor": -1800, "currency": "GBP"}, "gross": {"minor": -10799, "currency": "GBP"}, "basisPoints": 2000}], "subtotal": {"minor": -8999, "currency": "GBP"}, "taxTotal": {"minor": -1800, "currency": "GBP"}, "total": {"minor": -10799, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 2000, "taxable": {"minor": -8999, "currency": "GBP"}, "tax": {"minor": -1800, "currency": "GBP"}}]}},
  {"name": "the whole invoice credited gives its totals negated", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 3, "net": null}, {"line": 2, "quantity": 2, "net": null}, {"line": 3, "quantity": 1, "net": null}], "GB", "2026-09-16"], "expect": {"currency": "GBP", "lines": [{"description": "Consultancy, 3 days", "net": {"minor": -150000, "currency": "GBP"}, "tax": {"minor": -30000, "currency": "GBP"}, "gross": {"minor": -180000, "currency": "GBP"}, "basisPoints": 2000}, {"description": "Printed report", "net": {"minor": -2500, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}, "gross": {"minor": -2500, "currency": "GBP"}, "basisPoints": 0}, {"description": "Software licence", "net": {"minor": -8999, "currency": "GBP"}, "tax": {"minor": -1800, "currency": "GBP"}, "gross": {"minor": -10799, "currency": "GBP"}, "basisPoints": 2000}], "subtotal": {"minor": -161499, "currency": "GBP"}, "taxTotal": {"minor": -31800, "currency": "GBP"}, "total": {"minor": -193299, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 0, "taxable": {"minor": -2500, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}, {"basisPoints": 2000, "taxable": {"minor": -158999, "currency": "GBP"}, "tax": {"minor": -31800, "currency": "GBP"}}]}},
  {"name": "crediting a line's full net by amount is allowed", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 2, "quantity": null, "net": {"minor": 2500, "currency": "GBP"}}], "GB", "2026-09-16"], "expect": {"currency": "GBP", "lines": [{"description": "Printed report", "net": {"minor": -2500, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}, "gross": {"minor": -2500, "currency": "GBP"}, "basisPoints": 0}], "subtotal": {"minor": -2500, "currency": "GBP"}, "taxTotal": {"minor": 0, "currency": "GBP"}, "total": {"minor": -2500, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 0, "taxable": {"minor": -2500, "currency": "GBP"}, "tax": {"minor": 0, "currency": "GBP"}}]}},
  {"name": "units and an amount against one line, up to its net", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 2, "net": null}, {"line": 1, "quantity": null, "net": {"minor": 50000, "currency": "GBP"}}], "GB", "2026-09-16"], "expect": {"currency": "GBP", "lines": [{"description": "Consultancy, 3 days", "net": {"minor": -100000, "currency": "GBP"}, "tax": {"minor": -20000, "currency": "GBP"}, "gross": {"minor": -120000, "currency": "GBP"}, "basisPoints": 2000}, {"description": "Consultancy, 3 days", "net": {"minor": -50000, "currency": "GBP"}, "tax": {"minor": -10000, "currency": "GBP"}, "gross": {"minor": -60000, "currency": "GBP"}, "basisPoints": 2000}], "subtotal": {"minor": -150000, "currency": "GBP"}, "taxTotal": {"minor": -30000, "currency": "GBP"}, "total": {"minor": -180000, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 2000, "taxable": {"minor": -150000, "currency": "GBP"}, "tax": {"minor": -30000, "currency": "GBP"}}]}},
  {"name": "hospitality credited at the covid rate of the original tax point", "args": [[{"description": "Dinner, 4 covers", "unitPrice": {"minor": 5000, "currency": "GBP"}, "quantity": 4, "discountBasisPoints": 0, "taxCategory": "HOSPITALITY"}], [{"line": 1, "quantity": 1, "net": null}], "GB", "2020-12-25"], "expect": {"currency": "GBP", "lines": [{"description": "Dinner, 4 covers", "net": {"minor": -5000, "currency": "GBP"}, "tax": {"minor": -250, "currency": "GBP"}, "gross": {"minor": -5250, "currency": "GBP"}, "basisPoints": 500}], "subtotal": {"minor": -5000, "currency": "GBP"}, "taxTotal": {"minor": -250, "currency": "GBP"}, "total": {"minor": -5250, "currency": "GBP"}, "taxBreakdown": [{"basisPoints": 500, "taxable": {"minor": -5000, "currency": "GBP"}, "tax": {"minor": -250, "currency": "GBP"}}]}},
  {"name": "crediting more units than were invoiced is refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 4, "net": null}], "GB", "2026-09-16"], "expectError": "credits against line 1 exceed what it was invoiced for"},
  {"name": "two credits that together exceed the line are refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 2, "net": null}, {"line": 1, "quantity": 2, "net": null}], "GB", "2026-09-16"], "expectError": "credits against line 1 exceed what it was invoiced for"},
  {"name": "an amount above the line's net is refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 2, "quantity": null, "net": {"minor": 2501, "currency": "GBP"}}], "GB", "2026-09-16"], "expectError": "credits against line 2 exceed what it was invoiced for"},
  {"name": "line 0 does not exist", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 0, "quantity": 1, "net": null}], "GB", "2026-09-16"], "expectError": "credit refers to line 0, but the invoice has 3 lines"},
  {"name": "line 4 does not exist", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 4, "quantity": 1, "net": null}], "GB", "2026-09-16"], "expectError": "credit refers to line 4, but the invoice has 3 lines"},
  {"name": "both a quantity and an amount is refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 1, "net": {"minor": 100, "currency": "GBP"}}], "GB", "2026-09-16"], "expectError": "credit for line 1 needs exactly one of quantity and net"},
  {"name": "neither a quantity nor an amount is refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": null, "net": null}], "GB", "2026-09-16"], "expectError": "credit for line 1 needs exactly one of quantity and net"},
  {"name": "a zero quantity is refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 0, "net": null}], "GB", "2026-09-16"], "expectError": "credit quantity for line 1 must be greater than zero"},
  {"name": "a negative amount is refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": null, "net": {"minor": -100, "currency": "GBP"}}], "GB", "2026-09-16"], "expectError": "credit amount for line 1 must be greater than zero"},
  {"name": "an amount in another currency is refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": null, "net": {"minor": 100, "currency": "EUR"}}], "GB", "2026-09-16"], "expectError": "credit for line 1 must be in GBP"},
  {"name": "an empty credit note is refused", "args": [[{"description": "Consultancy, 3 days", "unitPrice": {"minor": 50000, "currency": "GBP"}, "quantity": 3, "discountBasisPoints": 0, "taxCategory": "STANDARD"}, {"description": "Printed report", "unitPrice": {"minor": 1250, "currency": "GBP"}, "quantity": 2, "discountBasisPoints": 0, "taxCategory": "ZERO"}, {"description": "Software licence", "unitPrice": {"minor": 9999, "currency": "GBP"}, "quantity": 1, "discountBasisPoints": 1000, "taxCategory": "STANDARD"}], [], "GB", "2026-09-16"], "expectError": "a credit note needs at least one line"},
  {"name": "a line that was itself a credit cannot be credited", "args": [[{"description": "Refund", "unitPrice": {"minor": 1000, "currency": "GBP"}, "quantity": -1, "discountBasisPoints": 0, "taxCategory": "STANDARD"}], [{"line": 1, "quantity": 1, "net": null}], "GB", "2026-09-16"], "expectError": "line 1 of the invoice is not a sale that can be credited"}
]