Files
HRM-System/docs/PLAN-payroll-frequency-update.md
2026-04-23 10:15:50 +08:00

35 lines
1.9 KiB
Markdown

# Add Semi-Monthly to Payroll Runs
## Analysis & Context
The user discovered that they cannot select "Semi-Monthly" when generating a new Payroll Run in the `hr/payroll-runs` page.
Root cause analysis reveals that:
1. The MySQL database table `payroll_runs` rigidly defines the `payroll_frequency` column as an `ENUM('weekly', 'biweekly', 'monthly')`.
2. The `PayrollRunController.php` heavily restricts the validation rules to strictly accept `in:weekly,biweekly,monthly`.
3. The React frontend (`resources/js/Pages/hr/payroll-runs/index.tsx`) hardcodes the Select dropdown items precisely to this list.
## Proposed Changes
This will be a full-stack update specifically touching:
1. **Database Migration**
- Create a new migration file: `add_semi_monthly_to_payroll_frequency_enum.php`.
- Execute a raw database statement:
`ALTER TABLE payroll_runs MODIFY COLUMN payroll_frequency ENUM('weekly', 'biweekly', 'semi-monthly', 'monthly') NOT NULL DEFAULT 'monthly';`
2. **Backend Controller**
- File: `app/Http/Controllers/PayrollRunController.php`
- Modify the `$request->validate()` rules inside the `store` and `update` methods to natively accept `semi-monthly`.
- Update the expected payload in the bulk CSV import logic if applicable.
3. **Frontend React Component**
- File: `resources/js/Pages/hr/payroll-runs/index.tsx`
- Modify the `Create` and `Edit` frontend modals to formally include `{ label: 'Semi-Monthly', value: 'semi-monthly' }` inside the Dropdown form payload.
## Open Questions
- Do you want previous payroll runs that were wrongly filed as `biweekly` or `monthly` migrated historically to `semi-monthly` as part of this operation, or just apply this capability moving forward?
## Verification Plan
1. Ensure the migration runs safely without dropping existing column data.
2. Compile Vite.
3. Test creating a sample Payroll Run using the new `Semi-Monthly` dropdown and verify the DB accepts it!