@php
    $is_first_loop = $loop->index === 0;
    $method_expected_balance = array_sum($revenues);
@endphp

<div class="flex-shrink-0 ps-3 col-3">

    {{-- Title --}}
    <h6 class="pt-1 mb-2">{{ $payment_method->method_name }}</h6>

    @if ($is_first_loop)

        {{-- Initial Cash --}}
        <div class="mb-3 input-group">
            <div class="input-group-prepend">
                <label class="input-group-text">
                    {{ __('entity_fields')['audit']['initial_cash'] }}
                </label>
            </div>
            <input type="number" name="initial_cash_{{ $tab_prefix }}" id="initial_cash_{{ $tab_prefix }}" required
                class="form-control" step="0.01"
                value="{{ number_format($initial_shift_cash->$tab_prefix, 2, '.', '') }}"
                onchange="roundDecimals(this)"
                onblur="calculateExpectedCashBalance('{{ $methodName }}', '{{ $tab_prefix }}')">
        </div>

        {{-- Brute Income --}}
        <div class="mb-3 input-group">
            <div class="input-group-prepend">
                <label class="input-group-text disabled-fields">
                    {{ __('entity_fields')['audit']['brute_income'] }}
                </label>
            </div>
            <input type="number" name="brute_income_{{ $tab_prefix }}" id="brute_income_{{ $tab_prefix }}" readonly required
                class="form-control disabled-fields" step="0.01"
                value="{{ number_format($method_expected_balance, 2, '.', '') }}"
                onchange="roundDecimals(this)">
        </div>

        {{-- Cash Withdrawn --}}
        <div class="mb-3 input-group">
            <div class="input-group-prepend">
                <label class="input-group-text">
                    {{ __('entity_fields')['audit']['cash_withdrawn'] }}
                </label>
            </div>
            <input type="number" name="cash_withdrawn_{{ $tab_prefix }}" id="cash_withdrawn_{{ $tab_prefix }}" required
                class="form-control" step="0.01" value="0.0"
                onchange="roundDecimals(this)"
                onblur="calculateExpectedCashBalance('{{ $methodName }}', '{{ $tab_prefix }}')">
        </div>

    @else

        {{-- Total Vouchers --}}
        <div class="mb-3 input-group">
            <div class="input-group-prepend">
                <label class="input-group-text">
                    {{ __('entity_fields')['audit']['total_vouchers'] }}
                </label>
            </div>
            <input type="number" name="{{ $methodName }}_total_vouchers_{{ $tab_prefix }}" required
                class="form-control" step=".1" min="0" placeholder="0 vouchers"
                onchange="roundInteger(this)">
        </div>

    @endif

    @php
        if ($is_first_loop)
            $method_expected_balance += $initial_shift_cash->$tab_prefix;
    @endphp

    {{-- Expected Balance --}}
    <div class="mb-3 input-group">
        <div class="input-group-prepend">
            <label class="input-group-text disabled-fields">
                {{ __('entity_fields')['audit']['expected_balance'] }}
            </label>
        </div>
        <input type="number" id="{{ $methodName }}_expected_balance_{{ $tab_prefix }}" name="{{ $methodName }}_expected_balance_{{ $tab_prefix }}" readonly required
            class="form-control disabled-fields" step="0.01"
            value="{{ number_format($method_expected_balance, 2, '.', '') }}"
            onchange="roundDecimals(this)">
    </div>

    {{-- Cash Count --}}
    <div class="mb-3 input-group">
        <div class="input-group-prepend">
            <label class="input-group-text">
                {{ __('entity_fields')['audit']['cash_count'] }}
            </label>
        </div>
        <input type="number" id="{{ $methodName }}_cash_count_{{ $tab_prefix }}" name="{{ $methodName }}_cash_count_{{ $tab_prefix }}" required
            class="form-control" placeholder="{{ \App\Helpers\Formats\FormatCurrencyHelper::currencyPlaceHolder() }}"
            step="0.01"
            onchange="roundDecimals(this); validateShortfall('{{ $methodName }}', '{{ $tab_prefix }}')"
            onblur="calculateBalanceShortfall('{{ $methodName }}', '{{ $tab_prefix }}')">
    </div>

    {{-- Balance Shortfall --}}
    <div class="mb-3 input-group">
        <div class="input-group-prepend">
            <label class="input-group-text disabled-fields">
                {{ __('entity_fields')['audit']['balance_shortfall'] }}
            </label>
        </div>
        <input type="number" id="{{ $methodName }}_balance_shortfall_{{ $tab_prefix }}" name="{{ $methodName }}_balance_shortfall_{{ $tab_prefix }}" readonly required
            class="form-control disabled-fields" step="0.01" value="0.0"
            onchange="roundDecimals(this)">
    </div>

    {{-- Shortfall Reason --}}
    <div class="mb-3 input-group" id="{{ $methodName }}_shortfall_reason_block_{{ $tab_prefix }}">
        <label class="input-group-text textarea-label">
            {{ __('entity_fields')['audit']['balance_shortfall_reason'] }}
        </label>
        <textarea id="{{ $methodName }}_balance_shortfall_reason_{{ $tab_prefix }}"
            name="{{ $methodName }}_balance_shortfall_reason_{{ $tab_prefix }}"
            rows="3" required></textarea>
    </div>
</div>
