🔗 Shift · Payroll · Attendance · Employee

How the four core pillars of HRSanad interlock — and why a change in one always ripples through the others.

👤 Employee Master 🕐 Shift Rostering 📍 Attendance Logs 💰 Payroll Engine

1. The Big Picture

Four pillars, one data flow

Think of HRSanad like a school system. Every child (employee) is enrolled in a class (shift), attendance is taken every day (attendance log), and at the end of the month the school issues a report card with grades (payslip). If a child changes class, misses lessons, or joins mid-term — all of it changes what the final report card shows.

👤
Employee
The who. Personal details, grade, salary structure, contract type, department.
🕐
Shift
The when. Expected start & end time, weekend pattern, work-hour quota per day.
📍
Attendance
The what happened. Actual clock-in/out, late minutes, early-out, absences, overtime.
💰
Payroll
The outcome. Monthly calculation using attendance deductions, OT pay, and salary components.
One-way dependency chain
Payroll depends on Attendance → Attendance depends on Shift → Shift depends on Employee. You cannot run payroll for an employee who has no shift, and you cannot evaluate attendance without knowing what shift was expected.

2. End-to-End Data Flow

From employee creation to payslip generation

👤 EMPLOYEE 🕐 SHIFT 📍 ATTENDANCE 💰 PAYROLL Create Employee Grade, Contract, Salary Assign Pay Components Basic, HRA, Transport… Define Shift Start/End time, Weekend Assign Shift Roster Employee ↔ Shift for period Clock In / Clock Out GPS, Biometric, Android Process Attendance Late, Early-out, OT, Absent Attendance Summary Days worked, OT hours, LOP Create Payroll Run Month, Company, Currency Calculate Payroll Pull attendance adjustments Generate Payslip PDF + WPS / JV Export Shift assigned Shift used as expected schedule Att. summary consumed Month-End: Payroll locks, attendance archives No attendance edits once payroll is Finalized

The dashed arrows show data dependencies: when payroll engine runs, it reaches back across all three pillars — Employee (for salary rates), Shift (for expected hours), and Attendance (for actuals) — to compute the final number.

3. Employee Master — The Root of Everything

Every calculation starts here

The Employee record is the anchor. It does not just store a name — it stores the financial blueprint for every other pillar.

🔗 What Employee feeds into Shift

  • An employee must exist before a shift roster can be assigned.
  • The employee's department determines which shifts are available to assign.
  • Contract type (full_time vs part_time) affects eligible shift patterns.
  • Probation employees can have separate shift rules.

🔗 What Employee feeds into Attendance

  • Attendance log is always keyed by employee ID — no employee, no attendance record.
  • Employee's joining date defines when attendance tracking begins.
  • Separation date defines when it ends — no attendance recorded after separation.
  • GPS work location radius is set per-employee (or inherited from department).

🔗 What Employee feeds into Payroll

  • Basic salary is the base for most pay component formulas.
  • Grade determines which pay components apply (via 3-layer inheritance).
  • Bank IBAN is copied into the WPS/payment file.
  • Joining date determines pro-ration of first-month salary.
  • Separation date determines last-month salary and gratuity trigger.

⚠️ What changes cascade

  • Grade change → triggers salary revision workflow → new pay components from next payroll run.
  • Status → Separated → attendance logs frozen → final payroll run generated automatically.
  • Department change → shift roster may need re-assignment for the employee.
  • Basic salary change → any formula-based component (HRA = 25% of basic) recalculates at next payroll run.
Database key
Every record in tna.shift_rosters, tna.attendance_logs, and finance.payroll_employee_details carries a employee_id foreign key pointing to personnel.employees.id. Deleting or separating an employee does not delete those records — they are retained for 7 years (UAE PDPL retention rule).

4. Shift — The Expected Schedule

What the system thinks should happen

A Shift is a template that says: "This role works from 09:00 to 18:00, Sunday to Thursday, with a 1-hour lunch break, totalling 8 hours per day."

What a Shift record contains

FieldExampleWhy it matters
shift_nameMorning ShiftDisplay label
start_time09:00Defines "on time" threshold
end_time18:00Defines "early-out" threshold
break_minutes60Subtracted from total hours worked
grace_minutes15Late arrival allowed without deduction
ot_start_after30 minOT counted only after this buffer beyond end_time
weekend_days[5, 6] = Fri, SatWeekend days → no attendance expected
work_hours_per_day8Used to calculate daily rate for LOP deduction

Shift Roster vs Shift Master

Think of it like this:

🕐 Shift Master Morning, Evening, Night Night Shift, Rotational… tna.shifts assigned via roster 📋 Shift Roster Employee A → Morning 01 Apr – 30 Jun 2026 tna.shift_rosters drives ATT

What happens when an employee has no shift?

Warning
If an employee has no active shift roster for a day, the attendance processor treats that day as Absent (LOP). Always assign a shift on or before the joining date to avoid incorrect deductions.

Overtime and the Shift

The shift's end_time and ot_start_after buffer define when overtime begins:

5. Attendance — What Actually Happened

Raw clock events → processed daily summaries → monthly aggregates

