Paid hours daily
Paid hours per day as Sona sends them to payroll, by location and pay type: the hours side of a labour cost report.
- Grain
- one row per local pay date x home org unit x pay type x entry type
- Built from
- 3Raw tables
- 3Staging
- 1Core
- 1Analytics
- Reads from Sona
- org_unitspay_linesusers
- Ships as
- Weld and dbt SQL, open source on GitHub
1-- core.sona.paid_hours_daily
2-- Paid hours per day as Sona sends them to payroll, by location and pay type: the
3-- hours side of a labour cost report.
4--
5-- Grain: one row per local pay date x home org unit x pay type x entry type.
6-- Depends on: staging.sona.pay_lines, staging.sona.users, staging.sona.org_units
7--
8-- Pay lines carry a user but no location, so each line is placed on the user's
9-- administrative (home) org unit and dated in that unit's time zone. Someone who
10-- covers a shift elsewhere still counts at home here; use shift_coverage_daily for
11-- hours by where the work happened.
12--
13-- Cost is not computed: Sona returns hourly and annual rates in the same field, so
14-- multiplying hours by rate is only right for part of the lines. Join your own rate
15-- table if you need cost.
16
17SELECT
18 DATE(p.starts_at, COALESCE(o.timezone, 'UTC')) AS pay_date,
19 u.home_org_unit_id AS org_unit_id,
20 ANY_VALUE(o.org_unit_name) AS org_unit_name,
21 p.pay_type,
22 p.entry_type,
23
24 COUNT(*) AS pay_lines,
25 COUNT(DISTINCT p.user_id) AS people_paid,
26 ROUND(SUM(p.duration_minutes) / 60.0, 2) AS paid_hours
27FROM {{staging.sona.pay_lines}} p
28LEFT JOIN {{staging.sona.users}} u
29 ON u.user_id = p.user_id
30LEFT JOIN {{staging.sona.org_units}} o
31 ON o.org_unit_id = u.home_org_unit_id
32GROUP BY pay_date, u.home_org_unit_id, p.pay_type, p.entry_typeThis model and the 4 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().
How it counts. And where it stops.
Pay lines carry a user but no location, so each line is placed on the user's administrative (home) org unit and dated in that unit's time zone. Someone who covers a shift elsewhere still counts at home here; use shift_coverage_daily for hours by where the work happened. Cost is not computed: Sona returns hourly and annual rates in the same field, so multiplying hours by rate is only right for part of the lines. Join your own rate table if you need cost.
Raw tables it reads
- raw.sona.org_units
- raw.sona.pay_lines
- raw.sona.users
More Sona models
Put Sona in front
of your agents.
Connect Sona, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.