When two rates tie, the higher one wins
The rule
Rates are set up by what work they apply to: a job’s rate, a location’s,
a shift’s. Of the rates matching a piece of work, the one naming the most of
its context wins. When two name as much (the job’s and the location’s), the
engine does not guess: it says so (rate_ambiguous) and pays nothing until
someone settles it. Many employers have a rule for this instead: the higher
rate wins, or the job’s rate always wins over the location’s.
Who uses it
Employers with rates by more than one thing: premium locations and skilled jobs, union scales and site differentials, staffing firms billing by site and by role. “Pay the higher of the applicable rates” is common in collective agreements and in public works; a contract may instead rank them.
How the recipe does it
Configuration only: a package (package.toml) of one layer. The standard
rate_tie step, in the rate stage, picks the highest of tied rates, and
the standard piece_rate step pays boxes packed by the rate chosen.
[[layer]]id = "rates"[[layer.step]]id = "ties"uses = "standard/rate_tie"params = { pick = "highest" } # or prefer = ["job", "location"][[layer.step]]id = "pieces"uses = "standard/piece_rate"params = { measure = "boxes", rate = "piece", pay = "pay", category = "piece_pay" }A contract that prefers the job’s rate is a layer of its own that
replaces the ties step with prefer = ["job"].
The rate stage runs before the allocate steps, on each tie the period’s
lines and counts would meet: for each workday, each of its contexts and each
kind of rate whose rates tie. Its step sees ctx.kind, ctx.context,
ctx.workday and ctx.rates (each id, amount, currency, matches)
and chooses one with ctx:choose(id, why). Then ctx:rate, in any allocate
step (here the standard piece rate), gives the chosen rate for that tie. A
tie no step chose for stays an exception.
What your setup needs
Set up before you adopt the recipe; the recipe’s steps read them by name, and adopting it is refused, with a list of what is missing, until they exist.
- A measure called
pay: the amount the recipe adds up (money in a currency, or a count).
The scenarios show each as it was set up for them.
Parameters
| Parameter | Meaning |
|---|---|
prefer | Dimensions in order: the rate naming the first one any rate names wins. |
pick | "highest" or "lowest" amount, when prefer settles nothing (of equal amounts, the first). Without it, an unsettled tie stays an exception. |
What the scenarios show
the-higher-piece-rate-wins: boxes packed at plant 7, where the job’s 30 cents and the plant’s 40 tie, pay 40; at plant 9 only the job’s rate matches, and pays 30.the-job-rate-is-preferred: withprefer = ["job"]the job’s rate wins even though lower; a tie between the plant’s and the night shift’s, which names no job, staysrate_ambiguous.
Legal note
This is a common way companies settle overlapping rates; check the rules where you operate and any agreement that applies. Where a law sets a minimum or prevailing rate, the rate paid must be at least that.
Get the recipe
The recipe’s package and its scenarios are in the example packages repository: attendance/highest_rate_wins. Test it, or your own copy of it, with hourctl attend test, and publish it with hourctl attend pkg publish.
The policy package
The package’s layers, with the standard steps each one runs and their settings:
name = "highest_rate_wins"version = "1.0.0"description = "Work that two pay rates match as closely (one by job, one by location) is paid at the higher, or at the one a contract prefers, instead of waiting for someone to settle it."
# What the tenant must have set up for the recipe: the steps read these by name.[needs]measures = ["pay"]
# Where rates of the same kind tie for a piece of work, the highest is# paid. Boxes packed are paid by the piece rate so chosen.[[layer]]id = "rates"[[layer.step]]id = "ties"uses = "standard/rate_tie"params = { pick = "highest" }[[layer.step]]id = "pieces"uses = "standard/piece_rate"params = { measure = "boxes", rate = "piece", pay = "pay", category = "piece_pay" }Scenarios
Each scenario gives a person’s punches and setup and the timecard they must produce, worked out with this package adopted (the format).
Boxes packed on the forklift job at plant 7: the job's piece rate (30 cents) and the plant's (40 cents) each name one value of the work, a tie. The policy pays the higher: 10 boxes at 40. Work matching only the job's rate is paid at it, with no tie to settle
description = "Boxes packed on the forklift job at plant 7: the job's piece rate (30 cents) and the plant's (40 cents) each name one value of the work, a tie. The policy pays the higher: 10 boxes at 40. Work matching only the job's rate is paid at it, with no tie to settle"
[policy]zone = "America/Chicago"
[[measure]]id = "boxes"kind = "count"
[[measure]]id = "pay"kind = "money"currency = "USD"
[[rate]]kind = "piece"matches = { job = "pack" }amount = 30currency = "USD"
[[rate]]kind = "piece"matches = { location = "plant-7" }amount = 40currency = "USD"
[[labor]]workday = "2026-10-05"measure = "boxes"quantity = 10category = "pieces"values = { job = "pack", location = "plant-7" }
[[labor]]workday = "2026-10-06"measure = "boxes"quantity = 10category = "pieces"values = { job = "pack", location = "plant-9" }
[expect]week = "2026-10-05"quantities = [ "2026-10-05 boxes 10 pieces job=pack location=plant-7", "2026-10-05 pay 4.00 USD piece_pay job=pack location=plant-7", "2026-10-06 boxes 10 pieces job=pack location=plant-9", "2026-10-06 pay 3.00 USD piece_pay job=pack location=plant-9",]A contract that says the job's rate wins over the plant's, whichever is higher: prefer = [job] pays the 30-cent job rate for work at plant 7. A tie no rate names a preferred dimension of, with no pick, stays a rate_ambiguous exception
description = "A contract that says the job's rate wins over the plant's, whichever is higher: prefer = [job] pays the 30-cent job rate for work at plant 7. A tie no rate names a preferred dimension of, with no pick, stays a rate_ambiguous exception"
[policy]zone = "America/Chicago"
# The contract's own layer: of tied rates, the job's wins.[[layer]]id = "job-rate-contract"[[layer.step]]id = "ties"change = "replace"uses = "standard/rate_tie"params = { prefer = ["job"] }
[[measure]]id = "boxes"kind = "count"
[[measure]]id = "pay"kind = "money"currency = "USD"
[[rate]]kind = "piece"matches = { job = "pack" }amount = 30currency = "USD"
[[rate]]kind = "piece"matches = { location = "plant-7" }amount = 40currency = "USD"
[[rate]]kind = "piece"matches = { shift = "night" }amount = 45currency = "USD"
[[labor]]workday = "2026-10-05"measure = "boxes"quantity = 10category = "pieces"values = { job = "pack", location = "plant-7" }
[[labor]]workday = "2026-10-06"measure = "boxes"quantity = 10category = "pieces"values = { location = "plant-7", shift = "night" }
[expect]week = "2026-10-05"quantities = [ "2026-10-05 boxes 10 pieces job=pack location=plant-7", "2026-10-05 pay 3.00 USD piece_pay job=pack location=plant-7", "2026-10-06 boxes 10 pieces location=plant-7 shift=night",]exceptions = [{ kind = "rate_ambiguous", at = "2026-10-06 00:00" }]