InvoiceComposerCustomer
in package
Customer input of {@see \App\UI\Api\Invoicer\Models\Generators\InvoiceComposer}.
Two variants, each with its own static factory:
- fromDirectory():
customerId(and optionallycontactId); the composer loads the snapshot from the Invoicer directory. Use it when the caller keeps the customer there. - fromSnapshot(): the caller passes ready-made fields. Use it when the customer is not in the directory, or when the invoice must carry data valid at another moment than the current directory state (the invoice is a snapshot, the directory is live).
IMPORTANT: the snapshot fields are always copied to the invoice, also for fromDirectory().
customerId on the invoice is only a reference; an address changed in the directory must not
alter an invoice that was already issued.
The private constructor keeps it out of DI search, see InvoiceComposerLine.
Table of Contents
Properties
- $contactId : int|null
- $customerId : int|null
- $loadFromDirectory : bool
- $snapshot : array<string|int, mixed>
Methods
- fromDirectory() : self
- Customer from the Invoicer directory. `contactId` must belong to the same customer; the composer ignores a foreign contact and falls back to the customer's first contact, so it never attaches somebody else's address.
- fromSnapshot() : self
- Customer from ready-made fields. `customerId` and `contactId` are optional; fill them when the customer is in the directory and the invoice should only keep the reference.
- __construct() : mixed
Properties
$contactId read-only
public
int|null
$contactId
= null
$customerId read-only
public
int|null
$customerId
= null
$loadFromDirectory read-only
public
bool
$loadFromDirectory
= false
$snapshot read-only
public
array<string|int, mixed>
$snapshot
= []
Methods
fromDirectory()
Customer from the Invoicer directory. `contactId` must belong to the same customer; the composer ignores a foreign contact and falls back to the customer's first contact, so it never attaches somebody else's address.
public
static fromDirectory(int $customerId[, int|null $contactId = null ]) : self
Parameters
- $customerId : int
- $contactId : int|null = null
Return values
selffromSnapshot()
Customer from ready-made fields. `customerId` and `contactId` are optional; fill them when the customer is in the directory and the invoice should only keep the reference.
public
static fromSnapshot(array<string, string|int|bool|null> $snapshot[, int|null $customerId = null ][, int|null $contactId = null ]) : self
Parameters
- $snapshot : array<string, string|int|bool|null>
-
see the constructor
- $customerId : int|null = null
- $contactId : int|null = null
Return values
self__construct()
private
__construct([int|null $customerId = null ][, int|null $contactId = null ][, bool $loadFromDirectory = false ][, array<string, string|int|bool|null> $snapshot = [] ]) : mixed
Parameters
- $customerId : int|null = null
-
reference to
cms_mod_invoicer_customers;nullfor a free snapshot - $contactId : int|null = null
-
specific contact of the customer;
nullmeans the first contact in the directory - $loadFromDirectory : bool = false
-
truemakes the composer load the fields from the directory,falseuses only what is in this DTO - $snapshot : array<string, string|int|bool|null> = []
-
invoice fields without the
customerprefix (name,name2,street,city,postcode,country,countryCode,regNo,vatId,email,phone,informations,vatInformations,userTypeId,languageId,contactId) plus the delivery set (useDelivery,dlvName,dlvName2,dlvStreet,dlvCity,dlvPostcode,dlvCountry,dlvCountryCode,dlvInformations). The composer ignores unknown keys, so a typo neither fails nor is copied; check it in a harness.