@casomoltd/nhs-pay 0.19.4 → 0.21.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 (90) hide show
  1. package/README.md +95 -18
  2. package/dist/afc-scales.d.ts +14 -7
  3. package/dist/afc-scales.js +19 -19
  4. package/dist/afc-scales.js.map +1 -1
  5. package/dist/bands.d.ts +2 -2
  6. package/dist/commutation.d.ts +49 -5
  7. package/dist/commutation.js +124 -43
  8. package/dist/commutation.js.map +1 -1
  9. package/dist/dates.d.ts +2 -0
  10. package/dist/dates.js +4 -0
  11. package/dist/dates.js.map +1 -1
  12. package/dist/errors.d.ts +70 -12
  13. package/dist/errors.js +85 -19
  14. package/dist/errors.js.map +1 -1
  15. package/dist/factor-basis.d.ts +87 -0
  16. package/dist/factor-basis.js +99 -0
  17. package/dist/factor-basis.js.map +1 -0
  18. package/dist/gad/erf-1-401-2023-06-30.d.ts +47 -0
  19. package/dist/gad/erf-1-401-2023-06-30.js +73 -0
  20. package/dist/gad/erf-1-401-2023-06-30.js.map +1 -0
  21. package/dist/gad/erf-1-402-2023-06-30.d.ts +48 -0
  22. package/dist/gad/erf-1-402-2023-06-30.js +84 -0
  23. package/dist/gad/erf-1-402-2023-06-30.js.map +1 -0
  24. package/dist/gad/erf-1-407-2023-06-30.d.ts +47 -0
  25. package/dist/gad/erf-1-407-2023-06-30.js +73 -0
  26. package/dist/gad/erf-1-407-2023-06-30.js.map +1 -0
  27. package/dist/gad/erf-2023-06-30.d.ts +3 -0
  28. package/dist/gad/erf-2023-06-30.js +1 -0
  29. package/dist/gad/erf-2023-06-30.js.map +1 -1
  30. package/dist/gad/factor-table.d.ts +62 -31
  31. package/dist/gad/factor-table.js +67 -34
  32. package/dist/gad/factor-table.js.map +1 -1
  33. package/dist/gad/lrf-2-416-2023-06-30.d.ts +46 -0
  34. package/dist/gad/lrf-2-416-2023-06-30.js +72 -0
  35. package/dist/gad/lrf-2-416-2023-06-30.js.map +1 -0
  36. package/dist/gad/lrf-2023-06-30.d.ts +3 -0
  37. package/dist/gad/lrf-2023-06-30.js +1 -0
  38. package/dist/gad/lrf-2023-06-30.js.map +1 -1
  39. package/dist/gad/promotional-scale-2020.d.ts +37 -0
  40. package/dist/gad/promotional-scale-2020.js +38 -0
  41. package/dist/gad/promotional-scale-2020.js.map +1 -0
  42. package/dist/index.d.ts +17 -4
  43. package/dist/index.js +22 -13
  44. package/dist/index.js.map +1 -1
  45. package/dist/iso-date.d.ts +7 -0
  46. package/dist/iso-date.js +11 -0
  47. package/dist/iso-date.js.map +1 -1
  48. package/dist/member-benefits.d.ts +237 -0
  49. package/dist/member-benefits.js +440 -0
  50. package/dist/member-benefits.js.map +1 -0
  51. package/dist/pay-path.d.ts +70 -0
  52. package/dist/pay-path.js +155 -0
  53. package/dist/pay-path.js.map +1 -0
  54. package/dist/pension/curve.d.ts +74 -0
  55. package/dist/pension/curve.js +134 -0
  56. package/dist/pension/curve.js.map +1 -0
  57. package/dist/pension/history.js +3 -3
  58. package/dist/pension/history.js.map +1 -1
  59. package/dist/pension/ledger.d.ts +71 -31
  60. package/dist/pension/ledger.js +41 -6
  61. package/dist/pension/ledger.js.map +1 -1
  62. package/dist/pension/money.d.ts +23 -6
  63. package/dist/pension/money.js +23 -1
  64. package/dist/pension/money.js.map +1 -1
  65. package/dist/pension/uplift.d.ts +23 -0
  66. package/dist/pension/uplift.js +34 -1
  67. package/dist/pension/uplift.js.map +1 -1
  68. package/dist/pension-projection.d.ts +54 -52
  69. package/dist/pension-projection.js +65 -219
  70. package/dist/pension-projection.js.map +1 -1
  71. package/dist/scale-point.d.ts +11 -1
  72. package/dist/scales.d.ts +9 -9
  73. package/dist/scales.js +68 -67
  74. package/dist/scales.js.map +1 -1
  75. package/dist/sections/final-salary.d.ts +97 -0
  76. package/dist/sections/final-salary.js +99 -0
  77. package/dist/sections/final-salary.js.map +1 -0
  78. package/dist/sections/section-1995.d.ts +20 -0
  79. package/dist/sections/section-1995.js +52 -0
  80. package/dist/sections/section-1995.js.map +1 -0
  81. package/dist/sections/section-2008.d.ts +16 -0
  82. package/dist/sections/section-2008.js +44 -0
  83. package/dist/sections/section-2008.js.map +1 -0
  84. package/dist/sections/section-2015.d.ts +43 -0
  85. package/dist/sections/section-2015.js +57 -0
  86. package/dist/sections/section-2015.js.map +1 -0
  87. package/dist/values.d.ts +4 -5
  88. package/dist/values.js +4 -5
  89. package/dist/values.js.map +1 -1
  90. package/package.json +9 -5
