API reference / Quittio \ Core \ View
ViewModelFactory
final class in quittio/core
Quittio\Core\View\ViewModelFactory · Source
Builds the template view model from calculated invoice data.
Constants#
| Constant | Value | Description |
|---|---|---|
CONTINUATION_MARGIN_TOP | 40.0 | Top page margin of the following pages, below their header (logo, title, number and buyer). |
PAGE_MARGIN_TOP | 15.0 | Top page margin of the first page of the default templates in millimetres (the letterhead starts here). |
PAYMENT_QR_MODES | [\Quittio\Core\Data\Presentation\Presentation::PAYMENT_QR_AUTO, \Quittio\Core\Data\Presentation\Presentation::PAYMENT_QR_GIROCODE, \Quittio\Core\Data\Presentati … | |
SPECIAL_SCHEME_CODES | ['VATEX-EU-D', 'VATEX-EU-F', 'VATEX-EU-I', 'VATEX-EU-J'] | Margin schemes and travel agents (section 25, 25a UStG): no separate VAT statement. |
Methods#
| Method | Description |
|---|---|
->build() | The view model of an invoice. |
->buildDocument() | View model for quotes, delivery notes, reminders and other documents. Templates see the same structure as for invoices plus the "documentInfo" node. |
::isSpecialSchemeLine() | Whether a line is taxed under a margin scheme or the special scheme for travel agents (section 25, 25a UStG): category E with one of SPECIAL_SCHEME_CODES on the line. |
::legalNoteTexts() | The "legalNotes" of the view model: exemption reasons (BT-120) and regulatory, legal and tax notes (BT-22), in this order and without duplicates. |
::mergePresentation() | $own over $defaults, property by property: values of $own that equal the defaults of an empty Presentation count as not set and keep the value of $defaults, unless $own names the property in $explicit (e.g. false, [] or "A4" over a configured value). Labels are merged key by key. |
::mixedExemptGroup() | The exempt VAT group (category E) when it mixes lines of a special scheme with other exempt lines: EN 16931 allows only one E group (BR-E-01), whose code then conflicts. The PDF shows the two parts in rows of their own when the line net amounts add up to the taxable amount of the group and no document level allowance or charge is exempt: then ['special' => net amount, 'other' => net amount]; ['special' => null, 'other' => null] when they cannot be told apart; null when the group does not mix. |
::otherNotes() | The notes outside "legalNotes" in the order of the view model's "notes". |
::remittance() | Remittance information (BT-83), otherwise the invoice number. |
::vatRowIndexes() | The index of the row of the view model's "vatRows" that shows each VAT breakdown row (BG-23), by the index of the breakdown: a mixed exempt group (mixedExemptGroup()) takes two rows, its first one is given. |
build()#
public function build(
InvoiceData $invoice,
ViewContext $context = new \Quittio\Core\View\ViewContext(),
): InvoiceViewModelThe view model of an invoice.
| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData | |
$context | ViewContext = new \Quittio\Core\View\ViewContext() |
- Returns
InvoiceViewModel- Throws
CalculationException– when the invoice is not calculated
buildDocument()#
public function buildDocument(
DocumentData $document,
ViewContext $context = new \Quittio\Core\View\ViewContext(),
): InvoiceViewModelView model for quotes, delivery notes, reminders and other documents. Templates see the same structure as for invoices plus the "documentInfo" node.
| Parameter | Type | Description |
|---|---|---|
$document | DocumentData | |
$context | ViewContext = new \Quittio\Core\View\ViewContext() |
- Returns
InvoiceViewModel- Throws
CalculationException– when the document is not calculated
isSpecialSchemeLine()#
public static function isSpecialSchemeLine(InvoiceLine $line): boolWhether a line is taxed under a margin scheme or the special scheme for travel agents (section 25, 25a UStG): category E with one of SPECIAL_SCHEME_CODES on the line.
| Parameter | Type | Description |
|---|---|---|
$line | InvoiceLine |
- Returns
bool
legalNoteTexts()#
public static function legalNoteTexts(InvoiceData $invoice): list<string>The "legalNotes" of the view model: exemption reasons (BT-120) and regulatory, legal and tax notes (BT-22), in this order and without duplicates.
| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData |
- Returns
list<string>
mergePresentation()#
public static function mergePresentation(
Presentation $own,
Presentation $defaults,
): Presentation$own over $defaults, property by property: values of $own that equal the defaults of an empty Presentation count as not set and keep the value of $defaults, unless $own names the property in $explicit (e.g. false, [] or "A4" over a configured value). Labels are merged key by key.
| Parameter | Type | Description |
|---|---|---|
$own | Presentation | |
$defaults | Presentation |
- Returns
Presentation
mixedExemptGroup()#
public static function mixedExemptGroup(
InvoiceData $invoice,
): array{special: ?BigDecimal, other: ?BigDecimal}|nullThe exempt VAT group (category E) when it mixes lines of a special scheme with other exempt lines: EN 16931 allows only one E group (BR-E-01), whose code then conflicts. The PDF shows the two parts in rows of their own when the line net amounts add up to the taxable amount of the group and no document level allowance or charge is exempt: then ['special' => net amount, 'other' => net amount]; ['special' => null, 'other' => null] when they cannot be told apart; null when the group does not mix.
| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData |
- Returns
array{special: ?Brick\Math\BigDecimal, other: ?Brick\Math\BigDecimal}|null
otherNotes()#
public static function otherNotes(InvoiceData $invoice): list<Note>The notes outside "legalNotes" in the order of the view model's "notes".
| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData |
- Returns
list<Note>
remittance()#
public static function remittance(InvoiceData $invoice): stringRemittance information (BT-83), otherwise the invoice number.
| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData |
- Returns
string
vatRowIndexes()#
public static function vatRowIndexes(InvoiceData $invoice): array<int, int>The index of the row of the view model's "vatRows" that shows each VAT breakdown row (BG-23), by the index of the breakdown: a mixed exempt group (mixedExemptGroup()) takes two rows, its first one is given.
| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData |
- Returns
array<int, int>