Rate card compliance rule

The pay and bill engine resolves the rate card that applies to a shift by walking a hierarchy that puts the candidate first: Contact, Job, Site, Account, ParentAccount, CostCenter. A candidate who holds a personal rate card therefore overrides whatever job, site or account card the shift was priced against, and the shift quietly costs more than it was sold for.

Reads legacy rate card items. With the rate sheet engine (see the pay and bill engine), cards are priced through rate sheets, lines and modifiers, and the card's base rates and Active flag are gone (cards use Status__c). This rule still reads the deprecated Rate_Card_Item__c rows: it treats a card as effective when its Status is blank or Active, and a card's Base Pay Rate as blank, so cards configured only through the Rate Card Studio price nothing here and the comparison is skipped. The sample loaders load b3s__Status__c instead of the removed b3s__Active__c and b3s__Base_Pay_Rate__c.

Nothing surfaced that at assignment time. The Rate Card compliance rule closes the gap: when the candidate being matched holds a rate card that charges more than the shift's own card, the rule adds a small negative score so the expensive candidate sinks in the matching ranking. It never blocks the assignment, and it never eliminates the candidate from search results.

What the rule does

  1. Finds the candidate's rate card for this shift: an effective card that names the worker, whose context matches.
  2. If there is none, the rule returns nothing. The shift's own card applies unchanged, so there is nothing to compare.
  3. Finds the shift's rate card: an effective card that names no worker, whose context matches.
  4. Prices the shift through each card's own rate card items, then compares the two totals.

Which card applies

A rate card can name a Job, a Site and an Account, alone or together, and can name a Contact as well.

Every context a card names has to match the shift. A card scoped to a different job or site is discarded outright, even if its account is right. A card that names nothing is a global fallback.

Where several cards qualify, the most specific wins: Job, then Site, then Account, then the global fallback. Within one level of specificity the usual tie-break applies, latest Valid From first, then most recently created.

This runs twice, over two disjoint sets of cards:

Side Cards considered Global card allowed
Candidate cards whose Contact is the worker being matched yes, it is the worker's fallback rate
Shift cards with no Contact no, a shift card has to name a job, site or account

So a worker on a general agreement of 24 an hour who also holds a 19 an hour card for one specific site is compared at 19 when scheduled at that site, and at 24 everywhere else. A worker whose only card is scoped to a different account is treated as having no card at all, and the rule stays silent.

A card is effective when it is active, its Valid From is on or before the shift date, and its Valid To is blank or on or after the shift date.

How the shift is priced

The rule prices the shift's own start and end against each card's items. Items are sorted by Priority ascending, blank Priority last, and each item claims the time it is entitled to out of what is still uncovered. Time already claimed by a higher priority item is never claimed twice.

Behavior What the item claims
Daily Flat one flat charge for the shift. Claims no time, so other items still price the hours
Hourly Standard the overlap between the shift and the item's time band
Hourly Start-Anchored the whole shift, when the shift starts inside the band
Hourly End-Anchored the whole shift, when the shift ends inside the band

Time bands. Band Start and Band End are projected onto every calendar day the shift touches, plus the day before so a band that opened the previous evening is caught. A Band Start later than Band End wraps midnight, so 22:00 to 06:00 covers the night. A blank Band End runs to the next midnight. Both blank makes the item an all day catch all.

Days of week. A blank Days Of Week matches every day. Otherwise each claimed piece is tested against the weekday of its own start, in the shift site's timezone, so a Saturday only premium does not leak onto a Friday night shift that runs past midnight.

Rates. An item charges its explicit Pay Rate, or the card's Base Pay Rate multiplied by the item's Multiplier when no explicit rate is set, or the bare Base Pay Rate when neither is set.

Time nothing claims is priced at the card's Base Pay Rate, so both cards are compared over the same hours and a card whose bands miss the shift does not look cheap. A card with no base rate and time left over cannot be priced, and the comparison is skipped.

Overtime is excluded. Items with a rate type of Overtime or Double Overtime are skipped. The comparison is a straight time one.

Timezones

event.start and event.end reach the rule already shifted into the shift site's timezone, so every band and weekday comparison is against the site's wall clock rather than the scheduler user's.

Scoring

The candidate's total is compared against the shift's total for the same hours.

