AllowanceSplitter
in package
FinalYes
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).
Table of Contents
Methods
- __construct() : mixed
- splitAllowance() : array<int, DocumentAllowance>
Methods
__construct()
public
__construct([LineCalculator $lineCalculator = new LineCalculator() ]) : mixed
Parameters
- $lineCalculator : LineCalculator = new LineCalculator()
splitAllowance()
public
splitAllowance(array<int, InvoiceLine> $lines, string $currency, BigDecimal|null $percent, Money|null $amount[, string|null $reason = null ][, AllowanceReasonCode|RawCode|null $reasonCode = null ]) : array<int, DocumentAllowance>
Parameters
- $lines : array<int, InvoiceLine>
- $currency : string
- $percent : BigDecimal|null
- $amount : Money|null
- $reason : string|null = null
- $reasonCode : AllowanceReasonCode|RawCode|null = null