BR-FXEXT-08
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.
What the rule checks
As the rule set's publisher wrote it. The rule runs on every element the context matches, and fails where the test is false; the validator reports the line of that element.
//ram:IncludedSupplyChainTradeLineItem
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
Checked with France Factur-X EXTENDED, Factur-X / ZUGFeRD EXTENDED