Rate basis templates

Rate basis templates

Rate Basis (b3s__Rate_Basis__c) says how a booking is charged: by the hour, for a full day or for a half day. It lives on Shift, Booking Request, Working Pattern and (new) Working Pattern Day, and the pay and bill engine picks the matching rate line through a condition on it (see Pay and bill engine).

A Rate Basis Template (b3s__Rate_Basis_Template__c) adds two things on top of the value:

  1. Which values a job allows. A school might book Full Day and Half Day only, while a hospital job books Hourly only. The picker offers only the allowed values, and the server rejects any other value.
  2. The times a value implies. Picking Full Day can fill 07:30 to 14:00 and, when the template locks its times, leave the user to pick only the date.

Templates are keyed by the picklist value. Shifts, booking requests and working patterns carry no lookup to a template: each record stores its own rate basis value and its own times. That has three consequences worth knowing:

Without any active templates the feature is off: every Rate Basis value is allowed, no times are pre-set and every app behaves as before.

Data model

Rate basis template object

Object b3s__Rate_Basis_Template__c, tab Rate Basis Templates, in the 3B WFM and 3B VMS apps. Sharing model Public Read/Write.

Field API name Type Notes
Template Name Name Text Tie-breaker for ordering.
Rate Basis b3s__Rate_Basis__c Picklist (global value set Rate Basis), required The value this template allows and pre-sets times for.
Start Time b3s__Start_Time__c Time Site wall-clock start.
End Time b3s__End_Time__c Time Site wall-clock end. An end at or before the start ends the next day, so 07:00 to 07:00 is 24 hours.
Lock Times b3s__Lock_Times__c Checkbox, default off On: the user picks the date only; start and end come from the template and are read-only.
Job b3s__Job__c Lookup (Job), clear on delete Optional. Restricts this job.
Account b3s__Account__c Lookup (Account), clear on delete Optional. With Job blank, restricts every job of this account that has no job templates.
Active b3s__Active__c Checkbox, default on Inactive rows neither restrict nor pre-set.
Sort Order b3s__Sort_Order__c Number(4, 0) Option order in the picker. Blank sorts last.

Validation rules:

Working pattern day rate basis

New picklist b3s__Working_Pattern_Day__c.b3s__Rate_Basis__c on the pattern day (global value set Rate Basis, not required), on the Working Pattern Day layout and in the Working Pattern Type layout's related list. When placement shifts are generated, the Working Pattern (placement) value wins, then the Booking Request value, and the day value is the fallback:

Shift.Rate_Basis__c = Working Pattern value, else Booking Request value, else Working Pattern Day value

A placement approved from a booking request copies the request's Rate Basis, so a booking with a Rate Basis applies it to every day. Day values (for example Monday to Wednesday Full Day and Thursday Half Day) apply only when neither the placement nor its booking request has a Rate Basis. In the Client Shift Manager this is what a custom booking schedule does: the request level Rate Basis is left blank and each day carries its own value.

No picklist default. The Rate Basis value set has no default value, so a record created outside a configured form (standard record page, Data Loader, API, Flow) has a blank Rate Basis, and a placement with no Rate Basis falls back to its booking request, then to the pattern day. The sample app forms set Hourly with "default": "Hourly" on their Rate Basis select.

Resolution: job, then account, then global

For a record's job and account, the effective templates are resolved like this:

  1. Pick one level. Active templates for the job, if any exist. Else active templates with Job blank for the account, if any exist. Else global templates (Job and Account both blank). Levels never merge: a job with one job template allows only that one value.
  2. One template per value within the level: the lowest Sort Order (blank last), then Name.
  3. Order the result by Sort Order (blank last), then Name.
  4. An empty result means unrestricted: every picklist value is allowed and nothing is pre-set.

The record's account:

Record Account used
Shift Job's Account, else Site's Account
Booking Request Job's Account, else the request's b3s__Account__c, else Site's Account

Worked example:

Template Rate Basis Times Lock Job Account Sort
Full Day Full Day 07:30 to 14:00 Yes 10
Half Day Half Day 07:30 to 11:00 Yes 20
Hourly Hourly none No 30
Acme Full Day Full Day 08:00 to 16:00 Yes Acme 10
Job Half AM Half Day 07:00 to 11:00 Yes Job X 5
Record Allowed
Job X (any account) Half Day only, 07:00 to 11:00 locked (job level wins)
Another Acme job Full Day only, 08:00 to 16:00 locked (account level)
Any other job, or no job Full Day, Half Day, Hourly with the global times

