@casomoltd/nhs-pay 0.19.4 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -5
- package/dist/afc-scales.d.ts +14 -7
- package/dist/afc-scales.js +19 -19
- package/dist/afc-scales.js.map +1 -1
- package/dist/bands.d.ts +2 -2
- package/dist/commutation.d.ts +49 -5
- package/dist/commutation.js +124 -43
- package/dist/commutation.js.map +1 -1
- package/dist/dates.d.ts +2 -0
- package/dist/dates.js +4 -0
- package/dist/dates.js.map +1 -1
- package/dist/errors.d.ts +70 -12
- package/dist/errors.js +85 -19
- package/dist/errors.js.map +1 -1
- package/dist/factor-basis.d.ts +87 -0
- package/dist/factor-basis.js +99 -0
- package/dist/factor-basis.js.map +1 -0
- package/dist/gad/erf-1-401-2023-06-30.d.ts +47 -0
- package/dist/gad/erf-1-401-2023-06-30.js +73 -0
- package/dist/gad/erf-1-401-2023-06-30.js.map +1 -0
- package/dist/gad/erf-1-402-2023-06-30.d.ts +48 -0
- package/dist/gad/erf-1-402-2023-06-30.js +84 -0
- package/dist/gad/erf-1-402-2023-06-30.js.map +1 -0
- package/dist/gad/erf-1-407-2023-06-30.d.ts +47 -0
- package/dist/gad/erf-1-407-2023-06-30.js +73 -0
- package/dist/gad/erf-1-407-2023-06-30.js.map +1 -0
- package/dist/gad/erf-2023-06-30.d.ts +3 -0
- package/dist/gad/erf-2023-06-30.js +1 -0
- package/dist/gad/erf-2023-06-30.js.map +1 -1
- package/dist/gad/factor-table.d.ts +62 -31
- package/dist/gad/factor-table.js +67 -34
- package/dist/gad/factor-table.js.map +1 -1
- package/dist/gad/lrf-2-416-2023-06-30.d.ts +46 -0
- package/dist/gad/lrf-2-416-2023-06-30.js +72 -0
- package/dist/gad/lrf-2-416-2023-06-30.js.map +1 -0
- package/dist/gad/lrf-2023-06-30.d.ts +3 -0
- package/dist/gad/lrf-2023-06-30.js +1 -0
- package/dist/gad/lrf-2023-06-30.js.map +1 -1
- package/dist/gad/promotional-scale-2020.d.ts +37 -0
- package/dist/gad/promotional-scale-2020.js +38 -0
- package/dist/gad/promotional-scale-2020.js.map +1 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.js +21 -12
- package/dist/index.js.map +1 -1
- package/dist/iso-date.d.ts +7 -0
- package/dist/iso-date.js +11 -0
- package/dist/iso-date.js.map +1 -1
- package/dist/member-benefits.d.ts +237 -0
- package/dist/member-benefits.js +440 -0
- package/dist/member-benefits.js.map +1 -0
- package/dist/pay-path.d.ts +70 -0
- package/dist/pay-path.js +155 -0
- package/dist/pay-path.js.map +1 -0
- package/dist/pension/curve.d.ts +74 -0
- package/dist/pension/curve.js +134 -0
- package/dist/pension/curve.js.map +1 -0
- package/dist/pension/history.js +3 -3
- package/dist/pension/history.js.map +1 -1
- package/dist/pension/ledger.d.ts +71 -31
- package/dist/pension/ledger.js +41 -6
- package/dist/pension/ledger.js.map +1 -1
- package/dist/pension/money.d.ts +23 -6
- package/dist/pension/money.js +23 -1
- package/dist/pension/money.js.map +1 -1
- package/dist/pension/uplift.d.ts +23 -0
- package/dist/pension/uplift.js +34 -1
- package/dist/pension/uplift.js.map +1 -1
- package/dist/pension-projection.d.ts +25 -31
- package/dist/pension-projection.js +40 -197
- package/dist/pension-projection.js.map +1 -1
- package/dist/scale-point.d.ts +11 -1
- package/dist/scales.d.ts +9 -9
- package/dist/scales.js +68 -67
- package/dist/scales.js.map +1 -1
- package/dist/sections/final-salary.d.ts +97 -0
- package/dist/sections/final-salary.js +99 -0
- package/dist/sections/final-salary.js.map +1 -0
- package/dist/sections/section-1995.d.ts +20 -0
- package/dist/sections/section-1995.js +52 -0
- package/dist/sections/section-1995.js.map +1 -0
- package/dist/sections/section-2008.d.ts +16 -0
- package/dist/sections/section-2008.js +44 -0
- package/dist/sections/section-2008.js.map +1 -0
- package/dist/sections/section-2015.d.ts +43 -0
- package/dist/sections/section-2015.js +57 -0
- package/dist/sections/section-2015.js.map +1 -0
- package/dist/values.d.ts +4 -5
- package/dist/values.js +4 -5
- package/dist/values.js.map +1 -1
- package/package.json +5 -3
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
|
|
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
|
|
@@ -129,7 +133,64 @@ consultant scale is 20 payroll steps over 5 threshold labels, so
|
|
|
129
133
|
dental grades. Both fail loud (`ScaleUnavailable`) for an
|
|
130
134
|
unpublished nation/year or grade rather than defaulting.
|
|
131
135
|
|
|
132
|
-
###
|
|
136
|
+
### Value a member's pension across sections
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import {SECTIONS, isoDate, memberBenefits} from '@casomoltd/nhs-pay';
|
|
140
|
+
|
|
141
|
+
// Built once from the member; `today` pins the date the figures
|
|
142
|
+
// are as at, so they reproduce.
|
|
143
|
+
const benefits = memberBenefits(
|
|
144
|
+
{
|
|
145
|
+
dateOfBirth: isoDate('1979-01-01'),
|
|
146
|
+
service: [
|
|
147
|
+
{section: SECTIONS.s1995, joined: isoDate('2004-04-01'),
|
|
148
|
+
left: isoDate('2022-03-31')},
|
|
149
|
+
{section: SECTIONS.s2015, joined: isoDate('2022-04-01'),
|
|
150
|
+
left: null},
|
|
151
|
+
],
|
|
152
|
+
pay: {
|
|
153
|
+
declared: [],
|
|
154
|
+
current: {todaysMoney: 51932, asAt: isoDate('2026-09-01')},
|
|
155
|
+
ladder: null, // or the member's AfC band points and current point
|
|
156
|
+
},
|
|
157
|
+
statement: null, // or a 2015 Section balance off a statement
|
|
158
|
+
},
|
|
159
|
+
{assumedCpi: 0.02},
|
|
160
|
+
new Date(2026, 8, 23),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
benefits.remedy; // true: in service by 31 March 2012 and after 2015
|
|
164
|
+
benefits.now(); // held today, the remedy window on the legacy basis
|
|
165
|
+
|
|
166
|
+
// Asked once per option. Every section is drawn on one date.
|
|
167
|
+
for (const kind of ['legacy-basis', 'section-2015-basis'] as const) {
|
|
168
|
+
const position = benefits.at({
|
|
169
|
+
leaving: isoDate('2039-09-30'),
|
|
170
|
+
drawing: isoDate('2039-09-30'),
|
|
171
|
+
remedy: {kind},
|
|
172
|
+
cash: {kind: 'maximum'},
|
|
173
|
+
});
|
|
174
|
+
position.awards; // one per section and basis, each factored
|
|
175
|
+
position.crystallised; // the pension and automatic lump sum, summed
|
|
176
|
+
position.cash; // the cash taken across the whole
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Each section keeps its own rules — denominator, pay measure,
|
|
181
|
+
pension age, lump sum, factors — so no caller can combine them
|
|
182
|
+
into one the scheme lacks. Pay comes from the member's pay path
|
|
183
|
+
(`promotionalIndex` is GAD's curve behind it). Service the library
|
|
184
|
+
does not model, such as a break, is refused with
|
|
185
|
+
`BenefitNotModelled` and a `code` to branch on; `NOT_MODELLED`
|
|
186
|
+
links each code to the issue tracking it. See
|
|
187
|
+
[*A member's benefits across sections*](docs/how-it-works.md#a-members-benefits-across-sections).
|
|
188
|
+
|
|
189
|
+
### Project a 2015 Section pension on flat pay
|
|
190
|
+
|
|
191
|
+
**Deprecated.** `projectPension` is kept for this flat-pay question
|
|
192
|
+
until [#21](https://github.com/casomoltd/nhs-pay/issues/21); for a
|
|
193
|
+
member across sections, use `memberBenefits` above.
|
|
133
194
|
|
|
134
195
|
```ts
|
|
135
196
|
import {
|
|
@@ -237,13 +298,16 @@ Table A25 (AfC 2025/26 data for England, NI, Wales).
|
|
|
237
298
|
[scales-2627]: https://www.nhsemployers.org/articles/pay-scales-202627
|
|
238
299
|
[nhsprb-39]: https://assets.publishing.service.gov.uk/media/698df41175466636847f6a93/NHSPRB_39th_Report_2026.pdf
|
|
239
300
|
|
|
240
|
-
###
|
|
301
|
+
### NHS pension
|
|
241
302
|
|
|
242
303
|
| Data | Source |
|
|
243
304
|
| ---- | ------ |
|
|
244
305
|
| September CPI + in-service rate | [HM Treasury Revaluation Orders][sis], one SI per year |
|
|
245
|
-
|
|
|
246
|
-
|
|
|
306
|
+
| 2015 Section accrual rate, NPA | NHSBSA 2015 Members' Guide (V13) |
|
|
307
|
+
| 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 |
|
|
308
|
+
| McCloud remedy eligibility and window | Public Service Pensions and Judicial Offices Act 2022 ss.1–2; rollback by SI 2023/985 |
|
|
309
|
+
| ERF / LRF factors: 0-420, 0-421, 1-401, 1-402, 1-407, 2-416 | GAD NHS EW consolidated factor workbook |
|
|
310
|
+
| Promotional pay index | GAD, summary of the 2020 valuation assumptions, page 3 |
|
|
247
311
|
| Commutation rate (£12 : £1) | NHSBSA Key Notes — 2015 Scheme Estimates (V2) |
|
|
248
312
|
| Permitted maximum (lowest of three limbs) | [Sch 29 Finance Act 2004 para 2][sch29] |
|
|
249
313
|
| Applicable amount, defined benefits, `(A + (B × C)) / 4` | [Sch 29 Finance Act 2004 para 2C][sch29p2c] |
|
package/dist/afc-scales.d.ts
CHANGED
|
@@ -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,
|
|
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 {
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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,
|
|
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,
|
|
105
|
+
export declare const SCOTLAND_SCALES_2025_26: Record<AfcBandId, SteppedPoint[]>;
|
package/dist/afc-scales.js
CHANGED
|
@@ -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,
|
|
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
|
-
/**
|
|
156
|
-
|
|
157
|
-
|
|
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(
|
|
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 [
|
|
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
|
-
|
|
318
|
+
...point,
|
|
319
319
|
salary: yearSalaries[i],
|
|
320
320
|
}));
|
|
321
321
|
}
|
package/dist/afc-scales.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afc-scales.js","sourceRoot":"","sources":["../src/afc-scales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAErE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAMtC,OAAO,EAAC,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAC,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAC,kBAAkB,EAAC,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,wBAAwB,GACzB,MAAM,yCAAyC,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,gBAAgB,GAAsB,CAAC,QAAQ,CAAC,CAAC;AAuBvD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AK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CACzC,uBAAuB,CACS,EAAE,CAAC;QACnC,MAAM,YAAY,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 {
|
|
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:
|
|
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
|
package/dist/commutation.d.ts
CHANGED
|
@@ -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
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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;
|
package/dist/commutation.js
CHANGED
|
@@ -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
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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.
|
|
211
|
-
*
|
|
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
|
-
*
|
|
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
|
|
229
|
-
+
|
|
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
|
|
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 {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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 =
|
|
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:
|
|
318
|
-
|
|
319
|
-
|
|
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
|
package/dist/commutation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commutation.js","sourceRoot":"","sources":["../src/commutation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"commutation.js","sourceRoot":"","sources":["../src/commutation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAIpE,uDAAuD;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,uDAAuD;AACvD,gEAAgE;AAChE,8DAA8D;AAC9D,8DAA8D;AAC9D,0DAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC,uDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;CACd,CAAC;AAiEX;;;;;;;;;;;;;;;;;GAiBG;AACH,M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AAI,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QACzD,MAAM,IAAI,UAAU,CAClB,WAAW,KAAK,0CAA0C;cACxD,aAAa,SAAS,CAAC,IAAI,kBAAkB;cAC7C,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAC1B,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC;QAC3D,IAAI,EAAE,KAAK;KACZ,CAAC;AACJ,CAAC"}
|
package/dist/dates.d.ts
CHANGED
|
@@ -47,3 +47,5 @@ export declare function yearsBetween(from: Date, to: Date): number;
|
|
|
47
47
|
* would move NPA a day earlier to 28 Feb.
|
|
48
48
|
*/
|
|
49
49
|
export declare function npaDate(dateOfBirth: Date, npa: number): Date;
|
|
50
|
+
/** The earliest of some dates. */
|
|
51
|
+
export declare function earliest(...dates: readonly Date[]): Date;
|
package/dist/dates.js
CHANGED
|
@@ -83,4 +83,8 @@ export function yearsBetween(from, to) {
|
|
|
83
83
|
export function npaDate(dateOfBirth, npa) {
|
|
84
84
|
return new Date(dateOfBirth.getFullYear() + npa, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
85
85
|
}
|
|
86
|
+
/** The earliest of some dates. */
|
|
87
|
+
export function earliest(...dates) {
|
|
88
|
+
return new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
89
|
+
}
|
|
86
90
|
//# sourceMappingURL=dates.js.map
|
package/dist/dates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.js","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IA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