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.
- 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 equaltotal
unit_price Γ quantity
must equaluntaxed_amount
untaxed_amount Γ tax_rate
must equaltax_amount
βοΈ 3. About regroup_line
The regroup_line
parameter defines whether lines are grouped before validation and posting.
Parameter | Default | Behavior |
---|---|---|
regroup_line | true | Lines are grouped by account, tax code, and analytical distribution before validation. |
- 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.
regroup_line = false
):
- Each line is validated individually.
- We recommend disabling regrouping unless itβs explicitly required by your accounting logic.
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 theinvoice_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.