<table class="table table-hover table-sm">
    <thead>
    <tr>
        <th>&nbsp;</th>
        <th>{{ trans('list.description') }}</th>
        <th>{{ trans('list.amount') }}</th>
        <th class="hidden-sm hidden-xs">{{ trans('list.date') }}</th>
        {% if not hideSource %}
            <th class="hidden-xs">{{ trans('list.from') }}</th>
        @endif
        {% if not hideDestination %}
            <th class="hidden-xs">{{ trans('list.to') }}</th>
        @endif

        {{-- Hide budgets? --}}
        {% if not hideBudget %}
            <th class="hidden-xs">
                <span class="bi bi-pie-chart" title="{{ trans('list.budget') }}"></span>
            </th>
        @endif

        {{-- Hide categories? --}}
        {% if not hideCategory %}
            <th class="hidden-xs">
                <span class="bi bi-bookmark" title="{{ trans('list.category') }}"></span>
            </th>
        @endif
    </tr>
    </thead>
    <tbody>
    {{-- Make sum: --}}
    {% set sum = 0 %}
    {% set symbol = '' %}
    {% set decimal_places =2 %}
    {% for transaction in journals %}
        {{-- add to sum --}}
        {% set symbol = transaction.currency_symbol %}
        {% set decimal_places = transaction.currency_decimal_places %}
        <tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}">
            <td class="hidden-xs">
                {% if transaction.transaction_type_type == 'Withdrawal' %}
                    <span class="bi bi-arrow-left" title="{{ trans('firefly.Withdrawal') }}"></span>
                @endif

                {% if transaction.transaction_type_type == 'Deposit' %}
                    <span class="bi bi-arrow-right" title="{{ trans('firefly.Deposit') }}"></span>
                @endif

                {% if transaction.transaction_type_type == 'Transfer' %}
                    <span class="bi bi-arrow-left-right" title="{{ trans('firefly.Transfer') }}"></span>
                @endif

                {% if transaction.transaction_type_type == 'Reconciliation' %}
                    XX
                @endif

                {% if transaction.transaction_type_type == 'Opening balance' %}
                    XX
                @endif
            </td>

            <td>
                <a href="{{ route('transactions.show',transaction.transaction_group_id) }}">
                    {% if transaction.group_title|length > 0 %}
                        {{ transaction.group_title }} ({{ transaction.description }})
                    @else
                        {{ transaction.description }}
                    @endif
                </a>
            </td>

            <td>
                {% if transaction.transaction_type_type == 'Deposit' %}
                    {!! format_amount_by_symbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
                    {% if null != transaction.foreign_amount %}
                        ({!! format_amount_by_symbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
                    @endif
                    {% set sum = (sum + (transaction.amount*-1)) %}
                {% elseif transaction.transaction_type_type == 'Transfer' %}
                    <span class="text-info money-transfer">
                        {!! format_amount_by_symbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
                        {% if null != transaction.foreign_amount %}
                            ({!! format_amount_by_symbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
                        @endif
                            </span>
                    {% set sum = (sum + transaction.amount*-1) %}
                @else
                    {!! format_amount_by_symbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
                    {% if null != transaction.foreign_amount %}
                        ({!! format_amount_by_symbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
                    @endif
                    {% set sum = (sum + transaction.amount) %}
                @endif

            </td>

            <td class="hidden-sm hidden-xs">
                {{ transaction.date.isoFormat($monthAndDayFormat) }}
            </td>

            {% if not hideSource %}
                <td class="hidden-xs">
                    <a href="{{ route('accounts.show', transaction.source_account_id) }}">
                        {{ transaction.source_account_name }}
                    </a>
                </td>
            @endif

            {% if not hideDestination %}
                <td class="hidden-xs">
                    <a href="{{ route('accounts.show', transaction.destination_account_id) }}">
                        {{ transaction.destination_account_name }}
                    </a>
                </td>
            @endif

            <!-- Do NOT hide the budget? -->
            {% if not hideBudget %}
                <td class="hidden-xs">
                    {% if transaction.budget_id %}
                        <a href="{{ route('budgets.show', [transaction.budget_id]) }}">
                            {{ transaction.budget_name }}
                        </a>
                    @endif
                </td>
            @endif

            <!-- Do NOT hide the category? -->
            {% if not hideCategory %}
                <td class="hidden-xs">
                    {% if transaction.category_id %}
                        <a href="{{ route('categories.show', [transaction.category_id]) }}">
                            {{ transaction.category_name }}
                        </a>
                    @endif
                </td>
            @endif
        </tr>
    @endforeach
    </tbody>
    <tfoot>
    <tr>
        <td colspan="2" class="text-end"><em>{{ __('firefly.sum') }}:</em></td>
        <td>
            {% if sum != 0 %}
                {!! format_amount_by_symbol(sum, symbol, decimal_places) }}
            @endif
        </td>
    </tr>
    </tfoot>
</table>