Attendance has two layers: raw events (clock in/out timestamps) and processed records (the interpretation of those events against the expected shift).

Layer 1 — Raw Attendance Logs (tna.attendance_logs)

ColumnWhat it stores
employee_idLinks to personnel.employees
clock_in_timeExact timestamp when employee clocked in
clock_out_timeExact timestamp when employee clocked out (null until they do)
clock_in_lat / lngGPS coordinates at clock-in
clock_out_lat / lngGPS coordinates at clock-out
clock_in_photo_urlFace photo taken at clock-in (uploaded to Azure Blob)
sourceandroid / web / biometric / import

Layer 2 — Processed Attendance (tna.processed_attendance)

The attendance processor runs daily (or can be triggered manually) and compares each raw log against the shift roster to produce:

Output fieldHow it's calculated
statuspresent / absent / late / half_day / holiday / weekend
late_minutesclock_in_time minus shift start_time (minus grace minutes)
early_out_minutesshift end_time minus clock_out_time
ot_minutesclock_out_time minus (shift end_time + ot_start_after buffer)
total_hours(clock_out − clock_in − break_minutes) / 60
lop_days0 or 1 depending on status and policy

Daily Attendance Decision Tree

Process Day Weekend or Public Holiday? Mark: Holiday/Weekend YES Has active shift roster? NO Mark: Absent (LOP) NO Clock-in recorded? YES Mark: Absent (LOP) NO Present ✓ Calc late, early-out, OT YES

Monthly Attendance Aggregates

At the end of each month (before payroll runs), the system totals the daily records into a monthly summary per employee:

AggregateUsed by Payroll for…
Total days presentConfirming full-month entitlement
Total LOP (Loss of Pay) daysSalary deduction: basic ÷ 30 × LOP days
Total late minutesLate deduction if policy enabled: basic ÷ (30 × 8 × 60) × late_mins
Total OT hoursOT earnings: OT hours × hourly rate × 1.5 or 2

6. Payroll — The Outcome

Where all four pillars converge into a single number

Payroll is the consumer of the other three pillars. When the payroll engine runs for a month, it reads from all of them simultaneously.

What payroll reads from each pillar

💰 Payroll Engine calculate() 👤 Employee Basic salary Pay components (HRA, Trans…) IBAN, joining date 🕐 Shift work_hours_per_day weekend_days OT thresholds 📍 Attendance LOP days OT hours Late / Early-out minutes 🌴 Leave Approved leave days (if leave is paid, no LOP deduction)

The Payroll Calculation Formula (simplified)

How the engine computes net pay

Gross Earnings = Basic + All earning components (HRA, Transport, OT pay…)
Deductions = LOP deduction + Late deduction + Loan instalment + Employee statutory deductions
Net Pay = Gross Earnings − Deductions

Where each attendance number goes in payroll

Attendance factPayroll impactFormula
0 LOP daysFull month salary paid
3 LOP daysDeduction added as line itembasic ÷ 30 × 3
2 hours OTOT earnings added(basic ÷ 30 ÷ 8) × 2 × 1.5
45 late minutes (deduction policy ON)Minute-level deduction(basic ÷ 30 ÷ 8 ÷ 60) × 45
5 approved paid leave daysNo LOP; leave days treated as presentAttendance overridden by leave record
Joined on 15th of monthHalf-month pro-rationeach component × (days remaining ÷ 30)

7. Leave — The Bridge Between Attendance and Payroll

Approved leave overrides absence so salary is protected

Leave is not stored inside the attendance table. It lives in its own module (leave.leave_requests). But when payroll runs, it joins against approved leaves so that a day marked "absent" in attendance becomes "paid leave" in payroll — and no LOP deduction is applied.

📍 Attendance 2026-05-12: ABSENT (no clock-in recorded) 🌴 Leave Module 2026-05-12: ANNUAL Status: APPROVED ✓ Payroll joins 💰 Payroll Result 2026-05-12: PAID LEAVE No LOP deduction ✓

Conversely, if an employee takes unpaid leave (or unpaid absence), the attendance record stays as ABSENT and payroll applies the LOP deduction normally.

8. The Ripple Effect — Changing One Pillar

Every change has a downstream consequence

You change… Immediate effect Downstream effect
Employee Basic salary New salary stored in employee record All formula-based components (HRA = 25% basic) recalculate at next payroll run. Current month unaffected if already calculated.
Employee Grade Salary revision workflow triggered New grade's default pay components inherited. Applies from next payroll run after approval.
Employee Status → Separated Separation date recorded Attendance logging stops. Final payroll run generated with pro-rated last month. Gratuity calculation triggered.
Shift End time moved from 18:00 to 17:00 Shift master updated All future attendance processed with new end time. OT now accumulates 1 hour earlier. Historical records unaffected.
Shift Weekend changed (Fri+Sat → Sat+Sun) Shift master updated Friday attendance now expected. Employees working previously will show as present; those who don't will show absent (LOP) from the roster change date onward.
Attendance Clock-in corrected (HR edit) Raw log updated; processed record recalculated If payroll already calculated for this month, payroll must be recalculated to pick up the correction. You cannot edit attendance after payroll is Finalized/Locked.
Attendance Manual absence → approved leave entered retroactively Leave record created with approved status Payroll recalculation reverses the LOP deduction and replaces it with paid leave credit.
Payroll Run finalized Payroll locked for the month Attendance records for that month become read-only. Any corrections require HR admin unlock + new payroll revision run.
Lock order matters
HRSanad enforces a strict lock hierarchy: Attendance must be reviewed and signed off before payroll can be finalized. Once payroll is finalized, attendance for that period becomes read-only to prevent retroactive manipulation.

