@casomoltd/nhs-pay 0.19.4 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -18
- 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 +17 -4
- package/dist/index.js +22 -13
- 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 +54 -52
- package/dist/pension-projection.js +65 -219
- 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 +9 -5
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Sources:
|
|
9
9
|
*
|
|
10
|
-
* GAD
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* GAD consolidated factor workbook
|
|
11
|
+
* → ERF1/LRF1 values: src/gad/ holds the verbatim
|
|
12
|
+
* transcriptions, and each carries its own issue, version
|
|
13
|
+
* and provenance
|
|
14
14
|
*
|
|
15
15
|
* GAD "NHSPS 2015 E&W — Early and late retirement in normal
|
|
16
16
|
* health — Factors and guidance", 7 August 2019 — methodology
|
|
@@ -83,10 +83,6 @@
|
|
|
83
83
|
* that uplift produced. `pension/ledger.ts` holds one row per
|
|
84
84
|
* scheme year; this module is the orchestrator over it.
|
|
85
85
|
*
|
|
86
|
-
* NHSBSA Key Notes — 2015 Scheme Estimates (V2), March 2025
|
|
87
|
-
* → Commutation rate: £12 lump sum per £1 pension
|
|
88
|
-
* → HMRC 25% cap on lump sum
|
|
89
|
-
*
|
|
90
86
|
* ── One rate after the seed ─────────────────────────
|
|
91
87
|
*
|
|
92
88
|
* A projection reads no published Revaluation Order. Every
|
|
@@ -151,33 +147,32 @@
|
|
|
151
147
|
* back-computing CPI as rate − 1.5 would make the test of the
|
|
152
148
|
* +1.5 rule agree with itself.
|
|
153
149
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* at the cost described above.
|
|
150
|
+
* Compounding at a flat real 1.5% instead is the multiplicative
|
|
151
|
+
* reading of the same rule, and runs about 0.6% high over a full
|
|
152
|
+
* career at 2% CPI.
|
|
158
153
|
*/
|
|
159
|
-
import { npaDate, periodInYearsMonths,
|
|
154
|
+
import { earliest, npaDate, periodInYearsMonths, } from './dates.js';
|
|
160
155
|
import { createPrices } from './pension/prices.js';
|
|
161
|
-
import { ACCRUAL_RATE, buildLedger } from './pension/ledger.js';
|
|
156
|
+
import { ACCRUAL_RATE, atDrawing, buildLedger, flatPay, } from './pension/ledger.js';
|
|
162
157
|
import { estimateHistory } from './pension/history.js';
|
|
163
|
-
import {
|
|
164
|
-
import {
|
|
165
|
-
import {
|
|
166
|
-
import {
|
|
167
|
-
import { LRF_0_421 } from './gad/lrf-2023-06-30.js';
|
|
158
|
+
import { seedFromBalanceAt } from './pension/uplift.js';
|
|
159
|
+
import { buildCurve, walkThrough } from './pension/curve.js';
|
|
160
|
+
import { schemeYearEndDate, schemeYearEndFor, seedFromJoinDate, } from './pension/seed.js';
|
|
161
|
+
import { factorTable } from './factor-basis.js';
|
|
168
162
|
// ── Constants ───────────────────────────────────────
|
|
169
163
|
/* The accrual rate is owned by the ledger that applies it and
|
|
170
164
|
re-exported here, so the record and every figure read off it
|
|
171
165
|
cannot hold two different 1/54s. */
|
|
172
166
|
export { ACCRUAL_RATE };
|
|
173
167
|
// ── Factor Tables ───────────────────────────────────
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
const ERF1 =
|
|
178
|
-
const LRF1 =
|
|
168
|
+
// The 2015 Section's two tables, read through the one set every
|
|
169
|
+
// factor in the library comes from, so this and `memberBenefits`
|
|
170
|
+
// cannot round the same drawing two ways.
|
|
171
|
+
const ERF1 = factorTable('0-420');
|
|
172
|
+
const LRF1 = factorTable('0-421');
|
|
179
173
|
/**
|
|
180
|
-
* Provenance of the in-force table behind a factor
|
|
174
|
+
* Provenance of the 2015 Section's in-force table behind a factor
|
|
175
|
+
* kind — the
|
|
181
176
|
* citation facts (table ref, guidance name, issue date, source
|
|
182
177
|
* PDF) consumers render instead of hand-typing them, so a page
|
|
183
178
|
* showing "GAD factors issued 30 June 2023" updates itself when
|
|
@@ -198,6 +193,13 @@ export function factorProvenance(kind) {
|
|
|
198
193
|
* at NPA is not an early retirement with a factor of 1: naming
|
|
199
194
|
* a table there hands a consumer an ERF citation to render at a
|
|
200
195
|
* member who took no reduction.
|
|
196
|
+
*
|
|
197
|
+
* A second route to the factor `factor2015` reads through
|
|
198
|
+
* `factor-basis.ts`, kept because this public signature takes the
|
|
199
|
+
* pension-age date where that door takes a date of birth. It
|
|
200
|
+
* retires with `projectPension`
|
|
201
|
+
* (https://github.com/casomoltd/nhs-pay/issues/21), and until then
|
|
202
|
+
* `tests/section-factors.test.ts` holds the two routes equal.
|
|
201
203
|
*/
|
|
202
204
|
export function retirementFactor(retirementDate, npDate) {
|
|
203
205
|
if (retirementDate >= npDate) {
|
|
@@ -213,6 +215,21 @@ export function retirementFactor(retirementDate, npDate) {
|
|
|
213
215
|
const period = periodInYearsMonths(retirementDate, npDate);
|
|
214
216
|
return { factor: ERF1.factorFor(period), type: 'erf' };
|
|
215
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* The **2015 Section's** early retirement factor for drawing a
|
|
220
|
+
* whole period before its pension age: {@link retirementFactor} for
|
|
221
|
+
* a caller that holds the period rather than the two dates it
|
|
222
|
+
* spans. The 1995 and 2008 Sections are keyed by age and are not
|
|
223
|
+
* read here. A whole period has no part-month to round, so the
|
|
224
|
+
* table is read at exactly that row. Months are 0 to 11; a period
|
|
225
|
+
* past the last printed row raises
|
|
226
|
+
* {@link RetirementFactorOutOfRange}. It stays when
|
|
227
|
+
* `projectPension` retires: a caller holding a period is not a
|
|
228
|
+
* projection.
|
|
229
|
+
*/
|
|
230
|
+
export function erf2015For(period) {
|
|
231
|
+
return ERF1.factorFor({ ...period, days: 0 });
|
|
232
|
+
}
|
|
216
233
|
// ── Core Calculations ───────────────────────────────
|
|
217
234
|
/** Annual pension accrual for one year of service */
|
|
218
235
|
export function yearlyAccrual(pensionablePay) {
|
|
@@ -221,7 +238,14 @@ export function yearlyAccrual(pensionablePay) {
|
|
|
221
238
|
// ── Projection Orchestrator ─────────────────────────
|
|
222
239
|
/**
|
|
223
240
|
* Generate a full pension projection including curve
|
|
224
|
-
* data for both nominal and real
|
|
241
|
+
* data for both nominal and real views, the real one a second run
|
|
242
|
+
* at zero CPI rather than the nominal one deflated.
|
|
243
|
+
*
|
|
244
|
+
* @deprecated For the 2015 Section alone, on pay held flat.
|
|
245
|
+
* `memberBenefits` values a member across every section they
|
|
246
|
+
* hold; this stays for the flat-salary question until that can
|
|
247
|
+
* be asked of `memberBenefits` too:
|
|
248
|
+
* https://github.com/casomoltd/nhs-pay/issues/21
|
|
225
249
|
*
|
|
226
250
|
* `today` is the evaluation date — the anchor for the
|
|
227
251
|
* accrued/projected split and the real-terms deflator.
|
|
@@ -238,11 +262,8 @@ export function projectPension(input, today = new Date()) {
|
|
|
238
262
|
|
|
239
263
|
Cheap, deterministic and pure, so running the model twice
|
|
240
264
|
costs a few microseconds and buys a definition a reader can
|
|
241
|
-
check by hand
|
|
242
|
-
|
|
243
|
-
stated balance, and three failed attempts at placing the
|
|
244
|
-
anchor — all to arrive at 1.47% where the member's own
|
|
245
|
-
arithmetic says 1.5%. */
|
|
265
|
+
check by hand, where deflating arrives at 1.47% against the
|
|
266
|
+
member's own 1.5%. */
|
|
246
267
|
const cash = resolveProjection(input, today);
|
|
247
268
|
const todays = input.assumedCpi === 0
|
|
248
269
|
? cash
|
|
@@ -270,43 +291,6 @@ export function projectPension(input, today = new Date()) {
|
|
|
270
291
|
todaysMoneyLedger: todays.ledger,
|
|
271
292
|
};
|
|
272
293
|
}
|
|
273
|
-
/**
|
|
274
|
-
* A member's stated balance, on whatever date it is stated —
|
|
275
|
-
* the day they read it, or the day their statement prints. That
|
|
276
|
-
* is a position mid-scheme-year, and a seed is a year-end
|
|
277
|
-
* closing balance, so it has to be carried back to one.
|
|
278
|
-
*
|
|
279
|
-
* In November the April uplift has already been applied to the
|
|
280
|
-
* figure being read, so dividing it out lands on the last
|
|
281
|
-
* year-end closing balance and the walk re-applies it — no
|
|
282
|
-
* double count, and no year of accrual thrown away. On a date
|
|
283
|
-
* before that April the figure already IS the year-end balance
|
|
284
|
-
* and nothing is divided, which is why a statement printed on
|
|
285
|
-
* 31 March passes through untouched.
|
|
286
|
-
*
|
|
287
|
-
* ONE route for both the dated and the undated case, because
|
|
288
|
-
* there is only one question: what was the closing balance at
|
|
289
|
-
* the year end before this date? `seedFromStatement` stays
|
|
290
|
-
* strict about wanting a year end; this is what finds it.
|
|
291
|
-
* Statements print on arbitrary days — 7 November is a real
|
|
292
|
-
* one — so the strict form alone could not serve them.
|
|
293
|
-
*/
|
|
294
|
-
function seedFromBalanceAt(balance, asOf, exitDate, retirementDate, prices) {
|
|
295
|
-
const lastYearEnd = schemeYearClosedBy(asOf);
|
|
296
|
-
/* The uplift undone here is the one OPENING year
|
|
297
|
-
`lastYearEnd + 1`, and it is the very object `buildLedger`
|
|
298
|
-
re-applies to that year: inverting the walk exactly is this
|
|
299
|
-
function's only job, so both sides ask `openingUpliftFor`
|
|
300
|
-
rather than each naming the phase, the year and the CPI
|
|
301
|
-
series for themselves. */
|
|
302
|
-
const applied = openingUpliftFor(lastYearEnd, exitDate, retirementDate, prices);
|
|
303
|
-
const already = applied.appliedOn <= asOf;
|
|
304
|
-
return seedFromStatement(already ? balance / (1 + applied.percent / 100) : balance, schemeYearEndDate(lastYearEnd));
|
|
305
|
-
}
|
|
306
|
-
/** The earliest of some dates. */
|
|
307
|
-
function earliest(...dates) {
|
|
308
|
-
return new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
309
|
-
}
|
|
310
294
|
function resolveProjection(input, today) {
|
|
311
295
|
const { currentSalary, dateOfBirth, exitDate, retirementDate, npa, assumedCpi, } = input;
|
|
312
296
|
/* The drawing date is used EXACTLY AS GIVEN, to the day.
|
|
@@ -317,16 +301,12 @@ function resolveProjection(input, today) {
|
|
|
317
301
|
down §3.4) exist precisely for the part-months a date-exact
|
|
318
302
|
answer produces.
|
|
319
303
|
|
|
320
|
-
A
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
a whole number of years apart. That is its simplification
|
|
327
|
-
to declare, in its own methods, and it did not belong in
|
|
328
|
-
here: a library that has already thrown the precision away
|
|
329
|
-
cannot offer it back to the next caller. */
|
|
304
|
+
A consumer may want less than that, such as retirement
|
|
305
|
+
priced in whole years from NPA. It gets that by handing
|
|
306
|
+
this function two dates a whole number of years apart, and
|
|
307
|
+
declares the simplification in its own methods: a library
|
|
308
|
+
that has already thrown the precision away cannot offer it
|
|
309
|
+
back to the next caller. */
|
|
330
310
|
const isEstimation = input.kind === 'estimation';
|
|
331
311
|
const prices = createPrices(assumedCpi, today);
|
|
332
312
|
// The ONLY place the input variant is read.
|
|
@@ -334,13 +314,10 @@ function resolveProjection(input, today) {
|
|
|
334
314
|
? seedFromJoinDate(input.joinDate)
|
|
335
315
|
: seedFromBalanceAt(input.accruedPension, input.statementDate, exitDate, retirementDate, prices);
|
|
336
316
|
const { factor, type: factorType } = retirementFactor(retirementDate, npaDate(dateOfBirth, npa));
|
|
337
|
-
const
|
|
338
|
-
// Walk five years past the later of NPA and retirement, which
|
|
339
|
-
// is as far as the curve is ever asked to reach.
|
|
340
|
-
const through = Math.max(retireYear, schemeYearEndFor(npaDate(dateOfBirth, npa))) + 6;
|
|
317
|
+
const through = walkThrough(retirementDate, npaDate(dateOfBirth, npa));
|
|
341
318
|
const ledger = buildLedger({
|
|
342
319
|
seed,
|
|
343
|
-
|
|
320
|
+
payIn: flatPay(currentSalary),
|
|
344
321
|
exitDate,
|
|
345
322
|
retirementDate,
|
|
346
323
|
prices,
|
|
@@ -348,23 +325,12 @@ function resolveProjection(input, today) {
|
|
|
348
325
|
drawingFor: () => ({
|
|
349
326
|
on: retirementDate,
|
|
350
327
|
factor,
|
|
351
|
-
|
|
352
|
-
provenance: factorType === null
|
|
328
|
+
table: factorType === null
|
|
353
329
|
? null
|
|
354
|
-
: factorProvenance(factorType),
|
|
330
|
+
: { kind: factorType, provenance: factorProvenance(factorType) },
|
|
355
331
|
}),
|
|
356
332
|
});
|
|
357
|
-
|
|
358
|
-
// year end — a member handing over a balance and drawing it
|
|
359
|
-
// the same day. There is no row then, but there is still an
|
|
360
|
-
// answer: the balance they handed over.
|
|
361
|
-
const retireRow = ledger.years.find((r) => r.schemeYearEnd === retireYear);
|
|
362
|
-
const revalued = retireRow === undefined
|
|
363
|
-
? ledger.accruedAt(retirementDate)
|
|
364
|
-
: retireRow.revalued + retireRow.earned;
|
|
365
|
-
const drawn = retireRow === undefined
|
|
366
|
-
? revalued * factor
|
|
367
|
-
: retireRow.closing;
|
|
333
|
+
const { revalued, drawn } = atDrawing(ledger, retirementDate, factor);
|
|
368
334
|
/* Illustration only, and only where a statement leaves a gap:
|
|
369
335
|
an estimation path already walks from the join date, so
|
|
370
336
|
there is nothing to fill in. Calibrated to land exactly on
|
|
@@ -387,9 +353,8 @@ function resolveProjection(input, today) {
|
|
|
387
353
|
The seed IS a balance at a scheme year end, so the months
|
|
388
354
|
between it and today are rows of this walk like any
|
|
389
355
|
other; starting the curve at today withholds them.
|
|
390
|
-
Starting at today also
|
|
391
|
-
the
|
|
392
|
-
floating in space beside a chart that begins after it. */
|
|
356
|
+
Starting at today would also put a past leaving date
|
|
357
|
+
outside the curve's range. */
|
|
393
358
|
curveFrom: earliest(today, exitDate, schemeYearEndDate(history === null ? seed.atSchemeYearEnd : history.from - 1)),
|
|
394
359
|
/* The close of that year, not the exit date — see
|
|
395
360
|
docs/how-it-works.md, "An exit date names a SCHEME
|
|
@@ -401,123 +366,4 @@ function resolveProjection(input, today) {
|
|
|
401
366
|
annualPension: drawn,
|
|
402
367
|
};
|
|
403
368
|
}
|
|
404
|
-
/**
|
|
405
|
-
* A member's age on a date, as WHOLE YEARS plus the fraction of
|
|
406
|
-
* the year since their birthday.
|
|
407
|
-
*
|
|
408
|
-
* The whole part is calendar arithmetic, so it is the age they
|
|
409
|
-
* would give if asked. The fraction only orders points within a
|
|
410
|
-
* year, which is all the chart needs it for.
|
|
411
|
-
*/
|
|
412
|
-
function ageAtYearEnd(dateOfBirth, on) {
|
|
413
|
-
const birthdayIn = (year) => new Date(year, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
414
|
-
const thisYear = birthdayIn(on.getFullYear());
|
|
415
|
-
const reached = thisYear <= on;
|
|
416
|
-
const whole = on.getFullYear() - dateOfBirth.getFullYear()
|
|
417
|
-
- (reached ? 0 : 1);
|
|
418
|
-
const last = reached ? thisYear : birthdayIn(on.getFullYear() - 1);
|
|
419
|
-
const next = reached ? birthdayIn(on.getFullYear() + 1) : thisYear;
|
|
420
|
-
return whole
|
|
421
|
-
+ (on.getTime() - last.getTime())
|
|
422
|
-
/ (next.getTime() - last.getTime());
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* The curve is the ledger's own steps, plotted ON THEM.
|
|
426
|
-
*
|
|
427
|
-
* **One point per scheme year, at its 31 March close** — the
|
|
428
|
-
* date an Annual Benefit Statement is drawn to, so every
|
|
429
|
-
* plotted value is a figure a member can lay beside paper.
|
|
430
|
-
*
|
|
431
|
-
* **Never at BIRTHDAYS**, which is the plotting the age axis
|
|
432
|
-
* invites. A birthday falls somewhere inside a scheme year:
|
|
433
|
-
* after the April uplift but before the year's slice lands, or
|
|
434
|
-
* the other way about. So a member born in January reads their
|
|
435
|
-
* 43rd-birthday point as "the 2026 figure" and gets a balance
|
|
436
|
-
* with neither the year's accrual in it nor any relation to a
|
|
437
|
-
* year end — values right for their dates and wrong for every
|
|
438
|
-
* question anyone asks of them, which surfaces as "the chart
|
|
439
|
-
* disagrees with my statement".
|
|
440
|
-
*
|
|
441
|
-
* The x-axis stays an AGE, because that is how people think
|
|
442
|
-
* about retiring. Age N is plotted at the close of the scheme
|
|
443
|
-
* year N's birthday falls in — the year that birthday belongs
|
|
444
|
-
* to — so the axis is unchanged and only the dates behind it
|
|
445
|
-
* move onto the scheme's own calendar.
|
|
446
|
-
*
|
|
447
|
-
* Nothing is drawn before the ledger's own start. For a
|
|
448
|
-
* statement that is the statement's date, and the reason is
|
|
449
|
-
* not tidiness: a member enters one figure, not their history,
|
|
450
|
-
* so anything earlier would be that figure run BACKWARDS
|
|
451
|
-
* through rates nobody checked. An inverse calculation drawn
|
|
452
|
-
* as history is a claim the tool cannot support.
|
|
453
|
-
*/
|
|
454
|
-
function buildCurve(cash, todays) {
|
|
455
|
-
const { today, dateOfBirth, retirementDate, npa } = cash;
|
|
456
|
-
const endAge = Math.max(npa + 5, yearsBetween(dateOfBirth, retirementDate) + 5);
|
|
457
|
-
/** The scheme year an age's birthday falls in. */
|
|
458
|
-
const yearOfAge = (age) => schemeYearEndFor(new Date(dateOfBirth.getFullYear() + age, dateOfBirth.getMonth(), dateOfBirth.getDate()));
|
|
459
|
-
/** The age whose birthday falls in a scheme year — the
|
|
460
|
-
* inverse, used once to find where the axis starts. */
|
|
461
|
-
const ageInYear = (schemeYearEnd) => {
|
|
462
|
-
const end = schemeYearEndDate(schemeYearEnd);
|
|
463
|
-
const birthday = new Date(schemeYearEnd, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
464
|
-
return schemeYearEnd - dateOfBirth.getFullYear()
|
|
465
|
-
- (birthday > end ? 1 : 0);
|
|
466
|
-
};
|
|
467
|
-
const startAge = ageInYear(schemeYearEndFor(cash.curveFrom));
|
|
468
|
-
const points = [];
|
|
469
|
-
for (let label = startAge; label <= Math.ceil(endAge); label++) {
|
|
470
|
-
const year = yearOfAge(label);
|
|
471
|
-
const on = schemeYearEndDate(year);
|
|
472
|
-
/* The age the member actually IS on that 31 March, not the
|
|
473
|
-
whole age whose birthday the scheme year contains.
|
|
474
|
-
|
|
475
|
-
Those differ by anything from nought to twelve months —
|
|
476
|
-
the gap between a birthday and the following 31 March —
|
|
477
|
-
so plotting at the whole age put every value up to a year
|
|
478
|
-
early on the x-axis. Where "today" fell in that gap the
|
|
479
|
-
curve ran BACKWARDS: a member born in June read 7,738 at
|
|
480
|
-
39, 8,577 at 40, then 7,854 at 40.2 for today, then
|
|
481
|
-
9,429 at 41. Three of those are right; the axis was
|
|
482
|
-
wrong.
|
|
483
|
-
|
|
484
|
-
A January birthday hides it, being three months from the
|
|
485
|
-
year end. A June one puts nine months of accrual in the
|
|
486
|
-
wrong place.
|
|
487
|
-
|
|
488
|
-
Built as WHOLE AGE + fraction rather than as a span in
|
|
489
|
-
365.25-day years, so that `Math.floor(age)` is the age
|
|
490
|
-
the member actually is on that 31 March — by calendar
|
|
491
|
-
arithmetic, not within a rounding of it. Someone born on
|
|
492
|
-
1 April reads 42.997 at the year end before their 43rd
|
|
493
|
-
birthday, which floors correctly today and sits three
|
|
494
|
-
thousandths from flooring wrongly after enough leap
|
|
495
|
-
days. The fraction still orders the points; only the
|
|
496
|
-
whole part is now guaranteed. */
|
|
497
|
-
const age = ageAtYearEnd(dateOfBirth, on);
|
|
498
|
-
/* Two walks meet here, and the estimate owns everything up
|
|
499
|
-
to and including the statement's own year — its last row
|
|
500
|
-
IS the stated balance, so reading it there rather than
|
|
501
|
-
the main ledger changes nothing and keeps the join
|
|
502
|
-
seamless. */
|
|
503
|
-
const from = (r) => r.history !== null && year <= r.history.to
|
|
504
|
-
? r.history.ledger
|
|
505
|
-
: r.ledger;
|
|
506
|
-
const row = from(cash).years.find((r) => r.schemeYearEnd === year);
|
|
507
|
-
points.push({
|
|
508
|
-
age,
|
|
509
|
-
nominal: from(cash).atDate(on),
|
|
510
|
-
real: from(todays).atDate(on),
|
|
511
|
-
accrued: on <= today,
|
|
512
|
-
/* Off the row where there is one, and otherwise from the
|
|
513
|
-
SAME rule the row was built by — never a second copy of
|
|
514
|
-
it here. Compared by scheme YEAR, matching the ledger:
|
|
515
|
-
a point sits at a 31 March close, so a member who left
|
|
516
|
-
in January of that year would read as deferred on the
|
|
517
|
-
very year they were still paying in. */
|
|
518
|
-
phase: row?.phase ?? phaseAt(year, schemeYearEndFor(cash.exitDate), schemeYearEndFor(cash.retirementDate)),
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
return points;
|
|
522
|
-
}
|
|
523
369
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwJG;AAEH,OAAO,EACL,QAAQ,EACR,OAAO,EACP,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EACL,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,GAC9C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AA8I9C,uDAAuD;AAEvD;;sCAEsC;AACtC,OAAO,EAAC,YAAY,EAAC,CAAC;AAEtB,uDAAuD;AAEvD,gEAAgE;AAChE,iEAAiE;AACjE,0CAA0C;AAC1C,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAqB;IAErB,OAAO,IAAI,KAAK,KAAK;QACnB,CAAC,CAAC,IAAI,CAAC,UAAU;QACjB,CAAC,CAAC,IAAI,CAA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,CAAC,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC,EAAC;SACjE,CAAC;KACH,CAAC,CAAC;IAEH,MAAM,EAAC,QAAQ,EAAE,KAAK,EAAC,GAAG,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAEpE;;;kEAG8D;IAC9D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,WAAW;WACnC,KAAK,CAAC,QAAQ,KAAK,SAAS;QACjC,CAAC,CAAC,eAAe,CAAC;YACd,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,aAAa,EAAE,IAAI,CAAC,OAAO;YAC3B,sBAAsB,EAAE,IAAI,CAAC,eAAe;YAC5C,MAAM;SACP,CAAC;QACJ,CAAC,CAAC,IAAI,CAAC;IAET,OAAO;QACL,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG;QACjD,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;QACzD;;;;;;;wCAOgC;QAChC,SAAS,EAAE,QAAQ,CACjB,KAAK,EACL,QAAQ,EACR,iBAAiB,CACf,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAC3D,CACF;QACD;;;;8BAIsB;QACtB,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3D,oBAAoB,EAAE,QAAQ;QAC9B,aAAa,EAAE,KAAK;KACrB,CAAC;AACJ,CAAC"}
|
package/dist/scale-point.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ export interface ScalePoint {
|
|
|
14
14
|
/**
|
|
15
15
|
* Years of experience this point maps to (0-indexed), for scales the
|
|
16
16
|
* source lists *by year of service* — the SAS and consultant scales,
|
|
17
|
-
* whose figures step by year
|
|
17
|
+
* whose figures step by year, and every Agenda for Change band, whose
|
|
18
|
+
* "Year N" point is reached after N − 1 years in band. A pay path
|
|
19
|
+
* times a member's steps from it. Absent where the step is self-describing
|
|
18
20
|
* (a training stage, a dental band + point) and carries no year axis.
|
|
19
21
|
*/
|
|
20
22
|
yearsExperience?: number;
|
|
@@ -34,3 +36,11 @@ export interface ScalePoint {
|
|
|
34
36
|
*/
|
|
35
37
|
nodalPoint?: string;
|
|
36
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* A point on a stepped scale, which says when it is paid: every Agenda
|
|
41
|
+
* for Change point. A pay ladder takes these, so a point that cannot
|
|
42
|
+
* say when it is paid does not compile as a rung.
|
|
43
|
+
*/
|
|
44
|
+
export interface SteppedPoint extends ScalePoint {
|
|
45
|
+
readonly yearsExperience: number;
|
|
46
|
+
}
|
package/dist/scales.d.ts
CHANGED
|
@@ -36,26 +36,26 @@
|
|
|
36
36
|
* Handbook, amendment 62" (#sa-41), Annex 9
|
|
37
37
|
*
|
|
38
38
|
* The other three nations' sources are cited in their own circular
|
|
39
|
-
* files, beside the data they justify — including the
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* the circular.
|
|
39
|
+
* files, beside the data they justify — including the warning that
|
|
40
|
+
* Scotland's MSG consolidated table prints superseded 4.25% rates and
|
|
41
|
+
* must not be read instead of the circular.
|
|
43
42
|
*
|
|
44
43
|
* POINT LABELS — one convention, all four nations. A point's label is
|
|
45
44
|
* the year of service in which a member first reaches it: increment 1
|
|
46
45
|
* is `Year 1`, and the top point takes a `+` because service continues
|
|
47
46
|
* past it. No publisher prints such a label; every one is our reading
|
|
48
47
|
* of an interval the publisher does print. For the three circular
|
|
49
|
-
* nations
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* nations the year is derived in `afc-scales.ts` from the transcribed
|
|
49
|
+
* interval; England's are authored here as years. All four go through
|
|
50
|
+
* `afcPoint`, which writes the label and the year from one number, so
|
|
51
|
+
* a label and the timing a pay path reads from it cannot disagree.
|
|
52
52
|
*
|
|
53
53
|
* Labels are lookup keys for `afcResolver.fromScalePoint`, so changing
|
|
54
54
|
* one is an API change, and the fixtures assert them.
|
|
55
55
|
*/
|
|
56
56
|
import type { Nation, PayYear, YearLabel } from '@casomoltd/paye-calc';
|
|
57
57
|
import type { DocumentSource } from './document-source.js';
|
|
58
|
-
import type {
|
|
58
|
+
import type { SteppedPoint } from './scale-point.js';
|
|
59
59
|
import type { AfcBandId } from './afc-band.js';
|
|
60
60
|
export { AFC_BANDS, AFC_BAND_IDS } from './afc-band.js';
|
|
61
61
|
export type { AfcBandId } from './afc-band.js';
|
|
@@ -71,7 +71,7 @@ export interface HcasZones {
|
|
|
71
71
|
}
|
|
72
72
|
interface AfcScaleYear {
|
|
73
73
|
hcas: HcasZones;
|
|
74
|
-
scales: Record<AfcBandId,
|
|
74
|
+
scales: Record<AfcBandId, SteppedPoint[]>;
|
|
75
75
|
}
|
|
76
76
|
export declare const NLW_HOURLY: Partial<Record<YearLabel, number>>;
|
|
77
77
|
/**
|