Reconcile the header net amount with invoice line net amounts

Error BR-FXEXT-CO-10 Factur-X

Absolute Value of (Sum of Invoice line net amount (BT-106) - Σ Invoice line net amounts (BT-131))<= 0,01 * Number of line net amounts (BT-131).

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

The document-level net amount differs from the sum of the included invoice line net amounts by more than the permitted tolerance. The tolerance is 0.01 multiplied by the number of all ram:IncludedSupplyChainTradeLineItem entries.

What the rule means

The document-level net amount is expected to match the sum of the invoice line net amounts, subject to the explicitly permitted rounding tolerance.

Affected fields BT-106 BT-131
Please reconcile the invoice header net amount with the invoice lines

The invoice header net amount differs from the sum of the included invoice line net amounts by more than permitted. Check the header value and line amounts together.

What to do
  1. Compare FacturXInvoice.LineTotalAmount with the sum of the values from TradeLineItem.LineTotalAmount.
  2. For the sum, include only invoice lines without ram:LineStatusReasonCode or with reason DETAIL.
  3. Allow for the permitted difference of 0.01 per included ram:IncludedSupplyChainTradeLineItem.
  4. Generate the invoice again and validate it.
Check in FactoorSharp
  • FacturXInvoice.LineTotalAmount (BT-106)
  • TradeLineItem.LineTotalAmount (BT-131)
Technical details

The test sums ram:LineTotalAmount values rounded to two decimal places for line items without ram:LineStatusReasonCode or with reason DETAIL. It compares the sum with the header value and allows an absolute difference of at most 0.01 multiplied by the count of all ram:IncludedSupplyChainTradeLineItem entries.

Where the rule applies

The rule applies to ram:LineTotalAmount within ram:SpecifiedTradeSettlementHeaderMonetarySummation and compares it with the net amounts of the related ram:IncludedSupplyChainTradeLineItem entries.

Context (rule/@context)
//ram:SpecifiedTradeSettlementHeaderMonetarySummation
Test expression (assert/@test)
for $calculatedAmount in xs:decimal(round(sum(../../ram:IncludedSupplyChainTradeLineItem[ not(ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode) or ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode = 'DETAIL' ]/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ ram:LineTotalAmount) * xs:decimal(100)) div xs:decimal(100)), $totalAmount in xs:decimal(ram:LineTotalAmount), $nbLineItems in xs:decimal(count(../../ram:IncludedSupplyChainTradeLineItem)), $tolerance in xs:decimal(0.01), $maxTolerance in $nbLineItems * $tolerance, $diff in xs:decimal($totalAmount - $calculatedAmount), $abs in xs:decimal(abs($diff)) return $abs le $maxTolerance