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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hubyte.de/pdf-dokumenten-template-bearbeiten/english-documentation/zusammenfassung-template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
