49 lines
2.1 KiB
PHP
49 lines
2.1 KiB
PHP
<?php
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
$app = require_once __DIR__.'/../bootstrap/app.php';
|
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
|
$kernel->bootstrap();
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Services\PayrollService;
|
|
use App\Models\Employee;
|
|
|
|
$payrollService = new PayrollService();
|
|
|
|
// Get all active employees with salary configurations
|
|
$employees = Employee::with('user')->get();
|
|
|
|
$startDate = '2026-05-11';
|
|
$endDate = '2026-05-25';
|
|
|
|
echo "=========================================================================\n";
|
|
echo "COMPUTED PAYROLL DETAILS FOR PERIOD: $startDate to $endDate\n";
|
|
echo "=========================================================================\n";
|
|
|
|
foreach ($employees as $emp) {
|
|
$user = $emp->user;
|
|
if (!$user) continue;
|
|
|
|
$salary = \App\Models\EmployeeSalary::where('employee_id', $user->id)->first();
|
|
$frequency = $salary ? $salary->pay_frequency : 'unknown';
|
|
$rate = $salary ? $salary->basic_salary : 0.0;
|
|
|
|
$res = $payrollService->calculateForPeriod($emp, $startDate, $endDate);
|
|
|
|
echo "\nEmployee: {$user->name} | Freq: {$frequency} | Rate/Base: {$rate}\n";
|
|
echo " Attendance: Expected Days: {$res['summary']['expected_working_days']} | Days Worked: {$res['summary']['days_worked']} | Absences: {$res['summary']['absences']} | Rendered Hours: {$res['summary']['rendered_hours']}\n";
|
|
echo " Earnings:\n";
|
|
foreach ($res['earnings'] as $earning) {
|
|
echo " - {$earning['name']}: " . number_format((float)$earning['amount'], 2) . "\n";
|
|
}
|
|
echo " TOTAL EARNINGS (Gross): " . number_format($res['total_earnings'], 2) . "\n";
|
|
|
|
echo " Deductions:\n";
|
|
foreach ($res['deductions'] as $deduction) {
|
|
echo " - {$deduction['name']}: " . number_format((float)$deduction['amount'], 2) . "\n";
|
|
}
|
|
echo " TOTAL DEDUCTIONS: " . number_format($res['total_deductions'], 2) . "\n";
|
|
echo " Net Pay: " . number_format($res['net_pay'], 2) . "\n";
|
|
echo " Employer Contributions (SSS/PH/PI): " . number_format($res['employer_contributions']['total'], 2) . "\n";
|
|
}
|