BR-DEX-02
XRechnung 2.0.2 · UBL
Original rule text
[BR-DEX-02] Der Wert von "Invoice line net amount" (BT-131) einer "INVOICE LINE" (BG-25) oder einer "SUB INVOICE LINE" (BG-DEX-01) soll der Summe der "Invoice line net amount" (BT-131) der direkt darunterliegenden "SUB INVOICE LINE" (BG-DEX-01) entsprechen.
(every $invoiceline in /ubl:Invoice/cac:InvoiceLine[ exists (./cac:SubInvoiceLine) ] satisfies $invoiceline/xs:decimal(cbc:LineExtensionAmount) = sum($invoiceline/cac:SubInvoiceLine/xs:decimal(cbc:LineExtensionAmount))) and (count( //cac:SubInvoiceLine [xs:decimal(cbc:LineExtensionAmount) = sum(child::cac:SubInvoiceLine/xs:decimal(cbc:LineExtensionAmount))]) = count(//cac:SubInvoiceLine [count(cac:SubInvoiceLine) > 0]))What this rule requires
This warning checks that a line's net amount equals the sum of its direct sub-lines' net amounts. For every cac:InvoiceLine that has at least one cac:SubInvoiceLine, its cbc:LineExtensionAmount must equal the sum of the child cac:SubInvoiceLine/cbc:LineExtensionAmount values. The same check applies to any cac:SubInvoiceLine that itself contains a cac:SubInvoiceLine. This is advisory, so the document is not rejected, but the validator reports the mismatched amounts.
How to fix
Update the cbc:LineExtensionAmount of each cac:InvoiceLine that has cac:SubInvoiceLine children to equal the sum of the direct child cac:SubInvoiceLine/cbc:LineExtensionAmount values. Do the same for any cac:SubInvoiceLine that has its own cac:SubInvoiceLine children. Alternatively, adjust the sub-line amounts so the sums match the parent amounts.
Guidance on this rule. The original text above is authoritative.