InvoiceTaxOverride
in package
Manual override of an invoice's tax treatment.
Replaces the former useVat / vatPercents of
InvoiceComposerRequest, which only said "charge or do not charge this many percent" and left
the invoice with a number nobody could justify. The override is complete: treatment code (decides
the VAT clause, PDF variant, invoice title and summary-report code), rate and a mandatory
reason, stored in cms_mod_invoicer_invoices.tax_override_reason next to the MANUAL_OVERRIDE
flag in tax_flags.
IMPORTANT: the engine never returns DOMESTIC_REVERSE_CHARGE (domestic reverse charge for
construction work) on its own; only this override can produce it. The system does not classify
the work, a person decides and records why.
create() returns null for an invalid code or a rate outside 0-100 %; the caller turns that
into a validation error. Silently dropping the override would issue the invoice in a different
tax mode than the admin asked for.
Table of Contents
Properties
- $code : TaxTreatmentCode
- $percents : string
- $reason : string
Methods
- chargeVat() : bool
- Tells whether tax is charged; a zero rate in a manual override means no VAT.
- create() : self|null
- The only way to create an override. Returns `null` when the input is unusable: - unknown treatment code, - non-numeric rate or a rate outside 0-100 %, - empty reason (mandatory; the admin form enforces it at field level too).
- __construct() : mixed
Properties
$code
public
TaxTreatmentCode
$code
$percents
public
string
$percents
$reason
public
string
$reason
Methods
chargeVat()
Tells whether tax is charged; a zero rate in a manual override means no VAT.
public
chargeVat() : bool
Return values
boolcreate()
The only way to create an override. Returns `null` when the input is unusable: - unknown treatment code, - non-numeric rate or a rate outside 0-100 %, - empty reason (mandatory; the admin form enforces it at field level too).
public
static create(string|null $code, int|float|string|null $percents, string|null $reason) : self|null
Parameters
- $code : string|null
- $percents : int|float|string|null
- $reason : string|null
Return values
self|null__construct()
private
__construct(TaxTreatmentCode $code, string $percents, non-empty-string $reason) : mixed
Parameters
- $code : TaxTreatmentCode
- $percents : string
-
rate in percent as a decimal string ('0.00' means no tax)
- $reason : non-empty-string
-
why the override is applied; mandatory because it is the tax evidence