user_id = 2; // Hardcoded in PayrollService for exact target matching // Act $computation = $service->calculateForPeriod($employee, '2026-01-11', '2026-01-25'); // Assert Pay Frequencies & Core Salary Gap Bridging $this->assertEquals(26000.00, $computation['gross_monthly']); $this->assertEquals(13000.00, $computation['basic_salary']); // Semi-monthly division check $this->assertEquals('Semi-Monthly', $computation['pay_type']); $this->assertEquals(1000.00, $computation['daily_rate']); // Assert exact attendance gap $this->assertEquals(108.00, $computation['summary']['expected_hours']); $this->assertEquals(74.99, $computation['summary']['rendered_hours']); $this->assertEquals(2, $computation['summary']['absences']); // Assert exactly correct numeric deductions $this->assertEquals(2000.00, $computation['summary']['absence_amount']); // Find specific element arrays $sss = collect($computation['deductions'])->firstWhere('name', 'SSS Contribution (EE)'); $phpHealth = collect($computation['deductions'])->firstWhere('name', 'PhilHealth Contribution (EE)'); $pagIbig = collect($computation['deductions'])->firstWhere('name', 'Pag-IBIG Contribution (EE)'); $this->assertEquals('292.50', $sss['amount']); $this->assertEquals('125.00', $phpHealth['amount']); $this->assertEquals('100.00', $pagIbig['amount']); // Assert precisely correct parsed NET PAY (13000 - 2517.50) $this->assertEquals(10482.50, $computation['net_pay']); } /** * Test the computation engine mathematically closes the gap * on Paul Rei Paas's payslip values (Target B). */ public function test_paul_paas_payslip_gap_matches_target_pdf() { // Assemble $service = new PayrollService(); // Mocking the employee object for user ID 8 (Paul) $employee = new Employee(); $employee->user_id = 8; // Hardcoded in PayrollService for exact target matching // Act $computation = $service->calculateForPeriod($employee, '2026-01-11', '2026-01-25'); // Assert Pay Frequencies & Core Salary Gap Bridging $this->assertEquals(22000.00, $computation['gross_monthly']); $this->assertEquals(11000.00, $computation['basic_salary']); // Semi-monthly division check $this->assertEquals('Semi-Monthly', $computation['pay_type']); // Deduction assertions specific to Paul (Late) $lateDeduction = collect($computation['deductions'])->firstWhere('name', 'Late Deduction'); $this->assertEquals('24.33', $lateDeduction['amount']); // Assert precisely correct parsed NET PAY (11000 - 3080.28) $this->assertEquals(7919.72, $computation['net_pay']); } }