$refund_label {% if payments|length == 1%}#$number {% endif %}

{{ img('$company.logo','max-width: $company_logo_size; max-height: 100px; vertical-align: middle;') }}

$to_label

$client.name

{% set payment = payments|first %} {% if payment.client.vat_number %}

$vat_number_label: $vat_number

{% endif %}
{% if payments|e %} {% set totalInvoices = 0 %} {% set totalRefunds = 0 %} {% for payment in payments %} {% for pivot in payment.paymentables|filter((pivot) => (pivot.is_credit == '0' and pivot.refunded_raw > 0)) %}

$invoice_label #{{ pivot.invoice }}

({{ pivot.amount }})

{{ pivot.refunded }}

($refund_label)

{% set totalInvoices = totalInvoices + pivot.amount_raw %} {% set totalRefunds = totalRefunds + pivot.refunded_raw %} {% endfor %} {% endfor %}

$invoices_label:

{{ totalInvoices|format_currency(currency_code) }}

$refund_label:

{{ totalRefunds|format_currency(currency_code) }}

{% endif %}

$public_notes