{% load i18n %}

<form action="{% url 'django_ledger:data-import-job-txs' entity_slug=view.kwargs.entity_slug job_pk=view.kwargs.job_pk %}"
      method="post">

    {{ staged_txs_formset.non_form_errors }}
    {% if staged_txs_formset.errors %}
        {{ staged_txs_formset.errors }}
    {% endif %}
    {{ staged_txs_formset.management_form }}
    {% csrf_token %}

    <div class="table-container">
        <table class="table is-narrow is-fullwidth is-bordered is-striped django-ledger-table-bottom-margin-75">
            <thead>
            <tr class="has-text-centered is-error">
                <th>Dated Posted</th>
                <th>Description</th>
                <th>Amount</th>
                <th>Map To</th>
                <th>Commit TX</th>
                {#                <th>TX</th>#}
            </tr>
            </thead>


            <tbody>

            {% for txf in staged_txs_formset %}
                <tr>

                    {% for hidden_field in txf.hidden_fields %}
                        {{ hidden_field }}
                    {% endfor %}

                    <td>{{ txf.date_posted.value }}</td>
                    <td>{{ txf.name.value }}</td>
                    <td class="{% if txf.amount.value < 0 %}has-text-danger{% endif %}">
                        ${{ txf.amount.value }}</td>
                    <td>{{ txf.earnings_account }}</td>
                    <td>{{ txf.tx_import }}</td>
                </tr>
            {% endfor %}

            </tbody>


        </table>


    </div>

    <div class="columns is-centered">
        <div class="column is-4 has-text-centered">
            <button class="button is-primary is-small is-fullwidth">{% trans 'Save/Import' %}</button>
        </div>
        <div class="column is-4 has-text-centered">
            <a class="button is-info is-small is-fullwidth"
               href="{% url 'django_ledger:bank-account-update' entity_slug=view.kwargs.entity_slug bank_account_pk=bank_account_model.uuid %}">
                {% trans 'Bank Account' %}</a>
        </div>
    </div>


</form>

