---
title: "ViewModelFactory – API-Referenz · Quittio"
description: "Builds the template view model from calculated invoice data."
canonical_url: "https://quittio.dev/docs/api/Quittio/Core/View/ViewModelFactory"
locale: de
meta:
  "og:description": "Builds the template view model from calculated invoice data."
  "og:image": "https://quittio.dev/og/quittio-de.jpg"
  "og:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
  "og:image:height": "630"
  "og:image:type": image/jpeg
  "og:image:width": "1200"
  "og:title": "ViewModelFactory – API-Referenz · Quittio"
  "twitter:image": "https://quittio.dev/og/quittio-de.jpg"
  "twitter:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
---

> Index of every page on this site: [llms.txt](https://quittio.dev/llms.txt)

[API reference](https://quittio.dev/docs/api) / [Quittio](https://quittio.dev/docs/api/Quittio) \\ [Core](https://quittio.dev/docs/api/Quittio/Core) \\ [View](https://quittio.dev/docs/api/Quittio/Core/View)

# ViewModelFactory

final class in quittio/core

`Quittio\Core\View\ViewModelFactory` · [Source](https://github.com/Quittio/quittio/blob/v0.7.1/packages/core/src/View/ViewModelFactory.php#L21)

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

The view model of an invoice.

| Parameter | Type | Description |
| --- | --- | --- |
| `$invoice` | `[InvoiceData](https://quittio.dev/docs/api/Quittio/Core/Data/InvoiceData)` | |
| `$context` | `[ViewContext](https://quittio.dev/docs/api/Quittio/Core/View/ViewContext)` = `new \Quittio\Core\View\ViewContext()` | |

<dl><dt>Returns</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/View/InvoiceViewModel">InvoiceViewModel</a></code></dd>
<dt>Throws</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Calculation/CalculationException">CalculationException</a></code> – when the invoice is not calculated</dd></dl>

### `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.

| Parameter | Type | Description |
| --- | --- | --- |
| `$document` | `[DocumentData](https://quittio.dev/docs/api/Quittio/Core/Documents/DocumentData)` | |
| `$context` | `[ViewContext](https://quittio.dev/docs/api/Quittio/Core/View/ViewContext)` = `new \Quittio\Core\View\ViewContext()` | |

<dl><dt>Returns</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/View/InvoiceViewModel">InvoiceViewModel</a></code></dd>
<dt>Throws</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Calculation/CalculationException">CalculationException</a></code> – when the document is not calculated</dd></dl>

### `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.

| Parameter | Type | Description |
| --- | --- | --- |
| `$line` | `[InvoiceLine](https://quittio.dev/docs/api/Quittio/Core/Data/Lines/InvoiceLine)` | |

<dl><dt>Returns</dt>
<dd><code>bool</code></dd>
</dl>

### `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.

| Parameter | Type | Description |
| --- | --- | --- |
| `$invoice` | `[InvoiceData](https://quittio.dev/docs/api/Quittio/Core/Data/InvoiceData)` | |

<dl><dt>Returns</dt>
<dd><code>list&lt;string&gt;</code></dd>
</dl>

### `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.

| Parameter | Type | Description |
| --- | --- | --- |
| `$own` | `[Presentation](https://quittio.dev/docs/api/Quittio/Core/Data/Presentation/Presentation)` | |
| `$defaults` | `[Presentation](https://quittio.dev/docs/api/Quittio/Core/Data/Presentation/Presentation)` | |

<dl><dt>Returns</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Data/Presentation/Presentation">Presentation</a></code></dd>
</dl>

### `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.

| Parameter | Type | Description |
| --- | --- | --- |
| `$invoice` | `[InvoiceData](https://quittio.dev/docs/api/Quittio/Core/Data/InvoiceData)` | |

<dl><dt>Returns</dt>
<dd><code>array{special: ?Brick\Math\BigDecimal, other: ?Brick\Math\BigDecimal}|null</code></dd>
</dl>

### `otherNotes()`#

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

static

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

| Parameter | Type | Description |
| --- | --- | --- |
| `$invoice` | `[InvoiceData](https://quittio.dev/docs/api/Quittio/Core/Data/InvoiceData)` | |

<dl><dt>Returns</dt>
<dd><code>list&lt;<a href="https://quittio.dev/docs/api/Quittio/Core/Data/Note">Note</a>&gt;</code></dd>
</dl>

### `remittance()`#

```
public static function remittance(InvoiceData $invoice): string
```

static

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

| Parameter | Type | Description |
| --- | --- | --- |
| `$invoice` | `[InvoiceData](https://quittio.dev/docs/api/Quittio/Core/Data/InvoiceData)` | |

<dl><dt>Returns</dt>
<dd><code>string</code></dd>
</dl>

### `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.

| Parameter | Type | Description |
| --- | --- | --- |
| `$invoice` | `[InvoiceData](https://quittio.dev/docs/api/Quittio/Core/Data/InvoiceData)` | |

<dl><dt>Returns</dt>
<dd><code>array&lt;int, int&gt;</code></dd>
</dl>

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://quittio.dev/#website","@type":"WebSite","description":"E-Rechnungen für PHP und Laravel: ZUGFeRD, XRechnung und Peppol erstellen, prüfen, lesen und archivieren.","inLanguage":"de-DE","name":"Quittio","url":"https://quittio.dev/","publisher":{"@id":"https://quittio.dev/#identity"},"workTranslation":{"@id":"https://quittio.dev/en#website"}},{"@id":"https://quittio.dev/docs/api/Quittio/Core/View/ViewModelFactory#webpage","@type":"WebPage","description":"Builds the template view model from calculated invoice data.","name":"ViewModelFactory – API-Referenz","url":"https://quittio.dev/docs/api/Quittio/Core/View/ViewModelFactory","isPartOf":{"@id":"https://quittio.dev/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://quittio.dev/docs/api/Quittio/Core/View/ViewModelFactory"]}],"primaryImageOfPage":{"@id":"https://quittio.dev/#logo"}},{"@id":"https://quittio.dev/#identity","@type":"Organization","description":"Open-Source-Bibliothek für E-Rechnungen in PHP und Laravel (ZUGFeRD, XRechnung, Peppol) und Quittio Managed.","email":"kontakt@niklasforst.de","legalName":"Niklas Forst – Softwareentwicklung","name":"Quittio","url":"https://quittio.dev","founder":{"@type":"Person","name":"Niklas Forst","url":"https://quittio.dev/ueber"},"logo":{"@id":"https://quittio.dev/#logo"},"sameAs":["https://github.com/Quittio/quittio","https://packagist.org/packages/quittio/quittio"]},{"@id":"https://quittio.dev/#logo","@type":"ImageObject","caption":"Quittio","contentUrl":"https://quittio.dev/logo.png","inLanguage":"de-DE","url":"https://quittio.dev/logo.png"}]}
```