@casomoltd/nhs-pay 0.10.4 → 0.12.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 +48 -0
- package/dist/award.d.ts +8 -8
- package/dist/award.js +8 -8
- package/dist/circulars/england-md-1-2026r.d.ts +2 -3
- package/dist/circulars/england-md-1-2026r.js +2 -3
- package/dist/circulars/england-md-1-2026r.js.map +1 -1
- package/dist/circulars/ni-hsc-tc8-05-2025.d.ts +2 -2
- package/dist/circulars/ni-hsc-tc8-05-2025.js +2 -2
- package/dist/circulars/scotland-pcs-dd-2025-01.d.ts +2 -3
- package/dist/circulars/scotland-pcs-dd-2025-01.js +2 -3
- package/dist/circulars/scotland-pcs-dd-2025-01.js.map +1 -1
- package/dist/circulars/scotland-pcs-dd-2026-01.d.ts +2 -2
- package/dist/circulars/scotland-pcs-dd-2026-01.js +2 -2
- package/dist/circulars/wales-mdw-01-2025.d.ts +2 -2
- package/dist/circulars/wales-mdw-01-2025.js +2 -2
- package/dist/circulars/wales-mdw-01-2026.d.ts +2 -2
- package/dist/circulars/wales-mdw-01-2026.js +2 -2
- package/dist/format.d.ts +8 -0
- package/dist/format.js +14 -0
- package/dist/format.js.map +1 -1
- package/dist/gad/erf-2023-06-30.d.ts +39 -3
- package/dist/gad/erf-2023-06-30.js +39 -3
- package/dist/gad/erf-2023-06-30.js.map +1 -1
- package/dist/gad/factor-table.d.ts +10 -0
- package/dist/gad/factor-table.js.map +1 -1
- package/dist/gad/lrf-2023-06-30.d.ts +39 -3
- package/dist/gad/lrf-2023-06-30.js +39 -3
- package/dist/gad/lrf-2023-06-30.js.map +1 -1
- package/dist/hcas-pcts.js +3 -1
- package/dist/hcas-pcts.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/npa.d.ts +28 -0
- package/dist/npa.js +60 -0
- package/dist/npa.js.map +1 -0
- package/dist/pension/history.d.ts +105 -0
- package/dist/pension/history.js +115 -0
- package/dist/pension/history.js.map +1 -0
- package/dist/pension/ledger.d.ts +146 -0
- package/dist/pension/ledger.js +193 -0
- package/dist/pension/ledger.js.map +1 -0
- package/dist/pension/prices.d.ts +125 -0
- package/dist/pension/prices.js +108 -0
- package/dist/pension/prices.js.map +1 -0
- package/dist/pension/seed.d.ts +75 -0
- package/dist/pension/seed.js +82 -0
- package/dist/pension/seed.js.map +1 -0
- package/dist/pension/uplift.d.ts +151 -0
- package/dist/pension/uplift.js +135 -0
- package/dist/pension/uplift.js.map +1 -0
- package/dist/pension-projection.d.ts +249 -12
- package/dist/pension-projection.js +406 -101
- package/dist/pension-projection.js.map +1 -1
- package/dist/pension.js +9 -10
- package/dist/pension.js.map +1 -1
- package/dist/post.d.ts +24 -16
- package/dist/post.js +2 -3
- package/dist/post.js.map +1 -1
- package/dist/revaluation.d.ts +189 -0
- package/dist/revaluation.js +270 -0
- package/dist/revaluation.js.map +1 -0
- package/dist/scales.d.ts +17 -10
- package/dist/scales.js +17 -10
- package/dist/scales.js.map +1 -1
- package/dist/take-home.d.ts +9 -5
- package/dist/take-home.js +9 -5
- package/dist/take-home.js.map +1 -1
- package/package.json +2 -2
|
@@ -26,12 +26,141 @@
|
|
|
26
26
|
* → Deferred revaluation: CPI only
|
|
27
27
|
* → In-payment revaluation: CPI (Pensions Increase Order)
|
|
28
28
|
*
|
|
29
|
+
* ── Two projections, not one and a deflator ─────────
|
|
30
|
+
*
|
|
31
|
+
* Everything is computed in CASH — actual pounds at a stated
|
|
32
|
+
* date — because that is the ruler the scheme itself uses: its
|
|
33
|
+
* records, its uplifts and a member's statement are all cash
|
|
34
|
+
* figures.
|
|
35
|
+
*
|
|
36
|
+
* Today's money is NOT that divided by inflation. It is the
|
|
37
|
+
* SAME model run with the caller's assumption set to ZERO, so
|
|
38
|
+
* the pot grows 1.5% a year while a member is paying in and
|
|
39
|
+
* not at all once they are deferred, and pay stays the figure
|
|
40
|
+
* they gave. `projectPension` runs both and pairs them; every
|
|
41
|
+
* reported figure carries the two readings and its own date.
|
|
42
|
+
*
|
|
43
|
+
* **So today's money does not move with the CPI assumption**,
|
|
44
|
+
* and a deferred pension is exactly flat in it. Deflating
|
|
45
|
+
* instead leaves 1.5 / (1 + cpi) of real growth — 1.47% at 2% —
|
|
46
|
+
* which is defensible arithmetic and not what anyone means by
|
|
47
|
+
* ignoring inflation. A member checking by hand takes 1.5% a
|
|
48
|
+
* year on a flat salary; the tool's own two views are defined
|
|
49
|
+
* that way, so this is.
|
|
50
|
+
*
|
|
51
|
+
* It also means there is no anchor date, no face-value window,
|
|
52
|
+
* and no rule that a stated balance must never be restated: at a
|
|
53
|
+
* zero assumption there is nothing to restate, so that property
|
|
54
|
+
* holds by construction rather than by a clamp. An anchor is the
|
|
55
|
+
* tempting repair and there is no right placement for one —
|
|
56
|
+
* every candidate produces a defensible figure that disagrees
|
|
57
|
+
* with a real statement.
|
|
58
|
+
*
|
|
59
|
+
* **CPI + 1.5 is an ADDITION, never a multiplication.** 3.1% CPI
|
|
60
|
+
* gives 4.6%, which is what the Treasury Order made and what a
|
|
61
|
+
* member's statement shows — not the 4.6465% that 1.031 x 1.015
|
|
62
|
+
* produces. The multiplicative reading is tempting because it
|
|
63
|
+
* makes the scheme look CPI-free in real terms, so ONE
|
|
64
|
+
* projection serves both rulers and cannot disagree with itself.
|
|
65
|
+
* Read as the scheme writes it, the real rate is 1.5 / (1 + cpi)
|
|
66
|
+
* and DOES move with the assumption — so the two rulers can
|
|
67
|
+
* disagree, and the model says so rather than pretending
|
|
68
|
+
* otherwise. Two runs are what buy back a stable today's-money
|
|
69
|
+
* reading, at no cost in arithmetic the scheme does not do.
|
|
70
|
+
* Deferred and in payment are CPI exactly, so those phases are
|
|
71
|
+
* flat in real terms either way.
|
|
72
|
+
*
|
|
73
|
+
* Decided in the open at
|
|
74
|
+
* https://github.com/casomoltd/nhs-pay/issues/10
|
|
75
|
+
*
|
|
76
|
+
* ── Annual, and stepped ─────────────────────────────
|
|
77
|
+
*
|
|
78
|
+
* The scheme year is the unit. The pot moves once a year, on
|
|
79
|
+
* 6 April (1 April through 2022), and is unchanged in between —
|
|
80
|
+
* so the model steps rather than compounds continuously, and a
|
|
81
|
+
* figure read four months after an uplift is the same figure
|
|
82
|
+
* that uplift produced. `pension/ledger.ts` holds one row per
|
|
83
|
+
* scheme year; this module is the orchestrator over it.
|
|
84
|
+
*
|
|
29
85
|
* NHSBSA Key Notes — 2015 Scheme Estimates (V2), March 2025
|
|
30
86
|
* → Commutation rate: £12 lump sum per £1 pension
|
|
31
87
|
* → HMRC 25% cap on lump sum
|
|
88
|
+
*
|
|
89
|
+
* ── One rate after the seed ─────────────────────────
|
|
90
|
+
*
|
|
91
|
+
* A projection reads no published Revaluation Order. Every
|
|
92
|
+
* uplift after the seed is the caller's assumption, whether or
|
|
93
|
+
* not an Order covers that year, and whether the member is
|
|
94
|
+
* still paying in or left a decade ago.
|
|
95
|
+
*
|
|
96
|
+
* An Order is a NOMINAL rate, and today's money is this same
|
|
97
|
+
* model at an assumption of ZERO. Applying one inside that run
|
|
98
|
+
* puts a whole year of CPI into a reading defined to contain
|
|
99
|
+
* none — 8.2 points for a member holding a 2024 statement, 3.2
|
|
100
|
+
* for a 2025 one — so the size of the error is not a property
|
|
101
|
+
* of the member at all, only of the piece of paper they
|
|
102
|
+
* happened to type in.
|
|
103
|
+
*
|
|
104
|
+
* Nor is the exactness collectable. The year-end figure an Order
|
|
105
|
+
* produces here also contains this library's guess at that
|
|
106
|
+
* year's pay, so there is nothing to check it against until a
|
|
107
|
+
* statement the member has not received. What IS checkable stays
|
|
108
|
+
* checkable: the stated figure itself is never restated.
|
|
109
|
+
*
|
|
110
|
+
* Decided in the open at
|
|
111
|
+
* https://github.com/casomoltd/nhs-pay/issues/13
|
|
112
|
+
*
|
|
113
|
+
* ── Checked against a real statement ────────────────
|
|
114
|
+
*
|
|
115
|
+
* Reconciled line by line against a member's NHS Annual
|
|
116
|
+
* Benefit Statement (2015 Section, updated to 31/03/2025;
|
|
117
|
+
* name and membership number redacted):
|
|
118
|
+
* Archived as "Annual Benefit Statement, 2015 Section,
|
|
119
|
+
* redacted" — see docs/source-archive.md.
|
|
120
|
+
*
|
|
121
|
+
* The accrual rate, the in-service revaluation, the HMRC
|
|
122
|
+
* lump-sum cap and the commutation residual all reproduced
|
|
123
|
+
* it. No figure from it is recorded here — the earnings
|
|
124
|
+
* beside those rates are the member's and stay out.
|
|
125
|
+
*
|
|
126
|
+
* It settled the ORDER of the accrual loop, previously an
|
|
127
|
+
* untested assumption: a year's slice is added AFTER the pot
|
|
128
|
+
* is revalued, never before, so a slice earns no revaluation
|
|
129
|
+
* in the scheme year it is earned. The other order overstated
|
|
130
|
+
* that statement by 3.2%, and every internal test still
|
|
131
|
+
* passed. `pension/ledger.ts` is written in that order and
|
|
132
|
+
* `revaluation never touches the year's own slice` holds it
|
|
133
|
+
* there.
|
|
134
|
+
*
|
|
135
|
+
* A ten-year projection built BY HAND from that statement is
|
|
136
|
+
* the golden oracle in `tests/golden-abs.test.ts` — reproduced
|
|
137
|
+
* to the penny on every row. It was hand-built before this
|
|
138
|
+
* code, which is the point of it: a fixture derived from the
|
|
139
|
+
* implementation agrees with whatever the implementation is
|
|
140
|
+
* changed to.
|
|
141
|
+
*
|
|
142
|
+
* ── Added, not compounded ───────────────────────────
|
|
143
|
+
*
|
|
144
|
+
* The scheme ADDS CPI and 1.5 PERCENTAGE POINTS: 3.1% CPI
|
|
145
|
+
* gives 4.6%, which is what the Treasury Order made and what
|
|
146
|
+
* the statement above shows. revaluation.ts carries every
|
|
147
|
+
* published year with its SI, and `pension/uplift.ts` derives
|
|
148
|
+
* the rate forward from the CPI figure — never backward, since
|
|
149
|
+
* back-computing CPI as rate − 1.5 would make the test of the
|
|
150
|
+
* +1.5 rule agree with itself.
|
|
151
|
+
*
|
|
152
|
+
* This module used to compound instead, at a flat real 1.5%:
|
|
153
|
+
* the multiplicative reading of the same rule, running about
|
|
154
|
+
* 0.6% high over a full career at 2% CPI. That is now fixed,
|
|
155
|
+
* at the cost described above.
|
|
32
156
|
*/
|
|
33
157
|
import { invariant } from './errors.js';
|
|
34
158
|
import { npaDate, periodInYearsMonths, yearsBetween, } from './dates.js';
|
|
159
|
+
import { createPrices } from './pension/prices.js';
|
|
160
|
+
import { buildLedger } from './pension/ledger.js';
|
|
161
|
+
import { estimateHistory } from './pension/history.js';
|
|
162
|
+
import { openingUpliftFor } from './pension/uplift.js';
|
|
163
|
+
import { schemeYearClosedBy, schemeYearEndDate, schemeYearEndFor, seedFromJoinDate, seedFromStatement, } from './pension/seed.js';
|
|
35
164
|
import { FactorTable } from './gad/factor-table.js';
|
|
36
165
|
import { ERF_0_420 } from './gad/erf-2023-06-30.js';
|
|
37
166
|
import { LRF_0_421 } from './gad/lrf-2023-06-30.js';
|
|
@@ -40,14 +169,24 @@ import { LRF_0_421 } from './gad/lrf-2023-06-30.js';
|
|
|
40
169
|
export const ACCRUAL_RATE = 1 / 54;
|
|
41
170
|
/** Commutation: £12 lump sum per £1 pension */
|
|
42
171
|
export const COMMUTATION_FACTOR = 12;
|
|
43
|
-
/** In-service revaluation bonus above CPI */
|
|
44
|
-
const ACTIVE_REVAL_BONUS = 0.015;
|
|
45
172
|
// ── Factor Tables ───────────────────────────────────
|
|
46
173
|
// Which issue is in force is exactly these two constructions —
|
|
47
174
|
// swap the import when GAD supersedes a table (the two tables
|
|
48
175
|
// change on different dates, hence one issue file per table).
|
|
49
176
|
const ERF1 = new FactorTable(ERF_0_420);
|
|
50
177
|
const LRF1 = new FactorTable(LRF_0_421);
|
|
178
|
+
/**
|
|
179
|
+
* Provenance of the in-force table behind a factor kind — the
|
|
180
|
+
* citation facts (table ref, guidance name, issue date, source
|
|
181
|
+
* PDF) consumers render instead of hand-typing them, so a page
|
|
182
|
+
* showing "GAD factors issued 30 June 2023" updates itself when
|
|
183
|
+
* a later issue supersedes the table above.
|
|
184
|
+
*/
|
|
185
|
+
export function factorProvenance(kind) {
|
|
186
|
+
return kind === 'erf'
|
|
187
|
+
? ERF1.provenance
|
|
188
|
+
: LRF1.provenance;
|
|
189
|
+
}
|
|
51
190
|
// ── Retirement Factor ───────────────────────────────
|
|
52
191
|
/**
|
|
53
192
|
* Determine whether ERF or LRF applies and return the
|
|
@@ -119,123 +258,289 @@ export function commute(adjustedPension, fraction) {
|
|
|
119
258
|
* could flip the ms-precision accrued flag).
|
|
120
259
|
*/
|
|
121
260
|
export function projectPension(input, today = new Date()) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
261
|
+
/* TWO RUNS, not one run read two ways. Cash at the caller's
|
|
262
|
+
assumption; today's money with that assumption set to zero,
|
|
263
|
+
which is what "ignore inflation" means: the pension
|
|
264
|
+
revalues at 1.5% a year while accruing and not at all once
|
|
265
|
+
deferred, and pay stays the figure the caller gave.
|
|
266
|
+
|
|
267
|
+
Cheap, deterministic and pure, so running the model twice
|
|
268
|
+
costs a few microseconds and buys a definition a reader can
|
|
269
|
+
check by hand. The deflated alternative cost an anchor
|
|
270
|
+
date, a face-value window, a rule against restating a
|
|
271
|
+
stated balance, and three failed attempts at placing the
|
|
272
|
+
anchor — all to arrive at 1.47% where the member's own
|
|
273
|
+
arithmetic says 1.5%. */
|
|
274
|
+
const cash = resolveProjection(input, today);
|
|
275
|
+
const todays = input.assumedCpi === 0
|
|
276
|
+
? cash
|
|
277
|
+
: resolveProjection({ ...input, assumedCpi: 0 }, today);
|
|
278
|
+
const pair = (n, r, asAt) => ({ nominal: n, real: r, asAt });
|
|
125
279
|
return {
|
|
126
|
-
accruedAtExit:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
280
|
+
accruedAtExit: pair(cash.accruedAtExit, todays.accruedAtExit,
|
|
281
|
+
// Dated at the close it is the closing of.
|
|
282
|
+
schemeYearEndDate(schemeYearEndFor(cash.exitDate))),
|
|
283
|
+
revaluedAtRetirement: pair(cash.revaluedAtRetirement, todays.revaluedAtRetirement, cash.retirementDate),
|
|
284
|
+
annualPension: pair(cash.annualPension, todays.annualPension, cash.retirementDate),
|
|
285
|
+
accruedNow: pair(cash.ledger.atDate(today), todays.ledger.atDate(today), today),
|
|
286
|
+
factor: cash.factor,
|
|
287
|
+
factorType: cash.factorType,
|
|
288
|
+
adjustmentAmount: pair(cash.revaluedAtRetirement - cash.annualPension, todays.revaluedAtRetirement - todays.annualPension, cash.retirementDate),
|
|
289
|
+
curve: buildCurve(cash, todays),
|
|
290
|
+
isEstimation: cash.isEstimation,
|
|
291
|
+
estimatedHistory: todays.history,
|
|
292
|
+
ledger: cash.ledger,
|
|
293
|
+
todaysMoneyLedger: todays.ledger,
|
|
134
294
|
};
|
|
135
295
|
}
|
|
136
|
-
// ── Internal Helpers ────────────────────────────────
|
|
137
296
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
297
|
+
* A member's stated balance, on whatever date it is stated —
|
|
298
|
+
* the day they read it, or the day their statement prints. That
|
|
299
|
+
* is a position mid-scheme-year, and a seed is a year-end
|
|
300
|
+
* closing balance, so it has to be carried back to one.
|
|
301
|
+
*
|
|
302
|
+
* In November the April uplift has already been applied to the
|
|
303
|
+
* figure being read, so dividing it out lands on the last
|
|
304
|
+
* year-end closing balance and the walk re-applies it — no
|
|
305
|
+
* double count, and no year of accrual thrown away. On a date
|
|
306
|
+
* before that April the figure already IS the year-end balance
|
|
307
|
+
* and nothing is divided, which is why a statement printed on
|
|
308
|
+
* 31 March passes through untouched.
|
|
309
|
+
*
|
|
310
|
+
* ONE route for both the dated and the undated case, because
|
|
311
|
+
* there is only one question: what was the closing balance at
|
|
312
|
+
* the year end before this date? `seedFromStatement` stays
|
|
313
|
+
* strict about wanting a year end; this is what finds it.
|
|
314
|
+
* Statements print on arbitrary days — 7 November is a real
|
|
315
|
+
* one — so the strict form alone could not serve them.
|
|
140
316
|
*/
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
return pension;
|
|
317
|
+
function seedFromBalanceAt(balance, asOf, exitDate, retirementDate, prices) {
|
|
318
|
+
const lastYearEnd = schemeYearClosedBy(asOf);
|
|
319
|
+
/* The uplift undone here is the one OPENING year
|
|
320
|
+
`lastYearEnd + 1`, and it is the very object `buildLedger`
|
|
321
|
+
re-applies to that year: inverting the walk exactly is this
|
|
322
|
+
function's only job, so both sides ask `openingUpliftFor`
|
|
323
|
+
rather than each naming the phase, the year and the CPI
|
|
324
|
+
series for themselves. */
|
|
325
|
+
const applied = openingUpliftFor(lastYearEnd, exitDate, retirementDate, prices);
|
|
326
|
+
const already = applied.appliedOn <= asOf;
|
|
327
|
+
return seedFromStatement(already ? balance / (1 + applied.percent / 100) : balance, schemeYearEndDate(lastYearEnd));
|
|
154
328
|
}
|
|
155
|
-
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
* which simulateAccrual returns untouched — so the
|
|
159
|
-
* statement path's "already past exit" case needs no
|
|
160
|
-
* special branch.
|
|
161
|
-
*/
|
|
162
|
-
function accruedNominalAt(anchor, date) {
|
|
163
|
-
const years = Math.max(0, yearsBetween(anchor.accrualOrigin, date));
|
|
164
|
-
return simulateAccrual(anchor.accrualBase, anchor.currentSalary, anchor.activeRate, years);
|
|
329
|
+
/** The earliest of some dates. */
|
|
330
|
+
function earliest(...dates) {
|
|
331
|
+
return new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
165
332
|
}
|
|
166
|
-
/** The single place input.kind is read */
|
|
167
333
|
function resolveProjection(input, today) {
|
|
168
334
|
const { currentSalary, dateOfBirth, exitDate, retirementDate, npa, assumedCpi, } = input;
|
|
335
|
+
/* The drawing date is used EXACTLY AS GIVEN, to the day.
|
|
336
|
+
Retiring on a birthday, mid-month, or on a scheme year end
|
|
337
|
+
are three different questions and this function answers
|
|
338
|
+
whichever one it is asked — the GAD tables are printed by
|
|
339
|
+
year AND month, and the rounding rules (ERF up §2.3, LRF
|
|
340
|
+
down §3.4) exist precisely for the part-months a date-exact
|
|
341
|
+
answer produces.
|
|
342
|
+
|
|
343
|
+
A CONSUMER may want less than that. The NHS pension
|
|
344
|
+
calculator prices retirement in whole years from NPA,
|
|
345
|
+
because it draws a chart whose every point is a 31 March
|
|
346
|
+
and a factor that moved when you retired "on time" would
|
|
347
|
+
be harder to follow than one that is a little rough. It
|
|
348
|
+
gets that by handing this function two birthdays, which are
|
|
349
|
+
a whole number of years apart. That is its simplification
|
|
350
|
+
to declare, in its own methods, and it did not belong in
|
|
351
|
+
here: a library that has already thrown the precision away
|
|
352
|
+
cannot offer it back to the next caller. */
|
|
169
353
|
const isEstimation = input.kind === 'estimation';
|
|
170
|
-
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
accrualOrigin: isEstimation ? input.joinDate : today,
|
|
176
|
-
currentSalary,
|
|
177
|
-
activeRate: assumedCpi + ACTIVE_REVAL_BONUS,
|
|
178
|
-
};
|
|
179
|
-
const accruedAtExit = accruedNominalAt(anchor, exitDate);
|
|
180
|
-
// Revalue from exit to retirement (deferred = CPI
|
|
181
|
-
// only); revalue self-guards non-positive periods
|
|
182
|
-
const revaluedAtRetirement = revalue(accruedAtExit, assumedCpi, yearsBetween(exitDate, retirementDate));
|
|
183
|
-
// Apply ERF/LRF
|
|
354
|
+
const prices = createPrices(assumedCpi, today);
|
|
355
|
+
// The ONLY place the input variant is read.
|
|
356
|
+
const seed = isEstimation
|
|
357
|
+
? seedFromJoinDate(input.joinDate)
|
|
358
|
+
: seedFromBalanceAt(input.accruedPension, input.statementDate ?? today, exitDate, retirementDate, prices);
|
|
184
359
|
const { factor, type: factorType } = retirementFactor(retirementDate, npaDate(dateOfBirth, npa));
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
360
|
+
const retireYear = schemeYearEndFor(retirementDate);
|
|
361
|
+
// Walk five years past the later of NPA and retirement, which
|
|
362
|
+
// is as far as the curve is ever asked to reach.
|
|
363
|
+
const through = Math.max(retireYear, schemeYearEndFor(npaDate(dateOfBirth, npa))) + 6;
|
|
364
|
+
const ledger = buildLedger({
|
|
365
|
+
seed,
|
|
366
|
+
pensionableEarnings: currentSalary,
|
|
190
367
|
exitDate,
|
|
191
368
|
retirementDate,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
369
|
+
prices,
|
|
370
|
+
through,
|
|
371
|
+
drawingFor: () => ({
|
|
372
|
+
on: retirementDate,
|
|
373
|
+
factor,
|
|
374
|
+
kind: factorType === 'none' ? 'erf' : factorType,
|
|
375
|
+
provenance: factorProvenance(factorType === 'none' ? 'erf' : factorType),
|
|
376
|
+
commuted: null,
|
|
377
|
+
}),
|
|
378
|
+
});
|
|
379
|
+
// Absent when retirement falls at or before the seed's own
|
|
380
|
+
// year end — a member handing over a balance and drawing it
|
|
381
|
+
// the same day. There is no row then, but there is still an
|
|
382
|
+
// answer: the balance they handed over.
|
|
383
|
+
const retireRow = ledger.years.find((r) => r.schemeYearEnd === retireYear);
|
|
384
|
+
const revalued = retireRow === undefined
|
|
385
|
+
? ledger.accruedAt(retirementDate)
|
|
386
|
+
: retireRow.revalued + retireRow.earned;
|
|
387
|
+
const drawn = retireRow === undefined
|
|
388
|
+
? revalued * factor
|
|
389
|
+
: retireRow.closing;
|
|
390
|
+
/* Illustration only, and only where a statement leaves a gap:
|
|
391
|
+
an estimation path already walks from the join date, so
|
|
392
|
+
there is nothing to fill in. Calibrated to land exactly on
|
|
393
|
+
the stated balance, so the two arms meet without a seam. */
|
|
394
|
+
const history = input.kind === 'statement'
|
|
395
|
+
&& input.joinDate !== undefined
|
|
396
|
+
? estimateHistory({
|
|
397
|
+
joinDate: input.joinDate,
|
|
398
|
+
statedBalance: seed.opening,
|
|
399
|
+
statementSchemeYearEnd: seed.atSchemeYearEnd,
|
|
400
|
+
prices,
|
|
401
|
+
})
|
|
402
|
+
: null;
|
|
403
|
+
return {
|
|
404
|
+
today, dateOfBirth, exitDate, retirementDate, npa,
|
|
405
|
+
prices, ledger, history, isEstimation, factor, factorType,
|
|
406
|
+
/* The earliest date the ledger holds a balance for, which
|
|
407
|
+
is the seed's own year end — NOT today.
|
|
408
|
+
|
|
409
|
+
The seed IS a balance at a scheme year end, so the months
|
|
410
|
+
between it and today are rows of this walk like any
|
|
411
|
+
other; starting the curve at today withholds them.
|
|
412
|
+
Starting at today also puts a past leaving date OUTSIDE
|
|
413
|
+
the plotted range, leaving the "stops paying in" marker
|
|
414
|
+
floating in space beside a chart that begins after it. */
|
|
415
|
+
curveFrom: earliest(today, exitDate, schemeYearEndDate(history === null ? seed.atSchemeYearEnd : history.from - 1)),
|
|
416
|
+
/* The close of that year, not the exit date — see
|
|
417
|
+
docs/how-it-works.md, "An exit date names a SCHEME
|
|
418
|
+
YEAR, not a day". Reading the date puts this a whole
|
|
419
|
+
year's accrual below the rest of this object for a
|
|
420
|
+
mid-year leaver. */
|
|
421
|
+
accruedAtExit: ledger.closingAt(schemeYearEndFor(exitDate)),
|
|
422
|
+
revaluedAtRetirement: revalued,
|
|
423
|
+
annualPension: drawn,
|
|
200
424
|
};
|
|
201
425
|
}
|
|
202
|
-
/**
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
426
|
+
/**
|
|
427
|
+
* A member's age on a date, as WHOLE YEARS plus the fraction of
|
|
428
|
+
* the year since their birthday.
|
|
429
|
+
*
|
|
430
|
+
* The whole part is calendar arithmetic, so it is the age they
|
|
431
|
+
* would give if asked. The fraction only orders points within a
|
|
432
|
+
* year, which is all the chart needs it for.
|
|
433
|
+
*/
|
|
434
|
+
function ageAtYearEnd(dateOfBirth, on) {
|
|
435
|
+
const birthdayIn = (year) => new Date(year, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
436
|
+
const thisYear = birthdayIn(on.getFullYear());
|
|
437
|
+
const reached = thisYear <= on;
|
|
438
|
+
const whole = on.getFullYear() - dateOfBirth.getFullYear()
|
|
439
|
+
- (reached ? 0 : 1);
|
|
440
|
+
const last = reached ? thisYear : birthdayIn(on.getFullYear() - 1);
|
|
441
|
+
const next = reached ? birthdayIn(on.getFullYear() + 1) : thisYear;
|
|
442
|
+
return whole
|
|
443
|
+
+ (on.getTime() - last.getTime())
|
|
444
|
+
/ (next.getTime() - last.getTime());
|
|
218
445
|
}
|
|
219
446
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
447
|
+
* The curve is the ledger's own steps, plotted ON THEM.
|
|
448
|
+
*
|
|
449
|
+
* **One point per scheme year, at its 31 March close** — the
|
|
450
|
+
* date an Annual Benefit Statement is drawn to, so every
|
|
451
|
+
* plotted value is a figure a member can lay beside paper.
|
|
452
|
+
*
|
|
453
|
+
* **Never at BIRTHDAYS**, which is the plotting the age axis
|
|
454
|
+
* invites. A birthday falls somewhere inside a scheme year:
|
|
455
|
+
* after the April uplift but before the year's slice lands, or
|
|
456
|
+
* the other way about. So a member born in January reads their
|
|
457
|
+
* 43rd-birthday point as "the 2026 figure" and gets a balance
|
|
458
|
+
* with neither the year's accrual in it nor any relation to a
|
|
459
|
+
* year end — values right for their dates and wrong for every
|
|
460
|
+
* question anyone asks of them, which surfaces as "the chart
|
|
461
|
+
* disagrees with my statement".
|
|
462
|
+
*
|
|
463
|
+
* The x-axis stays an AGE, because that is how people think
|
|
464
|
+
* about retiring. Age N is plotted at the close of the scheme
|
|
465
|
+
* year N's birthday falls in — the year that birthday belongs
|
|
466
|
+
* to — so the axis is unchanged and only the dates behind it
|
|
467
|
+
* move onto the scheme's own calendar.
|
|
468
|
+
*
|
|
469
|
+
* Nothing is drawn before the ledger's own start. For a
|
|
470
|
+
* statement that is the statement's date, and the reason is
|
|
471
|
+
* not tidiness: a member enters one figure, not their history,
|
|
472
|
+
* so anything earlier would be that figure run BACKWARDS
|
|
473
|
+
* through rates nobody checked. An inverse calculation drawn
|
|
474
|
+
* as history is a claim the tool cannot support.
|
|
223
475
|
*/
|
|
224
|
-
function
|
|
225
|
-
const { today,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
|
|
476
|
+
function buildCurve(cash, todays) {
|
|
477
|
+
const { today, dateOfBirth, retirementDate, npa } = cash;
|
|
478
|
+
const endAge = Math.max(npa + 5, yearsBetween(dateOfBirth, retirementDate) + 5);
|
|
479
|
+
/** The scheme year an age's birthday falls in. */
|
|
480
|
+
const yearOfAge = (age) => schemeYearEndFor(new Date(dateOfBirth.getFullYear() + age, dateOfBirth.getMonth(), dateOfBirth.getDate()));
|
|
481
|
+
/** The age whose birthday falls in a scheme year — the
|
|
482
|
+
* inverse, used once to find where the axis starts. */
|
|
483
|
+
const ageInYear = (schemeYearEnd) => {
|
|
484
|
+
const end = schemeYearEndDate(schemeYearEnd);
|
|
485
|
+
const birthday = new Date(schemeYearEnd, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
486
|
+
return schemeYearEnd - dateOfBirth.getFullYear()
|
|
487
|
+
- (birthday > end ? 1 : 0);
|
|
488
|
+
};
|
|
489
|
+
const startAge = ageInYear(schemeYearEndFor(cash.curveFrom));
|
|
490
|
+
const points = [];
|
|
491
|
+
for (let label = startAge; label <= Math.ceil(endAge); label++) {
|
|
492
|
+
const year = yearOfAge(label);
|
|
493
|
+
const on = schemeYearEndDate(year);
|
|
494
|
+
/* The age the member actually IS on that 31 March, not the
|
|
495
|
+
whole age whose birthday the scheme year contains.
|
|
496
|
+
|
|
497
|
+
Those differ by anything from nought to twelve months —
|
|
498
|
+
the gap between a birthday and the following 31 March —
|
|
499
|
+
so plotting at the whole age put every value up to a year
|
|
500
|
+
early on the x-axis. Where "today" fell in that gap the
|
|
501
|
+
curve ran BACKWARDS: a member born in June read 7,738 at
|
|
502
|
+
39, 8,577 at 40, then 7,854 at 40.2 for today, then
|
|
503
|
+
9,429 at 41. Three of those are right; the axis was
|
|
504
|
+
wrong.
|
|
505
|
+
|
|
506
|
+
A January birthday hides it, being three months from the
|
|
507
|
+
year end. A June one puts nine months of accrual in the
|
|
508
|
+
wrong place.
|
|
509
|
+
|
|
510
|
+
Built as WHOLE AGE + fraction rather than as a span in
|
|
511
|
+
365.25-day years, so that `Math.floor(age)` is the age
|
|
512
|
+
the member actually is on that 31 March — by calendar
|
|
513
|
+
arithmetic, not within a rounding of it. Someone born on
|
|
514
|
+
1 April reads 42.997 at the year end before their 43rd
|
|
515
|
+
birthday, which floors correctly today and sits three
|
|
516
|
+
thousandths from flooring wrongly after enough leap
|
|
517
|
+
days. The fraction still orders the points; only the
|
|
518
|
+
whole part is now guaranteed. */
|
|
519
|
+
const age = ageAtYearEnd(dateOfBirth, on);
|
|
520
|
+
/* Two walks meet here, and the estimate owns everything up
|
|
521
|
+
to and including the statement's own year — its last row
|
|
522
|
+
IS the stated balance, so reading it there rather than
|
|
523
|
+
the main ledger changes nothing and keeps the join
|
|
524
|
+
seamless. */
|
|
525
|
+
const from = (r) => r.history !== null && year <= r.history.to
|
|
526
|
+
? r.history.ledger
|
|
527
|
+
: r.ledger;
|
|
528
|
+
const row = from(cash).years.find((r) => r.schemeYearEnd === year);
|
|
529
|
+
points.push({
|
|
530
|
+
age,
|
|
531
|
+
nominal: from(cash).atDate(on),
|
|
532
|
+
real: from(todays).atDate(on),
|
|
533
|
+
accrued: on <= today,
|
|
534
|
+
// Compared by scheme YEAR, matching the ledger's own
|
|
535
|
+
// rule, not by date: a point sits at a 31 March close, so
|
|
536
|
+
// a member who left in January of that year would read as
|
|
537
|
+
// deferred on the very year they were still paying in.
|
|
538
|
+
phase: row?.phase
|
|
539
|
+
?? (year <= schemeYearEndFor(cash.exitDate)
|
|
540
|
+
? 'active'
|
|
541
|
+
: 'deferred'),
|
|
542
|
+
});
|
|
234
543
|
}
|
|
235
|
-
|
|
236
|
-
// projection reports, never a re-derivation of it
|
|
237
|
-
const yrsInPayment = yearsBetween(retirementDate, pointDate);
|
|
238
|
-
const nominal = revalue(resolved.annualPension, assumedCpi, yrsInPayment);
|
|
239
|
-
return { nominal, accrued: false };
|
|
544
|
+
return points;
|
|
240
545
|
}
|
|
241
546
|
//# sourceMappingURL=pension-projection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pension-projection.js","sourceRoot":"","sources":["../src/pension-projection.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pension-projection.js","sourceRoot":"","sources":["../src/pension-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2JG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,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