.cursor/skills/nazim-org-hr-payroll/SKILL.md
--- name: nazim-org-hr-payroll description: Documents the Organization HR Payroll module in Nazim: compensation profiles, payroll periods, payroll runs, and the run lifecycle (create run, calculate, finalize, mark paid). Use when working on the payroll page, run calculation, finalization, compensation profiles, payroll periods, or org_hr_payroll feature. --- # Nazim Org HR Payroll ## Overview Payroll lives under **Org Admin** (`/org-admin/hr/payroll`). It is gated by the `org_hr_payroll` feat
npx skillsauth add AHMADJAN-New/nazim-web .cursor/skills/nazim-org-hr-payrollInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Payroll lives under Org Admin (/org-admin/hr/payroll). It is gated by the org_hr_payroll feature and uses three building blocks: compensation profiles (per-staff salary), payroll periods (date ranges), and payroll runs (one run per period, with a strict lifecycle). Running payroll means creating a run for a period, calculating pay from compensation and assignments, then finalizing and marking it paid.
Payroll runs follow a fixed state flow:
| Status | Meaning | Allowed actions | |------------|--------|------------------| | draft | Run created, not yet calculated | Calculate | | processing | Calculated; has run items (gross/deduction/net per staff) | Finalize | | finalized | Locked; payslips generated | Mark paid | | paid | Period closed | None (read-only) |
Rules:
hr_payroll.run): Only when status is draft or processing. Recomputes run items from active compensation profiles and assignments for the period date range; sets status to processing.hr_payroll.approve): Only when status is processing and run has items. Locks run, creates payslips for each run item; sets status to finalized.hr_payroll.approve): Only when status is finalized. Sets run and period to paid; no further changes.Backend rejects: recalculating finalized/paid runs; finalizing without items; marking paid when not finalized.
| Permission | Use |
|------------|-----|
| hr_payroll.read | View compensation, periods, runs, run detail |
| hr_payroll.create | Create compensation profiles, periods, runs |
| hr_payroll.run | Trigger calculate on a run |
| hr_payroll.approve | Finalize run, mark run paid |
UI shows Calculate only when hr_payroll.run and status is draft/processing; Finalize when hr_payroll.approve and status is processing; Mark paid when hr_payroll.approve and status is finalized.
Queries
useOrgHrCompensation(staffId?) → compensation profiles (optional filter by staff).useOrgHrPayrollPeriods() → list of periods.useOrgHrPayrollRuns({ payrollPeriodId?, status? }) → list of runs.useOrgHrPayrollRun(runId) → single run + run items (for detail view).Mutations
useCreateOrgHrCompensation, useUpdateOrgHrCompensation, useDeleteOrgHrCompensation.useCreateOrgHrPayrollPeriod.useCreateOrgHrPayrollRun (payload: payroll_period_id, run_name optional).useCalculateOrgHrPayrollRun(runId).useFinalizeOrgHrPayrollRun(runId).useMarkOrgHrPayrollRunPaid(runId).After calculate/finalize/mark paid, invalidate org-hr-payroll-runs, org-hr-payroll-run, and org-hr-analytics-overview.
API (orgHrApi)
Prefix /org-hr. All payroll endpoints use middleware feature:org_hr_payroll.
GET/POST /compensation/profiles, PUT/DELETE /compensation/profiles/{id}.GET /payroll/periods, POST /payroll/periods.GET /payroll/runs, POST /payroll/runs, GET /payroll/runs/{id}.POST /payroll/runs/{id}/calculate, POST /payroll/runs/{id}/finalize, POST /payroll/runs/{id}/mark-paid.orgHrCompensationCreateSchema / orgHrCompensationUpdateSchema in frontend/src/lib/validations/orgHr.ts. Base schema is an object; create schema adds a refine (effective_to >= effective_from). Update schema uses base .partial().extend({ staff_id: optional }) (do not call .partial() on the refined create schema).orgHrPayrollPeriodCreateSchema (name, period_start, period_end, pay_date optional; refine period_end >= period_start).orgHrPayrollRunCreateSchema (payroll_period_id, run_name optional).processing, period status processing.processing and at least one run item; in a transaction: set run status finalized, period finalized, create payslip per run item.finalized; set run and period status paid.Compensation and period create/update validate organization and (for compensation) no duplicate active profile per staff. Period create checks no overlapping period dates.
| Area | Path |
|------|------|
| Page | frontend/src/pages/organization/hr/OrganizationHrPayrollPage.tsx |
| Hooks | frontend/src/hooks/orgHr/useOrgHr.ts (compensation, periods, runs, calculate, finalize, mark paid) |
| API | frontend/src/lib/api/client.ts (orgHrApi compensation, payroll periods/runs) |
| Validation | frontend/src/lib/validations/orgHr.ts |
| Types | frontend/src/types/domain/orgHr.ts, frontend/src/types/api/orgHr.ts |
| Mapper | frontend/src/mappers/orgHrMapper.ts |
| Backend | backend/app/Http/Controllers/OrganizationHrController.php (compensationIndex, payrollPeriods, payrollRuns, createPayrollRun, calculatePayrollRun, finalizePayrollRun, markPayrollRunPaid) |
| Routes | backend/routes/api.php under org-hr prefix, feature:org_hr_payroll |
hr_payroll.read / hr_payroll.create / hr_payroll.run / hr_payroll.approve for visibility and actions..partial() (not the refined create schema).feature:org_hr_payroll; validate organization and run/period ownership.tools
Toast notifications for Nazim. Use when showing success/error/info messages. ALWAYS use showToast from @/lib/toast with translation keys; never toast from sonner directly. RTL positioning is automatic.
tools
Enforces status badge patterns for Nazim UI. Use when displaying status in tables, cards, or dialogs. Covers Badge variants, semantic colors, statusBadgeVariant, statusOptions with color.
development
Enforces mobile-first responsive patterns for Nazim UI. Use when building pages, tables, forms, charts, or buttons. Covers page container, FilterPanel, tabs, grids, tables, charts, cards, buttons.
development
PDF and Excel report generation for Nazim. Use when adding or changing reports. Backend uses ReportService and ReportConfig; frontend uses useServerReport. Covers branding, DateConversionService, RTL, acceptance criteria.