@casomoltd/nhs-pay 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -21
- package/dist/afc-scales.d.ts +43 -10
- package/dist/afc-scales.js +50 -16
- package/dist/afc-scales.js.map +1 -1
- package/dist/allowances.js +11 -11
- package/dist/allowances.js.map +1 -1
- package/dist/award.d.ts +3 -3
- package/dist/award.js +21 -21
- package/dist/award.js.map +1 -1
- package/dist/circulars/england-md-1-2026-r2.d.ts +13 -0
- package/dist/circulars/england-md-1-2026-r2.js +13 -0
- package/dist/circulars/england-md-1-2026-r2.js.map +1 -1
- package/dist/circulars/ni-hsc-tc8-05-2025.d.ts +22 -0
- package/dist/circulars/ni-hsc-tc8-05-2025.js +22 -0
- package/dist/circulars/ni-hsc-tc8-05-2025.js.map +1 -1
- package/dist/circulars/scotland-pcs-dd-2025-01.d.ts +20 -0
- package/dist/circulars/scotland-pcs-dd-2025-01.js +20 -0
- package/dist/circulars/scotland-pcs-dd-2025-01.js.map +1 -1
- package/dist/circulars/scotland-pcs-dd-2026-01.d.ts +19 -0
- package/dist/circulars/scotland-pcs-dd-2026-01.js +30 -10
- package/dist/circulars/scotland-pcs-dd-2026-01.js.map +1 -1
- package/dist/circulars/scotland-pcs-dd-2026-02.d.ts +10 -0
- package/dist/circulars/scotland-pcs-dd-2026-02.js +10 -0
- package/dist/circulars/scotland-pcs-dd-2026-02.js.map +1 -1
- package/dist/circulars/wales-mdw-01-2025.d.ts +17 -0
- package/dist/circulars/wales-mdw-01-2025.js +17 -0
- package/dist/circulars/wales-mdw-01-2025.js.map +1 -1
- package/dist/circulars/wales-mdw-01-2026.d.ts +20 -0
- package/dist/circulars/wales-mdw-01-2026.js +20 -0
- package/dist/circulars/wales-mdw-01-2026.js.map +1 -1
- package/dist/commutation.js +3 -2
- package/dist/commutation.js.map +1 -1
- package/dist/dental-grades.d.ts +25 -0
- package/dist/dental-grades.js +25 -0
- package/dist/dental-grades.js.map +1 -0
- package/dist/dental-scales.d.ts +5 -21
- package/dist/dental-scales.js +73 -72
- package/dist/dental-scales.js.map +1 -1
- package/dist/format.js +3 -2
- package/dist/format.js.map +1 -1
- package/dist/hcas-pcts.d.ts +1 -1
- package/dist/hcas-zone.d.ts +23 -0
- package/dist/hcas-zone.js +17 -0
- package/dist/hcas-zone.js.map +1 -0
- package/dist/hcas.d.ts +26 -18
- package/dist/hcas.js +45 -24
- package/dist/hcas.js.map +1 -1
- package/dist/index.d.ts +23 -14
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/dist/medical-grades.d.ts +33 -0
- package/dist/medical-grades.js +33 -0
- package/dist/medical-grades.js.map +1 -0
- package/dist/medical-scales.d.ts +10 -33
- package/dist/medical-scales.js +104 -158
- package/dist/medical-scales.js.map +1 -1
- package/dist/member/input-period.d.ts +18 -5
- package/dist/member/input-period.js +24 -13
- package/dist/member/input-period.js.map +1 -1
- package/dist/pay-round.js +3 -3
- package/dist/pay-round.js.map +1 -1
- package/dist/pay-year.d.ts +17 -0
- package/dist/pay-year.js +20 -0
- package/dist/pay-year.js.map +1 -0
- package/dist/pension/ledger.d.ts +7 -0
- package/dist/pension/ledger.js +18 -11
- package/dist/pension/ledger.js.map +1 -1
- package/dist/pension.js +2 -1
- package/dist/pension.js.map +1 -1
- package/dist/post.d.ts +20 -21
- package/dist/post.js +54 -53
- package/dist/post.js.map +1 -1
- package/dist/published/england-afc.d.ts +29 -0
- package/dist/published/england-afc.js +142 -0
- package/dist/published/england-afc.js.map +1 -0
- package/dist/published/hcas-zones.d.ts +18 -0
- package/dist/published/hcas-zones.js +46 -0
- package/dist/published/hcas-zones.js.map +1 -0
- package/dist/published/wales-living-wage.d.ts +36 -0
- package/dist/published/wales-living-wage.js +30 -0
- package/dist/published/wales-living-wage.js.map +1 -0
- package/dist/regions.d.ts +25 -14
- package/dist/regions.js +61 -71
- package/dist/regions.js.map +1 -1
- package/dist/resolver.d.ts +46 -41
- package/dist/resolver.js +70 -142
- package/dist/resolver.js.map +1 -1
- package/dist/role.d.ts +3 -3
- package/dist/scale-point.d.ts +11 -7
- package/dist/scale-point.js +29 -1
- package/dist/scale-point.js.map +1 -1
- package/dist/scale-tables.d.ts +42 -60
- package/dist/scale-tables.js +65 -105
- package/dist/scale-tables.js.map +1 -1
- package/dist/scale-translators.d.ts +90 -0
- package/dist/scale-translators.js +97 -0
- package/dist/scale-translators.js.map +1 -0
- package/dist/scales.d.ts +138 -101
- package/dist/scales.js +221 -457
- package/dist/scales.js.map +1 -1
- package/dist/sources.d.ts +8 -12
- package/dist/sources.js +9 -15
- package/dist/sources.js.map +1 -1
- package/dist/take-home.js +1 -2
- package/dist/take-home.js.map +1 -1
- package/dist/values.d.ts +10 -3
- package/dist/values.js +11 -4
- package/dist/values.js.map +1 -1
- package/dist/working-week.d.ts +23 -8
- package/dist/working-week.js +55 -25
- package/dist/working-week.js.map +1 -1
- package/package.json +3 -3
- package/dist/bands.d.ts +0 -63
- package/dist/bands.js +0 -78
- package/dist/bands.js.map +0 -1
package/dist/resolver.js
CHANGED
|
@@ -1,168 +1,96 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pay-scale resolvers — build a {@link Post} from a
|
|
3
3
|
* published pay scale. The AfC resolver reads the
|
|
4
|
-
* Agenda-for-Change tables; medical
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Agenda-for-Change tables; the medical and dental resolvers
|
|
5
|
+
* read their own, all producing the same uniform Post.
|
|
6
|
+
* Polymorphism lives here, not on the Post.
|
|
7
7
|
*
|
|
8
8
|
* Each resolver stamps the Post's {@link Role} identity from
|
|
9
9
|
* the inputs it already holds (band / point / region), so the
|
|
10
10
|
* Post knows which scale position it came from.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import { onlyPointLabelled } from './scale-point.js';
|
|
13
|
+
import { afcBandPoints, afcPointOf, getAfcScales, latestAfcYear, } from './scales.js';
|
|
13
14
|
import { afcRegionToNation } from './regions.js';
|
|
14
|
-
import { getAfcScales } from './bands.js';
|
|
15
15
|
import { grossSalary } from './hcas.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
16
|
+
import { MEDICAL_FAMILY } from './medical-scales.js';
|
|
17
|
+
import { DENTAL_FAMILY } from './dental-scales.js';
|
|
18
|
+
import { ScaleUnavailable } from './errors.js';
|
|
19
19
|
import { Post } from './post.js';
|
|
20
20
|
export const afcResolver = {
|
|
21
|
-
fromSalary
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const nation = afcRegionToNation(region);
|
|
26
|
-
const scales = getAfcScales(year, nation);
|
|
27
|
-
// The point must be ON this band's published scale. Without it,
|
|
28
|
-
// the accessor this round now prefers will happily build a
|
|
29
|
-
// Northern Ireland Post from an England point — the exact
|
|
30
|
-
// substitution the per-nation tables exist to prevent, and one
|
|
31
|
-
// `fromScalePoint` ruled out by construction.
|
|
32
|
-
// Matched by VALUE, not reference: a consumer may map the points
|
|
33
|
-
// through its own view type before handing one back, and identity
|
|
34
|
-
// would then reject a legitimate call.
|
|
35
|
-
const meta = scales.bands.find((b) => b.band === band);
|
|
36
|
-
const onScale = meta?.points.some((p) => p.label === point.label && p.salary === point.salary);
|
|
37
|
-
if (!onScale) {
|
|
38
|
-
throw new ScaleUnavailable(nation, year, band, point.label);
|
|
39
|
-
}
|
|
40
|
-
const gross = grossSalary(point.salary, region, scales.hcas);
|
|
41
|
-
return Post.fromSalary(gross, nation, year, taxYear, {
|
|
42
|
-
kind: 'afc',
|
|
43
|
-
band,
|
|
44
|
-
point,
|
|
45
|
-
region,
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
fromScalePoint(band, pointLabel, region, year, taxYear) {
|
|
21
|
+
fromSalary: Post.offScale,
|
|
22
|
+
fromPoint: afcFromPoint,
|
|
23
|
+
fromScalePoint({ band, pointLabel, region, payYear, taxYear }) {
|
|
24
|
+
// `afcPointOf` owns the one-point-per-label rule for AfC.
|
|
49
25
|
const nation = afcRegionToNation(region);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
if (!meta) {
|
|
53
|
-
throw new ScaleUnavailable(nation, year, band);
|
|
54
|
-
}
|
|
55
|
-
const matches = meta.points.filter((p) => p.label === pointLabel);
|
|
56
|
-
if (matches.length === 0) {
|
|
57
|
-
throw new ScaleUnavailable(nation, year, band, pointLabel);
|
|
58
|
-
}
|
|
59
|
-
// The same rule as the medical and dental resolvers. A domain rule
|
|
60
|
-
// has to hold on every path, and this one landed on one of two.
|
|
61
|
-
if (matches.length > 1) {
|
|
62
|
-
throw new AmbiguousScalePoint(band, pointLabel, matches.length);
|
|
63
|
-
}
|
|
64
|
-
return this.fromPoint(band, matches[0], region, year, taxYear);
|
|
26
|
+
const { current } = afcPointOf(payYear, nation, band, pointLabel);
|
|
27
|
+
return afcFromPoint({ band, point: current, region, payYear, taxYear });
|
|
65
28
|
},
|
|
66
29
|
availableGrades(nation, year) {
|
|
67
|
-
return getAfcScales(year, nation).
|
|
68
|
-
},
|
|
69
|
-
latestYearFor(gradeId, nation) {
|
|
70
|
-
// That nation's own published years, not England's: probing
|
|
71
|
-
// England's list would call getAfcScales for a year this
|
|
72
|
-
// nation has not published, which throws ScaleUnavailable —
|
|
73
|
-
// breaking the "or null" contract for the exact case the
|
|
74
|
-
// method exists to answer.
|
|
75
|
-
for (const year of [...afcPayYears(nation)].reverse()) {
|
|
76
|
-
const published = getAfcScales(year, nation)
|
|
77
|
-
.bands.some((b) => b.band === gradeId);
|
|
78
|
-
if (published) {
|
|
79
|
-
return year;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
30
|
+
return getAfcScales(year, nation).map((b) => b.band);
|
|
83
31
|
},
|
|
32
|
+
// Every band is on every AfC year's ladder (`getAfcScales` maps the
|
|
33
|
+
// whole band list), so a band's latest year is the nation's latest.
|
|
34
|
+
latestYearFor: (_band, nation) => latestAfcYear(nation),
|
|
84
35
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// owns the list of years it publishes (MEDICAL/DENTAL_PAY_YEARS, derived
|
|
88
|
-
// from its own tables), which `latestYearFor` probes newest-first.
|
|
89
|
-
/**
|
|
90
|
-
* Grade IDs published for a nation/year, or `[]` if the whole
|
|
91
|
-
* combination is unpublished — a non-throwing probe for `latestYearFor`
|
|
92
|
-
* (which walks years that may not all exist for a nation), distinct
|
|
93
|
-
* from `availableGrades`, which fails loud like the AfC resolver.
|
|
94
|
-
*/
|
|
95
|
-
function publishedGrades(load) {
|
|
96
|
-
try {
|
|
97
|
-
return load().map((m) => m.grade);
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
if (e instanceof ScaleUnavailable) {
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
|
-
throw e;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
36
|
+
export const medicalResolver = makeNationScaleResolver(MEDICAL_FAMILY, (grade, point, nation) => ({ kind: 'medical', grade, point, nation }));
|
|
37
|
+
export const dentalResolver = makeNationScaleResolver(DENTAL_FAMILY, (grade, point, nation) => ({ kind: 'dental', grade, point, nation }));
|
|
106
38
|
/**
|
|
107
|
-
* Build a {@link NationScaleResolver} over a
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
39
|
+
* Build a {@link NationScaleResolver} over a {@link GradeFamily} and its
|
|
40
|
+
* {@link Role} stamp. Both the medical and dental resolvers are this
|
|
41
|
+
* factory with a different family and role — the polymorphism the design
|
|
42
|
+
* intends, with no per-family machinery.
|
|
111
43
|
*/
|
|
112
|
-
function makeNationScaleResolver(
|
|
44
|
+
function makeNationScaleResolver(family, toRole) {
|
|
45
|
+
const fromPoint = ({ grade, point, ...identity }) => {
|
|
46
|
+
const { nation, payYear } = identity;
|
|
47
|
+
assertOnScale(family.pointsFor(grade, payYear, nation), point, () => new ScaleUnavailable(nation, payYear, grade, point.label));
|
|
48
|
+
return Post.fromSalary(point.salary, identity, toRole(grade, point, nation));
|
|
49
|
+
};
|
|
113
50
|
return {
|
|
114
|
-
fromSalary
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
throw new ScaleUnavailable(nation, year, grade);
|
|
121
|
-
}
|
|
122
|
-
const matches = meta.points.filter((p) => p.label === pointLabel);
|
|
123
|
-
if (matches.length === 0) {
|
|
124
|
-
throw new ScaleUnavailable(nation, year, grade, pointLabel);
|
|
125
|
-
}
|
|
126
|
-
// Loud, not first-match. Where a label names several points the
|
|
127
|
-
// caller has asked a question the data cannot answer, and the
|
|
128
|
-
// salaries happening to agree today is not a reason to guess.
|
|
129
|
-
if (matches.length > 1) {
|
|
130
|
-
throw new AmbiguousScalePoint(grade, pointLabel, matches.length);
|
|
131
|
-
}
|
|
132
|
-
return Post.fromSalary(matches[0].salary, nation, year, taxYear, toRole(grade, matches[0], nation));
|
|
133
|
-
},
|
|
134
|
-
fromPoint(grade, point, nation, year, taxYear) {
|
|
135
|
-
// The point must belong to the scale it is being resolved
|
|
136
|
-
// against. `fromPoint` takes a point the caller is already
|
|
137
|
-
// holding, so nothing else checks that it came from THIS
|
|
138
|
-
// grade, nation and year — and a consumer that renders one
|
|
139
|
-
// nation's table and resolves against another gets a Post
|
|
140
|
-
// built from a salary that nation does not pay.
|
|
141
|
-
//
|
|
142
|
-
// By VALUE, not identity: a consumer may map points through
|
|
143
|
-
// its own view type before handing one back.
|
|
144
|
-
const meta = getScales(year, nation)
|
|
145
|
-
.find((m) => m.grade === grade);
|
|
146
|
-
const onScale = meta?.points.some((p) => p.label === point.label && p.salary === point.salary);
|
|
147
|
-
if (!onScale) {
|
|
148
|
-
throw new ScaleUnavailable(nation, year, grade, point.label);
|
|
149
|
-
}
|
|
150
|
-
return Post.fromSalary(point.salary, nation, year, taxYear, toRole(grade, point, nation));
|
|
51
|
+
fromSalary: Post.offScale,
|
|
52
|
+
fromScalePoint({ grade, pointLabel, ...identity }) {
|
|
53
|
+
const { nation, payYear } = identity;
|
|
54
|
+
const points = family.pointsFor(grade, payYear, nation);
|
|
55
|
+
const point = onlyPointLabelled(points, pointLabel, grade, () => new ScaleUnavailable(nation, payYear, grade, pointLabel));
|
|
56
|
+
return fromPoint({ grade, point, ...identity });
|
|
151
57
|
},
|
|
58
|
+
fromPoint,
|
|
152
59
|
availableGrades(nation, year) {
|
|
153
|
-
return
|
|
154
|
-
},
|
|
155
|
-
latestYearFor(gradeId, nation) {
|
|
156
|
-
for (const year of years) {
|
|
157
|
-
const published = publishedGrades(() => getScales(year, nation)).includes(gradeId);
|
|
158
|
-
if (published) {
|
|
159
|
-
return year;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
60
|
+
return family.scalesFor(year, nation).map((m) => m.grade);
|
|
163
61
|
},
|
|
62
|
+
latestYearFor: (gradeId, nation) => family.latestYearOf(gradeId, nation),
|
|
164
63
|
};
|
|
165
64
|
}
|
|
166
|
-
|
|
167
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The point on a grade's published scale equal to `point`, or a throw.
|
|
67
|
+
*
|
|
68
|
+
* `fromPoint` takes a point the caller is already holding, so nothing
|
|
69
|
+
* else checks it came from THIS grade, nation and year; without this, a
|
|
70
|
+
* consumer that renders one nation's table and resolves against another
|
|
71
|
+
* gets a Post built from a salary that nation does not pay. Matched by
|
|
72
|
+
* VALUE, not identity: a consumer may map points through its own view
|
|
73
|
+
* type before handing one back.
|
|
74
|
+
*/
|
|
75
|
+
function assertOnScale(points, point, unavailable) {
|
|
76
|
+
const onScale = points.some((p) => p.label === point.label && p.salary === point.salary);
|
|
77
|
+
if (!onScale) {
|
|
78
|
+
throw unavailable();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Build a Post from an AfC point the caller holds, refusing a point that
|
|
82
|
+
* is not on the band's published scale. */
|
|
83
|
+
function afcFromPoint({ band, point, region, payYear, taxYear }) {
|
|
84
|
+
const nation = afcRegionToNation(region);
|
|
85
|
+
// The point must be ON this band's published scale, or an England
|
|
86
|
+
// point would build a Northern Ireland Post.
|
|
87
|
+
assertOnScale(afcBandPoints(payYear, nation, band), point, () => new ScaleUnavailable(nation, payYear, band, point.label));
|
|
88
|
+
const gross = grossSalary(point.salary, region, payYear);
|
|
89
|
+
return Post.fromSalary(gross, { nation, payYear, taxYear }, {
|
|
90
|
+
kind: 'afc',
|
|
91
|
+
band,
|
|
92
|
+
point,
|
|
93
|
+
region,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
168
96
|
//# sourceMappingURL=resolver.js.map
|
package/dist/resolver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EACL,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,GACvD,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAuG/B,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,UAAU,EAAE,IAAI,CAAC,QAAQ;IAEzB,SAAS,EAAE,YAAY;IAEvB,cAAc,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAC;QACzD,0DAA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GASG;AACH,SAAS,aAAa,CACpB,MAA6B,EAC7B,KAAiB,EACjB,WAAmC;IAEnC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CACzB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAC5D,CAAC;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC;AACH,CAAC;AAED;4CAC4C;AAC5C,SAAS,YAAY,CACnB,EAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAgB;IAEtD,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACzC,kEAAkE;IAClE,6CAA6C;IAC7C,aAAa,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,EACvD,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAC,EAAE;QACxD,IAAI,EAAE,KAAK;QACX,IAAI;QACJ,KAAK;QACL,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
package/dist/role.d.ts
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
*
|
|
10
10
|
* `afc`, `vsm`, `medical` and `dental` all ship today.
|
|
11
11
|
*/
|
|
12
|
-
import type { AfcBandId } from './
|
|
12
|
+
import type { AfcBandId } from './afc-band.js';
|
|
13
13
|
import type { ScalePoint } from './scale-point.js';
|
|
14
14
|
import type { AfcRegionId } from './regions.js';
|
|
15
|
-
import type { MedicalGradeId } from './medical-
|
|
16
|
-
import type { DentalGradeId } from './dental-
|
|
15
|
+
import type { MedicalGradeId } from './medical-grades.js';
|
|
16
|
+
import type { DentalGradeId } from './dental-grades.js';
|
|
17
17
|
import type { Nation } from '@casomoltd/paye-calc';
|
|
18
18
|
/** An Agenda-for-Change post: a band at a point, in a region. */
|
|
19
19
|
export interface AfcRole {
|
package/dist/scale-point.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* The canonical pay-scale point — the single shape every pay scale
|
|
3
|
-
* reduces to (AfC band points, medical grades, dental spines), read by
|
|
4
|
-
* the resolvers to build a Post. Domain-neutral: it belongs to no one
|
|
5
|
-
* pay family, which is why it lives here rather than in any one scale
|
|
6
|
-
* file.
|
|
7
|
-
*/
|
|
1
|
+
import type { ScaleUnavailable } from './errors.js';
|
|
8
2
|
export interface ScalePoint {
|
|
9
3
|
/** The point's own step identity: a band point, pay-scale code,
|
|
10
4
|
* training stage, consultant threshold, or dental band + point. */
|
|
@@ -50,3 +44,13 @@ export interface PayLadder {
|
|
|
50
44
|
readonly points: readonly SteppedPoint[];
|
|
51
45
|
readonly current: SteppedPoint;
|
|
52
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The one point labelled `label` among `points`, or a throw: none is
|
|
49
|
+
* {@link ScaleUnavailable}, several is {@link AmbiguousScalePoint}. `scale`
|
|
50
|
+
* names the band or grade for the error.
|
|
51
|
+
*
|
|
52
|
+
* Loud, not first-match, on every family's path. Where a label names
|
|
53
|
+
* several points the caller has asked a question the data cannot answer,
|
|
54
|
+
* and the salaries happening to agree today is not a reason to guess.
|
|
55
|
+
*/
|
|
56
|
+
export declare function onlyPointLabelled<P extends ScalePoint>(points: readonly P[], label: string, scale: string, unavailable: () => ScaleUnavailable): P;
|
package/dist/scale-point.js
CHANGED
|
@@ -1,2 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The canonical pay-scale point — the single shape every pay scale
|
|
3
|
+
* reduces to (AfC band points, medical grades, dental spines), read by
|
|
4
|
+
* the resolvers to build a Post, with `PayLadder` (a scale's points and
|
|
5
|
+
* the member's own) and `onlyPointLabelled`, the rule every family's
|
|
6
|
+
* label lookup applies. Domain-neutral: it belongs to no one pay family,
|
|
7
|
+
* which is why it lives here rather than in any one scale file.
|
|
8
|
+
*/
|
|
9
|
+
import { AmbiguousScalePoint } from './errors.js';
|
|
10
|
+
/**
|
|
11
|
+
* The one point labelled `label` among `points`, or a throw: none is
|
|
12
|
+
* {@link ScaleUnavailable}, several is {@link AmbiguousScalePoint}. `scale`
|
|
13
|
+
* names the band or grade for the error.
|
|
14
|
+
*
|
|
15
|
+
* Loud, not first-match, on every family's path. Where a label names
|
|
16
|
+
* several points the caller has asked a question the data cannot answer,
|
|
17
|
+
* and the salaries happening to agree today is not a reason to guess.
|
|
18
|
+
*/
|
|
19
|
+
export function onlyPointLabelled(points, label, scale, unavailable) {
|
|
20
|
+
const matches = points.filter((p) => p.label === label);
|
|
21
|
+
const [first] = matches;
|
|
22
|
+
if (first === undefined) {
|
|
23
|
+
throw unavailable();
|
|
24
|
+
}
|
|
25
|
+
if (matches.length > 1) {
|
|
26
|
+
throw new AmbiguousScalePoint(scale, label, matches.length);
|
|
27
|
+
}
|
|
28
|
+
return first;
|
|
29
|
+
}
|
|
2
30
|
//# sourceMappingURL=scale-point.js.map
|
package/dist/scale-point.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale-point.js","sourceRoot":"","sources":["../src/scale-point.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"scale-point.js","sourceRoot":"","sources":["../src/scale-point.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAmDhD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAoB,EACpB,KAAa,EACb,KAAa,EACb,WAAmC;IAEnC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IACxD,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;IACxB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/scale-tables.d.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* `(grade, nation, year)` and resolve to `ScalePoint[]`, uniform with
|
|
6
6
|
* AfC. Verbatim transcription lives in `circulars/*`; the per-family
|
|
7
7
|
* selection + mapping lives in the translation layers
|
|
8
|
-
* (`medical-scales.ts`, `dental-scales.ts`)
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* (`medical-scales.ts`, `dental-scales.ts`), with the row translators
|
|
9
|
+
* they share in `scale-translators.ts`. This module owns the canonical
|
|
10
|
+
* container and the family object every read goes through
|
|
11
|
+
* ({@link gradeFamily}).
|
|
11
12
|
*/
|
|
12
13
|
import type { Nation, PayYear, YearLabel } from '@casomoltd/paye-calc';
|
|
13
14
|
import type { DocumentSource } from './document-source.js';
|
|
@@ -39,6 +40,39 @@ export interface GradeMeta<G extends string> {
|
|
|
39
40
|
}
|
|
40
41
|
/** Canonical basic-pay tables keyed year → nation → grade → scale. */
|
|
41
42
|
export type GradeScaleTables<G extends string> = Partial<Record<YearLabel, Partial<Record<Nation, Partial<Record<G, GradeScale>>>>>>;
|
|
43
|
+
/**
|
|
44
|
+
* One nation-based pay family (medical, dental): every read over its
|
|
45
|
+
* tables, so the families share one implementation rather than two
|
|
46
|
+
* copies that can drift.
|
|
47
|
+
*/
|
|
48
|
+
export interface GradeFamily<G extends string> {
|
|
49
|
+
/** Pay years with a published table, newest first. */
|
|
50
|
+
readonly years: readonly PayYear[];
|
|
51
|
+
/** The grades published for a nation and year, in the family's grade
|
|
52
|
+
* order. Throws {@link ScaleUnavailable} where none is published,
|
|
53
|
+
* rather than defaulting to another nation's or year's figures. */
|
|
54
|
+
scalesFor(year: PayYear, nation: Nation): GradeMeta<G>[];
|
|
55
|
+
/** True where the nation and year publish `grade`: the non-throwing
|
|
56
|
+
* question a consumer asks before reading a year it is not sure of. */
|
|
57
|
+
publishes(grade: G, year: PayYear, nation: Nation): boolean;
|
|
58
|
+
/** The points of one grade's scale. Throws {@link ScaleUnavailable}
|
|
59
|
+
* where the nation and year do not publish it. */
|
|
60
|
+
pointsFor(grade: G, year: PayYear, nation: Nation): readonly ScalePoint[];
|
|
61
|
+
/** The newest year the family publishes any grade for a nation, or null
|
|
62
|
+
* where it publishes none. */
|
|
63
|
+
latestYear(nation: Nation): PayYear | null;
|
|
64
|
+
/** The newest year the family publishes `grade` for a nation, or null. */
|
|
65
|
+
latestYearOf(grade: G, nation: Nation): PayYear | null;
|
|
66
|
+
/** The newest document of the newest year the family publishes for a
|
|
67
|
+
* nation: by issue date among that year's grades, so a round split
|
|
68
|
+
* over two circulars cites the later one, and a nation behind cites
|
|
69
|
+
* its last year's. */
|
|
70
|
+
latestSource(nation: Nation): DocumentSource;
|
|
71
|
+
/** The document that publishes one grade's scale. Throws
|
|
72
|
+
* {@link ScaleUnavailable} where the nation and year publish a table
|
|
73
|
+
* but not this grade. */
|
|
74
|
+
sourceFor(grade: G, year: PayYear, nation: Nation): DocumentSource;
|
|
75
|
+
}
|
|
42
76
|
/**
|
|
43
77
|
* Bind every grade in a mapping to the document it was read from.
|
|
44
78
|
*
|
|
@@ -60,62 +94,10 @@ export declare function fromDocument<G extends string>(source: DocumentSource, p
|
|
|
60
94
|
*
|
|
61
95
|
* A grade can have exactly one publishing circular in a nation and
|
|
62
96
|
* year. Spreading two partial records instead would let the later one
|
|
63
|
-
* win in silence
|
|
64
|
-
*
|
|
97
|
+
* win in silence, so the grade's figures would be whichever document was
|
|
98
|
+
* listed last rather than the one that publishes them.
|
|
65
99
|
*/
|
|
66
100
|
export declare function combineScales<G extends string>(...parts: Partial<Record<G, GradeScale>>[]): Partial<Record<G, GradeScale>>;
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
* {@link ScaleUnavailable} rather than defaulting to another nation's
|
|
71
|
-
* or year's figures.
|
|
72
|
-
*/
|
|
73
|
-
export declare function resolveGradeMetas<G extends string>(tables: GradeScaleTables<G>, gradeIds: readonly G[], year: PayYear, nation: Nation): GradeMeta<G>[];
|
|
74
|
-
/**
|
|
75
|
-
* An incremental scale with no distinct labels beyond position: the
|
|
76
|
-
* first point is "Minimum", the rest "Point 1", "Point 2", … (the
|
|
77
|
-
* devolved training grades). Input is the salary column, top to bottom.
|
|
78
|
-
*/
|
|
79
|
-
export declare const stepped: (salaries: readonly number[]) => readonly ScalePoint[];
|
|
80
|
-
/** A two-point salary range (salaried GP), min then max. */
|
|
81
|
-
export declare const range: (r: SalaryRange) => readonly ScalePoint[];
|
|
82
|
-
/** Plain "Point 1", "Point 2"… labelling (1-based). */
|
|
83
|
-
export declare const numbered: (salaries: readonly number[]) => readonly ScalePoint[];
|
|
84
|
-
/**
|
|
85
|
-
* One point per row, labelled by the row's `stage` (training grades).
|
|
86
|
-
* Carries the row's `nodalPoint` onto the point where the source lists one
|
|
87
|
-
* (the 2016-contract resident scales); rows without it stay stage-only.
|
|
88
|
-
*/
|
|
89
|
-
export declare const byStage: (rows: readonly {
|
|
90
|
-
stage: string;
|
|
91
|
-
salary: number;
|
|
92
|
-
nodalPoint?: string;
|
|
93
|
-
}[]) => readonly ScalePoint[];
|
|
94
|
-
/**
|
|
95
|
-
* One point per row, labelled by the row's pay-scale `code`. Carries
|
|
96
|
-
* whichever axis the source lists beside the code, because the code
|
|
97
|
-
* alone is opaque: `yearsExperience` for the SAS scales, `nodalPoint`
|
|
98
|
-
* for locally employed doctors, whose codes England publishes against
|
|
99
|
-
* the 2016-contract points and NOT in code order. Rows with neither
|
|
100
|
-
* (GP educators, closed grades) stay code-only.
|
|
101
|
-
*/
|
|
102
|
-
export declare const byCode: (rows: readonly {
|
|
103
|
-
code: string;
|
|
104
|
-
salary: number;
|
|
105
|
-
yearsExperience?: number;
|
|
106
|
-
nodalPoint?: string;
|
|
107
|
-
}[]) => readonly ScalePoint[];
|
|
108
|
-
/** One point per row, labelled "Band {band} Point {point}" (dental spine). */
|
|
109
|
-
export declare const bySpine: (rows: readonly {
|
|
110
|
-
band: string | number;
|
|
111
|
-
point: number;
|
|
112
|
-
salary: number;
|
|
113
|
-
}[]) => readonly ScalePoint[];
|
|
114
|
-
/**
|
|
115
|
-
* The `salaries` of the named incremental scale in a circular's list.
|
|
116
|
-
* Fails loud (at module load) on a mapping key that doesn't match a
|
|
117
|
-
* source scale — a translation-layer typo can't ship silently.
|
|
118
|
-
*/
|
|
119
|
-
export declare const scaleSalaries: <T extends {
|
|
120
|
-
salaries: readonly number[];
|
|
121
|
-
}>(rows: readonly T[], match: (r: T) => boolean, key: string) => readonly number[];
|
|
101
|
+
/** Build a {@link GradeFamily} over a family's tables, reading grades in
|
|
102
|
+
* `gradeIds` order. */
|
|
103
|
+
export declare function gradeFamily<G extends string>(tables: GradeScaleTables<G>, gradeIds: readonly G[]): GradeFamily<G>;
|