@extends('layouts.pdf') @section('styles') @endsection @section('content')
{{ $payrollTranslation['pay_slip_for_duration'] }} {{ \Carbon\Carbon::create()->month($payroll->month ?? 1)->format('F') }} {{ $payroll->year ?? $payrollTranslation['year_not_available'] }}
{{ $payrollTranslation['employee_id'] . ':' }} {{ optional($payroll->user)->employee_number ?? 'N/A' }} {{ $payrollTranslation['name'] . ':' }} {{ optional($payroll->user)->name ?? 'N/A' }} {{ $payrollTranslation['salary_slip'] . '#' . ':' }} {{ '9' }}
{{ $payrollTranslation['department'] . ':' }} {{ optional($payroll->user)->department->name ?? 'N/A' }} {{ $payrollTranslation['designation'] . ':' }} {{ optional($payroll->user)->designation->name ?? 'N/A' }} {{ $payrollTranslation['joining_date'] . ':' }} {{ optional($payroll->user)->joining_date ? \Carbon\Carbon::parse(optional($payroll->user)->joining_date)->format('d-m-Y') : 'N/A' }}
@php // Calculate the total earnings $filteredEarningComponents = collect($payroll->payrollComponents)->whereIn('type', [ 'custom_earning', 'earnings', ]); $totalMonthlyEarning = $filteredEarningComponents->sum('monthly_value') ?? 0; //Calculate special allowance $specialAllowance = $user->monthly_amount - $payroll->basic_salary - $totalMonthlyEarning; //earning components $additionalEarnings = collect($payroll->payrollComponents) ->where('type', 'additional_earning') ->values(); $totalAdditionalEarning = $additionalEarnings->sum('monthly_value') ?? 0; $earningsComponents = collect($payroll->payrollComponents) ->whereIn('type', ['earnings', 'custom_earning']) ->values(); //gross earnings sum $grossEarnings = round($payroll->basic_salary + $specialAllowance + $totalMonthlyEarning + $totalAdditionalEarning, 2); //deductions components $deductionComponents = collect($payroll->payrollComponents) ->groupBy('type') ->only(['deductions', 'pre_payments', 'custom_deduction']); //sum of deduction components $filteredDeductionComponents = collect($payroll->payrollComponents)->whereIn('type', [ 'custom_deduction', 'deductions', 'pre_payments', ]); $totalMonthlyDeductions = $filteredDeductionComponents->sum(function ($component) { return $component['monthly_value'] ?? 0; }); @endphp
{{-- Regular Earnings and Custom Earnings --}} @if ($earningsComponents->isNotEmpty()) @foreach ($earningsComponents as $component) @endforeach @endif @if ($specialAllowance > 0) @endif {{-- Additional Earnings --}} @if ($additionalEarnings->isNotEmpty()) @foreach ($additionalEarnings as $component) @endforeach @endif
{{ $payrollTranslation['earnings'] }} {{ $payrollTranslation['amount'] }}
{{ $payrollTranslation['basic_salary'] }} {{ number_format($payroll->basic_salary, 2) }}
{{ $component->name }} {{ number_format($component->monthly_value ?? 0, 2) }}
{{ $payrollTranslation['special_allowances'] }} {{ number_format($specialAllowance, 2) }}
{{ $component->name }} {{ number_format($component->monthly_value ?? 0, 2) }}
@foreach ($deductionComponents as $type => $components) @foreach ($components as $component) @endforeach @endforeach
{{ $payrollTranslation['deductions'] }} {{ $payrollTranslation['amount'] }}
{{ $component['name'] }} {{ number_format($component['monthly_value'], 2) }}
{{ $payrollTranslation['gross_earnings'] }} {{ $grossEarnings }}
{{ $payrollTranslation['total_deductions'] }} {{ $totalMonthlyDeductions }}
{{ $payrollTranslation['reimbursements'] }} {{ $payrollTranslation['amount'] }}
{{ $payrollTranslation['expense_claim'] }} {{ number_format(optional($payroll)->expense_amount ?? 0, 2) }}
{{ $payrollTranslation['net_salary'] . ':' }}  {{ $payroll->net_salary = round($payroll->net_salary, 2) }}
{{ $payrollTranslation['net_salary'] . ' = ' . $payrollTranslation['gross_earnings'] . ' - ' . $payrollTranslation['total_deductions'] . ' + ' . $payrollTranslation['reimbursements'] }}
@endsection