Reconcile the invoice total including VAT

Error BR-FXEXT-CO-15 Factur-X

If Invoice Total VAT amount (BT-110) ,where currency (BT-110-0) is equal to BT-5, is present, then the Absolute Value of (Invoice total amount with VAT (BT-112) - Invoice total amount without VAT (BT-109) - Invoice total VAT amount (BT-110)) <= 0,01 * (Number of line net amounts (BT-131) + Number of Document level allowance amounts (BT-92) + Number of Document level charges amounts (BT-99) + Number of Logistics Service fee amounts (BT-X-272). Else, Invoice total amount with VAT (BT-112) is equal to Invoice total amount without VAT (BT-109).

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

If exactly one ram:TaxTotalAmount in the invoice currency is present, ram:GrandTotalAmount must equal the sum of ram:TaxBasisTotalAmount and that tax amount, within a tolerance of 0.01 for each included invoice line, allowance, or charge. If there is not exactly one such tax amount, ram:GrandTotalAmount must equal ram:TaxBasisTotalAmount.

What the rule means

The invoice total including VAT (BT-112) is derived from the amount excluding VAT (BT-109) and the tax amount in the invoice currency (BT-110). If there is not exactly one tax amount in the invoice currency, the rule requires BT-112 and BT-109 to be equal.

Please reconcile the invoice total including VAT

The invoice total including VAT does not match the amount excluding VAT plus the tax amount in the invoice currency. If there is not exactly one tax amount in the invoice currency, the two invoice totals must be equal.

What to do
  1. Compare ram:GrandTotalAmount with ram:TaxBasisTotalAmount and the amount in ram:TaxTotalAmount whose currencyID matches ram:InvoiceCurrencyCode.
  2. Check the invoice currency through Currency and the amounts through GrandTotalAmount, TaxBasisAmount, and TaxTotalAmount.
  3. If there is not exactly one tax amount in the invoice currency, reconcile ram:GrandTotalAmount and ram:TaxBasisTotalAmount.
  4. Generate the invoice again and validate it.
Check in FactoorSharp
  • AbstractTradeAllowanceCharge.ActualAmount (Document level allowance: BT-92; Document level charge: BT-99)
  • FacturXInvoice.Currency (Invoice currency: BT-5)
  • FacturXInvoice.GrandTotalAmount (BT-112)
  • FacturXInvoice.TaxBasisAmount (BT-109)
  • FacturXInvoice.TaxTotalAmount (BT-110)
Technical details

The test counts ram:TaxTotalAmount elements whose currencyID equals ram:InvoiceCurrencyCode. With exactly one match, it checks that the absolute difference between ram:GrandTotalAmount and the sum of ram:TaxBasisTotalAmount and that tax amount is within 0.01 multiplied by the number of included lines, allowances, and charges. For any other match count, it checks that ram:GrandTotalAmount equals ram:TaxBasisTotalAmount.

Where the rule applies

Applies to ram:GrandTotalAmount and ram:TaxBasisTotalAmount in the monetary summary. It also compares tax amounts in ram:TaxTotalAmount whose currencyID matches the invoice currency in ram:InvoiceCurrencyCode.

Context (rule/@context)
//ram:SpecifiedTradeSettlementHeaderMonetarySummation
Test expression (assert/@test)
for $Currency in ../ram:InvoiceCurrencyCode, $BT109 in xs:decimal(ram:TaxBasisTotalAmount), $BT110 in xs:decimal(ram:TaxTotalAmount[@currencyID=$Currency]), $BT112 in xs:decimal(ram:GrandTotalAmount), $nbTaxTotalAmountInvoiceCurrency in count (ram:TaxTotalAmount[@currencyID=$Currency] ), $nbLineItems in xs:decimal(count(../../ram:IncludedSupplyChainTradeLineItem[ not(ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode) or ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode = 'DETAIL' ])), $nbAllowanceItems in xs:decimal(count(../ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/ udt:Indicator='false'])), $nbChargeItems in xs:decimal(count(../ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/ udt:Indicator='true']) + count(../ram:SpecifiedLogisticsServiceCharge)), $tolerance in xs:decimal(0.01), $maxTolerance in $tolerance * ($nbLineItems + $nbAllowanceItems + $nbChargeItems), $diff in xs:decimal($BT112 - $BT110 - $BT109), $abs in xs:decimal(abs($diff)) return ( $abs le $maxTolerance and $nbTaxTotalAmountInvoiceCurrency eq 1 ) or ($BT109 eq $BT112 and $nbTaxTotalAmountInvoiceCurrency ne 1)