{% load i18n %}
{% with order.addresses as addresses %}
<h2>{% trans "Billing address" %}</h2>
{% with addresses.billing as address %}{% include "plata/_address.html" %}{% endwith %}

<h2>{% trans "Shipping address" %}</h2>
{% with addresses.shipping as address %}{% include "plata/_address.html" %}{% endwith %}
{% endwith %}

<h2>{% trans "Order items" %}</h2>
<table border="1">
{% for item in order.items.all %}
<tr>
    <td>{{ item.product }}</td>
    <td>{{ item.quantity }} * {{ item.currency }} {{ item.unit_price|floatformat:2 }}</td>
    <td>{{ item.currency }} {{ item.discounted_subtotal|floatformat:2 }}</td>
</tr>
{% endfor %}
</table>

<h2>{% trans "Discounts" %}</h2>
{% for discount in order.applied_discounts.all %}
    {% if forloop.first %}
    <table>
    {% endif %}

    <tr>
        <td>{{ discount.name }}</td>
        <td>{{ discount.code }}</td>
    </tr>

    {% if forloop.last %}
    </table>
    {% endif %}
{% empty %}
    {% trans "No discounts" %}
{% endfor %}

<h2>{% trans "Total" %}</h2>
<table>
<tr>
    <th>{% trans "subtotal"|capfirst %}</th>
    <td>{{ order.currency }} {{ order.subtotal|floatformat:2 }}</td>
</tr>
<tr>
    <th>{% trans "discount"|capfirst %}</th>
    <td>{{ order.currency }} {{ order.discount|floatformat:2 }}</td>
</tr>
<tr>
    <th>{% trans "tax"|capfirst %}</th>
    <td>{{ order.currency }} {{ order.tax|floatformat:2 }}</td>
</tr>
<tr>
    <th>{% trans "total"|capfirst %}</th>
    <td>{{ order.currency }} {{ order.total|floatformat:2 }}</td>
</tr>
</table>
