@casomoltd/nhs-pay 0.32.0 → 0.34.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 (125) hide show
  1. package/README.md +24 -22
  2. package/dist/afc-band.d.ts +4 -4
  3. package/dist/afc-band.js +4 -4
  4. package/dist/afc-scales.d.ts +89 -60
  5. package/dist/afc-scales.js +166 -182
  6. package/dist/afc-scales.js.map +1 -1
  7. package/dist/allowances.js +11 -11
  8. package/dist/allowances.js.map +1 -1
  9. package/dist/award.d.ts +3 -3
  10. package/dist/award.js +21 -21
  11. package/dist/award.js.map +1 -1
  12. package/dist/circulars/afc-shapes.d.ts +41 -21
  13. package/dist/circulars/afc-shapes.js +9 -8
  14. package/dist/circulars/afc-shapes.js.map +1 -1
  15. package/dist/circulars/england-md-1-2026-r2.d.ts +13 -0
  16. package/dist/circulars/england-md-1-2026-r2.js +13 -0
  17. package/dist/circulars/england-md-1-2026-r2.js.map +1 -1
  18. package/dist/circulars/ni-hsc-afc-06-2025.d.ts +3 -2
  19. package/dist/circulars/ni-hsc-afc-06-2025.js +3 -2
  20. package/dist/circulars/ni-hsc-afc-06-2025.js.map +1 -1
  21. package/dist/circulars/ni-hsc-tc8-05-2025.d.ts +22 -0
  22. package/dist/circulars/ni-hsc-tc8-05-2025.js +22 -0
  23. package/dist/circulars/ni-hsc-tc8-05-2025.js.map +1 -1
  24. package/dist/circulars/scotland-pcs-dd-2025-01.d.ts +20 -0
  25. package/dist/circulars/scotland-pcs-dd-2025-01.js +20 -0
  26. package/dist/circulars/scotland-pcs-dd-2025-01.js.map +1 -1
  27. package/dist/circulars/scotland-pcs-dd-2026-01.d.ts +19 -0
  28. package/dist/circulars/scotland-pcs-dd-2026-01.js +30 -10
  29. package/dist/circulars/scotland-pcs-dd-2026-01.js.map +1 -1
  30. package/dist/circulars/scotland-pcs-dd-2026-02.d.ts +10 -0
  31. package/dist/circulars/scotland-pcs-dd-2026-02.js +10 -0
  32. package/dist/circulars/scotland-pcs-dd-2026-02.js.map +1 -1
  33. package/dist/circulars/wales-mdw-01-2025.d.ts +17 -0
  34. package/dist/circulars/wales-mdw-01-2025.js +17 -0
  35. package/dist/circulars/wales-mdw-01-2025.js.map +1 -1
  36. package/dist/circulars/wales-mdw-01-2026.d.ts +20 -0
  37. package/dist/circulars/wales-mdw-01-2026.js +20 -0
  38. package/dist/circulars/wales-mdw-01-2026.js.map +1 -1
  39. package/dist/commutation.js +3 -2
  40. package/dist/commutation.js.map +1 -1
  41. package/dist/dental-grades.d.ts +25 -0
  42. package/dist/dental-grades.js +25 -0
  43. package/dist/dental-grades.js.map +1 -0
  44. package/dist/dental-scales.d.ts +5 -21
  45. package/dist/dental-scales.js +73 -72
  46. package/dist/dental-scales.js.map +1 -1
  47. package/dist/format.js +3 -2
  48. package/dist/format.js.map +1 -1
  49. package/dist/hcas-pcts.d.ts +1 -1
  50. package/dist/hcas-pcts.js +1 -1
  51. package/dist/hcas-pcts.js.map +1 -1
  52. package/dist/hcas-zone.d.ts +23 -0
  53. package/dist/hcas-zone.js +17 -0
  54. package/dist/hcas-zone.js.map +1 -0
  55. package/dist/hcas.d.ts +26 -18
  56. package/dist/hcas.js +45 -24
  57. package/dist/hcas.js.map +1 -1
  58. package/dist/index.d.ts +25 -16
  59. package/dist/index.js +14 -10
  60. package/dist/index.js.map +1 -1
  61. package/dist/medical-grades.d.ts +33 -0
  62. package/dist/medical-grades.js +33 -0
  63. package/dist/medical-grades.js.map +1 -0
  64. package/dist/medical-scales.d.ts +10 -33
  65. package/dist/medical-scales.js +104 -158
  66. package/dist/medical-scales.js.map +1 -1
  67. package/dist/member/input-period.d.ts +18 -5
  68. package/dist/member/input-period.js +24 -13
  69. package/dist/member/input-period.js.map +1 -1
  70. package/dist/pay-round.js +3 -3
  71. package/dist/pay-round.js.map +1 -1
  72. package/dist/pay-year.d.ts +17 -0
  73. package/dist/pay-year.js +20 -0
  74. package/dist/pay-year.js.map +1 -0
  75. package/dist/pension/ledger.d.ts +7 -0
  76. package/dist/pension/ledger.js +18 -11
  77. package/dist/pension/ledger.js.map +1 -1
  78. package/dist/pension.js +2 -1
  79. package/dist/pension.js.map +1 -1
  80. package/dist/post.d.ts +20 -21
  81. package/dist/post.js +54 -53
  82. package/dist/post.js.map +1 -1
  83. package/dist/published/england-afc.d.ts +72 -0
  84. package/dist/published/england-afc.js +86 -0
  85. package/dist/published/england-afc.js.map +1 -0
  86. package/dist/published/hcas-zones.d.ts +18 -0
  87. package/dist/published/hcas-zones.js +46 -0
  88. package/dist/published/hcas-zones.js.map +1 -0
  89. package/dist/published/wales-living-wage.d.ts +36 -0
  90. package/dist/published/wales-living-wage.js +30 -0
  91. package/dist/published/wales-living-wage.js.map +1 -0
  92. package/dist/regions.d.ts +25 -14
  93. package/dist/regions.js +61 -71
  94. package/dist/regions.js.map +1 -1
  95. package/dist/resolver.d.ts +46 -41
  96. package/dist/resolver.js +70 -142
  97. package/dist/resolver.js.map +1 -1
  98. package/dist/role.d.ts +3 -3
  99. package/dist/scale-point.d.ts +11 -7
  100. package/dist/scale-point.js +29 -1
  101. package/dist/scale-point.js.map +1 -1
  102. package/dist/scale-tables.d.ts +42 -60
  103. package/dist/scale-tables.js +65 -105
  104. package/dist/scale-tables.js.map +1 -1
  105. package/dist/scale-translators.d.ts +90 -0
  106. package/dist/scale-translators.js +97 -0
  107. package/dist/scale-translators.js.map +1 -0
  108. package/dist/scales.d.ts +164 -102
  109. package/dist/scales.js +242 -462
  110. package/dist/scales.js.map +1 -1
  111. package/dist/sources.d.ts +8 -12
  112. package/dist/sources.js +9 -15
  113. package/dist/sources.js.map +1 -1
  114. package/dist/take-home.js +1 -2
  115. package/dist/take-home.js.map +1 -1
  116. package/dist/values.d.ts +10 -3
  117. package/dist/values.js +11 -4
  118. package/dist/values.js.map +1 -1
  119. package/dist/working-week.d.ts +23 -8
  120. package/dist/working-week.js +55 -25
  121. package/dist/working-week.js.map +1 -1
  122. package/package.json +3 -3
  123. package/dist/bands.d.ts +0 -63
  124. package/dist/bands.js +0 -78
  125. package/dist/bands.js.map +0 -1
