Skip to content

API reference / Quittio \ Core \ Calculation

DeclaredAmounts

final class in quittio/core

Quittio\Core\Calculation\DeclaredAmounts · Source

Declared amounts of an existing document (Meta::FLAG_DECLARED_AMOUNTS): whether they are needed at all, and the fingerprint of the amount inputs they belong to.

The fingerprint (Meta::amountsFingerprint(), set by the calculator on every result and by the builder on data with amounts) covers per line (with sub lines) the identifier, quantity, prices, base quantity, VAT category and rate, line allowances and charges and the net amount, the document allowances and charges, the VAT breakdown and the currency. Data whose fingerprint no longer matches was changed afterwards (e.g. with with() or in stored JSON): its amounts are stale and never kept. Data without fingerprint (e.g. read from XML) is taken as declared by its issuer.

Constants#

ConstantValueDescription
LINE_TOLERANCE'0.02'Tolerance of a declared line net amount (BT-131), as PEPPOL-EN16931-R120 tolerates it.
TAX_CURRENCY_TOLERANCE'0.01'Tolerance of a declared VAT total in accounting currency (BT-111) against round2(BT-110 × exchange rate): EN 16931 does not check it, the cumulative rounding of partial cancellations (Corrections\CancellationHistory) needs one cent.

Methods#

MethodDescription
::breakdownKey()VAT group key of a breakdown; categories without rate (O) ignore a rate written as 0.
::fingerprint()
::hasAmounts()Whether the data carries line net amounts or a VAT breakdown.
::isStale()Data whose amount inputs changed after Quittio calculated or declared its amounts (fingerprint mismatch), or flagged with declared amounts without fingerprint.
::isTrusted()Data flagged with declared amounts whose amount inputs still match the fingerprint.
::needed()Whether the recalculation does not reproduce the declared line net amounts (BT-131), the declared VAT breakdown (BT-116, BT-117) or the declared VAT total in accounting currency (BT-111) exactly, e.g. because another system rounded per line or a partial cancellation aligns its VAT with earlier ones. Data calculated by Quittio never needs declared amounts.

breakdownKey()#

public static function breakdownKey(VatCategory $category, ?BigDecimal $rate): string

static

VAT group key of a breakdown; categories without rate (O) ignore a rate written as 0.

ParameterTypeDescription
$categoryVatCategory
$rate?Brick\Math\BigDecimal
Returns
string

fingerprint()#

public static function fingerprint(InvoiceData $data): string

static

ParameterTypeDescription
$dataInvoiceData
Returns
string

hasAmounts()#

public static function hasAmounts(InvoiceData $data): bool

static

Whether the data carries line net amounts or a VAT breakdown.

ParameterTypeDescription
$dataInvoiceData
Returns
bool

isStale()#

public static function isStale(InvoiceData $data): bool

static

Data whose amount inputs changed after Quittio calculated or declared its amounts (fingerprint mismatch), or flagged with declared amounts without fingerprint.

ParameterTypeDescription
$dataInvoiceData
Returns
bool

isTrusted()#

public static function isTrusted(InvoiceData $data): bool

static

Data flagged with declared amounts whose amount inputs still match the fingerprint.

ParameterTypeDescription
$dataInvoiceData
Returns
bool

needed()#

public static function needed(
    InvoiceData $data,
    TotalsCalculator $calculator = new \Quittio\Core\Calculation\En16931Calculator(),
): bool

static

Whether the recalculation does not reproduce the declared line net amounts (BT-131), the declared VAT breakdown (BT-116, BT-117) or the declared VAT total in accounting currency (BT-111) exactly, e.g. because another system rounded per line or a partial cancellation aligns its VAT with earlier ones. Data calculated by Quittio never needs declared amounts.

ParameterTypeDescription
$dataInvoiceData
$calculatorTotalsCalculator = new \Quittio\Core\Calculation\En16931Calculator()
Returns
bool

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.