Time and Attendance

Time data feeds three different consumers with three different needs: payroll (pay), costing (charge), and compliance (prove). They rarely want the same number, which is why this is harder than it looks.

The three views of time

View Question Consumer
Attendance Was the person at work? Compliance, payroll
Worked time How many payable hours, at which rates? Payroll
Activity time What did they work on? Costing, projects, production orders

A worker clocks in at 07:58 and out at 17:04 (attendance = 9h06m), is paid 8h regular + 1h overtime (worked time = 9h), and books 4h to project A, 3.5h to project B, and 1.5h to indirect (activity = 9h). All three are correct; all three are different.

Work schedules

work_schedule_rule(
  id, name,
  period_work_schedule,      -- the repeating pattern
  daily_schedules[],         -- per day: start, end, breaks, planned hours
  rotation,                  -- for shift patterns
  holiday_calendar_id,
  valid_from, valid_to
)

Patterns you must support:

  • Fixed — Sun–Thu 09:00–18:00 (Bangladesh/Gulf) or Mon–Fri (most of the West)
  • Shift rotation — 3-shift continental, 4-on-4-off, DuPont
  • Flexitime — core hours plus flexible bands, with a running balance
  • Annualised hours — a yearly total, distributed unevenly
  • Part-time — with a defined pattern, not just an FTE fraction
  • Zero hours / on-call — paid only for hours worked, with call-out minimums
  • Compressed — 4×10 hours

The schedule provides the planned time against which actual is compared, and it drives absence valuation (how many hours does “one day of leave” consume?).

Time capture methods

Method Notes
Clock terminal (badge/biometric) Most accurate; biometric data is special-category under GDPR and needs explicit justification
Mobile app with geofence Field workers; privacy-sensitive
Web/self-service timesheet Office and professional services
Machine/production confirmation Time derived from shop-floor confirmations
Negative time recording Assume the schedule; record only exceptions. Much less data entry
Positive time recording Record everything actually worked

Negative recording is the default for salaried office staff — you only enter absences and overtime. Positive recording is used where hours drive pay or billing.

Time evaluation

The engine that turns raw clockings into payable and chargeable time.

Raw clockings:  07:58 in, 12:03 out, 12:48 in, 17:04 out
      ▼
Pair and validate:  detect missing clockings, overlaps, impossible sequences
      ▼
Apply rounding:     07:58 → 08:00 (round to schedule start, within grace)
      ▼
Deduct breaks:      45 min unpaid break (actual or scheduled, per policy)
      ▼
Compare to schedule: planned 8h, worked 8h21m
      ▼
Classify:
   Regular hours          8.00
   Overtime (>8/day)      0.35 @ 1.5×
   Night premium          0.00
   Holiday premium        0.00
      ▼
Generate wage types → payroll
Generate cost postings → cost centre / order / project
Update balances → flexitime, overtime bank, leave accrual

Rounding rules

Configuration, and a legal minefield:

Clock-in  rounded UP to the nearest 15 min  (employee arriving 08:07 starts at 08:15)
Clock-out rounded DOWN to the nearest 15 min

This systematically favours the employer and is illegal in several jurisdictions. US FLSA permits rounding only if it’s neutral over time. Get the rounding policy legally reviewed — an unfair rounding rule applied to 3,000 employees over 3 years is a class action.

Grace periods and tolerances

Late tolerance:   5 minutes (no deduction)
Early tolerance:  5 minutes
Beyond tolerance: full increment deducted or flagged for approval

Overtime

Rules vary enormously by jurisdiction and by collective agreement:

Rule type Example
Daily threshold Over 8h/day at 1.5×
Weekly threshold Over 40h/week at 1.5× (US FLSA)
Double time Over 12h/day at 2× (California)
7th consecutive day Premium regardless of hours
Night work 22:00–06:00 premium
Weekend/holiday Multiplier or a day in lieu
Rest period violation Penalty pay if <11h between shifts (EU Working Time Directive)
Overtime approval Must be pre-approved to be paid
Time off in lieu (TOIL) Banked as time instead of paid

