Hey guys!
I’m trying to modify my invoice- and quote-designs by using twig. But somehow i cannot create a table for the tasks. My code is:
<ninja>
{% if invoices %}
{% set invoice = invoices|first %}
{% if invoice.line_items|e %}
<table class="artikelliste">
<thead>
<tr>
<th>Artikel</th>
<th>Preis</th>
<th>Menge</th>
<th>USt.</th>
<th>Rabatt</th>
<th>Gesamt</th>
</tr>
</thead>
<tbody>
{% for item in invoice.line_items|filter(item => item.type_id == 1) %}
<tr>
<td>{{ item.product_key }}
<p class="artikeldetails">{{ item.notes }}</p>
</td>
<td>{{ item.cost }}</td>
<td>{{ item.quantity }}</td>
<td>{{ item.tax_rate1 }}</td>
<td>{{ item.discount }}</td>
<td>{{ item.line_total }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if tasks|e %}
<table class="artikelliste">
<thead>
<tr>
<th>Dienstleistung</th>
<th>€/Std.</th>
<th>Menge</th>
<th>USt.</th>
<th>Rabatt</th>
<th>Gesamt</th>
</tr>
</thead>
<tbody>
{% for task in tasks %}
<tr>
<td>{{ task.description }}
{% for t in task.time_log %}
<div class="task-dauer">{{ t.start_date }} bis {{ t.end_date }}, {{ (t.duration/60/60) }}</div>
<div class="task-protokoll">{{ t.description }}</div>
{% endfor %}
</td>
<td>{{ task.rate }}</td>
{% set duration = (task.duration/60/60) %}
<td>{{ duration }}</td>
<td>{{ item.tax_rate1 }}</td>
<td>{{ item.discount }}</td>
<td>{{ (task.rate_raw * duration)|format_currency(invoice.client.currency, locale=invoice.client.locale) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endif %}
</ninja>
I guess I must filter the tasks to those who are linked to the entity. But how?