package/README.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  NHS pay scales — Agenda for Change plus medical & dental —
4
4
  with pension tiers, regions, HCAS supplements, and a take-home
5
- calculator. Built on top of `@casomoltd/paye-calc`.
5
+ calculator built on top of `@casomoltd/paye-calc`. And a member's
6
+ NHS pension across the 1995, 2008 and 2015 Sections: final salary
7
+ and career average, the McCloud remedy window valued on either
8
+ basis, early and late retirement factors, and tax-free cash across
9
+ the whole drawing.
6
10
 
7
11
  See [`docs/pay-frameworks.md`](docs/pay-frameworks.md) for the domain
8
12
  model — the pay frameworks (AfC, medical, dental, VSM), the shared
@@ -40,30 +44,42 @@ dependency.
40
44
  ### Look up a band's salary range
41
45
 
42
46
  ```ts
43
- import {getAfcScales} from '@casomoltd/nhs-pay';
47
+ import {AFC_CURRENT_YEAR, getAfcScales} from '@casomoltd/nhs-pay';
44
48
 
45
- const {bands} = getAfcScales();
49
+ // A scale belongs to a pay year and a nation; neither has a default.
50
+ const {bands} = getAfcScales(AFC_CURRENT_YEAR, 'england');
46
51
  const band5 = bands.find((b) => b.band === '5')!;
47
- console.log(band5.salaryMin); // entry salary
48
- console.log(band5.salaryMax); // top of band
49
- console.log(band5.points); // all pay points
52
+ console.log(band5.salary.min); // entry salary
53
+ console.log(band5.salary.max); // top of band
54
+ console.log(band5.points); // all pay points
50
55
  ```
51
56
 
52
57
  ### Calculate take-home for a Band 5 nurse
53
58
 
54
59
  ```ts
55
60
  import {
56
- nhsTakeHome,
61
+ AFC_CURRENT_YEAR,
57
62
  getAfcScales,
63
+ getPensionTiers,
64
+ nationToTaxRegion,
65
+ nhsTakeHome,
58
66
  pensionTierRate,
59
67
  } from '@casomoltd/nhs-pay';
68
+ import {taxYear} from '@casomoltd/paye-calc';
60
69
 
61
- const {bands, pensionTiers} = getAfcScales();
70
+ const year = AFC_CURRENT_YEAR;
71
+ const {bands} = getAfcScales(year, 'england');
62
72
  const band5 = bands.find((b) => b.band === '5')!;
63
- const salary = band5.salaryMin;
64
- const rate = pensionTierRate(salary, pensionTiers);
65
-
66
- const thp = nhsTakeHome(salary, rate / 100);
73
+ const salary = band5.salary.min;
74
+ // The contribution tiers are their own dataset, fetched by year and nation.
75
+ const tax = taxYear(year);
76
+ const rate = pensionTierRate(salary, getPensionTiers(tax, 'england'));
77
+
78
+ // The tax year and region are required: a default would silently tax a
79
+ // Scottish member at rUK rates.
80
+ const thp = nhsTakeHome(
81
+ salary, rate / 100, tax, nationToTaxRegion('england'),
82
+ );
67
83
  console.log(thp.net); // annual net
68
84
  console.log(thp.incomeTax); // annual tax
69
85
  console.log(thp.nationalInsurance); // annual NI
@@ -74,12 +90,13 @@ console.log(thp.pensionDeduction); // annual pension
74
90
 
75
91
  ```ts
76
92
  import {
93
+ AFC_CURRENT_YEAR,
77
94
  getAfcScales,
78
95
  calculateHcasSupplement,
79
96
  } from '@casomoltd/nhs-pay';
80
97
 
81
- const {bands, hcas} = getAfcScales();
82
- const base = bands[0].salaryMin;
98
+ const {bands, hcas} = getAfcScales(AFC_CURRENT_YEAR, 'england');
99
+ const base = bands[0].salary.min;
83
100
  const supplement = calculateHcasSupplement(
84
101
  base, hcas.innerLondon,
85
102
  );
@@ -129,7 +146,64 @@ consultant scale is 20 payroll steps over 5 threshold labels, so
129
146
  dental grades. Both fail loud (`ScaleUnavailable`) for an
