API reference / Quittio \ Core \ Countries
CorrectionPolicy
final readonly class in quittio/core
Quittio\Core\Countries\CorrectionPolicy · Source
Default handling of cancellations and corrections in a country, and the titles of these documents. Quittio::cancellation() takes the cancellation strategy and the titles "cancellation" and "cancellation_self_billed"; Quittio::correction() the title "correction", Quittio::priceReduction() the title "price_reduction"; the title "self_billed" is the title of self-billed invoices in PDF and HTML (InvoiceTitle::policyTitle()); the Managed layer takes the correction strategy.
Constants#
| Constant | Value | Description |
|---|---|---|
CANCELLATION_CREDIT_NOTE | 'credit_note' | |
CANCELLATION_NEGATIVE_INVOICE | 'negative_invoice' | |
CORRECTION_CANCEL_AND_REISSUE | 'cancel_and_reissue' | |
CORRECTION_CORRECTED_INVOICE | 'corrected_invoice' |
Properties#
| Property | Type | Description |
|---|---|---|
$cancellationStrategy readonly | string | |
$correctionStrategy readonly | string | |
$strategyResolver readonly | (Closure(InvoiceData): ?string)|null | the cancellation strategy for a particular original, e.g. by the format it is sent in; null or a null result = $cancellationStrategy |
$titles readonly | array<string, array<string, string>> | document kind (cancellation, cancellation_self_billed, correction, price_reduction, self_billed) => [locale => title]; a missing locale falls back to "en" |
Methods#
| Method | Description |
|---|---|
->__construct() | |
->cancellationStrategyFor() | The cancellation strategy for the original: the one of the resolver, otherwise $cancellationStrategy. |
->cancellationTitle() | Title of a cancellation; self-billed originals use "cancellation_self_billed" if the country defines it, otherwise "cancellation". |
->title() | The title in the locale, else in its language ("de" for "de_CH"), else in English. |
__construct()#
public function __construct(
string $cancellationStrategy = self::CANCELLATION_CREDIT_NOTE,
string $correctionStrategy = self::CORRECTION_CANCEL_AND_REISSUE,
array<string, array<string, string>> $titles = [],
(Closure(InvoiceData): ?string)|null $strategyResolver = null,
)| Parameter | Type | Description |
|---|---|---|
$cancellationStrategy | string = self::CANCELLATION_CREDIT_NOTE | |
$correctionStrategy | string = self::CORRECTION_CANCEL_AND_REISSUE | |
$titles | array<string, array<string, string>> = [] | document kind (cancellation, cancellation_self_billed, correction, price_reduction, self_billed) => [locale => title]; a missing locale falls back to "en" |
$strategyResolver | (Closure(InvoiceData): ?string)|null = null | the cancellation strategy for a particular original, e.g. by the format it is sent in; null or a null result = $cancellationStrategy |
cancellationStrategyFor()#
public function cancellationStrategyFor(InvoiceData $original): stringThe cancellation strategy for the original: the one of the resolver, otherwise $cancellationStrategy.
| Parameter | Type | Description |
|---|---|---|
$original | InvoiceData |
- Returns
string
cancellationTitle()#
public function cancellationTitle(bool $selfBilled, string $locale = 'en'): ?stringTitle of a cancellation; self-billed originals use "cancellation_self_billed" if the country defines it, otherwise "cancellation".
| Parameter | Type | Description |
|---|---|---|
$selfBilled | bool | |
$locale | string = 'en' |
- Returns
?string
title()#
public function title(string $kind, string $locale = 'en'): ?stringThe title in the locale, else in its language ("de" for "de_CH"), else in English.
| Parameter | Type | Description |
|---|---|---|
$kind | string | |
$locale | string = 'en' |
- Returns
?string