CoolCMS API

VatIdCheckPresenterTrait

Admin VAT id verification UI, shared by the user edit page and the invoicing address book (contact):

  • badge with the last stored check of a saved VAT id (getVatIdCheckState(), no online call on render),
  • online verification = signal handleVerifyVatId() (admin has no limit),
  • manual verification = modal form per subject (createComponentVatIdManualForm(), Multiplier keyed by subject id) with a mandatory note (evidence) and valid / invalid, sent to VatIdCheck:saveManual,
  • automatic check after the edit form save (flashVatIdCheckAfterSave()); it never blocks the save,
  • history of the evidence (latest rows of cms_system_vat_id_checks, read only),
  • "document the company": address country outside the EU plus VAT id or registration number gives mode business: no online check, the modal stores a valid manual record under the address country with a mandatory note (evidence). The tax engine keeps BUSINESS_STATUS_DECLARED and only references the record.

"Subject" is the record carrying the VAT id (user id or address book contact id); the host presenter resolves it from stored data (findVatIdCheckSubject()), never from a request parameter, and names the privilege. Signals are same-origin protected (handle* in a presenter), the manual form has CSRF protection.

Translations: admin.system.vatIdCheck.* (absolute keys, admin.cs_CZ.neon of module system).

Tags
requires

$this->countryManager (\App\UI\Admin\System\Models\Managers\CountryManager)

phpstan-type

VatIdCheckHistoryItem array{checkedAt: string|null, source: string, result: string, resultVariant: string, requestIdentifier: string|null, checkedBy: string|null, name: string|null, note: string|null, error: string|null}

VatIdCheckState array{mode: string, status: string, variant: string, checkedAt: string|null, name: string|null, history: list<VatIdCheckHistoryItem>}

Table of Contents

Constants

VAT_ID_CHECK_MODE_BUSINESS  : string = 'business'
VAT_ID_CHECK_MODE_VAT_ID  : string = 'vatId'
VAT_ID_CHECK_DOMAIN  : string = 'admin.system.vatIdCheck'

Properties

$vatIdCheckStates  : array<int, VatIdCheckState|null>

Methods

getVatIdCheckState()  : VatIdCheckState|null
Badge state + history of a saved VAT id (mode `vatId`) or of a non-EU business (mode `business`) — stored evidence only, no online call on render.
handleVerifyVatId()  : void
Online check of the stored VAT id.
createComponentVatIdManualForm()  : Multiplier<string|int, Form>
Manual verification modal form, one per subject (`vatIdManualForm-<subjectId>`).
findVatIdCheckSubject()  : array{vatId: string, regNo: string, countryCode: string|null}|null
VAT id, registration number and address country of a subject from the stored record; null = unknown subject or neither VAT id nor registration number (the registration number alone counts only outside the EU).
flashVatIdCheckAfterSave()  : void
Automatic check after a successful save of the edit form (online only for a foreign EU VAT id — the Api decides). Flash with the state; nothing for a domestic / non-EU VAT id.
getVatIdCheckPrivilege()  : string
Admin privilege of the VAT id actions (the edit privilege of the host form).
buildVatIdCheckHistoryRow()  : VatIdCheckHistoryItem
One row of the history table — translation key suffixes only, texts in the template.
formatVatIdCheckDate()  : string|null
saveVatIdManualForm()  : void
vatIdCheckNumber()  : string

Constants

Properties

Methods

getVatIdCheckState()

Badge state + history of a saved VAT id (mode `vatId`) or of a non-EU business (mode `business`) — stored evidence only, no online call on render.

public getVatIdCheckState(int $subjectId) : VatIdCheckState|null
Parameters
$subjectId : int
Return values
VatIdCheckState|null —

null = nothing to verify

handleVerifyVatId()

Online check of the stored VAT id.

public handleVerifyVatId(int $subjectId) : void
Parameters
$subjectId : int
Attributes
#[Requires]
$methods: 'POST'

createComponentVatIdManualForm()

Manual verification modal form, one per subject (`vatIdManualForm-<subjectId>`).

protected createComponentVatIdManualForm() : Multiplier<string|int, Form>
Return values
Multiplier<string|int, Form>

findVatIdCheckSubject()

VAT id, registration number and address country of a subject from the stored record; null = unknown subject or neither VAT id nor registration number (the registration number alone counts only outside the EU).

protected abstract findVatIdCheckSubject(int $subjectId) : array{vatId: string, regNo: string, countryCode: string|null}|null
Parameters
$subjectId : int
Return values
array{vatId: string, regNo: string, countryCode: string|null}|null

flashVatIdCheckAfterSave()

Automatic check after a successful save of the edit form (online only for a foreign EU VAT id — the Api decides). Flash with the state; nothing for a domestic / non-EU VAT id.

protected flashVatIdCheckAfterSave(string|null $vatId, string|null $countryCode) : void
Parameters
$vatId : string|null
$countryCode : string|null

getVatIdCheckPrivilege()

Admin privilege of the VAT id actions (the edit privilege of the host form).

protected abstract getVatIdCheckPrivilege() : string
Return values
string

buildVatIdCheckHistoryRow()

One row of the history table — translation key suffixes only, texts in the template.

private buildVatIdCheckHistoryRow(array<string|int, mixed> $row, bool $business) : VatIdCheckHistoryItem
Parameters
$row : array<string|int, mixed>

bridge row (VatIdCheckHistoryRow of the Api)

$business : bool
Return values
VatIdCheckHistoryItem

formatVatIdCheckDate()

private formatVatIdCheckDate(mixed $value) : string|null
Parameters
$value : mixed
Return values
string|null

saveVatIdManualForm()

private saveVatIdManualForm(int $subjectId, ArrayHash<string|int, mixed> $values) : void
Parameters
$subjectId : int
$values : ArrayHash<string|int, mixed>

vatIdCheckNumber()

private vatIdCheckNumber(array{vatId: string, regNo: string, countryCode: string|null} $subject) : string
Parameters
$subject : array{vatId: string, regNo: string, countryCode: string|null}
Return values
string
On this page

Search results