package/dist/regions.js CHANGED
@@ -1,15 +1,19 @@
1
1
  /**
2
- * AFC region codes — collapse nation + HCAS into
3
- * a single query parameter.
2
+ * AFC region codes: one value that collapses a nation and,
3
+ * in England, an HCAS zone.
4
4
  *
5
5
  * HCAS is England-only and mutually exclusive with
6
- * non-England nations, so one param covers both.
6
+ * non-England nations, so one code covers both. This
7
+ * module owns the mapping both ways: a region's nation and
8
+ * zone, and the region for a nation and zone.
7
9
  *
8
10
  * UI-specific concerns (cookies, URL params, selector
9
11
  * options, zone labels) stay in the consumer.
10
12
  */
11
- import { TAX_REGIONS, NATIONS, } from '@casomoltd/paye-calc';
12
- // ── Region codes ────────────────────────────────
13
+ import { NATION_KEYS, nationToTaxRegion, } from '@casomoltd/paye-calc';
14
+ import { HCAS_ZONE_IDS } from './hcas-zone.js';
15
+ import { invariant } from './errors.js';
16
+ // ── Types ───────────────────────────────────────
13
17
  export const AFC_REGIONS = {
14
18
  ENG: 'eng',
15
19
  ENG_IL: 'eng-il',
@@ -19,85 +23,71 @@ export const AFC_REGIONS = {
19
23
  SCO: 'sco',
20
24
  NI: 'ni',
21
25
  };
26
+ // ── Tables ──────────────────────────────────────
27
+ /** Each HCAS zone's region code. Total over the zones by its type, so a
28
+ * zone with no region fails to compile; a region's own zone is read back
29
+ * from it ({@link afcRegionToHcasZone}), so the pairing is stated once. */
30
+ export const ZONE_TO_REGION = {
31
+ [HCAS_ZONE_IDS.INNER_LONDON]: AFC_REGIONS.ENG_IL,
32
+ [HCAS_ZONE_IDS.OUTER_LONDON]: AFC_REGIONS.ENG_OL,
33
+ [HCAS_ZONE_IDS.FRINGE]: AFC_REGIONS.ENG_FR,
34
+ };
22
35
  const AFC_REGION_ID_LIST = Object.values(AFC_REGIONS);
36
+ /** Each region code's nation. */
37
+ const REGION_NATION = {
38
+ [AFC_REGIONS.ENG]: NATION_KEYS.england,
39
+ [AFC_REGIONS.ENG_IL]: NATION_KEYS.england,
40
+ [AFC_REGIONS.ENG_OL]: NATION_KEYS.england,
41
+ [AFC_REGIONS.ENG_FR]: NATION_KEYS.england,
42
+ [AFC_REGIONS.WAL]: NATION_KEYS.wales,
43
+ [AFC_REGIONS.SCO]: NATION_KEYS.scotland,
44
+ [AFC_REGIONS.NI]: NATION_KEYS.northernIreland,
45
+ };
46
+ /** Each nation's base region: the one with no HCAS zone. */
47
+ const BASE_REGION = {
48
+ [NATION_KEYS.england]: AFC_REGIONS.ENG,
49
+ [NATION_KEYS.wales]: AFC_REGIONS.WAL,
50
+ [NATION_KEYS.scotland]: AFC_REGIONS.SCO,
51
+ [NATION_KEYS.northernIreland]: AFC_REGIONS.NI,
52
+ };
53
+ // ── Functions ───────────────────────────────────
23
54
  /** Type guard for region codes. */
24
55
  export function isAfcRegionId(raw) {
25
56
  return AFC_REGION_ID_LIST.includes(raw);
26
57
  }
27
- const REGION_INFO = {
28
- [AFC_REGIONS.ENG]: {
29
- taxRegion: TAX_REGIONS.rUK,
30
- hcasProp: null,
31
- isWales: false,
32
- },
33
- [AFC_REGIONS.ENG_IL]: {
34
- taxRegion: TAX_REGIONS.rUK,
35
- hcasProp: 'innerLondon',
36
- isWales: false,
37
- },
38
- [AFC_REGIONS.ENG_OL]: {
39
- taxRegion: TAX_REGIONS.rUK,
40
- hcasProp: 'outerLondon',
41
- isWales: false,
42
- },
43
- [AFC_REGIONS.ENG_FR]: {
44
- taxRegion: TAX_REGIONS.rUK,
45
- hcasProp: 'fringe',
46
- isWales: false,
47
- },
48
- [AFC_REGIONS.WAL]: {
49
- taxRegion: TAX_REGIONS.rUK,
50
- hcasProp: null,
51
- isWales: true,
52
- },
53
- [AFC_REGIONS.SCO]: {
54
- taxRegion: TAX_REGIONS.scotland,
55
- hcasProp: null,
56
- isWales: false,
57
- },
58
- [AFC_REGIONS.NI]: {
59
- taxRegion: TAX_REGIONS.rUK,
60
- hcasProp: null,
61
- isWales: false,
62
- },
63
- };
64
- /** Resolve a region code to tax/HCAS/label info. */
58
+ /** Resolve a region code to its tax region and HCAS zone. */
65
59
  export function resolveRegion(id) {
66
- return { id, ...REGION_INFO[id] };
60
+ return {
61
+ id,
62
+ taxRegion: nationToTaxRegion(REGION_NATION[id]),
63
+ zone: afcRegionToHcasZone(id),
64
+ };
67
65
  }
68
- // ── Region → Nation mapping ────────────────
69
- const REGION_TO_NATION = {
70
- [AFC_REGIONS.ENG]: 'england',
71
- [AFC_REGIONS.ENG_IL]: 'england',
72
- [AFC_REGIONS.ENG_OL]: 'england',
73
- [AFC_REGIONS.ENG_FR]: 'england',
74
- [AFC_REGIONS.WAL]: 'wales',
75
- [AFC_REGIONS.SCO]: 'scotland',
76
- [AFC_REGIONS.NI]: 'northern-ireland',
77
- };
78
66
  /** Map an AfC region code to a paye-calc Nation. */
79
67
  export function afcRegionToNation(id) {
80
- return REGION_TO_NATION[id];
68
+ return REGION_NATION[id];
81
69
  }
82
- // ── Zone → Region mapping ─────────────────
83
- export const ZONE_TO_REGION = {
84
- 'inner-london': AFC_REGIONS.ENG_IL,
85
- 'outer-london': AFC_REGIONS.ENG_OL,
86
- fringe: AFC_REGIONS.ENG_FR,
87
- };
88
- // ── Region → Zone mapping ─────────────────
89
- const REGION_TO_ZONE = Object.fromEntries(Object.entries(ZONE_TO_REGION)
90
- .map(([z, r]) => [r, z]));
91
70
  /** Map an AfC region code to its HCAS zone,
92
71
  * or null for non-HCAS regions. */
93
72
  export function afcRegionToHcasZone(id) {
94
- return REGION_TO_ZONE[id] ?? null;
73
+ const zones = Object.keys(ZONE_TO_REGION);
74
+ return zones.find((zone) => ZONE_TO_REGION[zone] === id) ?? null;
75
+ }
76
+ /** A nation's base AfC region: the one with no HCAS supplement, so its
77
+ * scale is the one the nation publishes. */
78
+ export function baseAfcRegion(nation) {
79
+ return BASE_REGION[nation];
95
80
  }
96
- // ── Nation type guard ──────────────────────
97
- const NATION_SET = new Set(Object.keys(NATIONS));
98
- /** Type guard for paye-calc Nation strings. */
99
- export function isNation(raw) {
100
- return typeof raw === 'string'
101
- && NATION_SET.has(raw);
81
+ /**
82
+ * The AfC region for a nation and, in England, an HCAS zone. Throws for a
83
+ * zone outside England: HCAS is England's only, so Wales with a fringe
84
+ * zone is a state the caller should not hold, not one to quietly read as
85
+ * England's fringe.
86
+ */
87
+ export function afcRegionOf(nation, zone) {
88
+ if (zone === null)
89
+ return BASE_REGION[nation];
90
+ invariant(nation === NATION_KEYS.england, `afcRegionOf: ${nation} has no HCAS zone (${zone})`);
91
+ return ZONE_TO_REGION[zone];
102
92
  }
103
93
  //# sourceMappingURL=regions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"regions.js","sourceRoot":"","sources":["../src/regions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,WAAW,EACX,OAAO,GACR,MAAM,sBAAsB,CAAC;AAQ9B,mDAAmD;AAEnD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,EAAE,EAAE,IAAI;CACA,CAAC;AAKX,MAAM,kBAAkB,GACtB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAE7B,mCAAmC;AACnC,MAAM,UAAU,aAAa,CAC3B,GAAW;IAEX,OACE,kBACD,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC;AAYD,MAAM,WAAW,GAGb;IACF,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QACjB,SAAS,EAAE,WAAW,CAAC,GAAG;QAC1B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,KAAK;KACf;IACD,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;QACpB,SAAS,EAAE,WAAW,CAAC,GAAG;QAC1B,QAAQ,EAAE,aAAa;QACvB,OA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CAAC;AAEF,mDAAmD;AAEnD,mCAAmC;AACnC,MAAM,UAAU,aAAa,CAC3B,GAAW;IAEX,OACE,kBACD,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,aAAa,CAC3B,EAAe;IAEf,OAAO;QACL,EAAE;QACF,SAAS,EAAE,iBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAC/C,IAAI,EAAE,mBAAmB,CAAC,EAAE,CAAC;KAC9B,CAAC;AACJ,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,iBAAiB,CAC/B,EAAe;IAEf,OAAO,aAAa,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED;oCACoC;AACpC,MAAM,UAAU,mBAAmB,CACjC,EAAe;IAEf,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAiB,CAAC;IAC1D,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC;AACnE,CAAC;AAED;6CAC6C;AAC7C,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,IAAuB;IAEvB,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9C,SAAS,CAAC,MAAM,KAAK,WAAW,CAAC,OAAO,EACtC,gBAAgB,MAAM,sBAAsB,IAAI,GAAG,CAAC,CAAC;IACvD,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -1,21 +1,50 @@
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 / dental resolvers
5
- * (Phase 2) will read their own, all producing the same
6
- * uniform Post. Polymorphism lives here, not on the Post.
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 type { Nation, PayYear, TaxYear } from '@casomoltd/paye-calc';
13
- import type { AfcBandId } from './scales.js';
12
+ import type { Nation, PayYear } from '@casomoltd/paye-calc';
13
+ import type { AfcBandId } from './afc-band.js';
14
14
  import type { ScalePoint } from './scale-point.js';
15
15
  import type { AfcRegionId } from './regions.js';
16
- import type { MedicalGradeId } from './medical-scales.js';
17
- import type { DentalGradeId } from './dental-scales.js';
16
+ import type { MedicalGradeId } from './medical-grades.js';
17
+ import type { DentalGradeId } from './dental-grades.js';
18
18
  import { Post } from './post.js';
19
+ import type { PostIdentity } from './post.js';
20
+ /**
21
+ * The two years a Post is built from, as {@link PostIdentity} names them:
22
+ * the pay year whose scale a point was read from, and the tax year whose
23
+ * deductions apply. Both are required, for the reason given there.
24
+ */
25
+ export type ScaleYears = Pick<PostIdentity, 'payYear' | 'taxYear'>;
26
+ /** An AfC point the caller holds, and where to price it. */
27
+ export interface AfcPointQuery extends ScaleYears {
28
+ readonly band: AfcBandId;
29
+ readonly point: ScalePoint;
30
+ readonly region: AfcRegionId;
31
+ }
32
+ /** An AfC point named by its label, and where to price it. */
33
+ export interface AfcLabelQuery extends ScaleYears {
34
+ readonly band: AfcBandId;
35
+ readonly pointLabel: string;
36
+ readonly region: AfcRegionId;
37
+ }
38
+ /** A medical or dental point the caller holds, and the Post it prices. */
39
+ export interface GradePointQuery<G extends string> extends PostIdentity {
40
+ readonly grade: G;
41
+ readonly point: ScalePoint;
42
+ }
43
+ /** A medical or dental point named by its label, and the Post it prices. */
44
+ export interface GradeLabelQuery<G extends string> extends PostIdentity {
45
+ readonly grade: G;
46
+ readonly pointLabel: string;
47
+ }
19
48
  /**
20
49
  * The uniform contract every pay family satisfies: build a
21
50
  * Post from a salary, and enumerate what is published. The
@@ -24,8 +53,10 @@ import { Post } from './post.js';
24
53
  * resolver's own interface, not this shared one.
25
54
  */
26
55
  export interface PayScaleResolver<G extends string> {
27
- fromSalary(salary: number, nation: Nation, year: PayYear, taxYear: TaxYear): Post;
28
- /** Grades with a published scale for this nation/year. */
56
+ /** An off-scale Post at a salary, in a nation and both years. */
57
+ fromSalary(salary: number, identity: PostIdentity): Post;
58
+ /** Grades with a published scale for this nation/year. Throws
59
+ * {@link ScaleUnavailable} where the nation publishes none that year. */
29
60
  availableGrades(nation: Nation, year: PayYear): readonly G[];
30
61
  /** Latest PAY year a grade is published for a nation, or null. */
31
62
  latestYearFor(gradeId: G, nation: Nation): PayYear | null;
@@ -34,7 +65,7 @@ export interface PayScaleResolver<G extends string> {
34
65
  * AfC resolver — adds a band + point + region entry. AfC
35
66
  * take-home threads an {@link AfcRegionId} (nation + HCAS
36
67
  * zone collapsed), not a bare Nation, so its scale-point
37
- * path resolves the HCAS / Wales-floor gross itself.
68
+ * path resolves the HCAS gross itself.
38
69
  */
39
70
  export interface AfcResolver extends PayScaleResolver<AfcBandId> {
40
71
  /**
@@ -48,26 +79,9 @@ export interface AfcResolver extends PayScaleResolver<AfcBandId> {
48
79
  * relabelling away from a repeat. A caller holding the point should
49
80
  * not depend on the property.
50
81
  */
51
- fromPoint(band: AfcBandId, point: ScalePoint, region: AfcRegionId,
52
- /** The year whose SCALE the point was read from. */
53
- year: PayYear,
54
- /**
55
- * The year whose tax, NI and pension tiers apply.
56
- *
57
- * REQUIRED, and deliberately not defaulted to `year`. A nation
58
- * whose pay round runs late pays last year's salary under this
59
- * year's deductions, and the contribution tier is set by the
60
- * scheme year, not by the round the salary came from. When this
61
- * defaulted, every caller that simply did not think about it got
62
- * the salary's own year — which is how a Northern Irish reader's
63
- * 2025-26 pay came to be priced at 2025-26 deductions in the
64
- * 2026-27 tax year. Making it explicit costs one argument and
65
- * removes the whole class.
66
- */
67
- taxYear: TaxYear): Post;
68
- fromScalePoint(band: AfcBandId, pointLabel: string, region: AfcRegionId, year: PayYear, taxYear: TaxYear): Post;
82
+ fromPoint(query: AfcPointQuery): Post;
83
+ fromScalePoint(query: AfcLabelQuery): Post;
69
84
  }
70
- export declare const afcResolver: AfcResolver;
71
85
  /**
72
86
  * A basic-pay-by-nation resolver (medical, dental) — like the AfC
73
87
  * resolver, but its scale-point entry threads a bare {@link Nation}
@@ -85,22 +99,13 @@ export interface NationScaleResolver<G extends string> extends PayScaleResolver<
85
99
  * over rather than round-trip through a string that may match
86
100
  * several and throw.
87
101
  */
88
- fromPoint(grade: G, point: ScalePoint, nation: Nation,
89
- /** The year whose SCALE the point was read from. */
90
- year: PayYear,
91
- /**
92
- * The year whose tax, NI and pension tiers apply.
93
- *
94
- * REQUIRED, for the reason given on {@link AfcResolver.fromPoint}:
95
- * defaulting it to the salary's own year is silent, and silence
96
- * is what mispriced a nation whose pay round had run late.
97
- */
98
- taxYear: TaxYear): Post;
99
- fromScalePoint(grade: G, pointLabel: string, nation: Nation, year: PayYear, taxYear: TaxYear): Post;
102
+ fromPoint(query: GradePointQuery<G>): Post;
103
+ fromScalePoint(query: GradeLabelQuery<G>): Post;
100
104
  }
101
105
  /** Medical (doctors) resolver — a grade + point + nation entry. */
102
106
  export type MedicalResolver = NationScaleResolver<MedicalGradeId>;
103
107
  /** Salaried dental resolver — a grade + point + nation entry. */
104
108
  export type DentalResolver = NationScaleResolver<DentalGradeId>;
109
+ export declare const afcResolver: AfcResolver;
105
110
  export declare const medicalResolver: MedicalResolver;
106
111
  export declare const dentalResolver: DentalResolver;
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 / dental resolvers
5
- * (Phase 2) will read their own, all producing the same
6
- * uniform Post. Polymorphism lives here, not on the Post.
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 { afcPayYears } from './scales.js';
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 { getMedicalScales, MEDICAL_PAY_YEARS } from './medical-scales.js';
17
- import { getDentalScales, DENTAL_PAY_YEARS } from './dental-scales.js';
18
- import { AmbiguousScalePoint, ScaleUnavailable } from './errors.js';
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(salary, nation, year, taxYear) {
22
- return Post.fromSalary(salary, nation, year, taxYear);
23
- },
24
- fromPoint(band, point, region, year, taxYear) {
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 scales = getAfcScales(year, nation);
51
- const meta = scales.bands.find((b) => b.band === band);
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).bands.map((b) => b.band);
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
- // Medical & dental scales carry basic pay by nation (no HCAS), so their
86
- // scale-point entry threads a Nation, not an AfC region. Each family
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 family's `getScales`
108
- * accessor and its {@link Role} stamp. Both the medical and dental
109
- * resolvers are this factory with different data and role — the
110
- * polymorphism the design intends, with no per-family machinery.
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(getScales, toRole, years) {
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(salary, nation, year, taxYear) {
115
- return Post.fromSalary(salary, nation, year, taxYear);
116
- },
117
- fromScalePoint(grade, pointLabel, nation, year, taxYear) {
118
- const meta = getScales(year, nation).find((m) => m.grade === grade);
119
- if (!meta) {
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 getScales(year, nation).map((m) => m.grade);
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
- export const medicalResolver = makeNationScaleResolver(getMedicalScales, (grade, point, nation) => ({ kind: 'medical', grade, point, nation }), MEDICAL_PAY_YEARS);
167
- export const dentalResolver = makeNationScaleResolver(getDentalScales, (grade, point, nation) => ({ kind: 'dental', grade, point, nation }), DENTAL_PAY_YEARS);
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
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAC,g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AAY,CAAC,OAAO,EAAE,MAAM,CAAC;KACzE,CAAC;AACJ,CAAC;AAED;;;;;;;;;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 './scales.js';
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-scales.js';
16
- import type { DentalGradeId } from './dental-scales.js';
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 {
@@ -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;