CoolCMS API

InvoiceComposerRequest
in package

FinalYes

Complete input of {@see \App\UI\Api\Invoicer\Models\Generators\InvoiceComposer::compose()}.

Another module uses it to say "issue me an invoice for this" without knowing the inner fields of the Invoice entity or the order they are filled in. What is not in this DTO the composer does not fill, except values derived from the seller or directory and fallbacks from the settings of module 7.

Deliberately absent:

  • orderId: Invoice.order_id already mixes two id spaces (eshop and legacy payments) and must not be reused to link a foreign module. The caller keeps the link on its own side.
  • totalPrice, totalPriceWithVat, rounding*: computed by InvoiceCalculator in beforeSave; a client-supplied number is not trusted.
  • pdf, qrCode: filled by InvoiceManager::completedSave() after the commit.
  • localizationId: the write goes through a Doctrine association and the composer must not inject the entity manager (only the manager tier may). The invoice therefore gets the currency-based formatting fallback; whoever needs a fixed localization sets it on the entity before save().

The private constructor keeps it out of DI search, see InvoiceComposerLine.

Table of Contents

Properties

$billingLineId  : int|null
$creationDate  : DateTime|null
$currencyId  : int
$customer  : InvoiceComposerCustomer|null
$customerIsBusiness  : bool|null
$defaultUnit  : string|null
$dueDate  : DateTime|null
$duePeriod  : int|null
$emailTo  : string|null
$informations  : string|null
$invoiceTypeId  : int
$languageId  : int|null
$lines  : array<string|int, mixed>
$number  : string|null
$paymentRegionId  : int|null
$pdfTemplateVariantId  : int|null
$productTypeId  : int|null
$sellerBankAccountId  : int|null
$sellerContactId  : int|null
$sellerId  : int
$sendEmail  : bool
$status  : string
$supplyKindId  : int|null
$supplyPlaceCountryCode  : string|null
$taxableSupplyDate  : DateTime|null
$taxOverride  : InvoiceTaxOverride|null
$userTypeId  : int|null
$useVat  : bool|null
$variableSymbol  : string|null
$vatPercents  : int|float|string|null

Methods

create()  : self
The only way to create a request; call it with named arguments.
__construct()  : mixed

Properties

Methods

create()

The only way to create a request; call it with named arguments.

public static create(int $sellerId, int $currencyId, int $invoiceTypeId, array<int, InvoiceComposerLine> $lines[, InvoiceComposerCustomer|null $customer = null ][, int|null $billingLineId = null ][, string|null $number = null ][, bool|null $useVat = null ][, int|float|string|null $vatPercents = null ][, int|null $supplyKindId = null ][, InvoiceTaxOverride|null $taxOverride = null ][, string|null $supplyPlaceCountryCode = null ][, bool|null $customerIsBusiness = null ][, string|null $defaultUnit = null ][, int|null $sellerContactId = null ][, int|null $sellerBankAccountId = null ][, int|null $productTypeId = null ][, int|null $userTypeId = null ][, int|null $paymentRegionId = null ][, int|null $languageId = null ][, DateTime|null $creationDate = null ][, DateTime|null $taxableSupplyDate = null ][, DateTime|null $dueDate = null ][, int|null $duePeriod = null ][, string $status = 'unpaid' ][, string|null $variableSymbol = null ][, string|null $informations = null ][, bool $sendEmail = false ][, string|null $emailTo = null ][, int|null $pdfTemplateVariantId = null ]) : self
Parameters
$sellerId : int
$currencyId : int
$invoiceTypeId : int
$lines : array<int, InvoiceComposerLine>
$customer : InvoiceComposerCustomer|null = null
$billingLineId : int|null = null
$number : string|null = null
$useVat : bool|null = null
$vatPercents : int|float|string|null = null
$supplyKindId : int|null = null
$taxOverride : InvoiceTaxOverride|null = null
$supplyPlaceCountryCode : string|null = null
$customerIsBusiness : bool|null = null
$defaultUnit : string|null = null
$sellerContactId : int|null = null
$sellerBankAccountId : int|null = null
$productTypeId : int|null = null
$userTypeId : int|null = null
$paymentRegionId : int|null = null
$languageId : int|null = null
$creationDate : DateTime|null = null
$taxableSupplyDate : DateTime|null = null
$dueDate : DateTime|null = null
$duePeriod : int|null = null
$status : string = 'unpaid'
$variableSymbol : string|null = null
$informations : string|null = null
$sendEmail : bool = false
$emailTo : string|null = null
$pdfTemplateVariantId : int|null = null
Return values
self

__construct()

