CoolCMS API

InvoiceComposerCustomer
in package

FinalYes

Customer input of {@see \App\UI\Api\Invoicer\Models\Generators\InvoiceComposer}.

Two variants, each with its own static factory:

  • fromDirectory(): customerId (and optionally contactId); 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

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
self

fromSnapshot()

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; null for a free snapshot

$contactId : int|null = null

specific contact of the customer; null means the first contact in the directory

$loadFromDirectory : bool = false

true makes the composer load the fields from the directory, false uses only what is in this DTO

$snapshot : array<string, string|int|bool|null> = []

invoice fields without the customer prefix (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.

On this page

Search results