UNPKG

section-2

Version:

A library for calculating unsocial hours entitlements under the NHS agenda for change's section 2

37 lines (36 loc) 2.7 kB
import { LeaveReliefUsh, Section2, Section2Params } from "../types/section2"; /** * Calculates Section2 object containing additional and unsocial hours in ms * * *Param names are in snake_case to maximise database compatibility* * * *Any param or returned value representing a duration is in ms to preserve accuracy and for database compatibility* * - Will return `0` for all values if invalid datetimes are passed * - Will force `actual_to` to be later or equal to `planned_to`, and `planned_to` to be later than `from` * * @param shift - shift parameters for calculating * @param shift.from - the datetime of the start of the shift * @param shift.planned_to - the datetime of the planned end of the shift * @param shift.actual_to - the datetime of the actual end of the shift, optional, falls back to `planned_to` * @param shift.type - the type of shift, defaults to `"Normal"` * @param shift.overrun_type - the type of overrun, defaults to `"OT"` * @param shift.id - the unique identifier of the shift, defaults to `undefined` * @param shift.employment_id - the unique identifier of the shift's employment, defaults to `undefined` * @param shift.break_override - the duration of the shift's break **in ms** to override the default of 30mins every 6hrs, defaults to `null` * @param shift.shifts - an array of shifts, used to calculate different rate thresholds and unsocial averages, defaults to `[]` * * @param options - options for calculation methods * @param options.weekly_hours - the weekly hours contracted **in ms**, defaults to `135000000` (37.5hrs; full time) * @param options.half_is_all_ush - if set to `true` shifts that are exactly half unsocial will earn the whole of the shift as unsocial (e.g. a normal Monday 1600-0000 = 7.5hrs lower rate), if `false` only shifts that are **more** than half unsocial will (e.g. a normal Monday 1600-0000 = 4hrs lower rate), defaults to `true` * @param options.break_from_higher - if set to `true` breaks will first be deducted from higher rate earnings, if `false` from lower rate first, defaults to `true` * @param options.leave_relief_ush_type - specifies the way unsocial hours are calculated when a shift is leave or TOIL on unplanned relief, defaults to `"best"` * * @returns Section2 */ export declare const calculateSection2: ({ from, planned_to, actual_to, type, overrun_type, id, employment_id, break_override, shifts, }: Section2Params, { weekly_hours, half_is_all_ush, break_from_higher, leave_relief_ush_type, }: { weekly_hours?: number; half_is_all_ush?: boolean; break_from_higher?: boolean; leave_relief_ush_type?: LeaveReliefUsh; }) => Section2; //# sourceMappingURL=section2.d.ts.map