private __construct([int $sellerId = 0 ][, int $currencyId = 0 ][, int $invoiceTypeId = 0 ][, InvoiceComposerCustomer|null $customer = null ][, array<int, InvoiceComposerLine> $lines = [] ][, int|null $billingLineId = null ][, string|null $number = null ][, bool|null $useVat = null ][, int|float|string|null $vatPercents = null ][, int|null $supplyKindId = null ][, InvoiceTaxOverride|null $taxOverride = null ][, string|null $supplyPlaceCountryCode = null ][, bool|null $customerIsBusiness = null ][, string|null $defaultUnit = null ][, int|null $sellerContactId = null ][, int|null $sellerBankAccountId = null ][, int|null $productTypeId = null ][, int|null $userTypeId = null ][, int|null $paymentRegionId = null ][, int|null $languageId = null ][, DateTime|null $creationDate = null ][, DateTime|null $taxableSupplyDate = null ][, DateTime|null $dueDate = null ][, int|null $duePeriod = null ][, string $status = 'unpaid' ][, string|null $variableSymbol = null ][, string|null $informations = null ][, bool $sendEmail = false ][, string|null $emailTo = null ][, int|null $pdfTemplateVariantId = null ]) : mixed
Parameters
$sellerId : int = 0

required; seller from the Invoicer directory. The composer builds the seller_* snapshot from it and an unknown id is a hard error (an invoice without a seller header must not reach the customer).

$currencyId : int = 0

required; invoice currency. Without it no payment QR code is generated and the PDF cannot format amounts.

$invoiceTypeId : int = 0

required; invoice type, the source of the PDF variant matrix and of a possible custom number line.

$customer : InvoiceComposerCustomer|null = null

customer; null means an invoice without a customer (internal or proforma print), accepted as a deliberate choice of the caller

$lines : array<int, InvoiceComposerLine> = []

billed lines; an empty array is an error (an invoice for zero with a number from a live line is always a caller mistake)

$billingLineId : int|null = null

billing line; null takes the line of the invoice type, then 7/invoice.default.billingLineId. It is mutually exclusive with $number, enforced by InvoiceManager::beforeSave(); the composer checks it earlier so that no PDF is wasted.

$number : string|null = null

manual number (import or migration); null lets the billing line generate it

$useVat : bool|null = null

IMPORTANT: fallback override of the VAT payer status without a justification; superseded by $taxOverride and kept only for existing callers. null takes the seller's tax status as of the tax point (SellerManager::resolveUseVatOn()). Ignored when $taxOverride is set.

$vatPercents : int|float|string|null = null

IMPORTANT: default rate for lines without a supply kind; null takes 7/invoice.default.vatPercents. A line with a supply kind does not use it, the engine decides the rate. Superseded by $taxOverride and the supply kind.

$supplyKindId : int|null = null

default supply kind of lines without their own; null leaves such lines without a kind and the engine is not called for them

$taxOverride : InvoiceTaxOverride|null = null

manual override of the tax treatment (code, rate and mandatory reason). It beats the engine result for the whole invoice, sets the MANUAL_OVERRIDE flag and stores the reason in tax_override_reason. The only way to get DOMESTIC_REVERSE_CHARGE.

$supplyPlaceCountryCode : string|null = null

ISO2 country of the place of supply (where the property is); read only for supply kinds with the immovable_service nature

$customerIsBusiness : bool|null = null

null derives it from the customer's registration and VAT numbers; true forces the business class (a non-EU company confirmed by the admin)

$defaultUnit : string|null = null

default unit of lines without their own; null takes 7/invoice.default.unit

$sellerContactId : int|null = null

specific seller contact; null takes 7/invoice.default.sellerContactId, then the seller's first contact

$sellerBankAccountId : int|null = null

specific seller bank account; null takes 7/invoice.default.sellerBankAccountId, then the seller's first account

$productTypeId : int|null = null

axis of the PDF variant matrix; null takes 7/invoice.default.productTypeId

$userTypeId : int|null = null

axis of the PDF variant matrix; null takes 7/invoice.default.userTypeId, then the customer contact

$paymentRegionId : int|null = null

axis of the PDF variant matrix; null takes 7/invoice.default.paymentRegionId, then the default region. Never null on the invoice: without a region the matrix finds no variant and the invoice would have no PDF.

$languageId : int|null = null

invoice language; null takes the customer's language, then the default language of the payment region, then 7/invoice.default.languageId, then 1

$creationDate : DateTime|null = null

issue date (also drives %Y and %m in the number mask and the sequence period_key); null means today

$taxableSupplyDate : DateTime|null = null

tax point; null equals the issue date

$dueDate : DateTime|null = null

due date; null means the issue date plus $duePeriod

$duePeriod : int|null = null

days until due when $dueDate is not set; null takes 7/invoice.default.duePeriod, then 14

$status : string = 'unpaid'

payment status (unpaid or paid); an invoice is issued as unpaid

$variableSymbol : string|null = null

null derives it from the invoice number (digits)

$informations : string|null = null

note printed on the invoice

$sendEmail : bool = false

"send by e-mail" flag; the composer sends nothing, it only records the intent

$emailTo : string|null = null

recipient; null with $sendEmail means the customer's e-mail

$pdfTemplateVariantId : int|null = null

hard-chosen PDF variant; null uses the matrix of the invoice type

On this page

Search results