Calculate the amount due correctly

Error BR-FXEXT-CO-16 Factur-X

Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) -Paid amount (BT-113) + Rounding amount (BT-114) + Sum of Charge amount collected on behalf of a third party (BT-179).

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

DuePayableAmount does not equal GrandTotalAmount minus TotalPrepaidAmount, plus RoundingAmount and the sum of the ActualAmount values in SpecifiedFinancialAdjustment.

What the rule means

The amount due is the invoice total including VAT minus amounts already paid. Rounding and charges collected on behalf of a third party are then taken into account.

Affected fields BT-115 BT-112 BT-113 BT-114 BT-179
Please calculate the amount due on the invoice correctly

The amount in DuePayableAmount does not match the other settlement totals. The amount due can be determined from the amounts provided.

What to do
  1. Compare DuePayableAmount with GrandTotalAmount minus TotalPrepaidAmount.
  2. Also include RoundingAmount and the ActualAmount values of FinancialAdjustment.
  3. Check the values in DuePayableAmount, GrandTotalAmount, TotalPrepaidAmount, RoundingAmount and FinancialAdjustment.ActualAmount.
  4. Generate the invoice again and validate it once more.
What it looks like
✗ Triggers the message
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
  <ram:GrandTotalAmount>100</ram:GrandTotalAmount>
  <ram:TotalPrepaidAmount>20</ram:TotalPrepaidAmount>
  <ram:RoundingAmount>1</ram:RoundingAmount>
  <ram:DuePayableAmount>80</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
✓ Correct
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
  <ram:GrandTotalAmount>100</ram:GrandTotalAmount>
  <ram:TotalPrepaidAmount>20</ram:TotalPrepaidAmount>
  <ram:RoundingAmount>1</ram:RoundingAmount>
  <ram:DuePayableAmount>81</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
Check in FactoorSharp
  • FacturXInvoice.DuePayableAmount (BT-115)
  • FacturXInvoice.GrandTotalAmount (BT-112)
  • FacturXInvoice.RoundingAmount (BT-114)
  • FacturXInvoice.TotalPrepaidAmount (BT-113)
  • FinancialAdjustment.ActualAmount (SpecifiedFinancialAdjustment: BT-179)
Technical details

The XPath compares DuePayableAmount with a decimal expression using the sums of the specified amounts; missing values in the sums contribute zero.

Where the rule applies

The rule applies to the amounts in SpecifiedTradeSettlementHeaderMonetarySummation and to SpecifiedFinancialAdjustment in the enclosing settlement context.

Context (rule/@context)
//ram:SpecifiedTradeSettlementHeaderMonetarySummation
Test expression (assert/@test)
xs:decimal(ram:DuePayableAmount) = xs:decimal(sum(ram:GrandTotalAmount/xs:decimal(.))) - xs:decimal(sum(ram:TotalPrepaidAmount/ xs:decimal(.))) + xs:decimal(sum(ram:RoundingAmount/xs:decimal(.))) + xs:decimal(sum(../ ram:SpecifiedFinancialAdjustment/ram:ActualAmount/xs:decimal(.)))