9. Database Relationships (Entity Model)

How the tables connect

personnel.employees 🔑 id (UUID PK) tenant_id employee_code full_name_en / ar grade_id → grades basic_salary joining_date, status separation_date tna.shifts 🔑 id (UUID PK) tenant_id start_time, end_time break_min, grace_min weekend_days[] tna.shift_rosters 🔑 id (UUID PK) 🔗 employee_id → employees 🔗 shift_id → shifts effective_from, to tenant_id tna.attendance_logs 🔗 employee_id · clock_in · GPS · photo finance.payroll_runs 🔑 id (UUID PK) tenant_id, period_year period_month, status run_type, currency finalized_at finance.payroll_emp_details 🔑 id 🔗 payroll_run_id 🔗 employee_id gross, deductions, net lop_days, ot_hours late_mins, ot_amount status, payslip_url

10. Month-End: How Everything Closes Together

The ordered sequence at the end of each payroll month

Review & close attendance Attendance

HR or TNA manager reviews the month's processed attendance. Corrects any missed clock-outs, manual entries for field staff, and retroactive leave adjustments. Signs off to freeze attendance.

Confirm approved leaves are recorded Leave

Any pending leave requests covering the month should be approved or rejected before payroll runs. Approved leaves protect the employee from LOP deductions on those days.

Create & calculate payroll run Payroll

HR creates the payroll run (month + company). System pulls employee pay components, attendance summary (LOP, OT, late minutes), and calculates gross, deductions, net for every active employee.

Review payroll summary Payroll

Payroll admin reviews the calculated run — checks outliers (unusually high OT, large LOP deductions). Can recalculate after corrections.

Approve & finalize Payroll

Workflow approval (if configured). Once approved → Finalized status. Attendance for this period locks. Payslips generated as PDFs. WPS/SIF file (UAE) or JV export (India/US) generated.

Distribute payslips ESS

Employees can log into the ESS portal to view and download their payslip. Push notification sent via Android app. Email notification sent if SMTP configured.

11. Real-World Example — Ahmed's May Payslip

Tracing one employee through all four pillars

Setup

What happened in May

DateEventAttendance recordPay impact
1–9 MayNormal workPresent, on time
11 MayArrived at 09:52 (37 min late, grace=15, net 22 min)Late: 22 minMinute deduction if policy on
12–13 MayAnnual leave approvedPresent (paid leave override)No LOP ✓
14 MayNo clock-in, no leaveAbsent (LOP)LOP: AED 5000 ÷ 30 = AED 167
20 MayStayed until 20:15 (2h 45m OT after 30min buffer)OT: 135 min = 2.25hOT: (5000÷30÷8) × 2.25 × 1.5 = AED 70
Rest of MayNormal workPresent, on time

Ahmed's May Payslip (simplified)

Earnings

Basic SalaryAED 5,000.00
Housing Allowance (25%)AED 1,250.00
Transport AllowanceAED 500.00
Overtime (2.25 hrs)AED 70.31
Gross EarningsAED 6,820.31

Deductions

LOP (1 day)AED 166.67
Late deduction (22 min)AED 3.83
Total DeductionsAED 170.50
Net Pay
AED 6,649.81
Key takeaway
Every single number on Ahmed's payslip — from the HRA to the OT amount to the LOP deduction — was computed by reading his Employee record (salary, grade), his Shift (hours, grace, OT threshold), and his Attendance (what actually happened each day). Change any one of those three, and the payslip changes.

12. Quick Reference — Key Tables

Where to look in the database for each concept

ConceptSchema.TableKey columns
Employee masterpersonnel.employeesid, grade_id, basic_salary, joining_date, status
Pay components per employeepersonnel.employee_pay_componentsemployee_id, component_id, amount, formula
Shift definitiontna.shiftsstart_time, end_time, grace_minutes, ot_start_after, weekend_days
Shift assignmenttna.shift_rostersemployee_id, shift_id, effective_from, effective_to
Raw attendancetna.attendance_logsemployee_id, clock_in_time, clock_out_time, source, GPS columns, photo URLs
Processed attendancetna.processed_attendanceemployee_id, date, status, late_min, ot_min, lop_days
Payroll run headerfinance.payroll_runsperiod_year, period_month, status, run_type
Payroll per employeefinance.payroll_employee_detailspayroll_run_id, employee_id, gross, deductions, net, lop_days, ot_hours
Leave requestsleave.leave_requestsemployee_id, leave_type_id, from_date, to_date, status
Gratuity slabsfinance.gratuity_slabscountry_code, years_from, years_to, days_per_year, salary_divisor