Skip to content

API reference / Quittio \ Core \ Calculation

AllowanceSplitter

final class in quittio/core

Quittio\Core\Calculation\AllowanceSplitter · Source

Splits a document discount over several VAT groups.

A document allowance has exactly one VAT category and rate. A discount on all lines is therefore split into one allowance per VAT group, in proportion to the signed line sum of the group. Rounding differences are distributed with the largest remainder method, so that the parts add up exactly to the total discount. A group with a negative sum (returns) receives a negative part.

For percentage discounts, base amount and percentage are kept on a part only if the part equals round2(base × percent / 100); otherwise only the amount is written, because validators check that formula (e.g. PEPPOL-EN16931-R040).

Methods#

MethodDescription
->__construct()
->splitAllowance()

__construct()#

public function __construct(
    LineCalculator $lineCalculator = new \Quittio\Core\Calculation\LineCalculator(),
)
ParameterTypeDescription
$lineCalculatorLineCalculator = new \Quittio\Core\Calculation\LineCalculator()

splitAllowance()#

public function splitAllowance(
    list<InvoiceLine> $lines,
    string $currency,
    ?BigDecimal $percent,
    ?Money $amount,
    ?string $reason = null,
    AllowanceReasonCode|RawCode|null $reasonCode = null,
): list<DocumentAllowance>
ParameterTypeDescription
$lineslist<InvoiceLine>
$currencystring
$percent?Brick\Math\BigDecimal
$amount?Brick\Money\Money
$reason?string = null
$reasonCodeAllowanceReasonCode|RawCode|null = null
Returns
list<DocumentAllowance>

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