10 — HR & Payroll

Employees, timeclock, payroll, employee portal, taxes

CEO Summary

HR system with employees, timeclock (clock in/out), timesheets, payroll runs, and an Employee Portal for self-service (pay stubs, tax forms, direct deposit). Data in dev-hr-{slug} DB. Business value: Compliance, labor cost visibility, employee self-service. Key metrics: Payroll accuracy, time-off balance. If this breaks: Payroll cannot run; employees cannot clock in/out or access portal.

Overview

HR system. Data in dev-hr-{slug} DB. Two entry points: Admin (staff dashboard) and Employee Portal (employee self-service).

Timeclock

RoutePurpose
POST /api/hr/timeclock/clock-inClock in
POST /api/hr/timeclock/clock-outClock out
POST /api/hr/timeclock/break-startStart break
POST /api/hr/timeclock/break-endEnd break
POST /api/tenant-time/punchToggle clock in/out (staff)
GET /api/tenant-time/statusCurrent clock status
GET /api/tenant-time/rosterTeam roster with clock status (managers)
POST /api/tenant-time/clock-out-staff/:staffIdManager clock out staff
GET /api/tenant-time/timesheet/:staffIdTimesheet for staff

Data: Timesheets table — staff_id, clock_in_at, clock_out_at, status

Employee Portal

URL: /employee-portal or /employee-portal/:orgSlug (e.g. /employee-portal/mariospizza)

Route file: backend/routes/hr/employeePortal.routes.js

Auth: Employee number + credential (PIN). Session cookie: employee_session.

EndpointPurpose
POST /api/employee-portal/loginAuthenticate (identifier, credential)
POST /api/employee-portal/logoutLogout
GET /api/employee-portal/meCurrent employee info
PUT /api/employee-portal/meUpdate email, phone, address, emergency contact
GET /api/employee-portal/pay-stubsPay stubs (year, limit, offset)
GET /api/employee-portal/pay-stubs/:idSingle pay stub
GET /api/employee-portal/tax-formsW-2/1099 (year)
POST /api/employee-portal/change-work-passwordChange work password
POST /api/employee-portal/change-portal-pinChange portal PIN (4 digits)
GET /api/employee-portal/bank-accountsDirect deposit accounts
POST /api/employee-portal/bank-accountsAdd bank account
PUT /api/employee-portal/bank-accounts/:idUpdate bank account
DELETE /api/employee-portal/bank-accounts/:idDelete bank account

Services: employeePortal.service.js, directDeposit.service.js

Admin HR Routes

hr.routes, payroll, time, tenantTime, teamHours, staff, hr/security

HR sub-routes: hr/employees, hr/departments, hr/benefits, hr/timeOff, hr/reports, hr/payrollRunManager, hr/payrollRuns, hr/payrollCalculation, hr/taxRates, hr/businessTaxInfo

Key Tables

business_tax_info, employees, employee_w4, employee_compensation, pay_periods, payroll_runs, payroll_line_items, time_off_requests, pto_balances, departments, benefit_plans

Employee Routing

tenantEmployeeRouting.service — tenant_employees (master) → route to correct tenant HR DB.