@extends('layouts.horizontal', ['title' => 'Staff Payment Calculator', 'topbarTitle' => 'Staff Payment Calculator']) @section('css') @vite(['node_modules/datatables.net-bs5/css/dataTables.bootstrap5.min.css', 'node_modules/datatables.net-responsive-bs5/css/responsive.bootstrap5.min.css', 'node_modules/datatables.net-fixedcolumns-bs5/css/fixedColumns.bootstrap5.min.css', 'node_modules/datatables.net-fixedheader-bs5/css/fixedHeader.bootstrap5.min.css', 'node_modules/datatables.net-buttons-bs5/css/buttons.bootstrap5.min.css', 'node_modules/datatables.net-select-bs5/css/select.bootstrap5.min.css', 'node_modules/dropzone/dist/dropzone.css', 'node_modules/select2/dist/css/select2.min.css', 'node_modules/flatpickr/dist/flatpickr.min.css']) @endsection @section('content')

Staff Payment Calculator

@php $breadcrumb = getCurrentMenuBreadcrumb(); @endphp @if(!empty($breadcrumb)) @endif
@if(session('Success'))
@endif @if(session('Error'))
@endif

Calculate Payments For: {{ $monthName }}-{{ $year }}

@csrf
@if(session('ho') === 'Yes')
@endif
@if(!empty($payables) && count($payables) > 0)
@php $allowance_list=0; @endphp @foreach($allowances as $allowance) @endforeach @php $x=1; $totalpayable=0; $grandTotalPayable = 0; $grandTotalDeductions = 0; $grandTotalFinal = 0; $grandTotalAdjustment = 0; $grandTotalOTAmount = 0; $grandTotalBasicSalary = 0; $grandTotalSalaryWithoutOT = 0; $grandTotalPayableWithoutOT = 0; @endphp @foreach($payables as $payable) @php $rowId = $payable['id_staff'] ?? $x; $salaryType = $payable['staff_salary_type'] ?? 'monthly'; $presentDays = $payable['Present'] ?? 0; $workHours = $payable['WorkHours'] ?? 0; $basicSalary = $payable['calculated_salary'] ?? 0; // Overtime data $totalOTAmount = $payable['total_overtime_amount'] ?? 0; $salaryWithoutOT = $basicSalary; $salaryWithOT = $basicSalary + $totalOTAmount; // Calculate allowance total $allowance_total = 0; $allowance_amounts = []; if(isset($payable['allowances'])) { foreach($payable['allowances'] as $allowance) { $allowance_total += $allowance['allowance_amount'] ?? 0; $allowance_amounts[$allowance['entity_name']] = $allowance['allowance_amount'] ?? 0; } } // Use the calculated PF from calculateStaffMonthPayables $employeePF = $payable['provident_fund'] / 2; $employerPF = $payable['provident_fund'] / 2; // Calculate totals $serviceCommission = $payable['service_commission'] ?? 0; $retailCommission = $payable['retail_commission'] ?? 0; $absentDeduction = $payable['absent_deduction'] ?? 0; $lateDeduction = $payable['late_deduction'] ?? 0; $taxDeduction = $payable['salary_monthly_tax'] ?? 0; $loanDeduction = $payable['loan_deduction'] ?? 0; // Get miscellaneous and other deductions $miscellaneous = 0; $reimbursements = 0; $otherDeduction = 0; // Calculate row totals WITHOUT overtime for Total Payable $tr_payable_without_ot = $salaryWithoutOT + $serviceCommission + $retailCommission + $allowance_total + $miscellaneous + $reimbursements; $tr_deductions = $absentDeduction + $lateDeduction + $employeePF + $taxDeduction + $otherDeduction + $loanDeduction; // Calculate final payable WITH overtime $tr_final_payable_with_ot = $tr_payable_without_ot - $tr_deductions + $totalOTAmount; // Update grand totals $grandTotalPayableWithoutOT += $tr_payable_without_ot; $grandTotalDeductions += $tr_deductions; $grandTotalFinal += floor($tr_final_payable_with_ot); $grandTotalAdjustment += ($tr_final_payable_with_ot - floor($tr_final_payable_with_ot)); $grandTotalOTAmount += $totalOTAmount; $grandTotalBasicSalary += $basicSalary; $grandTotalSalaryWithoutOT += $salaryWithoutOT; $totalpayable += floor($tr_final_payable_with_ot); @endphp @foreach($allowances as $a) @php $allowance_amount = $allowance_amounts[$a->entity_name] ?? 0; @endphp @endforeach @php $x++; @endphp @endforeach @foreach($allowances as $allowance) @php $allowanceTotal = 0; if(isset($allowance_amounts[$allowance->entity_name])) { $allowanceTotal = $allowance_amounts[$allowance->entity_name] * ($x-1); } @endphp @endforeach
ID Name Branch Basic Salary Total Overtime Salary (Excl. OT) Salary Type Commission Mode Income Generated Service Commission Retail Commission {{ $allowance->allowance_name }} @php $allowance_list++; @endphp Miscellaneous Reimbursements Provident Fund 'Employer' Deduction Absents Deduction Late Provident Fund 'Employee' Tax Deduction Other Deduction Loan Deduction Total Payable (Excl. OT) Total Deductions Final Payable (Incl. OT) Decimal Adjustment Actions
{{ $rowId }} {{ $payable['staff_fullname'] ?? 'N/A' }} {{ $payable['business_name'] ?? ($business->business_name ?? 'N/A') }} {{ number_format($basicSalary, 2) }} {{ number_format($totalOTAmount, 2) }} {{ number_format($salaryWithoutOT, 2) }} {{ ucfirst($salaryType) }} {{ $payable['commission_mode'] ?? 'N/A' }} {{ number_format($payable['service_income'] + $payable['retail_income'] ?? 0, 2) }} {{ number_format($serviceCommission, 2) }} {{ number_format($retailCommission, 2) }} {{ number_format($allowance_amount, 2) }} {{ number_format($employerPF, 2) }} {{ number_format($absentDeduction, 2) }} {{ number_format($lateDeduction, 2) }} {{ number_format($employeePF, 2) }} {{ number_format($taxDeduction, 2) }} {{ number_format($tr_payable_without_ot, 2) }} {{ number_format($tr_deductions, 2) }} {{ floor($tr_final_payable_with_ot) }} {{ number_format($tr_final_payable_with_ot - floor($tr_final_payable_with_ot), 2) }}
Grand Totals: {{ number_format($grandTotalBasicSalary, 2) }} {{ number_format($grandTotalOTAmount, 2) }} {{ number_format($grandTotalSalaryWithoutOT, 2) }} {{ number_format(($payable['service_income'] + $payable['retail_income'] ?? 0) * ($x-1), 2) }} {{ number_format($serviceCommission * ($x-1), 2) }} {{ number_format($retailCommission * ($x-1), 2) }}{{ number_format($allowanceTotal, 2) }}0.00 0.00 {{ number_format($employerPF * ($x-1), 2) }} {{ number_format($absentDeduction * ($x-1), 2) }} {{ number_format($lateDeduction * ($x-1), 2) }} {{ number_format($employeePF * ($x-1), 2) }} {{ number_format($taxDeduction * ($x-1), 2) }} 0.00 {{ number_format($loanDeduction * ($x-1), 2) }} {{ number_format($grandTotalPayableWithoutOT, 2) }} {{ number_format($grandTotalDeductions, 2) }} {{ number_format($grandTotalFinal, 2) }} {{ number_format($grandTotalAdjustment, 2) }}
@else

No Payment Data Available

Please select staff, month, and year filters and click "Calculate" to generate payment data.

@if($staffId > 0)

No payment data found for the selected staff in {{ $monthName }}-{{ $year }}

@endif
@endif
@endsection @section('scripts') @vite(['resources/js/app.js']) @endsection