@use('App\Enums\PaymentMethod') @use('App\Enums\PaymentStatus') @use('App\Enums\PaymentType') @php $payment ??= null; $selectedEmployeeId ??= null; $selectedMonth ??= null; $selectedUserId = (int) old('user_id', $payment?->user_id ?? $selectedEmployeeId ?? 0); $selectedType = old('type', $payment?->type->value ?? PaymentType::Salary->value); // Recording lets several types be paid together; editing changes one payment. $recording = $payment === null; $oldAmounts = collect(PaymentType::cases())->mapWithKeys(fn (PaymentType $type): array => [$type->value => (string) old("amounts.{$type->value}", '')]); $selectedMethod = old('method', $payment?->method->value ?? PaymentMethod::BankTransfer->value); $selectedStatus = old('status', $payment?->status->value ?? PaymentStatus::Paid->value); $paidOn = old('paid_on', $payment?->paid_on?->format('Y-m-d') ?? now()->format('Y-m-d')); $periodMonth = old('period_month', $payment?->period_month?->format('Y-m') ?? $selectedMonth ?? now()->format('Y-m')); // A month that came back from a failed submit is stored as a full date; show it as a month again. $periodMonth = preg_match('/^\d{4}-\d{2}-\d{2}$/', (string) $periodMonth) ? substr($periodMonth, 0, 7) : $periodMonth; @endphp
@foreach ($employees as $employee) @endforeach
@if ($recording)
{{ __('What is being paid') }}

{{ __('Fill in every amount that applies, like the salary plus a bonus. Leave the rest empty. Each one is kept as its own payment, recorded together.') }}

@foreach (PaymentType::cases() as $type)
@if ($type === PaymentType::Salary) {{-- What the employee's salary actually is for the chosen month, so the amount can be checked against it. --}} @endif
@if ($type === PaymentType::Salary) @endif
@endforeach
{{ __('Total') }}
@else
{{ __('Type') }}
@foreach (PaymentType::cases() as $type) @endforeach
@endif
@unless ($recording)
@endunless

{{ __('Optional. The salary month this covers.') }}

{{-- What the month looks like for this employee, so the amount can be checked against the salary. --}}
{{ __('Paid via') }}
@foreach (PaymentMethod::cases() as $method) @endforeach

{{ __('Optional. The transaction or cheque number.') }}

{{ __('Status') }}
@foreach (PaymentStatus::cases() as $status) @endforeach
{{ old('notes', $payment?->notes) }}
{{ __('Cancel') }} @unless ($payment) @endunless {{ $submitLabel }}