@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.
Files changed (115) hide show
  1. package/README.md +23 -21
  2. package/dist/afc-scales.d.ts +43 -10
  3. package/dist/afc-scales.js +50 -16
  4. package/dist/afc-scales.js.map +1 -1
  5. package/dist/allowances.js +11 -11
  6. package/dist/allowances.js.map +1 -1
  7. package/dist/award.d.ts +3 -3
  8. package/dist/award.js +21 -21
  9. package/dist/award.js.map +1 -1
  10. package/dist/circulars/england-md-1-2026-r2.d.ts +13 -0
  11. package/dist/circulars/england-md-1-2026-r2.js +13 -0
  12. package/dist/circulars/england-md-1-2026-r2.js.map +1 -1
  13. package/dist/circulars/ni-hsc-tc8-05-2025.d.ts +22 -0
  14. package/dist/circulars/ni-hsc-tc8-05-2025.js +22 -0
  15. package/dist/circulars/ni-hsc-tc8-05-2025.js.map +1 -1
  16. package/dist/circulars/scotland-pcs-dd-2025-01.d.ts +20 -0
  17. package/dist/circulars/scotland-pcs-dd-2025-01.js +20 -0
  18. package/dist/circulars/scotland-pcs-dd-2025-01.js.map +1 -1
  19. package/dist/circulars/scotland-pcs-dd-2026-01.d.ts +19 -0
  20. package/dist/circulars/scotland-pcs-dd-2026-01.js +30 -10
  21. package/dist/circulars/scotland-pcs-dd-2026-01.js.map +1 -1
  22. package/dist/circulars/scotland-pcs-dd-2026-02.d.ts +10 -0
  23. package/dist/circulars/scotland-pcs-dd-2026-02.js +10 -0
  24. package/dist/circulars/scotland-pcs-dd-2026-02.js.map +1 -1
  25. package/dist/circulars/wales-mdw-01-2025.d.ts +17 -0
  26. package/dist/circulars/wales-mdw-01-2025.js +17 -0
  27. package/dist/circulars/wales-mdw-01-2025.js.map +1 -1
  28. package/dist/circulars/wales-mdw-01-2026.d.ts +20 -0
  29. package/dist/circulars/wales-mdw-01-2026.js +20 -0
  30. package/dist/circulars/wales-mdw-01-2026.js.map +1 -1
  31. package/dist/commutation.js +3 -2
  32. package/dist/commutation.js.map +1 -1
  33. package/dist/dental-grades.d.ts +25 -0
  34. package/dist/dental-grades.js +25 -0
  35. package/dist/dental-grades.js.map +1 -0
  36. package/dist/dental-scales.d.ts +5 -21
  37. package/dist/dental-scales.js +73 -72
  38. package/dist/dental-scales.js.map +1 -1
  39. package/dist/format.js +3 -2
  40. package/dist/format.js.map +1 -1
  41. package/dist/hcas-pcts.d.ts +1 -1
  42. package/dist/hcas-zone.d.ts +23 -0
  43. package/dist/hcas-zone.js +17 -0
  44. package/dist/hcas-zone.js.map +1 -0
  45. package/dist/hcas.d.ts +26 -18
  46. package/dist/hcas.js +45 -24
  47. package/dist/hcas.js.map +1 -1
  48. package/dist/index.d.ts +23 -14
  49. package/dist/index.js +13 -9
  50. package/dist/index.js.map +1 -1
  51. package/dist/medical-grades.d.ts +33 -0
  52. package/dist/medical-grades.js +33 -0
  53. package/dist/medical-grades.js.map +1 -0
  54. package/dist/medical-scales.d.ts +10 -33
  55. package/dist/medical-scales.js +104 -158
  56. package/dist/medical-scales.js.map +1 -1
  57. package/dist/member/input-period.d.ts +18 -5
  58. package/dist/member/input-period.js +24 -13
  59. package/dist/member/input-period.js.map +1 -1
  60. package/dist/pay-round.js +3 -3
  61. package/dist/pay-round.js.map +1 -1
  62. package/dist/pay-year.d.ts +17 -0
  63. package/dist/pay-year.js +20 -0
  64. package/dist/pay-year.js.map +1 -0
  65. package/dist/pension/ledger.d.ts +7 -0
  66. package/dist/pension/ledger.js +18 -11
  67. package/dist/pension/ledger.js.map +1 -1
  68. package/dist/pension.js +2 -1
  69. package/dist/pension.js.map +1 -1
  70. package/dist/post.d.ts +20 -21
  71. package/dist/post.js +54 -53
  72. package/dist/post.js.map +1 -1
  73. package/dist/published/england-afc.d.ts +29 -0
  74. package/dist/published/england-afc.js +142 -0
  75. package/dist/published/england-afc.js.map +1 -0
  76. package/dist/published/hcas-zones.d.ts +18 -0
  77. package/dist/published/hcas-zones.js +46 -0
  78. package/dist/published/hcas-zones.js.map +1 -0
  79. package/dist/published/wales-living-wage.d.ts +36 -0
  80. package/dist/published/wales-living-wage.js +30 -0
  81. package/dist/published/wales-living-wage.js.map +1 -0
  82. package/dist/regions.d.ts +25 -14
  83. package/dist/regions.js +61 -71
  84. package/dist/regions.js.map +1 -1
  85. package/dist/resolver.d.ts +46 -41
  86. package/dist/resolver.js +70 -142
  87. package/dist/resolver.js.map +1 -1
  88. package/dist/role.d.ts +3 -3
  89. package/dist/scale-point.d.ts +11 -7
  90. package/dist/scale-point.js +29 -1
  91. package/dist/scale-point.js.map +1 -1
  92. package/dist/scale-tables.d.ts +42 -60
  93. package/dist/scale-tables.js +65 -105
  94. package/dist/scale-tables.js.map +1 -1
  95. package/dist/scale-translators.d.ts +90 -0
  96. package/dist/scale-translators.js +97 -0
  97. package/dist/scale-translators.js.map +1 -0
  98. package/dist/scales.d.ts +138 -101
  99. package/dist/scales.js +221 -457
  100. package/dist/scales.js.map +1 -1
  101. package/dist/sources.d.ts +8 -12
  102. package/dist/sources.js +9 -15
  103. package/dist/sources.js.map +1 -1
  104. package/dist/take-home.js +1 -2
  105. package/dist/take-home.js.map +1 -1
  106. package/dist/values.d.ts +10 -3
  107. package/dist/values.js +11 -4
  108. package/dist/values.js.map +1 -1
  109. package/dist/working-week.d.ts +23 -8
  110. package/dist/working-week.js +55 -25
  111. package/dist/working-week.js.map +1 -1
  112. package/package.json +3 -3
  113. package/dist/bands.d.ts +0 -63
  114. package/dist/bands.js +0 -78
  115. package/dist/bands.js.map +0 -1