Global templates restrict every job. As soon as one active global template exists, every job without job or account templates is limited to the global values. Create a global row for each value you want to keep available everywhere (for example an Hourly row with no times), or use only job and account rows.

Server-side enforcement

The package validates the Rate Basis on every Shift and Booking Request save. A record is checked only when its Rate Basis is non-blank and it is new or the value changed. If the resolved set is non-empty and the value is not in it, the save fails on the Rate Basis field with the custom label Rate_Basis_Not_Allowed:

Rate Basis Full Day is not allowed for this job. Allowed values: Half Day.

The label text is Rate Basis {0} is not allowed for this job. Allowed values: {1}. ({0} = the value, {1} = the allowed values, comma separated). Override or translate it like any custom label.

Details:

Configuring the apps

Every surface is opt in. The Version 12 release samples (Scheduling Context Providers WFM_Account, WFM_Contact, WFM_Group, WFM_Job and the Component Configuration WFM_Client_Shift_Manager) include the keys below; merge them into your own definitions.

The loader

The apps resolve templates from a loader of active rows (the same rules as the save validation). Name it rateBasisTemplates and load these fields.

Internal apps (Scheduler):

{
    "name": "rateBasisTemplates",
    "objectName": "b3s__Rate_Basis_Template__c",
    "filterRecordsBy": ["b3s__Active__c = true"],
    "groupRecordsBy": "Id",
    "fieldToLoad": [
        "Id", "Name", "b3s__Rate_Basis__c", "b3s__Start_Time__c", "b3s__End_Time__c",
        "b3s__Lock_Times__c", "b3s__Job__c", "b3s__Account__c", "b3s__Sort_Order__c"
    ]
}

Portal apps (Client Shift Manager) scope it to the contact's accounts so a client never sees another client's templates:

{
    "name": "rateBasisTemplates",
    "objectName": "b3s__Rate_Basis_Template__c",
    "filterRecordsBy": [
        "b3s__Active__c = true AND (b3s__Account__c = null OR b3s__Account__c IN :accountIds) AND (b3s__Job__c = null OR b3s__Job__r.b3s__Account__c IN :accountIds)"
    ],
    "groupRecordsBy": "Id",
    "fieldToLoad": [
        "Id", "Name", "b3s__Rate_Basis__c", "b3s__Start_Time__c", "b3s__End_Time__c",
        "b3s__Lock_Times__c", "b3s__Job__c", "b3s__Account__c", "b3s__Sort_Order__c"
    ]
}

If a form names a loader that does not exist, the browser console logs a warning and the field behaves as unrestricted.

Rate basis select

Add templateLoader to a Rate Basis field-select that has no loader key. Its options become the picklist values allowed for the form record's job and account, in template order.

Key Default Purpose
templateLoader none Loader holding the template rows. Turns the filter on.
templateJobField b3s__Work_Job__c Path of the job Id on the form record. null = no job (account or global level only).
templateAccountField ["b3s__Work_Job__r.b3s__Account__c", "b3s__Work_Site__r.b3s__Account__c"] One path or an ordered list; the first non-blank wins.
templateJobLoader none Loader of Job records carrying b3s__Account__c. Needed when the account path runs through the job relationship and the user has just picked the job, so the record has the job Id but not its account yet.

Shift form (Scheduler and Client Shift Manager):

{
    "field": "b3s__Rate_Basis__c",
    "labelOverride": "Rate Basis",
    "type": "field-select",
    "required": false,
    "columns": "col-span-2",
    "templateLoader": "rateBasisTemplates",
    "templateJobField": "b3s__Work_Job__c",
    "templateAccountField": ["b3s__Work_Job__r.b3s__Account__c", "b3s__Work_Site__r.b3s__Account__c"],
    "templateJobLoader": "jobs"
}

Booking request form (Client Shift Manager):

{
    "field": "b3s__Rate_Basis__c",
    "labelOverride": "Rate Basis",
    "type": "field-select",
    "default": "Hourly",
    "required": true,
    "templateLoader": "rateBasisTemplates",
    "templateJobField": "b3s__Job__c",
    "templateAccountField": ["b3s__Job__r.b3s__Account__c", "b3s__Account__c", "b3s__Site__r.b3s__Account__c"],
    "templateJobLoader": "jobs"
}

Behaviour:

Template times on a time range

Add a rateBasis object to the time range that holds the times the rate basis implies (usually the scheduled times).

