# BR-FXEXT-08

Source: https://xmlvalid.com/rules/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.

- Level: error
- Rule sets: Factur-X EXTENDED rules 1.09.2
- Context: `//ram:IncludedSupplyChainTradeLineItem`
- 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`

Validate a document against these rules: https://xmlvalid.com/validate
