Skip to main content

Invoice amounts validation and corrections

When creating invoices through the Unified API, several automatic validations are applied to ensure data consistency between line items and totals.
These checks prevent rounding mismatches and enforce coherent invoice structures across all connected accounting tools.

πŸ” 1. Total-level validation

At the invoice level, the following rules apply:
  • Line count check: An invoice must contain at least one line.
  • Total amount check: The total must be greater than or equal to 0.
  • Sum consistency:
    The sum of all line totals must match the invoice total, within a precision of 4 decimals.
If there’s a mismatch:
  • Difference > €0.01 β†’ ❌ Rejected
  • Difference ≀ €0.01 and no correction lines provided β†’ ❌ Rejected
  • Difference ≀ €0.01 and correction lines provided β†’ βœ… Accepted (corrections applied automatically)

πŸ” 2. Line-level validation

Each invoice line is validated individually:
  • untaxed_amount + tax_amount must equal total
  • unit_price Γ— quantity must equal untaxed_amount
  • untaxed_amount Γ— tax_rate must equal tax_amount

βš™οΈ 3. About regroup_line

The regroup_line parameter defines whether lines are grouped before validation and posting.
ParameterDefaultBehavior
regroup_linetrueLines are grouped by account, tax code, and analytical distribution before validation.
When regrouping is enabled:
  • Lines sharing the same account, tax code, or analytical distribution are merged.
  • Amounts are recalculated and rounded to 2 decimals.
  • A new total is computed, and a correction line may be added if needed.
When regrouping is disabled (regroup_line = false):
  • Each line is validated individually.
  • We recommend disabling regrouping unless it’s explicitly required by your accounting logic.
πŸ‘‰ Best practice:
Set regroup_line = false to keep full control over your invoice line structure and amounts.

🧾 4. Invoice corrections

When small rounding differences remain after regrouping or amount calculations, the Unified API can automatically create a correction line to ensure that the invoice total matches the sum of all lines exactly. You activate this feature by filling in the invoice_correction object. When this object is provided, the Unified API uses the account numbers and tax codes you define to generate the correction line automatically.

Example β€” invoice_correction object

"invoice_correction": {
  "sale_invoice_correction_tax_code": "FR_0",
  "purchase_invoice_correction_tax_code": "FR_0",
  "invoice_correction_credit_account_number": "758000",
  "invoice_correction_debit_account_number": "658000"
}
⌘I