@php $periodTitle = 'Payroll: '.($accounting_payroll_period->label ?? $accounting_payroll_period->period_start->format('M Y')); $periodSubtitle = $accounting_payroll_period->period_start->format('Y-m-d') .' – '.$accounting_payroll_period->period_end->format('Y-m-d') .' · '.$accounting_payroll_period->normalizedStatus() .($accounting_payroll_period->stamp_date ? ' · Stamp '.$accounting_payroll_period->stamp_date->format('j M Y') : ''); $generateConfirm = ($payrollOrganization['is_organization_wide'] ?? true) ? 'Generate payroll lines from active salary assignments for all eligible employees?' : 'Generate payroll lines for '.$payrollOrganization['organization_unit'].' only?'; $inWorkspaceContext = \App\Support\Navigation\WorkspaceEmbed::isEmbedded() || ($loanActiveWorkspace ?? null); $worksheetRows = $worksheetRows ?? []; $previewGross = array_sum(array_map(fn ($row) => (float) ($row['gross'] ?? 0), $worksheetRows)); $previewDeductions = array_sum(array_map(fn ($row) => (float) ($row['total_deductions'] ?? 0), $worksheetRows)); $previewNet = array_sum(array_map(fn ($row) => (float) ($row['net'] ?? 0), $worksheetRows)); $displayGross = (float) $accounting_payroll_period->total_gross > 0 ? (float) $accounting_payroll_period->total_gross : $previewGross; $displayDeductions = (float) $accounting_payroll_period->total_deductions > 0 ? (float) $accounting_payroll_period->total_deductions : $previewDeductions; $displayNet = (float) $accounting_payroll_period->total_net > 0 ? (float) $accounting_payroll_period->total_net : $previewNet; @endphp @if ($inWorkspaceContext) @endif @include('loan.accounting.partials.flash') @include('loan.accounting.books.payroll.partials.period-toolbar', ['generateConfirm' => $generateConfirm]) @include('loan.accounting.books.payroll.partials.gl-config-banner') @include('loan.accounting.books.payroll.partials.treasury-dispatch') @php $generation = $generationSummary ?? session('payroll_generation'); @endphp @if (is_array($generation) && (int) ($generation['created'] ?? 0) === 0 && $accounting_payroll_period->lines->isEmpty() && in_array($accounting_payroll_period->normalizedStatus(), ['generated', 'reviewed', 'approved'], true))

Payroll generated with zero lines

Generation ran, but no employees qualified. Each Active employee marked Include in HR payroll needs a basic salary on their employee record.

@endif @if (is_array($generation) && ! empty($generation['missing_salary']))

Employees skipped ({{ count($generation['missing_salary']) }})

    @foreach ($generation['missing_salary'] as $missing)
  • {{ $missing['employee_number'] ?? '—' }} · {{ $missing['name'] ?? 'Employee' }} @if (! empty($missing['reason'])) — {{ $missing['reason'] }} @endif
  • @endforeach
@endif @if (is_array($generation) && ! empty($generation['errors']))

Calculation errors

    @foreach ($generation['errors'] as $error)
  • {{ $error }}
  • @endforeach
@endif

Total gross

KES {{ number_format($displayGross, 2) }}

Total deductions

KES {{ number_format($displayDeductions, 2) }}

Total net

KES {{ number_format($displayNet, 2) }}

@include('loan.accounting.books.payroll.partials.period-cost-intelligence') @php $unpaidSummary = $unpaidLeaveSummary ?? null; @endphp @if (is_array($unpaidSummary) && (float) ($unpaidSummary['total_amount'] ?? 0) > 0)

Unpaid leave deductions

Total deductions: KES {{ number_format((float) $unpaidSummary['total_amount'], 2) }}

Total leave days: {{ number_format((float) $unpaidSummary['total_days'], 1) }}

Affected employees: {{ (int) ($unpaidSummary['affected_employees'] ?? 0) }}

@endif @include('loan.accounting.books.payroll.partials.period-worksheet') @if ($accounting_payroll_period->generated_at)

Generated {{ $accounting_payroll_period->generated_at->format('M j, Y H:i') }} @if ($accounting_payroll_period->generatedByUser) by {{ $accounting_payroll_period->generatedByUser->name }} @endif @if ($accounting_payroll_period->reviewed_at) · Reviewed {{ $accounting_payroll_period->reviewed_at->format('M j, Y H:i') }} @endif @if ($accounting_payroll_period->approved_at) · Approved {{ $accounting_payroll_period->approved_at->format('M j, Y H:i') }} @endif @if ($accounting_payroll_period->locked_at) · Locked {{ $accounting_payroll_period->locked_at->format('M j, Y H:i') }} @endif

@endif