@@ -5,11 +5,13 @@
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`). This module owns only the
9
- * canonical container, the grouping accessor, and the translators
10
- * generic enough to be shared across both families.
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
- import { ScaleUnavailable } from './errors.js';
13
+ import { salaryRangeOf } from './values.js';
14
+ import { ScaleUnavailable, invariant } from './errors.js';
13
15
  /**
14
16
  * Bind every grade in a mapping to the document it was read from.
15
17
  *
@@ -35,8 +37,8 @@ export function fromDocument(source, points) {
35
37
  *
36
38
  * A grade can have exactly one publishing circular in a nation and
37
39
  * year. Spreading two partial records instead would let the later one
38
- * win in silence — the same first-match-by-accident this module's
39
- * callers were rewritten to stop doing.
40
+ * win in silence, so the grade's figures would be whichever document was
41
+ * listed last rather than the one that publishes them.
40
42
  */
41
43
  export function combineScales(...parts) {
42
44
  const out = {};
@@ -51,105 +53,63 @@ export function combineScales(...parts) {
51
53
  }
52
54
  return out;
53
55
  }
54
- /**
55
- * Group a nation/year's grades into metas, in `gradeIds` order. `year`
56
- * and `nation` are both required; an absent combination throws
57
- * {@link ScaleUnavailable} rather than defaulting to another nation's
58
- * or year's figures.
59
- */
60
- export function resolveGradeMetas(tables, gradeIds, year, nation) {
61
- // The table keys on the label; the signature carries the basis.
62
- const key = year;
63
- const grades = tables[key]?.[nation];
64
- const metas = grades
65
- ? gradeIds.flatMap((grade) => {
66
- const scale = grades[grade];
67
- if (!scale) {
68
- return [];
56
+ /** Build a {@link GradeFamily} over a family's tables, reading grades in
57
+ * `gradeIds` order. */
58
+ export function gradeFamily(tables, gradeIds) {
59
+ // The table keys on the label; each signature carries the basis.
60
+ const gradesOf = (year, nation) => {
61
+ const key = year;
62
+ return tables[key]?.[nation];
63
+ };
64
+ const metasOf = (year, nation) => gradeMetas(gradesOf(year, nation), gradeIds);
65
+ const years = Object.keys(tables)
66
+ .sort((a, b) => b.localeCompare(a));
67
+ const publishes = (grade, year, nation) => gradesOf(year, nation)?.[grade] !== undefined;
68
+ const holds = (year, nation) => metasOf(year, nation).length > 0;
69
+ const latestYear = (nation) => years.find((year) => holds(year, nation)) ?? null;
70
+ const scaleOf = (grade, year, nation) => {
71
+ const scale = gradesOf(year, nation)?.[grade];
72
+ if (scale === undefined) {
73
+ throw new ScaleUnavailable(nation, year, grade);
74
+ }
75
+ return scale;
76
+ };
77
+ return {
78
+ years,
79
+ scalesFor(year, nation) {
80
+ const metas = metasOf(year, nation);
81
+ if (metas.length === 0) {
82
+ throw new ScaleUnavailable(nation, year);
69
83
  }
70
- const salaries = scale.points.map((p) => p.salary);
71
- return [
72
- {
73
- grade,
74
- points: scale.points,
75
- salary: {
76
- min: Math.min(...salaries),
77
- max: Math.max(...salaries),
78
- },
79
- source: scale.source,
80
- },
81
- ];
82
- })
83
- : [];
84
- if (metas.length === 0) {
85
- throw new ScaleUnavailable(nation, year);
86
- }
87
- return metas;
84
+ return metas;
85
+ },
86
+ publishes,
87
+ pointsFor: (grade, year, nation) => scaleOf(grade, year, nation).points,
88
+ latestYear,
89
+ latestYearOf: (grade, nation) => years.find((year) => publishes(grade, year, nation)) ?? null,
90
+ sourceFor: (grade, year, nation) => scaleOf(grade, year, nation).source,
91
+ latestSource(nation) {
92
+ const year = latestYear(nation);
93
+ // A plain error, not ScaleUnavailable: there is no year to name.
94
+ invariant(year !== null, `gradeFamily: ${nation} publishes no scale`);
95
+ // metasOf is never empty for a year latestYear found, so there is
96
+ // always a first.
97
+ const [first, ...rest] = metasOf(year, nation).map((m) => m.source);
98
+ return rest.reduce((a, b) => (b.issued > a.issued ? b : a), first);
99
+ },
100
+ };
101
+ }
102
+ /** A nation-year's grades as metas, in `gradeIds` order, skipping a grade
103
+ * the nation-year does not publish. */
104
+ function gradeMetas(grades, gradeIds) {
105
+ return gradeIds.flatMap((grade) => {
106
+ const scale = grades?.[grade];
107
+ return scale === undefined ? [] : [{
108
+ grade,
109
+ points: scale.points,
110
+ salary: salaryRangeOf(scale.points),
111
+ source: scale.source,
112
+ }];
113
+ });
88
114
  }
89
- // ── Shared translators ──────────────────────────
90
- // Small pure maps from a circular's verbatim rows to canonical points.
91
- // The per-family selection (which scale feeds which grade) lives in the
92
- // `*-scales.ts` translation layers; these translators are the pieces
93
- // generic enough to be shared by both.
94
- /**
95
- * An incremental scale with no distinct labels beyond position: the
96
- * first point is "Minimum", the rest "Point 1", "Point 2", … (the
97
- * devolved training grades). Input is the salary column, top to bottom.
98
- */
99
- export const stepped = (salaries) => salaries.map((salary, i) => ({
100
- label: i === 0 ? 'Minimum' : `Point ${i}`,
101
- salary,
102
- }));
103
- /** A two-point salary range (salaried GP), min then max. */
104
- export const range = (r) => [
105
- { label: 'Range minimum', salary: r.min },
106
- { label: 'Range maximum', salary: r.max },
107
- ];
108
- /** Plain "Point 1", "Point 2"… labelling (1-based). */
109
- export const numbered = (salaries) => salaries.map((salary, i) => ({ label: `Point ${i + 1}`, salary }));
110
- /**
111
- * One point per row, labelled by the row's `stage` (training grades).
112
- * Carries the row's `nodalPoint` onto the point where the source lists one
113
- * (the 2016-contract resident scales); rows without it stay stage-only.
114
- */
115
- export const byStage = (rows) => rows.map((r) => ({
116
- label: r.stage,
117
- salary: r.salary,
118
- ...(r.nodalPoint !== undefined ? { nodalPoint: r.nodalPoint } : {}),
119
- }));
120
- /**
121
- * One point per row, labelled by the row's pay-scale `code`. Carries
122
- * whichever axis the source lists beside the code, because the code
123
- * alone is opaque: `yearsExperience` for the SAS scales, `nodalPoint`
124
- * for locally employed doctors, whose codes England publishes against
125
- * the 2016-contract points and NOT in code order. Rows with neither
126
- * (GP educators, closed grades) stay code-only.
127
- */
128
- export const byCode = (rows) => rows.map((r) => ({
129
- label: r.code,
130
- salary: r.salary,
131
- ...(r.yearsExperience !== undefined
132
- ? { yearsExperience: r.yearsExperience }
133
- : {}),
134
- ...(r.nodalPoint !== undefined
135
- ? { nodalPoint: r.nodalPoint }
136
- : {}),
137
- }));
138
- /** One point per row, labelled "Band {band} Point {point}" (dental spine). */
139
- export const bySpine = (rows) => rows.map((r) => ({
140
- label: `Band ${r.band} Point ${r.point}`,
141
- salary: r.salary,
142
- }));
143
- /**
144
- * The `salaries` of the named incremental scale in a circular's list.
145
- * Fails loud (at module load) on a mapping key that doesn't match a
146
- * source scale — a translation-layer typo can't ship silently.
147
- */
148
- export const scaleSalaries = (rows, match, key) => {
149
- const found = rows.find(match);
150
- if (!found) {
151
- throw new Error(`scale-tables: no source scale for "${key}"`);
152
- }
153
- return found.salaries;
154
- };
155
115
  //# sourceMappingURL=scale-tables.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scale-tables.js","sourceRoot":"","sources":["../src/scale-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,OAAO,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAmC7C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAsB,EACtB,MAA0C;IAE1C,MAAM,GAAG,GAAmC,EAAE,CAAC;IAC/C,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAE7C,EAAE,CAAC;QACJ,GAAG,CAAC,KAAK,CAAC,GAAG,EAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAC,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAG,KAAuC;IAE1C,MAAM,GAAG,GAAmC,EAAE,CAAC;IAC/C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAE7C,EAAE,CAAC;YACJ,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CACb,wBAAwB,KAAK,gCAAgC;sBAC3D,yDAAyD,CAC5D,CAAC;YACJ,CAAC;YACD,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,C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KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACjC,KAAK;gBACL,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;gBACnC,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The row translators the medical and dental translation layers share:
3
+ * small pure maps from a circular's verbatim rows to canonical points,
4
+ * and the row selectors that pick a scale out of a circular's list. The
5
+ * per-family selection (which scale feeds which grade) lives in the
6
+ * `*-scales.ts` translation layers; these are the pieces generic enough
7
+ * to be shared by both.
8
+ */
9
+ import type { ScalePoint } from './scale-point.js';
10
+ import type { SalaryRange } from './values.js';
11
+ /**
12
+ * An incremental scale with no distinct labels beyond position: the
13
+ * first point is "Minimum", the rest "Point 1", "Point 2", … (the
14
+ * devolved training grades). Input is the salary column, top to bottom.
15
+ */
16
+ export declare const stepped: (salaries: readonly number[]) => readonly ScalePoint[];
17
+ /** One point per row, labelled by the row's printed grade (the GP
18
+ * educator and associate adviser posts). */
19
+ export declare const byGrade: (rows: readonly {
20
+ readonly grade: string;
21
+ readonly salary: number;
22
+ }[]) => readonly ScalePoint[];
23
+ /** One point per row, labelled "Point n" from the printed pay point, with
24
+ * its years of service (Northern Ireland's 2022 SAS scales). */
25
+ export declare const byPayPoint: (rows: readonly {
26
+ readonly payPoint: number;
27
+ readonly salary: number;
28
+ readonly yearsExperience: number;
29
+ }[]) => readonly ScalePoint[];
30
+ /**
31
+ * A scale printed by scale point with years of service (the 2022 specialty
32
+ * doctor and specialist contracts): point 0 is "Minimum", the rest
33
+ * "Point n", and a point's years of experience are its number.
34
+ */
35
+ export declare const byScalePoint: (rows: readonly {
36
+ readonly scalePoint: number;
37
+ readonly salary: number;
38
+ }[]) => readonly ScalePoint[];
39
+ /** A two-point salary range (salaried GP), min then max. */
40
+ export declare const range: (r: SalaryRange) => readonly ScalePoint[];
41
+ /** Plain "Point 1", "Point 2"… labelling (1-based). */
42
+ export declare const numbered: (salaries: readonly number[]) => readonly ScalePoint[];
43
+ /**
44
+ * One point per row, labelled by the row's `stage` (training grades).
45
+ * Carries the row's `nodalPoint` onto the point where the source lists one
46
+ * (the 2016-contract resident scales); rows without it stay stage-only.
47
+ */
48
+ export declare const byStage: (rows: readonly {
49
+ stage: string;
50
+ salary: number;
51
+ nodalPoint?: string;
52
+ }[]) => readonly ScalePoint[];
53
+ /**
54
+ * One point per row, labelled by the row's pay-scale `code`. Carries
55
+ * whichever axis the source lists beside the code, because the code
56
+ * alone is opaque: `yearsExperience` for the SAS scales, `nodalPoint`
57
+ * for locally employed doctors, whose codes England publishes against
58
+ * the 2016-contract points and NOT in code order. Rows with neither
59
+ * (GP educators, closed grades) stay code-only.
60
+ */
61
+ export declare const byCode: (rows: readonly {
62
+ code: string;
63
+ salary: number;
64
+ yearsExperience?: number;
65
+ nodalPoint?: string;
66
+ }[]) => readonly ScalePoint[];
67
+ /** One point per row, labelled "Band {band} Point {point}" (dental spine). */
68
+ export declare const bySpine: (rows: readonly {
69
+ band: string | number;
70
+ point: number;
71
+ salary: number;
72
+ }[]) => readonly ScalePoint[];
73
+ /**
74
+ * The `salaries` of the named incremental scale in a circular's list.
75
+ * Fails loud (at module load) on a mapping key that doesn't match a
76
+ * source scale — a translation-layer typo can't ship silently.
77
+ */
78
+ export declare const scaleSalaries: <T extends {
79
+ salaries: readonly number[];
80
+ }>(rows: readonly T[], match: (r: T) => boolean, key: string) => readonly number[];
81
+ /**
82
+ * The salaries of the row a circular prints under pay-scale `code`, the
83
+ * way the translation layer selects most rows. Throws where no row carries
84
+ * it, which happens at module load, so a code the circular does not print
85
+ * fails every test rather than serving an empty scale.
86
+ */
87
+ export declare const salariesOfCode: <T extends {
88
+ code: string;
89
+ salaries: readonly number[];
90
+ }>(rows: readonly T[], code: string) => readonly number[];
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The row translators the medical and dental translation layers share:
3
+ * small pure maps from a circular's verbatim rows to canonical points,
4
+ * and the row selectors that pick a scale out of a circular's list. The
5
+ * per-family selection (which scale feeds which grade) lives in the
6
+ * `*-scales.ts` translation layers; these are the pieces generic enough
7
+ * to be shared by both.
8
+ */
9
+ /**
10
+ * An incremental scale with no distinct labels beyond position: the
11
+ * first point is "Minimum", the rest "Point 1", "Point 2", … (the
12
+ * devolved training grades). Input is the salary column, top to bottom.
13
+ */
14
+ export const stepped = (salaries) => salaries.map((salary, i) => ({
15
+ label: i === 0 ? 'Minimum' : `Point ${i}`,
16
+ salary,
17
+ }));
18
+ /** One point per row, labelled by the row's printed grade (the GP
19
+ * educator and associate adviser posts). */
20
+ export const byGrade = (rows) => rows.map((r) => ({ label: r.grade, salary: r.salary }));
21
+ /** One point per row, labelled "Point n" from the printed pay point, with
22
+ * its years of service (Northern Ireland's 2022 SAS scales). */
23
+ export const byPayPoint = (rows) => rows.map((r) => ({
24
+ label: `Point ${r.payPoint}`,
25
+ salary: r.salary,
26
+ yearsExperience: r.yearsExperience,
27
+ }));
28
+ /**
29
+ * A scale printed by scale point with years of service (the 2022 specialty
30
+ * doctor and specialist contracts): point 0 is "Minimum", the rest
31
+ * "Point n", and a point's years of experience are its number.
32
+ */
33
+ export const byScalePoint = (rows) => rows.map((r) => ({
34
+ label: r.scalePoint === 0 ? 'Minimum' : `Point ${r.scalePoint}`,
35
+ salary: r.salary,
36
+ yearsExperience: r.scalePoint,
37
+ }));
38
+ /** A two-point salary range (salaried GP), min then max. */
39
+ export const range = (r) => [
40
+ { label: 'Range minimum', salary: r.min },
41
+ { label: 'Range maximum', salary: r.max },
42
+ ];
43
+ /** Plain "Point 1", "Point 2"… labelling (1-based). */
44
+ export const numbered = (salaries) => salaries.map((salary, i) => ({ label: `Point ${i + 1}`, salary }));
45
+ /**
46
+ * One point per row, labelled by the row's `stage` (training grades).
47
+ * Carries the row's `nodalPoint` onto the point where the source lists one
48
+ * (the 2016-contract resident scales); rows without it stay stage-only.
49
+ */
50
+ export const byStage = (rows) => rows.map((r) => ({
51
+ label: r.stage,
52
+ salary: r.salary,
53
+ ...(r.nodalPoint !== undefined ? { nodalPoint: r.nodalPoint } : {}),
54
+ }));
55
+ /**
56
+ * One point per row, labelled by the row's pay-scale `code`. Carries
57
+ * whichever axis the source lists beside the code, because the code
58
+ * alone is opaque: `yearsExperience` for the SAS scales, `nodalPoint`
59
+ * for locally employed doctors, whose codes England publishes against
60
+ * the 2016-contract points and NOT in code order. Rows with neither
61
+ * (GP educators, closed grades) stay code-only.
62
+ */
63
+ export const byCode = (rows) => rows.map((r) => ({
64
+ label: r.code,
65
+ salary: r.salary,
66
+ ...(r.yearsExperience !== undefined
67
+ ? { yearsExperience: r.yearsExperience }
68
+ : {}),
69
+ ...(r.nodalPoint !== undefined
70
+ ? { nodalPoint: r.nodalPoint }
71
+ : {}),
72
+ }));
73
+ /** One point per row, labelled "Band {band} Point {point}" (dental spine). */
74
+ export const bySpine = (rows) => rows.map((r) => ({
75
+ label: `Band ${r.band} Point ${r.point}`,
76
+ salary: r.salary,
77
+ }));
78
+ /**
79
+ * The `salaries` of the named incremental scale in a circular's list.
80
+ * Fails loud (at module load) on a mapping key that doesn't match a
81
+ * source scale — a translation-layer typo can't ship silently.
82
+ */
83
+ export const scaleSalaries = (rows, match, key) => {
84
+ const found = rows.find(match);
85
+ if (!found) {
86
+ throw new Error(`scale-translators: no source scale for "${key}"`);
87
+ }
88
+ return found.salaries;
89
+ };
90
+ /**
91
+ * The salaries of the row a circular prints under pay-scale `code`, the
92
+ * way the translation layer selects most rows. Throws where no row carries
93
+ * it, which happens at module load, so a code the circular does not print
94
+ * fails every test rather than serving an empty scale.
95
+ */
96
+ export const salariesOfCode = (rows, code) => scaleSalaries(rows, (r) => r.code === code, `code ${code}`);
97
+ //# sourceMappingURL=scale-translators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale-translators.js","sourceRo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