> For the complete documentation index, see [llms.txt](https://docs.hubyte.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hubyte.de/pdf-dokumenten-template-bearbeiten/english-documentation/zusammenfassung-template.md).

# Calculation summary

The field **"Twig template for the summary"** (card "Order items") controls the totals block displayed below the line items table – i.e. net total, taxes and grand total.

If a template is provided, it replaces Shopware's standard totals block. If the field is left empty, the standard block is used.

## Special feature: server-side rendering

Unlike the line items table, this template is **pre-rendered server-side** (`StringTemplateRenderer`) and then inserted into the document. The following variables are available:

| Variable    | Description                 |
| ----------- | --------------------------- |
| `order`     | The complete order object   |
| `lineItems` | The line items of the order |

## Example (shortened)

```twig
{% set currencyIsoCode = order.currency.isoCode %}
{% set shippingAddress = order.deliveries.first.getShippingOrderAddress %}

<div class="sum-container">
    <table class="sum-table">
        <tr>
            <td class="align-right">Total (net):</td>
            <td class="align-right">{{ order.amountNet|currency(currencyIsoCode) }}</td>
        </tr>

        {% for calculatedTax in order.price.calculatedTaxes.sortByTax %}
            <tr>
                <td class="align-right">plus {{ calculatedTax.taxRate }}% VAT:</td>
                <td class="align-right">{{ calculatedTax.tax|currency(currencyIsoCode) }}</td>
            </tr>
        {% endfor %}

        <tr class="bold">
            <td class="align-right">Grand total:</td>
            <td class="align-right">{{ order.price.totalPrice|currency(currencyIsoCode) }}</td>
        </tr>
    </table>
</div>
```

## Rounded grand total

The bundled default template also takes the order's rounding settings into account and displays both the raw and the rounded grand total if needed:

```twig
{% set displayRounded = order.totalRounding.interval != 0.01 or order.totalRounding.decimals != order.itemRounding.decimals %}

{% if displayRounded %}
    <tr>
        <td class="align-right">Grand total:</td>
        <td class="align-right">{{ order.price.rawTotal|currency(currencyIsoCode) }}</td>
    </tr>
    <tr class="bold">
        <td class="align-right">Grand total (rounded):</td>
        <td class="align-right">{{ order.price.totalPrice|currency(currencyIsoCode) }}</td>
    </tr>
{% else %}
    <tr class="bold">
        <td class="align-right">Grand total:</td>
        <td class="align-right">{{ order.price.totalPrice|currency(currencyIsoCode) }}</td>
    </tr>
{% endif %}
```

## Loading the default template

Using the **Load default template** button below the editor you restore the bundled default template (matching the currently selected language). The full template for copying can be found under [Template samples](/pdf-dokumenten-template-bearbeiten/english-documentation/template-vorlagen.md).

> **Note:** For the **delivery note**, loading the default template intentionally sets an empty template, since delivery notes usually do not contain price totals.
