Reconcile the subtotal with its child lines

Error BR-FXEXT-08 Factur-X

If the "Subtype of invoice item" (BT-X-8) has the value "Subtotal" (GROUP) and the "Net amount of the invoice item" (BT-131) is specified, it must correspond to the sum of the BT-131 of the next lower levels for which the "Subtype of the invoice item" (BT-X-8) has the value "Regular item (standard case)" (DETAIL) or "Subtotal" (GROUP). As a consequence, all lower levels shall contain a BT-131 value, when BT-X-8 has the value DETAIL or GROUP.

Mandatory rule: As long as it is violated, the invoice is invalid and will be rejected by validators.
What is wrong

The net amount ram:LineTotalAmount of a subtotal does not match the sum of the net amounts of its directly linked child invoice lines. Child lines with subtype DETAIL or GROUP are included, and each must also have a net amount.

What the rule means

The subtotal must correctly aggregate the amounts of its child detail lines and subtotals. This keeps the hierarchical structure of invoice lines arithmetically consistent.

Affected fields BT-X-8 BT-131
Please reconcile the subtotal amount with its child lines

The net amount of a subtotal does not match the sum of its linked child lines. Compare the amounts of the subtotal and its detail or group lines.

What to do
  1. Check that each child line’s ParentLineID refers to the LineID of its subtotal.
  2. Add the LineTotalAmount values of child lines with subtype DETAIL or GROUP.
  3. Set the subtotal’s LineTotalAmount to the matching sum and make sure the child amounts are present.
  4. Check the TradeLineItem.LineTotalAmount property.
  5. Regenerate the invoice and validate it again.
What it looks like
✗ Triggers the message
<ram:IncludedSupplyChainTradeLineItem>
  <ram:AssociatedDocumentLineDocument>
    <ram:LineID>1</ram:LineID>
    <ram:LineStatusReasonCode>GROUP</ram:LineStatusReasonCode>
  </ram:AssociatedDocumentLineDocument>
  <ram:SpecifiedLineTradeSettlement>
    <ram:SpecifiedTradeSettlementLineMonetarySummation>
      <ram:LineTotalAmount>100.00</ram:LineTotalAmount>
    </ram:SpecifiedTradeSettlementLineMonetarySummation>
  </ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:IncludedSupplyChainTradeLineItem>
  <ram:AssociatedDocumentLineDocument>
    <ram:LineID>2</ram:LineID>
    <ram:ParentLineID>1</ram:ParentLineID>
    <ram:LineStatusReasonCode>DETAIL</ram:LineStatusReasonCode>
  </ram:AssociatedDocumentLineDocument>
  <ram:SpecifiedLineTradeSettlement>
    <ram:SpecifiedTradeSettlementLineMonetarySummation>
      <ram:LineTotalAmount>60.00</ram:LineTotalAmount>
    </ram:SpecifiedTradeSettlementLineMonetarySummation>
  </ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
✓ Correct
<ram:IncludedSupplyChainTradeLineItem>
  <ram:AssociatedDocumentLineDocument>
    <ram:LineID>1</ram:LineID>
    <ram:LineStatusReasonCode>GROUP</ram:LineStatusReasonCode>
  </ram:AssociatedDocumentLineDocument>
  <ram:SpecifiedLineTradeSettlement>
    <ram:SpecifiedTradeSettlementLineMonetarySummation>
      <ram:LineTotalAmount>60.00</ram:LineTotalAmount>
    </ram:SpecifiedTradeSettlementLineMonetarySummation>
  </ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:IncludedSupplyChainTradeLineItem>
  <ram:AssociatedDocumentLineDocument>
    <ram:LineID>2</ram:LineID>
    <ram:ParentLineID>1</ram:ParentLineID>
    <ram:LineStatusReasonCode>DETAIL</ram:LineStatusReasonCode>
  </ram:AssociatedDocumentLineDocument>
  <ram:SpecifiedLineTradeSettlement>
    <ram:SpecifiedTradeSettlementLineMonetarySummation>
      <ram:LineTotalAmount>60.00</ram:LineTotalAmount>
    </ram:SpecifiedTradeSettlementLineMonetarySummation>
  </ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
Check in FactoorSharp
  • AssociatedDocument.LineStatusReasonCode (BT-X-8)
  • LineStatusReasonCodes (BT-X-8)
  • TradeLineItem.LineTotalAmount (BT-131)
Technical details

The XPath selects GROUP lines with a provided ram:LineTotalAmount and compares the amount, rounded to two decimal places, with the sum of directly linked DETAIL and GROUP lines identified through ram:ParentLineID.

Where the rule applies

This rule applies to invoice lines ram:IncludedSupplyChainTradeLineItem whose ram:LineStatusReasonCode is GROUP and whose ram:LineTotalAmount is provided.

Context (rule/@context)
//ram:IncludedSupplyChainTradeLineItem
Test expression (assert/@test)
every $item in //ram:IncludedSupplyChainTradeLineItem[ ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode = 'GROUP' and normalize-space(ram:SpecifiedLineTradeSettlement/ ram:SpecifiedTradeSettlementLineMonetarySummation/ ram:LineTotalAmount) != '' ] satisfies number(normalize-space($item/ram:SpecifiedLineTradeSettlement/ ram:SpecifiedTradeSettlementLineMonetarySummation/ ram:LineTotalAmount)) = round(sum( for $child in //ram:IncludedSupplyChainTradeLineItem[ normalize-space(ram:AssociatedDocumentLineDocument/ram:ParentLineID) = normalize-space($item/ ram:AssociatedDocumentLineDocument/ram:LineID) and ( ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode = 'DETAIL' or ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode = 'GROUP' ) ] return number(normalize-space( $child/ram:SpecifiedLineTradeSettlement/ ram:SpecifiedTradeSettlementLineMonetarySummation/ ram:LineTotalAmount)) )*100) div 100