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#
| Constant | Value | Description |
|---|---|---|
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#
| Method | Description |
|---|---|
::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): stringVAT group key of a breakdown; categories without rate (O) ignore a rate written as 0.
| Parameter | Type | Description |
|---|---|---|
$category | VatCategory | |
$rate | ?Brick\Math\BigDecimal |
- Returns
string
fingerprint()#
public static function fingerprint(InvoiceData $data): string| Parameter | Type | Description |
|---|---|---|
$data | InvoiceData |
- Returns
string
hasAmounts()#
public static function hasAmounts(InvoiceData $data): boolWhether the data carries line net amounts or a VAT breakdown.
| Parameter | Type | Description |
|---|---|---|
$data | InvoiceData |
- Returns
bool
isStale()#
public static function isStale(InvoiceData $data): boolData whose amount inputs changed after Quittio calculated or declared its amounts (fingerprint mismatch), or flagged with declared amounts without fingerprint.
| Parameter | Type | Description |
|---|---|---|
$data | InvoiceData |
- Returns
bool
isTrusted()#
public static function isTrusted(InvoiceData $data): boolData flagged with declared amounts whose amount inputs still match the fingerprint.
| Parameter | Type | Description |
|---|---|---|
$data | InvoiceData |
- Returns
bool
needed()#
public static function needed(
InvoiceData $data,
TotalsCalculator $calculator = new \Quittio\Core\Calculation\En16931Calculator(),
): boolWhether 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.
| Parameter | Type | Description |
|---|---|---|
$data | InvoiceData | |
$calculator | TotalsCalculator = new \Quittio\Core\Calculation\En16931Calculator() |
- Returns
bool