@casomoltd/nhs-pay 0.4.7
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/LICENSE +165 -0
- package/README.md +267 -0
- package/dist/bands.d.ts +42 -0
- package/dist/bands.js +161 -0
- package/dist/bands.js.map +1 -0
- package/dist/format.d.ts +20 -0
- package/dist/format.js +56 -0
- package/dist/format.js.map +1 -0
- package/dist/hcas-pcts.d.ts +19 -0
- package/dist/hcas-pcts.js +97 -0
- package/dist/hcas-pcts.js.map +1 -0
- package/dist/hcas.d.ts +28 -0
- package/dist/hcas.js +39 -0
- package/dist/hcas.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/pension-projection.d.ts +149 -0
- package/dist/pension-projection.js +352 -0
- package/dist/pension-projection.js.map +1 -0
- package/dist/pension.d.ts +64 -0
- package/dist/pension.js +96 -0
- package/dist/pension.js.map +1 -0
- package/dist/regions.d.ts +47 -0
- package/dist/regions.js +122 -0
- package/dist/regions.js.map +1 -0
- package/dist/scales.d.ts +79 -0
- package/dist/scales.js +329 -0
- package/dist/scales.js.map +1 -0
- package/dist/take-home.d.ts +12 -0
- package/dist/take-home.js +19 -0
- package/dist/take-home.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NHS 2015 CARE Pension Projection
|
|
3
|
+
*
|
|
4
|
+
* Models the 2015 scheme lifecycle:
|
|
5
|
+
* accrual → revaluation → crystallisation → commutation.
|
|
6
|
+
*
|
|
7
|
+
* Sources:
|
|
8
|
+
*
|
|
9
|
+
* GAD "NHSPS 2015 E&W — Early and late retirement in normal
|
|
10
|
+
* health — Factors and guidance", 7 August 2019
|
|
11
|
+
* → ERF1 table (Appendix B, p.25)
|
|
12
|
+
* → LRF1 table (Appendix C, p.26)
|
|
13
|
+
* → Rounding rules (§2.3 ERF, §3.4 LRF)
|
|
14
|
+
* → Order of operations (§1.18)
|
|
15
|
+
*
|
|
16
|
+
* NHSBSA 2015 Members' Guide (V13), May 2024
|
|
17
|
+
* → Accrual rate: 1/54 (p.6)
|
|
18
|
+
* → NPA = SPA, minimum 65
|
|
19
|
+
*
|
|
20
|
+
* NHS 2015 Scheme design document (gov.uk)
|
|
21
|
+
* → In-service revaluation: CPI + 1.5%
|
|
22
|
+
* → Deferred revaluation: CPI only
|
|
23
|
+
* → In-payment revaluation: CPI (Pensions Increase Order)
|
|
24
|
+
*
|
|
25
|
+
* NHSBSA Key Notes — 2015 Scheme Estimates (V2), March 2025
|
|
26
|
+
* → Commutation rate: £12 lump sum per £1 pension
|
|
27
|
+
* → HMRC 25% cap on lump sum
|
|
28
|
+
*/
|
|
29
|
+
// ── Constants ───────────────────────────────────────
|
|
30
|
+
/** 1/54 accrual rate — NHS 2015 CARE scheme */
|
|
31
|
+
export const ACCRUAL_RATE = 1 / 54;
|
|
32
|
+
/** Commutation: £12 lump sum per £1 pension */
|
|
33
|
+
export const COMMUTATION_FACTOR = 12;
|
|
34
|
+
/** In-service revaluation bonus above CPI */
|
|
35
|
+
const ACTIVE_REVAL_BONUS = 0.015;
|
|
36
|
+
// ── Factor Tables ───────────────────────────────────
|
|
37
|
+
/**
|
|
38
|
+
* ERF1 — Early Retirement Factors for 2015 scheme
|
|
39
|
+
* GAD Appendix B, p.25 (7 August 2019)
|
|
40
|
+
*
|
|
41
|
+
* Rows = years early (0–13), Columns = months (0–11)
|
|
42
|
+
* Factor applied to pension when retiring before NPA.
|
|
43
|
+
*/
|
|
44
|
+
const ERF1 = [
|
|
45
|
+
// 0mo 1mo 2mo 3mo 4mo 5mo 6mo
|
|
46
|
+
// 7mo 8mo 9mo 10mo 11mo
|
|
47
|
+
[1.000, 0.997, 0.994, 0.992, 0.989, 0.986,
|
|
48
|
+
0.983, 0.981, 0.978, 0.975, 0.972, 0.969], // 0yr
|
|
49
|
+
[0.967, 0.963, 0.960, 0.957, 0.953, 0.950,
|
|
50
|
+
0.947, 0.943, 0.940, 0.937, 0.933, 0.930], // 1yr
|
|
51
|
+
[0.927, 0.923, 0.919, 0.916, 0.912, 0.909,
|
|
52
|
+
0.905, 0.901, 0.898, 0.894, 0.891, 0.887], // 2yr
|
|
53
|
+
[0.884, 0.880, 0.876, 0.873, 0.869, 0.865,
|
|
54
|
+
0.862, 0.858, 0.854, 0.851, 0.847, 0.843], // 3yr
|
|
55
|
+
[0.840, 0.836, 0.832, 0.828, 0.824, 0.820,
|
|
56
|
+
0.816, 0.812, 0.808, 0.804, 0.800, 0.796], // 4yr
|
|
57
|
+
[0.792, 0.788, 0.784, 0.780, 0.776, 0.772,
|
|
58
|
+
0.768, 0.764, 0.760, 0.756, 0.751, 0.747], // 5yr
|
|
59
|
+
[0.733, 0.729, 0.724, 0.720, 0.715, 0.711,
|
|
60
|
+
0.706, 0.702, 0.697, 0.693, 0.689, 0.684], // 6yr
|
|
61
|
+
[0.680, 0.675, 0.671, 0.667, 0.662, 0.658,
|
|
62
|
+
0.653, 0.649, 0.645, 0.640, 0.636, 0.632], // 7yr
|
|
63
|
+
[0.627, 0.623, 0.619, 0.614, 0.610, 0.606,
|
|
64
|
+
0.602, 0.597, 0.593, 0.589, 0.585, 0.580], // 8yr
|
|
65
|
+
[0.576, 0.572, 0.568, 0.564, 0.560, 0.556,
|
|
66
|
+
0.552, 0.548, 0.544, 0.540, 0.536, 0.532], // 9yr
|
|
67
|
+
[0.528, 0.525, 0.521, 0.517, 0.513, 0.510,
|
|
68
|
+
0.506, 0.502, 0.498, 0.495, 0.491, 0.487], // 10yr
|
|
69
|
+
[0.484, 0.480, 0.477, 0.473, 0.470, 0.466,
|
|
70
|
+
0.463, 0.459, 0.456, 0.452, 0.449, 0.446], // 11yr
|
|
71
|
+
[0.442, 0.439, 0.436, 0.432, 0.429, 0.426,
|
|
72
|
+
0.422, 0.419, 0.416, 0.413, 0.409, 0.406], // 12yr
|
|
73
|
+
[0.540, 0.536, 0.531, 0.527, 0.522, 0.518,
|
|
74
|
+
0.514, 0.509, 0.505, 0.501, 0.496, 0.492], // 13yr
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* LRF1 — Late Retirement Factors for 2015 scheme
|
|
78
|
+
* GAD Appendix C, p.26 (7 August 2019)
|
|
79
|
+
*
|
|
80
|
+
* Rows = years late (0–10), Columns = months (0–11)
|
|
81
|
+
* Factor applied to pension when retiring after NPA.
|
|
82
|
+
*/
|
|
83
|
+
const LRF1 = [
|
|
84
|
+
// 0mo 1mo 2mo 3mo 4mo 5mo 6mo
|
|
85
|
+
// 7mo 8mo 9mo 10mo 11mo
|
|
86
|
+
[1.000, 1.007, 1.013, 1.020, 1.027, 1.034,
|
|
87
|
+
1.040, 1.047, 1.054, 1.061, 1.067, 1.074], // 0yr
|
|
88
|
+
[1.081, 1.088, 1.096, 1.103, 1.110, 1.117,
|
|
89
|
+
1.125, 1.132, 1.139, 1.146, 1.154, 1.161], // 1yr
|
|
90
|
+
[1.168, 1.176, 1.183, 1.191, 1.198, 1.206,
|
|
91
|
+
1.213, 1.221, 1.228, 1.236, 1.243, 1.251], // 2yr
|
|
92
|
+
[1.258, 1.266, 1.274, 1.282, 1.290, 1.298,
|
|
93
|
+
1.306, 1.314, 1.322, 1.330, 1.338, 1.346], // 3yr
|
|
94
|
+
[1.354, 1.362, 1.370, 1.378, 1.387, 1.395,
|
|
95
|
+
1.403, 1.412, 1.420, 1.429, 1.437, 1.446], // 4yr
|
|
96
|
+
[1.454, 1.463, 1.471, 1.480, 1.489, 1.497,
|
|
97
|
+
1.506, 1.515, 1.524, 1.533, 1.542, 1.551], // 5yr
|
|
98
|
+
[1.560, 1.569, 1.578, 1.587, 1.596, 1.606,
|
|
99
|
+
1.615, 1.624, 1.634, 1.643, 1.653, 1.662], // 6yr
|
|
100
|
+
[1.672, 1.681, 1.691, 1.701, 1.710, 1.720,
|
|
101
|
+
1.730, 1.740, 1.750, 1.760, 1.770, 1.780], // 7yr
|
|
102
|
+
[1.790, 1.800, 1.810, 1.821, 1.831, 1.841,
|
|
103
|
+
1.852, 1.862, 1.873, 1.883, 1.894, 1.905], // 8yr
|
|
104
|
+
[1.915, 1.926, 1.937, 1.948, 1.959, 1.970,
|
|
105
|
+
1.981, 1.992, 2.003, 2.014, 2.026, 2.037], // 9yr
|
|
106
|
+
[1.411, 1.418, 1.425, 1.433, 1.440, 1.447,
|
|
107
|
+
1.455, 1.462, 1.469, 1.477, 1.484, 1.492], // 10yr
|
|
108
|
+
];
|
|
109
|
+
// ── Factor Lookup ───────────────────────────────────
|
|
110
|
+
/** Look up ERF1 factor for given years and months early */
|
|
111
|
+
export function lookupErf1(years, months) {
|
|
112
|
+
if (!(years >= 0 && years <= 13
|
|
113
|
+
&& months >= 0 && months <= 11)) {
|
|
114
|
+
throw new Error(`ERF1 out of range: ${years}yr ${months}mo`
|
|
115
|
+
+ ' (max 13yr 11mo)');
|
|
116
|
+
}
|
|
117
|
+
return ERF1[years][months];
|
|
118
|
+
}
|
|
119
|
+
/** Look up LRF1 factor for given years and months late */
|
|
120
|
+
export function lookupLrf1(years, months) {
|
|
121
|
+
if (!(years >= 0 && years <= 10
|
|
122
|
+
&& months >= 0 && months <= 11)) {
|
|
123
|
+
throw new Error(`LRF1 out of range: ${years}yr ${months}mo`
|
|
124
|
+
+ ' (max 10yr 11mo)');
|
|
125
|
+
}
|
|
126
|
+
return LRF1[years][months];
|
|
127
|
+
}
|
|
128
|
+
// ── Date Arithmetic ─────────────────────────────────
|
|
129
|
+
/**
|
|
130
|
+
* Calculate the period between two dates in years,
|
|
131
|
+
* months, and remaining days.
|
|
132
|
+
*/
|
|
133
|
+
export function periodInYearsMonths(from, to) {
|
|
134
|
+
let years = to.getFullYear() - from.getFullYear();
|
|
135
|
+
let months = to.getMonth() - from.getMonth();
|
|
136
|
+
let days = to.getDate() - from.getDate();
|
|
137
|
+
if (days < 0) {
|
|
138
|
+
months -= 1;
|
|
139
|
+
// Days in previous month of 'to'
|
|
140
|
+
const prevMonth = new Date(to.getFullYear(), to.getMonth(), 0);
|
|
141
|
+
days += prevMonth.getDate();
|
|
142
|
+
}
|
|
143
|
+
if (months < 0) {
|
|
144
|
+
years -= 1;
|
|
145
|
+
months += 12;
|
|
146
|
+
}
|
|
147
|
+
return { years, months, days };
|
|
148
|
+
}
|
|
149
|
+
// ── NPA Date ────────────────────────────────────────
|
|
150
|
+
/** Calculate NPA date from date of birth and NPA age */
|
|
151
|
+
export function npaDate(dateOfBirth, npa) {
|
|
152
|
+
return new Date(dateOfBirth.getFullYear() + npa, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
153
|
+
}
|
|
154
|
+
// ── Retirement Factor ───────────────────────────────
|
|
155
|
+
/**
|
|
156
|
+
* Determine whether ERF or LRF applies and return the
|
|
157
|
+
* factor. ERF rounds UP to next month (§2.3), LRF
|
|
158
|
+
* rounds DOWN to complete months (§3.4).
|
|
159
|
+
*/
|
|
160
|
+
export function retirementFactor(retirementDate, npDate) {
|
|
161
|
+
if (retirementDate >= npDate) {
|
|
162
|
+
// Late or on-time retirement
|
|
163
|
+
const period = periodInYearsMonths(npDate, retirementDate);
|
|
164
|
+
if (period.years === 0 && period.months === 0
|
|
165
|
+
&& period.days === 0) {
|
|
166
|
+
return { factor: 1, type: 'none' };
|
|
167
|
+
}
|
|
168
|
+
// LRF rounds DOWN — ignore remaining days (§3.4)
|
|
169
|
+
return {
|
|
170
|
+
factor: lookupLrf1(period.years, period.months),
|
|
171
|
+
type: 'lrf',
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// Early retirement — ERF rounds UP to next month (§2.3)
|
|
175
|
+
const period = periodInYearsMonths(retirementDate, npDate);
|
|
176
|
+
let { years, months } = period;
|
|
177
|
+
// Round up: if there are remaining days, add a month
|
|
178
|
+
if (period.days > 0) {
|
|
179
|
+
months += 1;
|
|
180
|
+
if (months > 11) {
|
|
181
|
+
months = 0;
|
|
182
|
+
years += 1;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
factor: lookupErf1(years, months),
|
|
187
|
+
type: 'erf',
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// ── Core Calculations ───────────────────────────────
|
|
191
|
+
/** Annual pension accrual for one year of service */
|
|
192
|
+
export function yearlyAccrual(pensionablePay) {
|
|
193
|
+
return pensionablePay * ACCRUAL_RATE;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Compound revaluation over a number of years.
|
|
197
|
+
* Caller passes CPI + 1.5% for active, CPI for deferred.
|
|
198
|
+
*/
|
|
199
|
+
export function revalue(pension, annualRate, years) {
|
|
200
|
+
if (years <= 0)
|
|
201
|
+
return pension;
|
|
202
|
+
return pension * Math.pow(1 + annualRate, years);
|
|
203
|
+
}
|
|
204
|
+
// ── Commutation ─────────────────────────────────────
|
|
205
|
+
/**
|
|
206
|
+
* Maximum tax-free lump sum under HMRC 25% rule.
|
|
207
|
+
* Formula: (20 × pension) / (3 + 20/commutationFactor)
|
|
208
|
+
*/
|
|
209
|
+
export function maxLumpSum(adjustedPension) {
|
|
210
|
+
return (20 * adjustedPension) / (3 + 20 / COMMUTATION_FACTOR);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Calculate commutation at a given fraction of max.
|
|
214
|
+
* ERF/LRF is applied BEFORE commutation (§1.18).
|
|
215
|
+
*/
|
|
216
|
+
export function commute(adjustedPension, fraction) {
|
|
217
|
+
if (fraction < 0 || fraction > 1) {
|
|
218
|
+
throw new Error(`Commutation fraction must be 0–1, got ${fraction}`);
|
|
219
|
+
}
|
|
220
|
+
const max = maxLumpSum(adjustedPension);
|
|
221
|
+
const lumpSum = max * fraction;
|
|
222
|
+
const pensionGivenUp = lumpSum / COMMUTATION_FACTOR;
|
|
223
|
+
const residualPension = adjustedPension - pensionGivenUp;
|
|
224
|
+
return {
|
|
225
|
+
pensionGivenUp,
|
|
226
|
+
residualPension,
|
|
227
|
+
lumpSum,
|
|
228
|
+
maxLumpSum: max,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
// ── Projection Orchestrator ─────────────────────────
|
|
232
|
+
/**
|
|
233
|
+
* Generate a full pension projection including curve
|
|
234
|
+
* data for both nominal and real (CPI-deflated) views.
|
|
235
|
+
*/
|
|
236
|
+
export function projectPension(input) {
|
|
237
|
+
const { dateOfBirth, exitDate, retirementDate, npa, assumedCpi, } = input;
|
|
238
|
+
const today = new Date();
|
|
239
|
+
const npDateValue = npaDate(dateOfBirth, npa);
|
|
240
|
+
const isEstimation = input.kind === 'estimation';
|
|
241
|
+
const accruedAtExit = computeAccruedAtExit(input, today);
|
|
242
|
+
// Revalue from exit to retirement (deferred = CPI only)
|
|
243
|
+
const exitToRetirement = yearsBetween(exitDate, retirementDate);
|
|
244
|
+
const revaluedAtRetirement = exitToRetirement > 0
|
|
245
|
+
? revalue(accruedAtExit, assumedCpi, exitToRetirement)
|
|
246
|
+
: accruedAtExit;
|
|
247
|
+
// Apply ERF/LRF
|
|
248
|
+
const { factor, type: factorType } = retirementFactor(retirementDate, npDateValue);
|
|
249
|
+
const annualPension = revaluedAtRetirement * factor;
|
|
250
|
+
const adjustmentAmount = revaluedAtRetirement
|
|
251
|
+
- annualPension;
|
|
252
|
+
// Generate curve
|
|
253
|
+
const curve = buildCurve(input, accruedAtExit, today);
|
|
254
|
+
return {
|
|
255
|
+
accruedAtExit,
|
|
256
|
+
revaluedAtRetirement,
|
|
257
|
+
annualPension,
|
|
258
|
+
factor,
|
|
259
|
+
factorType,
|
|
260
|
+
adjustmentAmount,
|
|
261
|
+
curve,
|
|
262
|
+
isEstimation,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
// ── Internal Helpers ────────────────────────────────
|
|
266
|
+
/** Fractional years between two dates */
|
|
267
|
+
function yearsBetween(from, to) {
|
|
268
|
+
const msPerYear = 365.25 * 24 * 60 * 60 * 1000;
|
|
269
|
+
return (to.getTime() - from.getTime()) / msPerYear;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Simulate year-by-year accrual with in-service
|
|
273
|
+
* revaluation over a fractional number of years.
|
|
274
|
+
*/
|
|
275
|
+
function simulateAccrual(startPension, salary, activeRate, years) {
|
|
276
|
+
let pension = startPension;
|
|
277
|
+
const fullYears = Math.max(0, Math.floor(years));
|
|
278
|
+
for (let i = 0; i < fullYears; i++) {
|
|
279
|
+
pension = pension * (1 + activeRate)
|
|
280
|
+
+ yearlyAccrual(salary);
|
|
281
|
+
}
|
|
282
|
+
const partial = years - fullYears;
|
|
283
|
+
if (partial > 0) {
|
|
284
|
+
pension = pension * (1 + activeRate * partial)
|
|
285
|
+
+ yearlyAccrual(salary) * partial;
|
|
286
|
+
}
|
|
287
|
+
return pension;
|
|
288
|
+
}
|
|
289
|
+
/** Determine accrued pension at exit date */
|
|
290
|
+
function computeAccruedAtExit(input, today) {
|
|
291
|
+
const { currentSalary, exitDate, assumedCpi } = input;
|
|
292
|
+
const activeRate = assumedCpi + ACTIVE_REVAL_BONUS;
|
|
293
|
+
if (input.kind === 'statement') {
|
|
294
|
+
const yearsToExit = yearsBetween(today, exitDate);
|
|
295
|
+
if (yearsToExit <= 0)
|
|
296
|
+
return input.accruedPension;
|
|
297
|
+
return simulateAccrual(input.accruedPension, currentSalary, activeRate, yearsToExit);
|
|
298
|
+
}
|
|
299
|
+
// Estimation: accrue from join to exit
|
|
300
|
+
const joinToExit = yearsBetween(input.joinDate, exitDate);
|
|
301
|
+
return simulateAccrual(0, currentSalary, activeRate, Math.max(0, joinToExit));
|
|
302
|
+
}
|
|
303
|
+
/** Compute nominal pension for a point in active phase */
|
|
304
|
+
function activeNominal(input, pointDate, today, activeRate) {
|
|
305
|
+
const { currentSalary } = input;
|
|
306
|
+
if (input.kind === 'statement') {
|
|
307
|
+
const yrs = Math.max(0, yearsBetween(today, pointDate));
|
|
308
|
+
return simulateAccrual(input.accruedPension, currentSalary, activeRate, yrs);
|
|
309
|
+
}
|
|
310
|
+
const yrsFromJoin = yearsBetween(input.joinDate, pointDate);
|
|
311
|
+
return simulateAccrual(0, currentSalary, activeRate, Math.max(0, yrsFromJoin));
|
|
312
|
+
}
|
|
313
|
+
/** Build the projection curve at yearly intervals */
|
|
314
|
+
function buildCurve(input, accruedAtExit, today) {
|
|
315
|
+
const { dateOfBirth, exitDate, retirementDate, npa, assumedCpi, } = input;
|
|
316
|
+
const npDateValue = npaDate(dateOfBirth, npa);
|
|
317
|
+
const points = [];
|
|
318
|
+
const currentAge = yearsBetween(dateOfBirth, today);
|
|
319
|
+
const endAge = Math.max(npa + 5, yearsBetween(dateOfBirth, retirementDate) + 5);
|
|
320
|
+
const startAge = Math.floor(currentAge);
|
|
321
|
+
const activeRate = assumedCpi + ACTIVE_REVAL_BONUS;
|
|
322
|
+
// Pre-compute pension at retirement for in-payment
|
|
323
|
+
const exitToRet = Math.max(0, yearsBetween(exitDate, retirementDate));
|
|
324
|
+
const { factor } = retirementFactor(retirementDate, npDateValue);
|
|
325
|
+
const atRetirement = revalue(accruedAtExit, assumedCpi, exitToRet) * factor;
|
|
326
|
+
for (let age = startAge; age <= Math.ceil(endAge); age++) {
|
|
327
|
+
const pointDate = new Date(dateOfBirth.getFullYear() + age, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
328
|
+
const yearsFromToday = yearsBetween(today, pointDate);
|
|
329
|
+
const { nominal, accrued } = curvePointValue(input, pointDate, today, exitDate, retirementDate, accruedAtExit, assumedCpi, activeRate, atRetirement);
|
|
330
|
+
const deflator = Math.pow(1 + assumedCpi, Math.max(0, yearsFromToday));
|
|
331
|
+
const real = nominal / deflator;
|
|
332
|
+
points.push({ age, nominal, real, accrued });
|
|
333
|
+
}
|
|
334
|
+
return points;
|
|
335
|
+
}
|
|
336
|
+
/** Determine nominal value and accrued flag for a point */
|
|
337
|
+
function curvePointValue(input, pointDate, today, exitDate, retirementDate, accruedAtExit, assumedCpi, activeRate, atRetirement) {
|
|
338
|
+
if (pointDate <= exitDate) {
|
|
339
|
+
const nominal = activeNominal(input, pointDate, today, activeRate);
|
|
340
|
+
return { nominal, accrued: pointDate <= today };
|
|
341
|
+
}
|
|
342
|
+
if (pointDate <= retirementDate) {
|
|
343
|
+
const yrsDeferred = yearsBetween(exitDate, pointDate);
|
|
344
|
+
const nominal = revalue(accruedAtExit, assumedCpi, yrsDeferred);
|
|
345
|
+
return { nominal, accrued: false };
|
|
346
|
+
}
|
|
347
|
+
// In payment
|
|
348
|
+
const yrsInPayment = yearsBetween(retirementDate, pointDate);
|
|
349
|
+
const nominal = revalue(atRetirement, assumedCpi, yrsInPayment);
|
|
350
|
+
return { nominal, accrued: false };
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=pension-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pension-projection.js","sourceRoot":"","sources":["../src/pension-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAmFH,uDAAuD;AAEvD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,CAAC;AAEnC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,6CAA6C;AAC7C,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,uDAAuD;AAEvD;;;;;;GAMG;AACH,MAAM,IAAI,GAAG;IACX,iDAAiD;IACjD,mCAAmC;IACnC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QACvC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAG,MAAM;IACpD,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QACvC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAG,MAAM;IACpD,CAAC,KAAK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OAAO,GAAG,OAAO,CACrB,YAAY,EAAE,UAAU,EAAE,YAAY,CACvC,CAAC;IACF,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NHS pension tier types, lookup functions, and
|
|
3
|
+
* year-specific tier data.
|
|
4
|
+
*
|
|
5
|
+
* Source: https://www.nhsbsa.nhs.uk/member-hub/member-hub-contribution-rates
|
|
6
|
+
*/
|
|
7
|
+
import type { Nation, TaxYear } from '@casomoltd/paye-calc';
|
|
8
|
+
export interface PensionTier {
|
|
9
|
+
tier: number;
|
|
10
|
+
min: number;
|
|
11
|
+
/** Infinity for the top tier */
|
|
12
|
+
max: number;
|
|
13
|
+
rate: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Employer pension contribution for one of the UK's three NHS
|
|
17
|
+
* pension schemes, as fractions of pensionable pay.
|
|
18
|
+
*
|
|
19
|
+
* Unlike the member tiers, employer rates are set by periodic
|
|
20
|
+
* scheme valuation rather than each tax year. All three current
|
|
21
|
+
* rates took effect on 1 April 2024 (from the 2020 valuations)
|
|
22
|
+
* and hold for 2025/26 and 2026/27; the 2024 valuations
|
|
23
|
+
* determine the rates from 2027/28.
|
|
24
|
+
*/
|
|
25
|
+
export interface EmployerPensionRate {
|
|
26
|
+
/** Employer contribution rate as a fraction of pensionable pay. */
|
|
27
|
+
rate: number;
|
|
28
|
+
/**
|
|
29
|
+
* Separate administration levy charged on top of `rate`, as a
|
|
30
|
+
* fraction of pensionable pay (0 where the scheme charges none).
|
|
31
|
+
*/
|
|
32
|
+
adminLevy: number;
|
|
33
|
+
/** Tax year (April start) the current rate took effect. */
|
|
34
|
+
effectiveFrom: TaxYear;
|
|
35
|
+
/** Scheme administrator. */
|
|
36
|
+
administrator: string;
|
|
37
|
+
/** Authoritative source URL for the figures. */
|
|
38
|
+
source: string;
|
|
39
|
+
}
|
|
40
|
+
/** Employer pension contribution for a nation's NHS scheme. */
|
|
41
|
+
export declare function getEmployerPensionRate(nation: Nation): EmployerPensionRate;
|
|
42
|
+
/**
|
|
43
|
+
* Pension contribution rate (%) for a salary.
|
|
44
|
+
*/
|
|
45
|
+
export declare function pensionTierRate(salary: number, tiers: PensionTier[]): number;
|
|
46
|
+
/**
|
|
47
|
+
* Look up the matching pension tier for a salary.
|
|
48
|
+
* Returns tier number (1-based) and the tier band,
|
|
49
|
+
* or null if no tiers are provided.
|
|
50
|
+
*/
|
|
51
|
+
export declare function lookupPensionTier(salary: number, tiers: PensionTier[]): {
|
|
52
|
+
tier: number;
|
|
53
|
+
band: PensionTier;
|
|
54
|
+
} | null;
|
|
55
|
+
/**
|
|
56
|
+
* Get member pension contribution tiers for a tax year.
|
|
57
|
+
*
|
|
58
|
+
* These thresholds are England & Wales (NHSBSA), re-based to the
|
|
59
|
+
* AfC pay award each year. Scotland (SPPA) and NI (HSC) share the
|
|
60
|
+
* same six contribution *rates* but set their own pay-band
|
|
61
|
+
* thresholds, which can place the same salary in a different
|
|
62
|
+
* tier — do not treat these as UK-wide.
|
|
63
|
+
*/
|
|
64
|
+
export declare function getPensionTiers(year: TaxYear): PensionTier[];
|
package/dist/pension.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NHS pension tier types, lookup functions, and
|
|
3
|
+
* year-specific tier data.
|
|
4
|
+
*
|
|
5
|
+
* Source: https://www.nhsbsa.nhs.uk/member-hub/member-hub-contribution-rates
|
|
6
|
+
*/
|
|
7
|
+
import { TAX_YEARS } from '@casomoltd/paye-calc';
|
|
8
|
+
// England and Wales share the NHSBSA-administered scheme, so they
|
|
9
|
+
// share one rate; Scotland (SPPA) and NI (HSC) run their own.
|
|
10
|
+
const NHSBSA_EMPLOYER_RATE = {
|
|
11
|
+
rate: 0.237,
|
|
12
|
+
adminLevy: 0.0008,
|
|
13
|
+
effectiveFrom: TAX_YEARS.Y2024_25,
|
|
14
|
+
administrator: 'NHSBSA',
|
|
15
|
+
source: 'https://www.nhsbsa.nhs.uk/nhs-pension-scheme-employer-contribution-rates-202425',
|
|
16
|
+
};
|
|
17
|
+
const EMPLOYER_PENSION_RATES = {
|
|
18
|
+
england: NHSBSA_EMPLOYER_RATE,
|
|
19
|
+
wales: NHSBSA_EMPLOYER_RATE,
|
|
20
|
+
scotland: {
|
|
21
|
+
rate: 0.225,
|
|
22
|
+
adminLevy: 0,
|
|
23
|
+
effectiveFrom: TAX_YEARS.Y2024_25,
|
|
24
|
+
administrator: 'SPPA',
|
|
25
|
+
source: 'https://pensions.gov.scot/nhs/employers/employer-contributions',
|
|
26
|
+
},
|
|
27
|
+
'northern-ireland': {
|
|
28
|
+
rate: 0.232,
|
|
29
|
+
adminLevy: 0,
|
|
30
|
+
effectiveFrom: TAX_YEARS.Y2024_25,
|
|
31
|
+
administrator: 'HSC Pension Service',
|
|
32
|
+
source: 'https://www.health-ni.gov.uk/consultations/hsc-pension-scheme-employer-and-employee-contribution-rates',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
/** Employer pension contribution for a nation's NHS scheme. */
|
|
36
|
+
export function getEmployerPensionRate(nation) {
|
|
37
|
+
return EMPLOYER_PENSION_RATES[nation];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pension contribution rate (%) for a salary.
|
|
41
|
+
*/
|
|
42
|
+
export function pensionTierRate(salary, tiers) {
|
|
43
|
+
for (const tier of tiers) {
|
|
44
|
+
if (salary <= tier.max) {
|
|
45
|
+
return tier.rate * 100;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Look up the matching pension tier for a salary.
|
|
52
|
+
* Returns tier number (1-based) and the tier band,
|
|
53
|
+
* or null if no tiers are provided.
|
|
54
|
+
*/
|
|
55
|
+
export function lookupPensionTier(salary, tiers) {
|
|
56
|
+
for (const t of tiers) {
|
|
57
|
+
if (salary <= t.max) {
|
|
58
|
+
return { tier: t.tier, band: t };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
// ── Tier data by tax year ───────────────────────
|
|
64
|
+
const PENSION_TIERS_2025_26 = [
|
|
65
|
+
{ tier: 1, min: 0, max: 13259, rate: 0.052 },
|
|
66
|
+
{ tier: 2, min: 13260, max: 27797, rate: 0.065 },
|
|
67
|
+
{ tier: 3, min: 27798, max: 33868, rate: 0.083 },
|
|
68
|
+
{ tier: 4, min: 33869, max: 50845, rate: 0.098 },
|
|
69
|
+
{ tier: 5, min: 50846, max: 65190, rate: 0.107 },
|
|
70
|
+
{ tier: 6, min: 65191, max: Infinity, rate: 0.125 },
|
|
71
|
+
];
|
|
72
|
+
const PENSION_TIERS_2026_27 = [
|
|
73
|
+
{ tier: 1, min: 0, max: 13259, rate: 0.052 },
|
|
74
|
+
{ tier: 2, min: 13260, max: 28854, rate: 0.065 },
|
|
75
|
+
{ tier: 3, min: 28855, max: 35155, rate: 0.083 },
|
|
76
|
+
{ tier: 4, min: 35156, max: 52778, rate: 0.098 },
|
|
77
|
+
{ tier: 5, min: 52779, max: 67668, rate: 0.107 },
|
|
78
|
+
{ tier: 6, min: 67669, max: Infinity, rate: 0.125 },
|
|
79
|
+
];
|
|
80
|
+
const PENSION_TIERS = {
|
|
81
|
+
[TAX_YEARS.Y2025_26]: PENSION_TIERS_2025_26,
|
|
82
|
+
[TAX_YEARS.Y2026_27]: PENSION_TIERS_2026_27,
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Get member pension contribution tiers for a tax year.
|
|
86
|
+
*
|
|
87
|
+
* These thresholds are England & Wales (NHSBSA), re-based to the
|
|
88
|
+
* AfC pay award each year. Scotland (SPPA) and NI (HSC) share the
|
|
89
|
+
* same six contribution *rates* but set their own pay-band
|
|
90
|
+
* thresholds, which can place the same salary in a different
|
|
91
|
+
* tier — do not treat these as UK-wide.
|
|
92
|
+
*/
|
|
93
|
+
export function getPensionTiers(year) {
|
|
94
|
+
return (PENSION_TIERS[year] ?? PENSION_TIERS_2025_26);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=pension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pension.js","sourceRoot":"","sources":["../src/pension.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAoC/C,kEAAkE;AAClE,8DAA8D;AAC9D,MAAM,oBAAoB,GAAwB;IAChD,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,MAAM;IACjB,aAAa,EAAE,SAAS,CAAC,QAAQ;IACjC,aAAa,EAAE,QAAQ;IACvB,MAAM,EACJ,iFAAiF;CACpF,CAAC;AAEF,MAAM,sBAAsB,GAGxB;IACF,OAAO,EAAE,oBAAoB;IAC7B,KAAK,EAAE,oBAAoB;IAC3B,QAAQ,EAAE;QACR,IAAI,EAAE,KAAK;QACX,SAAS,EAAE,CAAC;QACZ,aAAa,EAAE,SAAS,CAAC,QAAQ;QACjC,aAAa,EAAE,MAAM;QACrB,MAAM,EACJ,gEAAgE;KACnE;IACD,kBAAkB,EAAE;QAClB,IAAI,EAAE,KAAK;QACX,SAAS,EAAE,CAAC;QACZ,aAAa,EAAE,SAAS,CAAC,QAAQ;QACjC,aAAa,EAAE,qBAAqB;QACpC,MAAM,EACJ,wGAAwG;KAC3G;CACF,CAAC;AAEF,+DAA+D;AAC/D,MAAM,UAAU,sBAAsB,CACpC,MAAc;IAEd,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAc,EACd,KAAoB;IAEpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,IAAI,GAAG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1C,EAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC;IAC9C,EAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC;IAC9C,EAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC;IAC9C,EAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC;IAC9C,EAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAC;CAClD,CAAC;AAEF,MAAM,aAAa,GAEf;IACF,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,qBAAqB;IAC3C,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,qBAAqB;CAC5C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAa;IAEb,OAAO,CACL,aAAa,CAAC,IAAI,CAAC,IAAI,qBAAqB,CAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AFC region codes — collapse nation + HCAS into
|
|
3
|
+
* a single query parameter.
|
|
4
|
+
*
|
|
5
|
+
* HCAS is England-only and mutually exclusive with
|
|
6
|
+
* non-England nations, so one param covers both.
|
|
7
|
+
*
|
|
8
|
+
* UI-specific concerns (cookies, URL params, selector
|
|
9
|
+
* options, zone labels) stay in hub-site.
|
|
10
|
+
*/
|
|
11
|
+
import type { TaxRegion, Nation } from '@casomoltd/paye-calc';
|
|
12
|
+
import type { HcasZones } from './scales.js';
|
|
13
|
+
import type { HcasZoneId } from './hcas.js';
|
|
14
|
+
export declare const AFC_REGIONS: {
|
|
15
|
+
readonly ENG: "eng";
|
|
16
|
+
readonly ENG_IL: "eng-il";
|
|
17
|
+
readonly ENG_OL: "eng-ol";
|
|
18
|
+
readonly ENG_FR: "eng-fr";
|
|
19
|
+
readonly WAL: "wal";
|
|
20
|
+
readonly SCO: "sco";
|
|
21
|
+
readonly NI: "ni";
|
|
22
|
+
};
|
|
23
|
+
export type AfcRegionId = (typeof AFC_REGIONS)[keyof typeof AFC_REGIONS];
|
|
24
|
+
/** Type guard for region codes. */
|
|
25
|
+
export declare function isAfcRegionId(raw: string): raw is AfcRegionId;
|
|
26
|
+
export interface ResolvedRegion {
|
|
27
|
+
id: AfcRegionId;
|
|
28
|
+
taxRegion: TaxRegion;
|
|
29
|
+
/** Key into AfcScaleYear.hcas, if applicable */
|
|
30
|
+
hcasProp: keyof HcasZones | null;
|
|
31
|
+
/** Short label for page titles */
|
|
32
|
+
label: string;
|
|
33
|
+
/** Tax system description for intro copy */
|
|
34
|
+
taxNote: string;
|
|
35
|
+
isWales: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Resolve a region code to tax/HCAS/label info. */
|
|
38
|
+
export declare function resolveRegion(id: AfcRegionId): ResolvedRegion;
|
|
39
|
+
/** Map an AfC region code to a paye-calc Nation. */
|
|
40
|
+
export declare function afcRegionToNation(id: AfcRegionId): Nation;
|
|
41
|
+
export declare const ZONE_TO_REGION: Record<HcasZoneId, AfcRegionId>;
|
|
42
|
+
/** Map an AfC region code to its HCAS zone,
|
|
43
|
+
* or null for non-HCAS regions. */
|
|
44
|
+
export declare function afcRegionToHcasZone(id: AfcRegionId): HcasZoneId | null;
|
|
45
|
+
export declare const ZONE_LABELS: Record<HcasZoneId, string>;
|
|
46
|
+
/** Type guard for paye-calc Nation strings. */
|
|
47
|
+
export declare function isNation(raw: string | null | undefined): raw is Nation;
|