Files
eatme/docs/data-model/pay-rates.md
Michal Pemcak 94933cac5c Update OKF docs bundle, README, and CLAUDE.md for today's features
Documents the shift planning and closure/payroll modules (new tables,
routes, stores), the dark redesign, and the docker-compose-broken-host
workaround. Adds CLAUDE.md pointing agents at docs/. Translates README to
English and keeps host-specific infrastructure details out of the repo.
2026-08-16 18:41:11 +02:00

1.8 KiB

type, title, description, resource, tags, timestamp
type title description resource tags timestamp
SQLite Table pay_rates Hourly rate history per employee, keyed by the date it takes effect. backend/src/db/index.ts
data-model
sqlite
payroll
2026-08-16T00:00:00Z

pay_rates

Versioned hourly rate per employee. There's no valid_to column — the active rate for a given date is simply the row with the largest valid_from <= that date (getRateAt in backend/src/services/payRates.ts). A new rate implicitly ends the previous one.

Schema

Column Type Description
id INTEGER PK autoincrement
employee_id INTEGER references employees
hourly_rate REAL Kč/hour
valid_from TEXT YYYY-MM-DD, takes effect from this date inclusive
created_at TEXT ISO 8601 UTC

UNIQUE (employee_id, valid_from) — setting a rate again for the same date overwrites it (ON CONFLICT ... DO UPDATE) rather than erroring.

Behavior

  • First rate ever set for an employee defaults valid_from to the employee's own created_at date when the admin doesn't specify one — so hours already worked before the admin got around to entering a rate still get paid correctly, rather than pricing at 0. This was a real bug found live: an admin set a rate today, and it didn't apply to shifts worked earlier that same month.
  • Every later rate change (a raise) defaults to today instead — not retroactive. This asymmetry lives in defaultValidFrom in backend/src/services/payRates.ts and is covered by a test in backend/src/services/payroll.test.ts.

Related