Zum Inhalt springen

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#

ConstantValueDescription
CONTINUATION_MARGIN_TOP40.0Top page margin of the following pages, below their header (logo, title, number and buyer).
PAGE_MARGIN_TOP15.0Top 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#

MethodDescription
->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(),
): InvoiceViewModel

The view model of an invoice.

ParameterTypeDescription
$invoiceInvoiceData
$contextViewContext = 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(),
): InvoiceViewModel

View model for quotes, delivery notes, reminders and other documents. Templates see the same structure as for invoices plus the "documentInfo" node.

ParameterTypeDescription
$documentDocumentData
$contextViewContext = new \Quittio\Core\View\ViewContext()
Returns
InvoiceViewModel
Throws
CalculationException – when the document is not calculated

isSpecialSchemeLine()#

public static function isSpecialSchemeLine(InvoiceLine $line): bool

static

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.

ParameterTypeDescription
$lineInvoiceLine
Returns
bool

legalNoteTexts()#

public static function legalNoteTexts(InvoiceData $invoice): list<string>

static

The "legalNotes" of the view model: exemption reasons (BT-120) and regulatory, legal and tax notes (BT-22), in this order and without duplicates.

ParameterTypeDescription
$invoiceInvoiceData
Returns
list<string>

mergePresentation()#

public static function mergePresentation(
    Presentation $own,
    Presentation $defaults,
): Presentation

static

$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.

ParameterTypeDescription
$ownPresentation
$defaultsPresentation
Returns
Presentation

mixedExemptGroup()#

public static function mixedExemptGroup(
    InvoiceData $invoice,
): array{special: ?BigDecimal, other: ?BigDecimal}|null

static

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.

ParameterTypeDescription
$invoiceInvoiceData
Returns
array{special: ?Brick\Math\BigDecimal, other: ?Brick\Math\BigDecimal}|null

otherNotes()#

public static function otherNotes(InvoiceData $invoice): list<Note>

static

The notes outside "legalNotes" in the order of the view model's "notes".

ParameterTypeDescription
$invoiceInvoiceData
Returns
list<Note>

remittance()#

public static function remittance(InvoiceData $invoice): string

static

Remittance information (BT-83), otherwise the invoice number.

ParameterTypeDescription
$invoiceInvoiceData
Returns
string

vatRowIndexes()#

public static function vatRowIndexes(InvoiceData $invoice): array<int, int>

static

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.

ParameterTypeDescription
$invoiceInvoiceData
Returns
array<int, int>

Die Open-Core-Pakete stehen unter der MIT-Lizenz. Die rechtlichen Formulierungen der Länderpakete sind mit einer Steuerberatung abzustimmen.