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#
| Method | Description |
|---|---|
->__construct() | |
->splitAllowance() |
__construct()#
public function __construct(
LineCalculator $lineCalculator = new \Quittio\Core\Calculation\LineCalculator(),
)| Parameter | Type | Description |
|---|---|---|
$lineCalculator | LineCalculator = 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>| Parameter | Type | Description |
|---|---|---|
$lines | list<InvoiceLine> | |
$currency | string | |
$percent | ?Brick\Math\BigDecimal | |
$amount | ?Brick\Money\Money | |
$reason | ?string = null | |
$reasonCode | AllowanceReasonCode|RawCode|null = null |
- Returns
list<DocumentAllowance>