{{-- Month-by-month account: $ledger rows from User::salaryLedger(), $thisMonth from User::salarySummaryFor(now()). --}} @use('App\Enums\PaymentType') @use('App\Models\Payment') @php $currency = $employee->currency(); // Salary and advance always get a column because they make up the month's pay; the other types appear once something was paid under them. $columns = collect(PaymentType::cases())->filter(fn (PaymentType $type): bool => $type->countsTowardsSalary() || $ledger->contains(fn (array $row): bool => $row['by_type'][$type->value] > 0)); @endphp

{{ __('Monthly salary account') }}

{{ __('One line per month: what was paid under each type, the total, and what is still left of the salary. Salary and advances count towards the month.') }}

{{ __(':month: :status', ['month' => now()->format('F'), 'status' => $thisMonth['status']->label()]) }}
@if ($ledger->isEmpty())

{{ __('No salary or payments recorded yet.') }}

@else
@foreach ($columns as $type) @endforeach @foreach ($ledger as $row) @foreach ($columns as $type) @php $amount = $row['by_type'][$type->value]; @endphp @endforeach @endforeach
{{ __('Month') }} {{ __('Salary due') }}{{ $type->label() }}{{ __('Total paid') }} {{ __('Remaining') }} {{ __('Status') }}
{{ $row['month']->format('F Y') }} @if ($loop->first) {{ __('this month') }} @endif {{ $row['salary'] > 0 ? Payment::formatMoney($row['salary'], $currency) : '—' }}{{ $amount > 0 ? Payment::formatMoney($amount, $currency) : '—' }}{{ $row['total'] > 0 ? Payment::formatMoney($row['total'], $currency) : '—' }} {{ $row['remaining'] > 0 ? Payment::formatMoney($row['remaining'], $currency) : '—' }} {{ $row['status']->label() }}
@endif