130
147
  unpublished nation/year or grade rather than defaulting.
131
148
 
132
- ### Project a 2015-scheme pension
149
+ ### Value a member's pension across sections
150
+
151
+ ```ts
152
+ import {SECTIONS, isoDate, memberBenefits} from '@casomoltd/nhs-pay';
153
+
154
+ // Built once from the member; `today` pins the date the figures
155
+ // are as at, so they reproduce.
156
+ const benefits = memberBenefits(
157
+ {
158
+ dateOfBirth: isoDate('1979-01-01'),
159
+ service: [
160
+ {section: SECTIONS.s1995, joined: isoDate('2004-04-01'),
161
+ left: isoDate('2022-03-31')},
162
+ {section: SECTIONS.s2015, joined: isoDate('2022-04-01'),
163
+ left: null},
164
+ ],
165
+ pay: {
166
+ declared: [],
167
+ current: {todaysMoney: 51932, asAt: isoDate('2026-09-01')},
168
+ ladder: null, // or the member's AfC band points and current point
169
+ },
170
+ statement: null, // or a 2015 Section balance off a statement
171
+ },
172
+ {assumedCpi: 0.02},
173
+ new Date(2026, 8, 23),
174
+ );
175
+
176
+ benefits.remedy; // true: in service by 31 March 2012 and after 2015
177
+ benefits.now(); // held today, the remedy window on the legacy basis
178
+
179
+ // Asked once per option. Every section is drawn on one date.
180
+ for (const kind of ['legacy-basis', 'section-2015-basis'] as const) {
181
+ const position = benefits.at({
182
+ leaving: isoDate('2039-09-30'),
183
+ drawing: isoDate('2039-09-30'),
184
+ remedy: {kind},
185
+ cash: {kind: 'maximum'},
186
+ });
187
+ position.awards; // one per section and basis, each factored
188
+ position.crystallised; // the pension and automatic lump sum, summed
189
+ position.cash; // the cash taken across the whole
190
+ }
191
+ ```
192
+
193
+ Each section keeps its own rules — denominator, pay measure,
194
+ pension age, lump sum, factors — so no caller can combine them
195
+ into one the scheme lacks. Pay comes from the member's pay path
196
+ (`promotionalIndex` is GAD's curve behind it). Service the library
197
+ does not model, such as a break, is refused with
198
+ `BenefitNotModelled` and a `code` to branch on; `NOT_MODELLED`
199
+ links each code to the issue tracking it. See
200
+ [*A member's benefits across sections*](docs/how-it-works.md#a-members-benefits-across-sections).
201
+
202
+ ### Project a 2015 Section pension on flat pay
203
+
204
+ **Deprecated.** `projectPension` is kept for this flat-pay question
205
+ until [#21](https://github.com/casomoltd/nhs-pay/issues/21); for a
206
+ member across sections, use `memberBenefits` above.
133
207
 
134
208
  ```ts
135
209
  import {
@@ -237,13 +311,16 @@ Table A25 (AfC 2025/26 data for England, NI, Wales).
237
311
  [scales-2627]: https://www.nhsemployers.org/articles/pay-scales-202627
238
312
  [nhsprb-39]: https://assets.publishing.service.gov.uk/media/698df41175466636847f6a93/NHSPRB_39th_Report_2026.pdf
239
313
 
240
- ### 2015 CARE pension projection
314
+ ### NHS pension
241
315
 
242
316
  | Data | Source |
243
317
  | ---- | ------ |
244
318
  | September CPI + in-service rate | [HM Treasury Revaluation Orders][sis], one SI per year |
245
- | Accrual rate, NPA | NHSBSA 2015 Members' Guide (V13) |
246
- | ERF / LRF factors | GAD NHS EW consolidated factor workbook |
319
+ | 2015 Section accrual rate, NPA | NHSBSA 2015 Members' Guide (V13) |
320
+ | 1995 and 2008 Sections' denominators, pay measures, lump sum | SI 1995/300 and SI 2008/653, as [`how-it-works.md`](docs/how-it-works.md) cites them |
321
+ | McCloud remedy eligibility and window | Public Service Pensions and Judicial Offices Act 2022 ss.1–2; rollback by SI 2023/985 |
322
+ | ERF / LRF factors: 0-420, 0-421, 1-401, 1-402, 1-407, 2-416 | GAD NHS EW consolidated factor workbook |
323
+ | Promotional pay index | GAD, summary of the 2020 valuation assumptions, page 3 |
247
324
  | Commutation rate (£12 : £1) | NHSBSA Key Notes — 2015 Scheme Estimates (V2) |
248
325
  | Permitted maximum (lowest of three limbs) | [Sch 29 Finance Act 2004 para 2][sch29] |
249
326
  | Applicable amount, defined benefits, `(A + (B × C)) / 4` | [Sch 29 Finance Act 2004 para 2C][sch29p2c] |
@@ -4,7 +4,7 @@
4
4
  * The counterpart to `medical-scales.ts` for Agenda for Change. The
5
5
  * verbatim transcriptions in `src/circulars/*` hold each publisher's
6
6
  * own table shape; this module maps them to the uniform
7
- * `Record<AfcBandId, ScalePoint[]>` the rest of the library speaks.
7
+ * `Record<AfcBandId, SteppedPoint[]>` the rest of the library speaks.
8
8
  *
9
9
  * **England is a deliberate exception and stays in `scales.ts`.** It
10
10
  * publishes no AfC circular — its scales are an NHS Employers web page
@@ -33,7 +33,7 @@
33
33
  import type { Nation, PayYear } from '@casomoltd/paye-calc';
34
34
  import type { DocumentSource } from './document-source.js';
35
35
  import type { AfcBandId } from './afc-band.js';
36
- import type { ScalePoint } from './scale-point.js';
36
+ import type { SteppedPoint } from './scale-point.js';
37
37
  /** Band 1 as a nation publishes it, for the one nation still paying it
38
38
  * to new entrants. */
39
39
  export interface AfcBand1 {
@@ -63,9 +63,16 @@ export interface AfcBand1Published extends AfcBand1 {
63
63
  * added to it.
64
64
  */
65
65
  export declare function afcBand1(year: PayYear, nation: Nation): AfcBand1Published | undefined;
66
- export declare const WALES_SCALES_2025_26: Record<AfcBandId, ScalePoint[]>;
67
- export declare const WALES_SCALES_2026_27: Record<AfcBandId, ScalePoint[]>;
68
- export declare const NI_SCALES_2025_26: Record<AfcBandId, ScalePoint[]>;
66
+ /**
67
+ * An Agenda for Change point from the year of service it is first
68
+ * reached in: the label every nation's scale prints, and the same year
69
+ * as a number, so a reader that needs the timing never has to parse it
70
+ * back out of the label. The one producer of both, for all four nations.
71
+ */
72
+ export declare function afcPoint(year: number, isTop: boolean, salary: number): SteppedPoint;
73
+ export declare const WALES_SCALES_2025_26: Record<AfcBandId, SteppedPoint[]>;
74
+ export declare const WALES_SCALES_2026_27: Record<AfcBandId, SteppedPoint[]>;
75
+ export declare const NI_SCALES_2025_26: Record<AfcBandId, SteppedPoint[]>;
69
76
  /**
70
77
  * Scotland 2026-27, from Annex C.
71
78
  *
@@ -74,7 +81,7 @@ export declare const NI_SCALES_2025_26: Record<AfcBandId, ScalePoint[]>;
74
81
  * number, which cannot produce a label — `scotlandAnnexB` below exists
75
82
  * so a fixture can check the two annexes agree.
76
83
  */
77
- export declare const SCOTLAND_SCALES_2026_27: Record<AfcBandId, ScalePoint[]>;
84
+ export declare const SCOTLAND_SCALES_2026_27: Record<AfcBandId, SteppedPoint[]>;
78
85
  /**
79
86
  * Annex B's salaries for a year, keyed by band, in printed order.
80
87
  *
@@ -95,4 +102,4 @@ export declare function scotlandAnnexB(year: '2025-26' | '2026-27'): Map<AfcBand
95
102
  * publishes twice is faithful; re-typing the same increments would
96
103
  * only add a second place to mistype them.
97
104
  */
98
- export declare const SCOTLAND_SCALES_2025_26: Record<AfcBandId, ScalePoint[]>;
105
+ export declare const SCOTLAND_SCALES_2025_26: Record<AfcBandId, SteppedPoint[]>;
@@ -4,7 +4,7 @@
4
4
  * The counterpart to `medical-scales.ts` for Agenda for Change. The
5
5
  * verbatim transcriptions in `src/circulars/*` hold each publisher's
6
6
  * own table shape; this module maps them to the uniform
7
- * `Record<AfcBandId, ScalePoint[]>` the rest of the library speaks.
7
+ * `Record<AfcBandId, SteppedPoint[]>` the rest of the library speaks.
8
8
  *
9
9
  * **England is a deliberate exception and stays in `scales.ts`.** It
10
10
  * publishes no AfC circular — its scales are an NHS Employers web page
@@ -152,9 +152,18 @@ function bandIdOf(printed) {
152
152
  invariant(id !== undefined, `afc-scales: no band id for the printed band "${printed}"`);
153
153
  return id;
154
154
  }
155
- /** A point's label from the year of service it is first reached in. */
156
- function yearLabelAt(year, isTop) {
157
- return isTop ? `Year ${year}+` : `Year ${year}`;
155
+ /**
156
+ * An Agenda for Change point from the year of service it is first
157
+ * reached in: the label every nation's scale prints, and the same year
158
+ * as a number, so a reader that needs the timing never has to parse it
159
+ * back out of the label. The one producer of both, for all four nations.
160
+ */
161
+ export function afcPoint(year, isTop, salary) {
162
+ return {
163
+ label: isTop ? `Year ${year}+` : `Year ${year}`,
164
+ salary,
165
+ yearsExperience: year - 1,
166
+ };
158
167
  }
159
168
  /**
160
169
  * A stepped row → its points.
@@ -165,16 +174,10 @@ function yearLabelAt(year, isTop) {
165
174
  function pointsFromStepped(row) {
166
175
  const points = [];
167
176
  let year = 1;
168
- points.push({
169
- label: yearLabelAt(year, false),
170
- salary: row.entry,
171
- });
177
+ points.push(afcPoint(year, false, row.entry));
172
178
  if (row.intermediate !== undefined) {
173
179
  year += row.yearsToNext;
174
- points.push({
175
- label: yearLabelAt(year, false),
176
- salary: row.intermediate,
177
- });
180
+ points.push(afcPoint(year, false, row.intermediate));
178
181
  invariant(row.yearsToTop !== undefined, `afc-scales: ${row.band} prints an intermediate step with no `
179
182
  + 'interval to the top');
180
183
  year += row.yearsToTop;
@@ -182,14 +185,14 @@ function pointsFromStepped(row) {
182
185
  else {
183
186
  year += row.yearsToNext;
184
187
  }
185
- points.push({ label: yearLabelAt(year, true), salary: row.top });
188
+ points.push(afcPoint(year, true, row.top));
186
189
  return points;
187
190
  }
188
191
  /** A flat row → its single point. */
189
192
  function pointsFromFlat(row) {
190
193
  // Year 1 without a `+`: the circular prints one figure and no
191
194
  // progression, so there is no service beyond the point to signal.
192
- return [{ label: 'Year 1', salary: row.salary }];
195
+ return [afcPoint(1, false, row.salary)];
193
196
  }
194
197
  /**
195
198
  * Scotland's Annex C → points.
@@ -207,10 +210,7 @@ function pointsFromJourney(rows) {
207
210
  }
208
211
  }
209
212
  invariant(runs.length > 0, 'afc-scales: a pay journey with no increments');
210
- return runs.map((run, i) => ({
211
- label: yearLabelAt(run.year, i === runs.length - 1),
212
- salary: run.salary,
213
- }));
213
+ return runs.map((run, i) => afcPoint(run.year, i === runs.length - 1, run.salary));
214
214
  }
215
215
  /** Every band a circular prints, keyed by id. */
216
216
  function scalesFrom(flat, stepped) {
@@ -315,7 +315,7 @@ export const SCOTLAND_SCALES_2025_26 = (() => {
315
315
  && yearSalaries.length === points.length, `afc-scales: Scotland ${band} has ${points.length} points in `
316
316
  + `Annex C but ${yearSalaries?.length ?? 0} in Annex B 2025-26`);
317
317
  out[band] = points.map((point, i) => ({
318
- label: point.label,
318
+ ...point,
319
319
  salary: yearSalaries[i],
320
320
  }));
321
321
  }
@@ -1 +1 @@
1
- {"version":3,"file":"afc-scales.js","sourceRoot":"","sources":["../src/afc-scales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG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,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,SAAS,CACP,YAAY,KAAK,SAAS;eACvB,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EACxC,wBAAwB,IAAI,QAAQ,MAAM,CAAC,MAAM,aAAa;cAC5D,eAAe,YAAY,EAAE,MAAM,IAAI,CAAC,qBAAqB,CAChE,CAAC;QACF,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACpC,GAAG,KAAK;YACR,MAAM,EAAE,YAAY,CAAC,CAAC,CAAE;SACzB,CAAC,CAAC,CAAC;IACN,CAAC;IACD,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC,EAAE,CAAC"}
package/dist/bands.d.ts CHANGED
@@ -9,12 +9,12 @@
9
9
  */
10
10
  import type { PayYear, Nation } from '@casomoltd/paye-calc';
11
11
  import type { AfcBandId, HcasZones } from './scales.js';
12
- import type { ScalePoint } from './scale-point.js';
12
+ import type { SteppedPoint } from './scale-point.js';
13
13
  import type { DocumentSource } from './document-source.js';
14
14
  import type { SalaryRange } from './values.js';
15
15
  export interface AfcBandMeta {
16
16
  band: AfcBandId;
17
- points: ScalePoint[];
17
+ points: SteppedPoint[];
18
18
  salary: SalaryRange;
19
19
  /** The document that publishes these figures for this nation and
20
20
  * year — the same value across a nation's bands, because one
@@ -5,11 +5,12 @@
5
5
  * Separate from the projection because it IS separate: nothing
6
6
  * in `pension-projection.ts` calls into here and the ledger
7
7
  * applies no commutation. It is a choice taken AT retirement, on
8
- * a pension the projection has already finished producing. It
9
- * borrows one thing, by type only: the `Prices` the projection
10
- * ran with, so the allowance is carried forward at the SAME
11
- * assumption the pension was projected at and cannot silently
12
- * use another.
8
+ * a pension already produced. It borrows two types from the
9
+ * pension layer: `ProjectionMoney`, the pair every figure travels
10
+ * as, and the `Prices` the projection ran with, so the allowance
11
+ * is carried forward at the SAME assumption the pension was
12
+ * projected at and cannot silently use another. `memberBenefits`
13
+ * calls {@link cashAt} across every section's crystallised total.
13
14
  *
14
15
  * ── Only one figure here is an NHS rule ─────────────
15
16
  *
@@ -329,3 +330,46 @@ export interface CommutationResult {
329
330
  * the pension at retirement after any factor.
330
331
  */
331
332
  export declare function commute(pension: ProjectionMoney, fraction: number, limits: CommutationLimits): CommutationResult;
333
+ /**
334
+ * What a member takes as cash when every section is drawn together:
335
+ * one total, because the scheme's rate is £12 for each £1 of pension
336
+ * in every section and the limit is a quarter of the capital value of
337
+ * everything crystallised. So nothing about the answer depends on
338
+ * which section the cash comes from, and no source is modelled.
339
+ *
340
+ * - `automatic-only`: the 1995 Section's automatic lump sum and
341
+ * nothing more — nil where the member holds none.
342
+ * - `maximum`: up to the permitted maximum, which counts the
343
+ * automatic lump sum, and never less than it.
344
+ * - `amount`: a stated total, the automatic lump sum included, in
345
+ * today's money — the field says which ruler, because a bare amount
346
+ * could be either.
347
+ */
348
+ export declare const CASH_CHOICES: {
349
+ readonly automaticOnly: "automatic-only";
350
+ readonly maximum: "maximum";
351
+ readonly amount: "amount";
352
+ };
353
+ export type CashChoice = {
354
+ readonly kind: typeof CASH_CHOICES.automaticOnly;
355
+ } | {
356
+ readonly kind: typeof CASH_CHOICES.maximum;
357
+ } | {
358
+ readonly kind: typeof CASH_CHOICES.amount;
359
+ readonly todaysMoney: number;
360
+ };
361
+ /**
362
+ * The cash at a drawing over the crystallised total. `lumpSum` in the
363
+ * result is ALL the cash, the automatic lump sum included, and
364
+ * `pensionGivenUp` is only what the cash above it cost.
365
+ *
366
+ * On `maximum` the automatic lump sum is paid even where the Lump Sum
367
+ * Allowance is below it, so `lumpSum` can exceed `limit.amount` there:
368
+ * the excess is taxed rather than refused, and `limit` still says what
369
+ * was tax-free.
370
+ *
371
+ * Throws RangeError for a stated amount below the automatic lump sum,
372
+ * which is paid whether or not it is asked for, or above the permitted
373
+ * maximum, which the scheme does not pay.
374
+ */
375
+ export declare function cashAt(pension: ProjectionMoney, automatic: ProjectionMoney, choice: CashChoice, limits: CommutationLimits): CommutationResult;
@@ -5,11 +5,12 @@
5
5
  * Separate from the projection because it IS separate: nothing
6
6
  * in `pension-projection.ts` calls into here and the ledger
7
7
  * applies no commutation. It is a choice taken AT retirement, on
8
- * a pension the projection has already finished producing. It
9
- * borrows one thing, by type only: the `Prices` the projection
10
- * ran with, so the allowance is carried forward at the SAME
11
- * assumption the pension was projected at and cannot silently
12
- * use another.
8
+ * a pension already produced. It borrows two types from the
9
+ * pension layer: `ProjectionMoney`, the pair every figure travels
10
+ * as, and the `Prices` the projection ran with, so the allowance
11
+ * is carried forward at the SAME assumption the pension was
12
+ * projected at and cannot silently use another. `memberBenefits`
13
+ * calls {@link cashAt} across every section's crystallised total.
13
14
  *
14
15
  * ── Only one figure here is an NHS rule ─────────────
15
16
  *
@@ -23,6 +24,7 @@
23
24
  * scheme-neutral home without a redesign.
24
25
  */
25
26
  import { invariant } from './errors.js';
27
+ import { divideMoney, minusMoney, moneyAt } from './pension/money.js';
26
28
  // ── The scheme's own rule ───────────────────────────
27
29
  /**
28
30
  * Commutation: £12 lump sum per £1 of annual pension given up.
@@ -207,8 +209,15 @@ export function nhsCommutationLimits(prices) {
207
209
  *
208
210
  * L = c × (v × (P − L/f) + L)
209
211
  *
210
- * for L gives the expression below. Written from the named
211
- * constants rather than from its rearrangement — the familiar
212
+ * for L gives the expression below. With an automatic lump sum A
213
+ * already paid, only the cash above it gives up pension:
214
+ *
215
+ * L = c × (v × (P − (L − A)/f) + L)
216
+ *
217
+ * which is the same solution with `P + A/f` in place of `P` — on
218
+ * today's constants `(60P + 5A)/14`, and `30P/7` where A is nothing.
219
+ *
220
+ * Written from the named constants rather than from its rearrangement — the familiar
212
221
  * `(20P) / (3 + 20/f)` is this same solution with `c = 0.25`
213
222
  * already substituted in, which hides the one number a reader
214
223
  * would want to check.
@@ -217,19 +226,20 @@ export function nhsCommutationLimits(prices) {
217
226
  * both money arguments must already be in that ruler. Exporting
218
227
  * it would put a pair of bare, ruler-less numbers on the public
219
228
  * API — the very thing {@link DatedAmount} exists to prevent.
220
- * Consumers get both rulers' limits from {@link commute}.
229
+ * Callers get both rulers' limits from {@link commute}, and from
230
+ * {@link cashAt} through a `Position`, via {@link limitsIn}.
221
231
  */
222
- function lumpSumLimit({ pension, allowance, commutationFactor }) {
232
+ function lumpSumLimit({ pension, automatic, allowance, commutationFactor }) {
223
233
  if (commutationFactor <= 0) {
224
234
  throw new RangeError(`Commutation factor must be positive, got `
225
235
  + `${commutationFactor}`);
226
236
  }
227
- if (pension < 0 || allowance < 0) {
228
- throw new RangeError(`Pension and allowance must be non-negative, got `
229
- + `${pension} and ${allowance}`);
237
+ if (pension < 0 || allowance < 0 || automatic < 0) {
238
+ throw new RangeError(`Pension, automatic lump sum and allowance must be `
239
+ + `non-negative, got ${pension}, ${automatic} and ${allowance}`);
230
240
  }
231
241
  const cap = HMRC_LUMP_SUM_CAP_PCT / 100;
232
- const schemeMax = (VALUATION_FACTOR * cap * pension)
242
+ const schemeMax = (VALUATION_FACTOR * cap * (pension + automatic / commutationFactor))
233
243
  / (1 - cap + (VALUATION_FACTOR * cap) / commutationFactor);
234
244
  // One comparison decides both the figure and the reason, so
235
245
  // the two cannot drift into disagreeing.
@@ -246,7 +256,8 @@ function lumpSumLimit({ pension, allowance, commutationFactor }) {
246
256
  The tolerance is not slack: at the scheme limb the two sides
247
257
  are EQUAL, and float leaves them differing by up to ~6e-11
248
258
  in either direction across the realistic range. */
249
- const capitalValue = VALUATION_FACTOR * (pension - amount / commutationFactor)
259
+ const capitalValue = VALUATION_FACTOR
260
+ * (pension - (amount - automatic) / commutationFactor)
250
261
  + amount;
251
262
  invariant(amount - cap * capitalValue <= Math.abs(capitalValue) * 1e-9, `Lump sum ${amount} exceeds ${HMRC_LUMP_SUM_CAP_PCT}% of `
252
263
  + `capital value ${capitalValue} — the fixed point is wrong`);
@@ -283,42 +294,112 @@ export function commute(pension, fraction, limits) {
283
294
  // see the note at the top of errors.ts.
284
295
  throw new RangeError(`Commutation fraction must be 0–1, got ${fraction}`);
285
296
  }
286
- const { allowance, prices, commutationFactor } = limits;
287
- // The allowance is a real-terms constant: the today's-money
288
- // run tests its stated value, the cash run tests the same cap
289
- // carried to the pension's own date.
290
- const today = lumpSumLimit({
291
- pension: pension.real,
292
- // Into the ruler the today's-money reading is anchored in —
293
- // the run date. Usually the identity, because that is where
294
- // a caller states the allowance; not assumed to be.
295
- allowance: prices.valueAt(allowance.amount, allowance.asAt, prices.asOf),
296
- commutationFactor,
297
- });
298
- const cash = lumpSumLimit({
299
- pension: pension.nominal,
300
- allowance: prices.valueAt(allowance.amount, allowance.asAt, pension.asAt),
301
- commutationFactor,
302
- });
303
- /* Takes the object, not two same-typed positional numbers: a
304
- transposition would swap the rulers silently. */
305
- const pair = (m) => ({ ...m, asAt: pension.asAt });
306
- const lumpSum = pair({
297
+ const { commutationFactor } = limits;
298
+ const nothing = moneyAt({ nominal: 0, real: 0 }, pension.asAt);
299
+ const { today, cash } = limitsIn(pension, nothing, limits);
300
+ const lumpSum = moneyAt({
307
301
  real: today.amount * fraction,
308
302
  nominal: cash.amount * fraction,
309
- });
310
- const pensionGivenUp = pair({
311
- real: lumpSum.real / commutationFactor,
312
- nominal: lumpSum.nominal / commutationFactor,
313
- });
303
+ }, pension.asAt);
304
+ const pensionGivenUp = divideMoney(lumpSum, commutationFactor);
314
305
  return {
315
306
  lumpSum,
316
307
  pensionGivenUp,
317
- residualPension: pair({
318
- real: pension.real - pensionGivenUp.real,
319
- nominal: pension.nominal - pensionGivenUp.nominal,
308
+ residualPension: minusMoney(pension, pensionGivenUp),
309
+ limit: { real: today, nominal: cash },
310
+ };
311
+ }
312
+ // ── Cash across a whole drawing ────────────────────────
313
+ /**
314
+ * What a member takes as cash when every section is drawn together:
315
+ * one total, because the scheme's rate is £12 for each £1 of pension
316
+ * in every section and the limit is a quarter of the capital value of
317
+ * everything crystallised. So nothing about the answer depends on
318
+ * which section the cash comes from, and no source is modelled.
319
+ *
320
+ * - `automatic-only`: the 1995 Section's automatic lump sum and
321
+ * nothing more — nil where the member holds none.
322
+ * - `maximum`: up to the permitted maximum, which counts the
323
+ * automatic lump sum, and never less than it.
324
+ * - `amount`: a stated total, the automatic lump sum included, in
325
+ * today's money — the field says which ruler, because a bare amount
326
+ * could be either.
327
+ */
328
+ export const CASH_CHOICES = {
329
+ automaticOnly: 'automatic-only',
330
+ maximum: 'maximum',
331
+ amount: 'amount',
332
+ };
333
+ /**
334
+ * The permitted maximum in both rulers, with an automatic lump sum
335
+ * counted in. The allowance is a real-terms constant: the today's-money
336
+ * reading tests it at the run date, where a caller usually states it,
337
+ * and the cash reading tests the same cap carried to the pension's own
338
+ * date.
339
+ */
340
+ function limitsIn(pension, automatic, { allowance, prices, commutationFactor }) {
341
+ return {
342
+ today: lumpSumLimit({
343
+ pension: pension.real,
344
+ automatic: automatic.real,
345
+ allowance: prices.valueAt(allowance.amount, allowance.asAt, prices.asOf),
346
+ commutationFactor,
347
+ }),
348
+ cash: lumpSumLimit({
349
+ pension: pension.nominal,
350
+ automatic: automatic.nominal,
351
+ allowance: prices.valueAt(allowance.amount, allowance.asAt, pension.asAt),
352
+ commutationFactor,
320
353
  }),
354
+ };
355
+ }
356
+ /**
357
+ * The cash at a drawing over the crystallised total. `lumpSum` in the
358
+ * result is ALL the cash, the automatic lump sum included, and
359
+ * `pensionGivenUp` is only what the cash above it cost.
360
+ *
361
+ * On `maximum` the automatic lump sum is paid even where the Lump Sum
362
+ * Allowance is below it, so `lumpSum` can exceed `limit.amount` there:
363
+ * the excess is taxed rather than refused, and `limit` still says what
364
+ * was tax-free.
365
+ *
366
+ * Throws RangeError for a stated amount below the automatic lump sum,
367
+ * which is paid whether or not it is asked for, or above the permitted
368
+ * maximum, which the scheme does not pay.
369
+ */
370
+ export function cashAt(pension, automatic, choice, limits) {
371
+ const { commutationFactor } = limits;
372
+ const { today, cash } = limitsIn(pension, automatic, limits);
373
+ const taken = cashTaken(choice, automatic, { today, cash }, limits);
374
+ const lumpSum = moneyAt(taken, pension.asAt);
375
+ const pensionGivenUp = divideMoney(minusMoney(lumpSum, automatic), commutationFactor);
376
+ return {
377
+ lumpSum,
378
+ pensionGivenUp,
379
+ residualPension: minusMoney(pension, pensionGivenUp),
321
380
  limit: { real: today, nominal: cash },
322
381
  };
323
382
  }
383
+ /** The total cash a choice takes, in both rulers. */
384
+ function cashTaken(choice, automatic, limit, { prices }) {
385
+ if (choice.kind === CASH_CHOICES.automaticOnly) {
386
+ return { nominal: automatic.nominal, real: automatic.real };
387
+ }
388
+ if (choice.kind === CASH_CHOICES.maximum) {
389
+ return {
390
+ nominal: Math.max(automatic.nominal, limit.cash.amount),
391
+ real: Math.max(automatic.real, limit.today.amount),
392
+ };
393
+ }
394
+ const value = choice.todaysMoney;
395
+ if (value < automatic.real || value > limit.today.amount) {
396
+ throw new RangeError(`Cash of ${value} is outside what can be taken: from the `
397
+ + `automatic ${automatic.real} to the maximum `
398
+ + `${limit.today.amount}`);
399
+ }
400
+ return {
401
+ nominal: prices.valueAt(value, prices.asOf, automatic.asAt),
402
+ real: value,
403
+ };
404
+ }
324
405
  //# sourceMappingURL=commutation.js.map