{% if buyer_lines >= seller_lines %}
	{% set top = 275 + (25 * buyer_lines) %}
{% else %}
	{% set top = 275 + (25 * seller_lines) %}
{% endif %}

{% set address_lines = [] %}
	{% for line in [footer.address_1, footer.address_2, footer.address_3] %}
		{% if line|length > 0 %}
			{% set address_lines = address_lines|merge([line]) %}
		{% endif %}
	{% endfor %}
{% set address = address_lines|join(',') %}

<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
		<title>{{ invoice.serie_nr }}</title>
		<style>
			{{css}}
		</style>
	</head>
	<body>
		{% if logo_source is not empty %}
			<img src='{{ logo_source }}' height='50' class='CompanyLogo'>
		{% endif %}
		<hr class='Rounded'>
		<div class='InvoiceInfo'>
			<p>{{ 'Invoice number'|trans }}: {{ invoice.serie_nr }}</p>
			<p>{{ 'Invoice date'|trans }}: {{ invoice.created_at|format_date }}</p>
			<p>{{ 'Due date'|trans }}: {{ invoice.due_at|format_date }}</p>
			<p>{{ 'Invoice status'|trans }}: {{ invoice.status|capitalize }}</p>
		</div>

		<h3 class='CompanyInfo'>{{ 'Company'|trans }}</h3>
		<div class='CompanyInfo'>
		<p>
		{% for key, value in seller %}
		{% if key == 'Name' %}<b>{% endif %}
		{% if key == 'Phone' %} {{ 'Phone'|trans }} :{% endif %}
				{{ value }}<br>
		{% if key == 'Name' %}</b>{% endif %}
		{% endfor %}
		</p>
		</div>

		<h3 class='ClientInfo'>{{ 'Client'|trans }}</h3>
		<div class='ClientInfo'>
		<p>
		{% for key, value in buyer %}
		{% if key == 'Company' %}<b>{% endif %}
		{% if key == 'Phone '%} {{ 'Phone'|trans }} :{% endif %}
				{{ value }}<br>
		{% if key == 'Company' %}</b>{% endif %}
		{% endfor %}
		</p>
		</div>

		<div class='Breakdown' style='top: {{top}}px'>
			<table style='width:100%'>
				<tr>
					<th style='text-align: center; width:25px;'>#</th>
					<th style='text-align: left'>{{ 'Product'|trans }}</th>
					<th style='text-align: right'>{{ 'Quantity & Price'|trans }}</th>
					<th style='text-align: right'>{{ 'Total'|trans }}</th>
				</tr>
				{% set nr = 0 %}
				{% for item in invoice.lines %}
					{% set nr = nr + 1 %}
					<tr>
						<td style='text-align: center; width:25px;'>{{ nr }}</td>
						<td style='text-align: left'>{{ item.title }}</td>
						<td style='text-align: right'>{{ item.quantity }}x {{ item.price|money(currency_code) }}</td>
						<td style='text-align: right'>{{ item.total|money(currency_code) }}</td>
					</tr>
				{% endfor %}
				<tr>
					<th colspan='4'>_________________________________________________________________________________________</th>
				</tr>
				{% if invoice.tax > 0 %}
					<tr>
						<th style='text-align: right' colspan='3'>{{ invoice.taxname }}
							{{ invoice.taxrate }}% Tax:</th>
						<th style='text-align: right'>{{ invoice.tax|money(currency_code) }}</th>
					</tr>
				{% endif %}
				{% if invoice.discount|default and invoice.discount > 0 %}
					<tr>
						<th style='text-align: right' colspan='3'>{{ 'Discount'|trans }}:</th>
						<th style='text-align: right'>{{ invoice.discount|money(currency_code) }}</th>
					</tr>
				{% endif %}
				<tr>
					<th style='text-align: right'  colspan='3'>{{ 'Total'|trans }}:</th>
					<th style='text-align: right'>{{ invoice.total|money(currency_code) }}</th>
				</tr>
			</table>
		<span class="muted-text">{{ footer.signature }}</span>
		</div>
		<div class='InvoiceFooter'>
			{% if footer.display_bank_info == 1 %}
				<b>{{ 'Payment details'|trans }}:</b><br >
				<b>{{ 'Account Owner'|trans }}:</b> {{ footer.company_name }} | <b>{{ 'Bank'|trans }}:</b> {{ footer.bank_name }} | <b>{{ 'BIC / SWIFT Code'|trans }}:</b> {{ footer.bic }} | <b>{{ 'Account number'|trans }}:</b> {{ footer.account_number }}<br><br>
			{% endif %}

			<b>{{ footer.company_name }}</b>
			{% if address %} {{ address }} <br> {% endif %}
			<b>{{ 'Email'|trans }}:</b> {{ footer.email }} | <b>
			{% if footer.phone %} {{ 'Phone'|trans }}:</b> {{ footer.phone }}<br> {% endif %}
			{% if footer.company_vat %} <b>{{ 'VAT ID'|trans }}:</b> {{ footer.company_vat }} | {% endif %}
			{% if footer.company_number %} <b>{{ 'Company Registration #:'|trans }}</b> {{ footer.company_number }} | {% endif %}
			<b>{{ 'Website'|trans }}: </b>{{ footer.www }}
		</div>
	</body>
</html>
