Is This Invoice Legal?
Before a PEPPOL BIS 3.0 e-invoice may travel the network it has to survive the EN 16931 arithmetic rules: every line's math, every VAT bucket, and every total must agree to the cent, and the validator must say exactly which rule broke and by how much. Your job is that validator, distilled to seven rules — each violation reported by its rule ID with the expected and the actual amount, judging the document exactly as written, never as it should have been.
Requirements
The starter contains four tables — keep their fields and keys exactly as shipped; the grading tests seed the first three and read the violations back from the fourth:
"Peppol Invoice Header"— the stated document totals:"Invoice No."(Code[20], the primary key) plus theDecimalfields"Line Net Total","Total VAT Amount","Total Incl. VAT","Prepaid Amount","Rounding Amount","Payable Amount"."Peppol Invoice Line"—"Line No."(Integer, the primary key) plus theDecimalfieldsQuantity,"Unit Price","Line Net Amount","VAT Rate"."Peppol VAT Breakdown"— one stated row per VAT rate:"VAT Rate"(Decimal, the primary key),"Taxable Amount","Tax Amount"."Peppol Rule Violation"— your output:"Entry No."(Integer, the primary key),"Rule ID"(Code[30]),"Line No."(Integer), and theDecimalfields"VAT Rate","Expected Amount","Actual Amount".
Create a codeunit named "Peppol Invoice Validator" with one public procedure:
procedure ValidateInvoice(Header: Record "Peppol Invoice Header"; var InvoiceLine: Record "Peppol Invoice Line"; var VatBreakdown: Record "Peppol VAT Breakdown"; var Violation: Record "Peppol Rule Violation"): BooleanGive your objects IDs in the 50100–50199 range and reference every object by name, never by ID.
Rules:
- Rounding to cents always means: to the nearest 0.01, an exact half cent rounding up (every amount that gets rounded in this task is non-negative).
- Every rule compares a stated value against a value recomputed from other stated values — never from your own corrections. A wrong line net makes exactly one rule fire; the sums the other rules check are sums of what the document says, not of what it should have said.
Solve it with Pro
You’re reading the opening of the statement. Pro unlocks the whole problem:
- The full statement
- Starter code in the browser editor
- 14 grading tests, run on Business Central 28.5
- 3 hints
- The reference solution
Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.
Already on Pro? Sign in