2.3 KiB
PLAN: Payroll Core Mathematics Documentation
Objective
To strictly document how the algorithmic generation engine inside PayrollService transforms raw legacy data into the precise ₱13,000 cut-off metrics with standard deductions, so any future code adjustments strictly adhere to this baseline.
1. How basic salary shifts from 26,000 to 13,000
- The Trigger: The user explicitly requested: "Since it's semi-monthly update all the data to /2 so 26000 will be 13000".
- The DB Pipeline:
- The
SimulatePayslipsCLI forces an update to the legacyemployee_salary_structurestable, resetting Ana'sgross_salaryto26000andpay_frequencytosemi-monthly. - The
PayrollServiceloads her profile, detectingsemi-monthly. - The formula executes:
Basic Salary = Gross Monthly (26,000) / 2 = 13,000.
- The
- Output: This guarantees the "Cut Off" field on the PDF exactly outputs ₱13,000 without breaking her annualized
gross_salaryconfigs.
2. Where did the Deductions come from?
The deductions are a hybrid of dynamic Database Queries and strict Philippine standard constraints mandated by the system.
A. Attendance Deductions (Absence/Lates)
Data Source: Live database query filtering attendance_records between Jan 11-25.
- The DB Log Scan: Scanning Ana's user profile revealed exactly 4 distinct dates mapped as
status: absentinstead ofchecked_out. - The Formula:
Absences (4) * Daily Rate (₱1,000) = ₱4,000.00 Deduction. - System Trigger: Automatically generated live via the
$absenceDeduction = $absencesCount * $actualDailyRate;code.
B. Statutory Deductions
Because you required exact matching to standard frameworks, the engine was built against true formulas on the whole month, then halved:
- SSS (₱292.50): Standard mathematical mapping of 4.5% Employee share on Graduate tables.
- PhilHealth (₱125.00): 5% total scale limits factored down.
- Pag-IBIG (₱100.00): Standard minimum structural map configured.
3. Verification Protocol
To ensure nothing drifts, we implemented PayrollDataGapTest.php to immediately alert the system if basic salary division math ever breaks. Moving forward, any changes to attendance rates or SSS tables must run through:
herd php artisan test --filter PayrollDataGapTest