RegalFire's picture
Initial release: GCC-InvoiceMath-Verified v1
1c31d52 verified
|
Raw History Blame Contribute Delete
2.98 kB

Invoice math contract v1.0

This is an explicit software-testing contract, not a national tax rulebook.

The input is only invoice plus this contract. Do not feed expected labels, family, mutation or provenance to a model being evaluated. A challenge file strips these fields. country is research metadata; currency precision determines calculation.

  1. Currency precision: SAR/AED/QAR two decimals; KWD/BHD/OMR three. Precision facts checked against SIX on 2026-09-30. These are the benchmark's arithmetic precision, not a statement that every e-invoice standard permits that precision in every field.
  2. All quantities/prices/allowances/charges/rates are nonnegative; quantity > 0. Rate is an explicitly supplied fraction from 0 to 1; no jurisdiction-specific tax rate is inferred. Negative line net is forbidden.
  3. Line net = round-half-up(quantity × unit_price − allowance + charge, currency precision).
  4. Line tax = round-half-up(line net × rate, currency precision). Tax is rounded per line, NOT on an invoice group or subtotal. This choice is part of the synthetic contract and may differ from a real tax standard.
  5. Net = sum(line net). Tax = sum(line tax). Gross = net + tax. Due = gross − prepaid. Prepaid must be an exact nonnegative currency amount no greater than gross.
  6. Credit notes contain positive line magnitudes and zero prepaid. Negate the final net/tax/gross/due for credit notes. This sign convention is explicitly synthetic.
  7. Output all four canonical ASCII decimal strings with exactly currency precision. valid means all claimed totals exactly equal these strings numerically. error_fields lists mismatched claimed fields in net,tax,gross,due order. A wrong net claim does not cascade into the expected gross: recompute each from original lines.
  8. Numeric styles are ASCII with dot decimal, Arabic-Indic digits with U+066B decimal, and either with three-digit grouping (comma or U+066C). In grouped style the leading group is one to three digits and later groups exactly three. Minus is ASCII U+002D. No mixed digit alphabets, whitespace, bidi controls, exponent notation, currency symbols, or NaN/Infinity. These excluded parser cases are tested by controls, not claimed as coverage families in the dataset.
  9. Ten designed families cover ties, per-line rounding, allowance, charge, prepayment, credit note, large precision stress, zero rate, mixed rates and zero due. Large-value stress is intentionally unrealistic to reveal binary floating-point errors. It is not an estimate of GCC invoice values.
  10. Every positive/negative pair differs in one claimed total by one minor unit. Keep pairs together in splits. There are five parameter variations per currency/family, not 600 independent business processes. No dialect or natural-language authenticity claim.

The benchmark excludes XML/UBL schemas, signing, QR codes, identification, real tax semantics, regulatory certification, OCR, exchange rates, and payment reconciliation.