@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'] }} {{ App\Classes\Common::formatAmountCurrency($company->currency, $payroll->basic_salary) }}
{{ $component->name }} {{ App\Classes\Common::formatAmountCurrency($company->currency, $component->monthly_value) }}
{{ $payrollTranslation['special_allowances'] }} {{ App\Classes\Common::formatAmountCurrency($company->currency, $specialAllowance) }}
{{ $component->name }} {{ App\Classes\Common::formatAmountCurrency($company->currency, $component->monthly_value) }}
@foreach ($deductionComponents as $type => $components) @foreach ($components as $component) @endforeach @endforeach
{{ $payrollTranslation['deductions'] }} {{ $payrollTranslation['amount'] }}
{{ $component['name'] }} {{ App\Classes\Common::formatAmountCurrency($company->currency, $component['monthly_value']) }}
{{ $payrollTranslation['gross_earnings'] }} {{ App\Classes\Common::formatAmountCurrency($company->currency, $grossEarnings) }}
{{ $payrollTranslation['total_deductions'] }} {{ App\Classes\Common::formatAmountCurrency($company->currency, $totalMonthlyDeductions) }}
{{ $payrollTranslation['reimbursements'] }} {{ $payrollTranslation['amount'] }}
{{ $payrollTranslation['expense_claim'] }} {{ App\Classes\Common::formatAmountCurrency($company->currency, $payroll->expense_amount ?? 0, 2) }}
{{ $payrollTranslation['net_salary'] . ':' }}  {{ App\Classes\Common::formatAmountCurrency($company->currency, $payroll->net_salary) }}
{{ $payrollTranslation['net_salary'] . ' = ' . $payrollTranslation['gross_earnings'] . ' - ' . $payrollTranslation['total_deductions'] . ' + ' . $payrollTranslation['reimbursements'] }}
@endsection