CoolCMS API

InvoiceTypeFormTrait

Edit/add form of an invoice type: multilingual texts (`name`/`filename`), main fields (`key`/`multipleUse`) and the PDF variant matrix.

The matrix maps ProductType x PaymentRegion x BuyerVatType x SellerUseVat to a PdfTemplateVariant (a selection, saved by full replace through the owned collection InvoiceType::pdfTemplateVariantRels). The presenter supplies the axes ($matrixProductTypes/$matrixUserTypes/$matrixPaymentRegions) and the variant options ($matrixPdfVariantOptions). 2D matrix pattern: TariffFormTrait.

The matrix is dense in both seller modes (seller_use_vat): the grid renders twice (VAT payer tab / non-payer tab, PdfVariantMatrixTrait::pdfVariantSellerModes()).

IMPORTANT: both halves must always be rendered; Nette evaluates a skipped widget as empty on submit and the full replace would delete that half of the matrix.

A second matrix is keyed by treatment code: a "default (*)" row plus one select per treatment code, stored in InvoiceType::pdfVariantTreatmentRels (dense, full replace in the same save of the invoice type, so one Api transaction). It applies to invoices with tax_treatment; the old matrix stays for invoices without a code.

Table of Contents

Methods

createComponentEditForm()  : Form
addInvoiceTypeMainFields()  : void
Type key, flag of multiple use on an invoice, credit note / default billing line.
addInvoiceTypeTranslationFields()  : void
Multilingual texts (`name`/`filename`), active by checkbox.
addPdfVariantMatrixFields()  : void
PDF variant matrix: one select per combination of productType x paymentRegion x buyerVatType x sellerUseVat. The halves by seller mode (VAT payer / non-payer) get their own fields, each in its own tab.
addPdfVariantTreatmentMatrixFields()  : void
Matrix by treatment code: one select per row of {@see InvoiceTypePdfVariantTreatmentRel::TREATMENT_ROWS}.
billingLineOptions()  : array<int, string>
buildInvoiceTypeEntity()  : InvoiceType
buildPdfVariantRels()  : ArrayCollection<int, InvoiceTypePdfTemplateVariantRel>
Builds the owned collection `InvoiceTypePdfTemplateVariantRel` from the matrix.
buildPdfVariantTreatmentRels()  : ArrayCollection<int, InvoiceTypePdfVariantTreatmentRel>
Builds the owned collection from the treatment code matrix.
pdfVariantFieldName()  : string
Field name of a matrix cell: the four axes joined by underscores (no collision with other fields); the 4th part is the seller mode (1 = VAT payer, 0 = non-payer), i.e. the half of the matrix.
pdfVariantTreatmentFieldName()  : string
Field name of a treatment code matrix row; `*` maps to `default` (an asterisk does not belong in a field name).
saveInvoiceTypeForm()  : bool
setInvoiceTypeFormDefaults()  : void

Methods

addInvoiceTypeMainFields()

Type key, flag of multiple use on an invoice, credit note / default billing line.

private addInvoiceTypeMainFields(Form $form) : void
Parameters
$form : Form

addInvoiceTypeTranslationFields()

Multilingual texts (`name`/`filename`), active by checkbox.

private addInvoiceTypeTranslationFields(Form $form) : void
Parameters
$form : Form

addPdfVariantMatrixFields()

PDF variant matrix: one select per combination of productType x paymentRegion x buyerVatType x sellerUseVat. The halves by seller mode (VAT payer / non-payer) get their own fields, each in its own tab.

private addPdfVariantMatrixFields(Form $form) : void
Parameters
$form : Form

addPdfVariantTreatmentMatrixFields()

Matrix by treatment code: one select per row of {@see InvoiceTypePdfVariantTreatmentRel::TREATMENT_ROWS}.

private addPdfVariantTreatmentMatrixFields(Form $form) : void

A "default (*)" row without a variant means no PDF; a code row without a variant follows the default row.

Parameters
$form : Form

billingLineOptions()

private billingLineOptions() : array<int, string>
Return values
array<int, string>

buildPdfVariantRels()

Builds the owned collection `InvoiceTypePdfTemplateVariantRel` from the matrix.

private buildPdfVariantRels(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, InvoiceTypePdfTemplateVariantRel>

Builds all combinations (also without a selected variant, because of the full replace) in both seller-mode halves; each half has its own field from its own tab.

Parameters
$values : ArrayHash<string|int, mixed>
Return values
ArrayCollection<int, InvoiceTypePdfTemplateVariantRel>

buildPdfVariantTreatmentRels()

Builds the owned collection from the treatment code matrix.

private buildPdfVariantTreatmentRels(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, InvoiceTypePdfVariantTreatmentRel>

Dense: all rows including "*" even without a selected variant (null), so the full replace never leaves an old row the admin cleared in the form.

Parameters
$values : ArrayHash<string|int, mixed>
Return values
ArrayCollection<int, InvoiceTypePdfVariantTreatmentRel>

pdfVariantFieldName()

Field name of a matrix cell: the four axes joined by underscores (no collision with other fields); the 4th part is the seller mode (1 = VAT payer, 0 = non-payer), i.e. the half of the matrix.

private pdfVariantFieldName(int|null $productTypeId, int|null $paymentRegionId, int|null $buyerVatType, int|null $sellerUseVat) : string
Parameters
$productTypeId : int|null
$paymentRegionId : int|null
$buyerVatType : int|null
$sellerUseVat : int|null
Return values
string

pdfVariantTreatmentFieldName()

Field name of a treatment code matrix row; `*` maps to `default` (an asterisk does not belong in a field name).

private pdfVariantTreatmentFieldName(string $taxTreatment) : string
Parameters
$taxTreatment : string
Return values
string

saveInvoiceTypeForm()

private saveInvoiceTypeForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
$values : ArrayHash<string|int, mixed>
Return values
bool
On this page

Search results