Candidate cost above shift cost Points
Up to 10 percent -5
Over 10 and up to 25 percent -10
Over 25 percent -20

The compliance line reads:

💰 Senior Nurse Agreement costs GBP 260.00 vs shift GBP 160.00 over 8h (+63%)

When the candidate costs the same or less, the rule emits a single zero point line so the panel shows the check ran without affecting the candidate's score:

✅ Senior Nurse Agreement costs GBP 152.00 vs shift GBP 160.00 over 8h

Because the score is negative, an assignment made anyway persists as an Event Alert with severity High.

Configuration

The rule is the Scheduling Compliance Rule record WFM_Scheduler_Rate_Card (Type Scheduling). Every rule of that type loads automatically, so deploying the record enables it and deleting it disables it. There is no per definition allowlist.

It needs two loaders, both listed in matchingLoaders on the shift schedulable of every scheduling context provider:

"matchingLoaders":[
    "contacts",
    "certificates",
    "certRequirements",
    "suitability",
    "sites",
    "workerContracts",
    "rateCards",
    "rateCardItems"
]

rateCards

Loads both sides of the comparison in one loader, grouped by contact. Candidate level cards and shift level cards arrive in the same record set, and the rule tells them apart by which lookup is populated. The query is scoped to the scheduler's context, so each context provider carries its own loader definition.

{
    "name": "rateCards",
    "objectName": "b3s__Rate_Card__c",
    "filterRecordsBy": [
        "b3s__Contact__c IN (SELECT b3s__Contact__c FROM b3s__Working_Pattern__c WHERE Id != null AND (b3s__Job__r.b3s__Account__c =:contextId OR b3s__Site__r.b3s__Account__c =:contextId))",
        "b3s__Account__c =:contextId OR b3s__Work_Job__r.b3s__Account__c =:contextId OR b3s__Work_Site__r.b3s__Account__c =:contextId"
    ],
    "groupRecordsBy": "b3s__Contact__c",
    "fieldToLoad": ["Name", "b3s__Contact__c", "b3s__Account__c", "b3s__Work_Job__c", "b3s__Work_Site__c", "b3s__Currency__c", "b3s__Valid_From__c", "b3s__Valid_To__c", "b3s__Status__c", "CreatedDate"]
}

The first clause pulls the candidate cards, the second the shift cards. Loader clauses run as separate queries and are merged and deduplicated by Id, so the two sets combine into one record list.

In Version 11, these loaders are entries in each provider's b3s__Loaders__c array. There are no separate loader records in the release examples:

Provider Object Name Candidate cards come from Shift cards come from
WFM_Account Account contacts with a working pattern at the account cards on the account, or on any job or site belonging to it
WFM_Contact Contact the contact jobs and sites on the contact's working patterns, plus accounts the contact is assigned to
WFM_Job b3s__Job__c contacts with a working pattern on the job the job, plus the job's account
WFM_Group b3s__Group__c contacts assigned to the group accounts assigned to the group

rateCardItems

Rate card items are configuration scale data, a handful of rows per card, so the item loader is unscoped and identical across all four contexts. It is grouped by parent card, which is how the rule reads it.

{
    "name": "rateCardItems",
    "objectName": "b3s__Rate_Card_Item__c",
    "filterRecordsBy": [
        "Id != null"
    ],
    "groupRecordsBy": "b3s__Rate_Card__c",
    "fieldToLoad": ["b3s__Rate_Card__c", "b3s__Rate_Type__c", "b3s__Pay_Rate__c", "b3s__Multiplier__c", "b3s__Priority__c", "b3s__Behavior__c", "b3s__Band_Start__c", "b3s__Band_End__c", "b3s__Days_Of_Week__c"]
}

If your org's item volume is large, replace the Id != null clause with an Apex filter plugin returning the item Ids for the context.

Scope of the comparison

The rule compares straight time rates. Extend it where your pricing needs more:

Verifying a deployment

In an org, open the scheduler on an account that has an account level card, give one candidate a contact level card priced above it, and run Find Candidates. The expensive candidate shows a Rate Card line with the percentage and ranks below candidates with no card of their own. Then add a second, cheaper card for the same candidate scoped to the shift's job, and confirm the line reprices against that one.