Solidmark Payroll, Schedule, and Account Integrity Fixes
Implementation report for the Solidmark repository
Source: Solidmark
Repository: Solidmark
Components: Schedule Management, Attendance, Payroll, Contributions, Employee Accounts, Brand Access
Completed: Sep 23, 2026 at 02:25 PM PHT
Summary
A coordinated integrity update was completed across employee creation, authentication, schedule management, attendance credit, government contributions, payroll calculations, and brand-scoped data access. The work removed calculation inconsistencies between attendance entry points, repaired contribution settings that incorrectly produced zero deductions for regular employees, and reconciled the live payroll cache against the corrected formulas.
Brand and Schedule Management
- Applied company and brand scope checks to branch, employee, schedule, and schedule-approval endpoints to prevent cross-brand records from appearing or being modified.
- Centralized work schedule resolution so work-week profiles and standalone employee shift schedules follow one calculation path.
- Updated schedule create, update, delete, and approval actions to recalculate affected attendance snapshots automatically.
- Marked overlapping payroll periods for recalculation whenever a schedule change affects stored attendance requirements.
- Removed one confirmed cross-brand live payroll cache record without deleting its employee profile.
Attendance Credit Calculations
- Applied scheduled required minutes, base minutes, breaks, rest-day status, rendered minutes, shortages, and credit multipliers consistently.
- Unified web attendance, mobile time-in and time-out, attendance edits, and approved late-attendance corrections under the shared schedule calculator.
- Recalculated late and undertime penalties from the resolved shift instead of relying on legacy fixed-hour assumptions.
- Verified compressed and extended shifts can produce their configured attendance credit while blank attendance remains zero.
Employee Accounts and Credentials
- Corrected the employee insert prepared statement so its parameter types and bound variables match all database columns.
- Standardized new employee credentials: the employee ID is the username and temporary password unless HR provides another password.
- Stored matching bcrypt password hashes on the user account and employee profile.
- Made bulk employee user/profile creation atomic so a failed profile insert cannot leave an unusable login-only account.
- Validated employee 2682259621: employee and user records are active, IDs match, and the employee ID verifies against the stored bcrypt password.
Payroll and Contribution Calculations
- Corrected first-cutoff detection so periods ending on days 1–19 are classified as semi-monthly rather than unknown.
- Recalculated employee and employer SSS, PhilHealth, and Pag-IBIG shares using each contribution’s deduction type and half/full mode.
- Repaired 45 regular employee payroll settings that were incorrectly cached with one or more contribution types set to none.
- Updated gross pay, regular earnings, overtime earnings, allowances, attendance deductions, loans, taxable compensation, withholding tax, and final net pay as one consistent calculation.
- Protected Option B totals from older database triggers that previously replaced overtime-inclusive gross and tax-inclusive net amounts with legacy values.
- Updated payroll finalization to preserve schedule metrics, overtime fields, employee and employer contributions, tax fields, incentives, retro pay, and formula metadata.
Contribution Override Behavior
- Rebuilt employee contribution override saving to target the exact employee, active brand, live payroll row, and payroll cutoff.
- Removed the invalid recalculation call that passed null cutoff dates and caused the generic save error.
- Made Save & Apply activate a legacy none contribution type for the selected cutoff before recalculating the payroll row.
- Returned the complete recalculated payroll row so the interface immediately refreshes contributions, tax, and net pay.
- Updated the interface request to include live payroll ID and cutoff dates and to display the backend’s actual validation error.
Data Reconciliation
- Recalculated every valid live payroll group after the formula and contribution corrections.
- Audited 91 current live payroll rows with zero employee-contribution total mismatches.
- Confirmed zero regular employees with a zero government-contribution total.
- Confirmed zero employer-contribution, gross-pay, net-pay, orphan-row, and dirty-cache mismatches.
Validation
- PHP syntax validation passed for all 35 modified PHP files.
- Frontend automated tests passed: 2 test files and 3 tests.
- Payroll net-pay, holiday-pay, and holiday attendance-credit regression checks passed.
- A transactional payroll-finalization test copied and verified 71 rows before rollback.
- The live contribution override endpoint successfully saved and applied a ₱1,000 SSS override and returned the recalculated payroll row.
- Production source compilation completed; service-worker output remained blocked by an operating-system file lock on frontend/dist/sw.js.
Code Validation
php -l completed successfully across all 35 modified PHP files.
vitest run completed successfully with 2 passing test files and 3 passing tests.
- A database consistency audit checked 91 live payroll rows and returned zero regular employees with zero contributions, zero employee or employer contribution mismatches, zero gross or net mismatches, zero orphan rows, and zero dirty rows.
- A transactional contribution test verified that an override updates the full share, applies the correct half/full deduction rule, and produces a matching recalculated net salary.
- The real contribution override endpoint successfully saved and applied an existing ₱1,000 SSS override for the selected employee, brand, and cutoff.
- A payroll-finalization transaction copied and compared 71 rows with zero tax, employer-contribution, or gross-pay mismatches before rollback.
Implementation Proof — Solidmark (Code Changes)
1. Contribution Cutoff Correction (payroll_recalculate_helper.php)
- if ($untilDay >= 11 && $untilDay <= 19) {
+ if ($untilDay >= 1 && $untilDay <= 19) {
return 'semi-monthly';
}
2. Scoped Contribution Override Recalculation (update_contribution_override.php)
- payroll_recalculate_employee_live_cache($conn, $employee_id, null, null);
+ $liveSql = 'SELECT * FROM payroll_live_cache
+ WHERE employee_id = ? AND company_id = ? AND brand_id = ?';
+ payroll_recalculate_employee_live_cache(
+ $conn, $employeeId,
+ (string)$liveRow['date_from'],
+ (string)$liveRow['date_until']
+ );
3. Schedule Changes Recalculate Attendance and Payroll (work_schedule_helper.php)
+ function work_schedule_recalculate_attendance_range(
+ mysqli $conn, string $employeeId,
+ string $dateFrom, ?string $dateUntil = null
+ ): int {
+ $dirtySql = "UPDATE payroll_live_cache
+ SET needs_recalc = 1
+ WHERE employee_id = ? AND date_until >= ?";
+ }
4. Employee Credential Integrity (add_employee.php)
- $employeePassword = hash('sha256', $employee_id);
+ $initialPassword = trim((string)($data['password'] ?? ''));
+ if ($initialPassword === '') $initialPassword = $employee_id;
+ $employeePassword = password_hash($initialPassword, PASSWORD_BCRYPT);
5. Final Payroll Totals Protected from Legacy Triggers (payroll_recalculate_helper.php)
+ 'gross_salary' => (float)$payload['gross_salary'],
+ 'total_salary_after_late' => (float)$payload['total_salary_after_late'],
+ 'net_salary_cached' => (float)$payload['net_salary_cached'],
+ 'employer_contribution_total_cached' =>
+ round($sssEmployerApplied + $pagibigEmployerApplied
+ + $philhealthEmployerApplied, 2),
Source and Tracking
Source: Solidmark repository
Scope: Schedule Management, Attendance, Payroll, Contributions, Employee Accounts, and Brand Isolation