Key Purpose
field Path of the Rate Basis on the form record, for example b3s__Rate_Basis__c. Required.
loader Template loader name. Required.
jobField, accountField, jobLoader Same meaning and defaults as templateJobField, templateAccountField and templateJobLoader above.
{
    "field": "b3s__Scheduled_Start_Time__c:b3s__Scheduled_End_Time__c",
    "labelOverride": "Scheduled Times",
    "type": "field-time-range-selector",
    "required": true,
    "siteTimezoneFieldPath": "b3s__Work_Site__r.b3s__Timezone__c",
    "rateBasis": {
        "field": "b3s__Rate_Basis__c",
        "loader": "rateBasisTemplates",
        "jobField": "b3s__Work_Job__c",
        "accountField": ["b3s__Work_Job__r.b3s__Account__c", "b3s__Work_Site__r.b3s__Account__c"],
        "jobLoader": "jobs"
    }
}

Behaviour:

Bulk shift creator

The bulk creator (Scheduler bulk create, and Client Shift Manager bulk creation where your definition uses it) reads two keys on the shift schedulable:

Key Values Purpose
timeEntryMode "times" (default), "rateBasis" rateBasis adds a required Rate Basis select to every selected day of a week template.
rateBasis { field, loader, jobField?, accountField?, jobLoader? } Required in rateBasis mode. Same shape as the time range key.
"shift": {
    "objectType": "b3s__Shift__c",
    "timeEntryMode": "rateBasis",
    "rateBasis": {
        "field": "b3s__Rate_Basis__c",
        "loader": "rateBasisTemplates",
        "jobField": "b3s__Work_Job__c",
        "accountField": ["b3s__Work_Job__r.b3s__Account__c", "b3s__Work_Site__r.b3s__Account__c"],
        "jobLoader": "jobs"
    },
    "startFieldPath": "b3s__Scheduled_Start_Time__c",
    "endFieldPath": "b3s__Scheduled_End_Time__c"
}

In rateBasis mode:

The shipped samples (the shift schedulable of the Client Shift Manager and of the WFM_Account, WFM_Contact, WFM_Group and WFM_Job Scheduling Context Providers) set "timeEntryMode": "rateBasis". Without the key, or with "times", bulk creation asks for times only.

Custom booking schedules

The Client Shift Manager request wizard can order a booking request with a Custom schedule instead of a reusable pattern type: weekdays, a Rate Basis per day and the day's hours, over one or more rotation weeks. It is saved as a Working Pattern Type flagged One Off with one Working Pattern Day per working day, each carrying its own b3s__Rate_Basis__c. Wizard flow and setup: Client Shift Manager.

The Schedule step reads the same two keys as the bulk creator, on the bookingRequest schedulable:

"bookingRequest": {
    "objectType": "b3s__Booking_Request__c",
    "timeEntryMode": "rateBasis",
    "rateBasis": {
        "field": "b3s__Rate_Basis__c",
        "loader": "rateBasisTemplates",
        "jobField": "b3s__Job__c",
        "accountField": ["b3s__Job__r.b3s__Account__c", "b3s__Account__c", "b3s__Site__r.b3s__Account__c"],
        "jobLoader": "jobs"
    }
}

Working pattern builder

The native Working Pattern Builder gets two Lightning App Builder properties:

Property API name Values Purpose
Time Entry Mode timeEntryMode Times (default), Rate Basis Rate Basis adds a required Rate Basis combobox per enabled day.
Job Lookup Field jobField API name, for example b3s__Job__c Rate Basis mode only. A Job lookup on the host record, used to resolve the job's templates. Blank = global templates.

In Rate Basis mode:

In Times mode (the default), new days are saved with a blank Rate Basis. Day values are a fallback: a placement or booking request with a Rate Basis overrides them.

Pattern days belong to the Working Pattern Type, which can be shared by several jobs. With jobField set, place the builder on a record that has both the type lookup (lookupField) and the job, such as a booking request or working pattern page.

Adding your own rate basis values

The package delivers Full Day, Half Day and Hourly in the managed global value set Rate Basis. You can add your own values (for example Evening or Sleep In) in Setup, under Picklist Value Sets.

Permissions and access

Example starting set

A common starting point is three global templates: Full Day 07:30 to 14:00 locked (sort 10), Half Day 07:30 to 11:00 locked (sort 20) and Hourly with no times (sort 30). Creating them restricts every job without its own templates to these three values. Delete or deactivate the rows to go back to unrestricted.

Surfaces without rate basis templates

These surfaces ship without Rate Basis Templates on purpose:

Surface Why
Vendor Portal, Clock, Timesheet Submission Vendors and workers do not set b3s__Rate_Basis__c; the client's choice on the shift applies.
Timesheet Approval Actual times are not editable there, so there are no times to pre-set.

Limitations