Never hardcode overtime rules. They differ by country, state, industry, union agreement, and employee grade, and they change with legislation. This must be a rules engine with dated, scoped rule sets.

Absence management

absence_type(
  code, name, category,       -- ANNUAL | SICK | PARENTAL | UNPAID | TRAINING | PUBLIC_HOLIDAY
  paid_flag, payment_pct,
  requires_approval, requires_certificate_after_days,
  counts_toward_service, accrues_leave_during,
  quota_deduction_unit,       -- DAYS | HOURS
  max_consecutive, notice_required_days
)
absence_quota(
  person_id, absence_type, quota_year,
  entitlement, carried_forward, accrued, taken, planned, remaining,
  expiry_date
)

Accrual models

  • Front-loaded — the full annual entitlement on 1 January
  • Monthly accrual — 1/12 each month; a leaver’s balance is pro-rated
  • Hours-worked accrual — common in the US: 1 hour per 30 worked
  • Service-based tiers — entitlement increases with tenure
  • Carry-forward with expiry — use it by 31 March or lose it

The accrual job runs monthly and must be idempotent — running it twice must not double the entitlement. This is a real bug that reaches production surprisingly often.

Statutory absences

Country-specific and legally mandatory: sick pay (SSP in the UK), maternity/paternity/parental leave, jury duty, bereavement, military service, public holidays (which vary by region within a country). This is deep localisation — see Localization.

Compliance: working time

Regulation Requirement
EU Working Time Directive Max 48h/week average, 11h daily rest, 24h weekly rest, 4 weeks paid leave
US FLSA Overtime for non-exempt employees; accurate records required
Bangladesh Labour Act Max hours, overtime rates, weekly holiday, maternity provisions
CJEU 2019 (Deutsche Bank ruling) EU employers must have an objective, reliable, accessible system to record all daily working time

That last one is significant: it made time recording mandatory across the EU for all employees, including salaried office staff who previously recorded nothing.

Compliance monitoring must be proactive: alert before an employee breaches maximum hours or minimum rest, not after. A report showing last month’s violations is evidence against you, not a control.

Time to cost

timesheet_entry(
  person_id, date, hours,
  activity_type,        -- the cost activity (labour, machine supervision)
  cost_object_type,     -- COST_CENTER | PROJECT | WBS | PRODUCTION_ORDER | SERVICE_ORDER
  cost_object_id,
  billable_flag, billing_rate, cost_rate,
  status,               -- DRAFT | SUBMITTED | APPROVED | POSTED
  approved_by, approved_at, journal_document_id
)

Posting:

  Project / order (WIP)    Dr  hours × cost rate
    Cost centre                Cr  (relieving the department that owns the person)

Note this is a secondary cost element posting — an internal allocation, not a new external cost. The salary already hit the cost centre via payroll; this moves it to where the work was done. See Cost and Management Accounting.

Cost rate vs billing rate: cost rate is what the person costs you (fully loaded); billing rate is what the client pays. The difference is your margin, and both live on the timesheet line.

Reconciliation

The check that catches most errors:

Attendance hours (from clockings)      168.5
Timesheet hours (booked to objects)    164.0
Unaccounted                              4.5   ← must be explained

Unaccounted time is either indirect work that should be booked to a cost centre, or missing timesheet entries. A weekly “unbooked time” report to managers keeps the data clean. Without it, project costs are systematically understated.

Developer notes

  1. Three views of time, three consumers. Don’t try to serve all three with one number.
  2. Time evaluation is a rules engine, scoped by country, agreement, and employee group, and effective-dated.
  3. Retroactive changes trigger recalculation — of time evaluation, of payroll, and of cost postings.
  4. Rounding rules need legal review.
  5. Accrual jobs must be idempotent.
  6. Biometric time capture is special-category personal data. Get a lawful basis and, in some countries, works-council approval before building it.
  7. Alert on compliance breaches proactively, before they happen.
  8. Timesheet approval is a control — self-approval must be impossible.

Next