@php use App\Models\Staff; @endphp @extends('admin.layouts.app') @section('title',get_setting('site_name').' Payroll') @section('content')
@csrf
{{ __('Bulk generate') }}
@if(\App\Services\SalaryStructureService::enabled())

{{ __('Bulk generate applies lunch from attendance and setup defaults for mobile/travel (no monthly override).') }}

@endif
@if($staff_id!=null)
@csrf
Attendance Summary
Allowance
House Allowance:

Medical Allowance :

Food Allowance:

Conveyance Allowance:

Utility Allowance:

@php $unpaid_leave_count=$leave->where('type','unpaid')->sum('number_of_days'); $unpaid_leave_amount=$perday_salary*$unpaid_leave_count; $count=0; $extra_delay_amount=0; if (get_setting('extra_delay')==1 && get_setting('extra_days')>0){ for ($i=0;$i<=$attendence->where('status','E')->count();$i=$i+get_setting('extra_days')){ if ($i>=get_setting('extra_days')){ $count++; } } $extra_delay_amount=$count*$perday_salary; } $pf_employee_amount = $salary->provident_fund; $pf_employer_amount = 0; if ((int)get_setting('pf') === 1) { $pfAccount = \App\Models\PfAccount::where('staff_id', $staff_ids)->first(); $pfSettings = \App\Models\PfSetting::first(); $probation = (int)($pfSettings->probation_months ?? 6); $eligible = false; if (!empty($salary->staff?->joing_date)) { $eligible = \Carbon\Carbon::parse($salary->staff->joing_date)->addMonths($probation)->startOfDay()->lte(\Carbon\Carbon::today()); } if ($eligible && $pfAccount && $pfAccount->is_enrolled && $pfAccount->status === 'active') { $base = (float)($salary->basic_salary ?? 0); $empRate = (float)($pfAccount->employee_rate ?? ($pfSettings->default_employee_rate ?? 0)); $emprRate = (float)($pfAccount->employer_rate ?? ($pfSettings->default_employer_rate ?? 0)); $pf_employee_amount = round($base * ($empRate/100), 2); $pf_employer_amount = round($base * ($emprRate/100), 2); } } $swf_employee_amount = 0; $swf_employer_amount = 0; if ((int)get_setting('swf') === 1) { $swfAccount = \App\Models\SwfAccount::where('staff_id', $staff_ids)->first(); $swfSettings = \App\Models\SwfSetting::first(); $swfProbation = (int)($swfSettings->probation_months ?? 6); $swfEligible = false; if (!empty($salary->staff?->joing_date)) { $swfEligible = \Carbon\Carbon::parse($salary->staff->joing_date)->addMonths($swfProbation)->startOfDay()->lte(\Carbon\Carbon::today()); } if ($swfEligible && $swfAccount && $swfAccount->is_enrolled && $swfAccount->status === 'active') { $swfBase = (float)($salary->basic_salary ?? 0); $swfEmpRate = (float)($swfAccount->employee_rate ?? ($swfSettings->default_employee_rate ?? 0)); $swfEmprRate = (float)($swfAccount->employer_rate ?? ($swfSettings->default_employer_rate ?? 0)); $swf_employee_amount = round($swfBase * ($swfEmpRate/100), 2); $swf_employer_amount = round($swfBase * ($swfEmprRate/100), 2); } } $custom_ded_total = (float) ($salary->customDeductionsTotal() ?? 0); $pre_tax_total_deductions=$pf_employee_amount+$swf_employee_amount+$custom_ded_total+$unpaid_leave_amount+$extra_delay_amount+$absent_count_amount+$advance_salary_recived->sum('amount'); $bonus_input = (float) old('bonus_amount', 0); $arrear_input = (float) old('arrear_amount', 0); $salary_base_gross = (float) ($salary->gross_salary ?? 0); $structureAdditionalGross = 0; $structurePayrollPreview = null; $structureUiMeta = \App\Services\SalaryStructureService::payrollUiMeta(); if (\App\Services\SalaryStructureService::enabled()) { $structurePayrollPreview = \App\Services\SalaryStructureService::computePayrollAdditions( $salary, (int) ($presentDays ?? 0), old('mobile_bill') !== null && old('mobile_bill') !== '' ? (float) old('mobile_bill') : null, old('travel_bill') !== null && old('travel_bill') !== '' ? (float) old('travel_bill') : null ); $structureAdditionalGross = (float) ($structurePayrollPreview['additional_gross'] ?? 0); } $total_gross_for_pay = $salary_base_gross + $structureAdditionalGross + $bonus_input + $arrear_input; $income_tax_amount = \App\Services\PayrollIncomeTaxService::computeMonthlyTax($total_gross_for_pay, $salary); $total_deductions=$pre_tax_total_deductions+$income_tax_amount; $total_allownace=$salary->house_rent+$salary->medical+$salary->food+$salary->conveyance+$salary->utility+$salary->Others + $salary->customAllowancesTotal(); $net_salary=$total_gross_for_pay-$pre_tax_total_deductions-$income_tax_amount; @endphp
Others Allowance:

