Match the net amount of a parent invoice line

Warning BR-DEX-02 XRechnung

The value of "Invoice line net amount" (BT-131) of an "INVOICE LINE" (BG-25) or a "SUB INVOICE LINE" (BG-DEX-01) should correspond to the sum of the "Invoice line net amount" (BT-131) of the directly underlying "SUB INVOICE LINE" (BG-DEX-01).

Recommendation: The invoice remains valid but should be corrected so that it can be processed automatically.
What is wrong

The value of cbc:LineExtensionAmount on a parent invoice line does not equal the sum of the amounts on its directly nested sub invoice lines. For nested sub invoice lines, each parent sub line must also equal the sum of its direct child sub lines.

What the rule means

The net amount of a parent invoice line must reflect the amounts of its direct sub invoice lines. This keeps the amounts of the invoice line and its sub lines arithmetically consistent.

Affected fields BT-131 BG-25
Please match the invoice line net amount to its sub invoice lines

The net amount of an invoice line does not match the sum of its direct sub invoice lines. You can reconcile the amounts on the parent and child lines.

What to do
  1. Find the cac:InvoiceLine or cac:SubInvoiceLine that has child cac:SubInvoiceLine elements.
  2. Compare its cbc:LineExtensionAmount with the sum of its direct sub lines.
  3. For nested sub lines, check the same sum relationship at each level.
  4. Check the amount mapping through TradeLineItem.LineTotalAmount.
  5. Regenerate the invoice and validate it again.
What it looks like
✗ Triggers the message
<cac:InvoiceLine>
  <cbc:LineExtensionAmount>10</cbc:LineExtensionAmount>
  <cac:SubInvoiceLine>
    <cbc:LineExtensionAmount>9</cbc:LineExtensionAmount>
  </cac:SubInvoiceLine>
</cac:InvoiceLine>
✓ Correct
<cac:InvoiceLine>
  <cbc:LineExtensionAmount>10</cbc:LineExtensionAmount>
  <cac:SubInvoiceLine>
    <cbc:LineExtensionAmount>10</cbc:LineExtensionAmount>
  </cac:SubInvoiceLine>
</cac:InvoiceLine>
Check in FactoorSharp
  • TradeLineItem.LineTotalAmount (BT-131)
Technical details

The test compares the decimal value of cbc:LineExtensionAmount on each parent invoice line with the sum of the decimal values of its direct cac:SubInvoiceLine children. It also checks the same sum relationship for nested sub invoice lines.

Where the rule applies

In an extended UBL invoice, the rule applies to cbc:LineExtensionAmount of a cac:InvoiceLine with child cac:SubInvoiceLine elements and to nested cac:SubInvoiceLine elements.

Original message from the Schematron
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.
Context (rule/@context)
/ubl:Invoice[$isExtension]
Test expression (assert/@test)
( 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 [ count(cac:SubInvoiceLine) > 0 and xs:decimal(cbc:LineExtensionAmount) = sum(cac:SubInvoiceLine/xs:decimal(cbc:LineExtensionAmount)) ]) = count(//cac:SubInvoiceLine [count(cac:SubInvoiceLine) > 0]))