Quittio 0.3 API

En16931Calculator
in package
implements TotalsCalculator

FinalYes

Calculation according to EN 16931.

Amounts are rounded half up to two decimals at the defined points only. VAT is calculated per VAT group (category and rate), not per line (BR-CO-17).

With Meta::FLAG_DECLARED_AMOUNTS (cancellations and unchanged data of InvoiceBuilder::from() whose declared amounts another system rounded differently) and a matching fingerprint of the amount inputs (DeclaredAmounts), declared line net amounts (BT-131) within 0.02 of quantity × price ± allowances and charges (PEPPOL-EN16931-R120) and declared VAT category tax amounts (BT-117) less than one currency unit from the recalculation (BR-CO-17) are kept; otherwise the recalculated amounts are used and Meta::FLAG_DECLARED_AMOUNTS_RECALCULATED is set (QUITTIO-DECLARED-AMOUNTS). Data whose amount inputs changed after the amounts were declared (fingerprint mismatch, e.g. a change with with() or in stored JSON) is recalculated completely. A declared VAT total in accounting currency (BT-111, Meta::declaredVatInTaxCurrency()) is kept within 0.01 of round2(BT-110 × exchange rate), e.g. the BT-111 of a partial cancellation aligned with the earlier ones (Corrections\CancellationHistory). In gross price mode the rounding amount (BT-114) follows the amounts finally used, so that the amount due stays the gross amount of the lines. The CalculationPolicy decides whether declared amounts are kept, recalculated or rejected.

Tags
phpstan-type

VatGroup array{category: VatCategory, rate: ?BigDecimal, lines: BigDecimal, allowances: BigDecimal, charges: BigDecimal, reasons: list, codes: array<string, VatExemptionReasonCode|RawCode|null>}

Table of Contents

Interfaces

TotalsCalculator
Calculates line amounts, allowances and charges, the VAT breakdown and totals.

Methods

__construct()  : mixed
calculate()  : InvoiceData
policy()  : CalculationPolicy
The policy of this calculator.
withPolicy()  : self
The same calculator with another policy.

Methods

On this page

Search results