Deductions
Provident Fund:

@if((int)get_setting('swf') === 1)
Staff Welfare Fund:

@endif @foreach($salary->normalizedCustomDeductions() as $customDed) @if((float)($customDed['amount'] ?? 0) > 0)
{{ $customDed['label'] ?: __('Other deduction') }}:

@endif @endforeach @if(\App\Services\PayrollIncomeTaxService::enabled() && $income_tax_amount > 0)
{{ \App\Services\PayrollIncomeTaxService::label() }}:

@endif
Unpaid Leave:
{{$unpaid_leave_count}}{{__(' days')}}

@if(get_setting('extra_delay')==1)
Absent For Extra Delay :
{{$count}}{{__(' days')}}

@endif
Absent:
{{$absent_count}}{{__(' days')}}

Loan/Advance Salary:
@php $amount=0; if($advance_salary_recived!=null){ foreach ($advance_salary_recived as $advance_salary){ $amount+=$advance_salary->amount; } } @endphp
@if($advance_salary_recived!=null) @foreach ($advance_salary_recived as $advance_salary) {{$advance_salary->month}} -{{$advance_salary->year}}{{'('.$advance_salary->amount.')'}} @endforeach @endif
Overview
{{ __('Bonus and arrear add to gross for this month; income tax uses total gross. Use 0 if none.') }} @if(\App\Services\SalaryStructureService::enabled())
{{ __('Attendance-based lunch and optional mobile/travel overrides are included in total gross when rules are enabled.') }} @endif
@if(\App\Services\SalaryStructureService::enabled() && $structurePayrollPreview)
{{ __('Salary structure (this month)') }}
@php $breakdown = $structurePayrollPreview['breakdown'] ?? []; $lunchAmt = 0; foreach ($breakdown as $bk => $bv) { if (str_contains($bk, 'lunch')) { $lunchAmt = (float) $bv; break; } } @endphp @if($lunchAmt > 0 || $structureUiMeta['lunch_rate'] > 0)

{{ __('Lunch') }}: {{ number_format($lunchAmt, 2) }} ({{ number_format($structureUiMeta['lunch_rate'], 2) }} × {{ (int) ($presentDays ?? 0) }} {{ __('days') }})

@endif @if($structureUiMeta['has_mobile'])
@endif @if($structureUiMeta['has_travel'])
@endif

{{ __('Variable additions this month') }}: {{ number_format($structureAdditionalGross, 2) }}

@endif
Basic Salary:

@if(\App\Services\SalaryStructureService::enabled())
{{ __('Structure add-ons') }}:

@endif
{{ __('Bonus') }}:

{{ __('Arrear') }}:

Total Allowance:

Total Deductions:

{{ __('Total gross') }}:

Net Salary:


@if(\App\Services\SalaryStructureService::enabled())
@endif







@endif @endsection @section('script') @endsection