{% if cart.viewHT %}
    {% set tax = 'HT' %}
{% else %}
    {% set tax = 'TTC' %}
{% endif %}

<section class="invoice grid-x grid-margin-x ">
    <div class="cell small-12 medium-6">
        <h4>{% trans %} shop.address_invoice {% endtrans %}</h4>
        <p>
        {% if cart.invoiceAddress.company %}
            {{ cart.invoiceAddress.company }}<br/>
        {% endif %}
        {% if cart.invoiceAddress.tvaNumber %}
            {{ cart.invoiceAddress.tvaNumber }}<br/>
        {% endif %}
        {{ cart.invoiceAddress.lastname }} {{ cart.invoiceAddress.firstname }}<br/>
        {{ cart.invoiceAddress.street }} {{ cart.invoiceAddress.postalCode }}  {{ cart.invoiceAddress.city }}<br/>
        {{ cart.invoiceAddress.countryName }} <br/>
        {{ cart.invoiceAddress.email }}<br/>
        {{ cart.invoiceAddress.phone }}</p>
    </div>
    <div class="cell small-12 medium-6">
        <h4>{% trans %} shop.address_shipping {% endtrans %}</h4>

        {% if cart.deliveryMethod %}
            <p>{{ cart.deliveryMethod.category.name }} : {{ cart.deliveryMethod.name }}</p>
            {% if cart.deliveryMethod.viewCounties %}
                <p>{% trans with {'%count%': cart.deliveryMethod.counties|length } %}order.county{% endtrans %}
                    : ({% for county in cart.deliveryMethod.counties %}
                    {{ county .code }} {% if loop.last == false %}-{% endif %}
                    {% endfor %})</p>
            {% endif %}
        {% else %}
            <p>{{ cart.deliveryAddress.lastname }} {{ cart.deliveryAddress.firstname }}<br/>
            {{ cart.deliveryAddress.street }} {{ cart.deliveryAddress.postalCode }}  {{ cart.deliveryAddress.city }}<br/>
            {{ cart.deliveryAddress.countryName }} <br/>
            {% if cart.deliveryAddress.email %} <br/>
                <i class="fa fa-envelope-o" aria-hidden="true"></i> {{ cart.deliveryAddress.email }}<br/>
            {% endif %}
            {% if cart.deliveryAddress.phone %}<i class="fa fa-phone"  aria-hidden="true"></i> {{ cart.deliveryAddress.phone }}</p>{% endif %}
        {% endif %}
    </div>
</section>
<section class="payment grid-x grid-margin-x">
    <div class="cell small-12">
        <table>
            <thead>
            <tr>
                <th>{% trans %} shop.product {% endtrans %}</th>
                <th>{% trans %} shop.quantity {% endtrans %}</th>
                <th>{% trans %} shop.price {% endtrans %} {{ tax }}</th>
                <th>{% trans %} shop.total {% endtrans %} </th>
            </tr>
            </thead>
            <tbody>
            {% for item in cart.items %}
                <tr>
                    <td>{{ item.variant.name|striptags }} {{ item.variant.type.volume }} {{ item.variant.type.unity }}</td>
                    <td>{{ item.quantity }}</td>
                    <td>{{ (item.price/100) | number_format(2) }} €</td>
                    <td>{{ (item.total/100) | number_format(2) }} € {{ tax }}</td>
                </tr>
            {% endfor %}
            <tr>
                <td></td>
                <td></td>
                <td>{% trans %} shop.total_product {% endtrans %} :</td>
                <td>{{ (cart.itemsTotal/100) | number_format(2) }} € {{ tax }}</td>
            </tr>
            {% if cart.promoValuePercent %}
                <tr>
                    <td></td>
                    <td></td>
                    <td>{% trans %} shop.discount {% endtrans %} :</td>
                    <td>- {{ (cart.promoValuePercent*100) | number_format(2) }}% {{ tax }}</td>
                </tr>
            {% endif %}
            {% if cart.promoValueAmount %}
                <tr>
                    <td></td>
                    <td></td>
                    <td>{% trans %} shop.discount {% endtrans %} :</td>
                    <td>- {{ (cart.promoValueAmount / 100) | number_format(2) }} € {{ tax }}</td>
                </tr>
            {% endif %}
            {% if cart.degressiveValue %}
                <tr>
                    <td></td>
                    <td></td>
                    <td>{% trans %}shop.degressive{% endtrans %} :</td>
                    <td>- {{ (cart.degressiveValue / 100) | number_format(2) }} € {{ tax }}</td>
                </tr>
            {% endif %}
            <tr>
                <td></td>
                <td></td>
                <td>{% trans %} shop.total_shipping {% endtrans %} :</td>
                <td>{{ (cart.shipping/100) | number_format(2) }} € {{ tax }}</td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td><strong>{% trans %} shop.total {% endtrans %} :</strong></td>
                <td><strong>
                        {% if cart.viewHT %}
                            {{ (cart.totalWithoutTax/100) | number_format(2) }} € {{ tax }}
                        {% else %}
                            {{ (cart.total/100) | number_format(2) }} € {{ tax }}
                        {% endif %}

                    </strong></td>
            </tr>
            {% if cart.viewHT %}
                <tr>
                    <td></td>
                    <td></td>
                    <td>{% trans %} shop.tax {% endtrans %} {{ cart.tax*100 }} % :</td>
                    <td>{{ (cart.totalTax/100) | number_format(2) }} €</td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td>Total TTC :</td>
                    <td>{{ (cart.total/100) | number_format(2) }} € TTC</td>
                </tr>
            {% endif %}
            </tbody>
        </table>
    </div>
    <div class="cell small-12 text-left">
        {% if cart.promo %}
            <p>{% trans %}shop.discount_code{% endtrans %} : {{ cart.promo }}</p><br/>
        {% endif %}
    </div>
    <div class="cell small-6 text-left">
        <a href="{{ path('shop') }}" class="success button"><i class="fas fa-angle-left"></i> {% trans %}shop.back{% endtrans %}</a>
    </div>
    <div class="cell small-6 text-right">
        <a class="button" href="{{ data.URL }}">{% trans %} shop.pay_order {% endtrans %} <i class="fas fa-angle-right"></i></a>
    </div>
</section>
