{% load account_keeping_tags i18n %}
<table class="table table-hover table-condensed small">
    <thead>
        <tr>
            <th>{% trans "ID" %}</th>
            <th>{% trans "Date" %}</th>
            <th>{% trans "Invoice number" %}</th>
            <th>{% trans "PDF" %}</th>
            <th>{% trans "Description" %}</th>
            <th>{% trans "Currency" %}</th>
            <th>{% trans "Amount (net)" %}</th>
            <th>{% trans "VAT" %}</th>
            <th>{% trans "Amount (gross)" %}</th>
            <th>{% trans "Transactions" %}</th>
        </tr>
    </thead>
    <tbody>
        {% for invoice in invoices %}
        <tr class="{% if invoice.invoice_type == transaction_types.withdrawal %}danger{% else %}success{% endif %}">
            <td><a href="{% url "admin:account_keeping_invoice_change" invoice.pk %}">{{ invoice.pk }}</a></td>
                <td>{{ invoice.invoice_date|date:"Y-m-d" }}</td>
                <td>{{ invoice.invoice_number|default:"n/a" }}</td>
                <td>{% if invoice.pdf %}<a href="{{ MEDIA_URL }}{{ invoice.pdf }}"><span class="glyphicon glyphicon-file"></span></a>{% else %}n/a{% endif %}</td>
                <td>{{ invoice.description|default:"n/a" }}</td>
                <td>{{ invoice.currency.iso_code }}</td>
                <td>{{ invoice.amount_net|currency }}</td>
                <td>{{ invoice.vat }}</td>
                <td>{{ invoice.amount_gross|currency }}</td>
                <td>
                    {% for transaction in invoice.transactions.all %}
                        <a href="{% url "admin:account_keeping_transaction_change" transaction.pk %}">{{ transaction.pk }}</a>
                        {% if not forloop.last %}, {% endif %}
                    {% endfor %}
                </td>
            </tr>
        {% endfor %}
    </tbody>
</table>
