@casomoltd/nhs-pay 0.28.0 → 0.30.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 +14 -3
- package/dist/dates.d.ts +3 -0
- package/dist/dates.js +7 -2
- package/dist/dates.js.map +1 -1
- package/dist/member/benefits.js +27 -32
- package/dist/member/benefits.js.map +1 -1
- package/dist/member/input-period.d.ts +41 -0
- package/dist/member/input-period.js +166 -0
- package/dist/member/input-period.js.map +1 -0
- package/dist/member/service.d.ts +4 -1
- package/dist/member/service.js +12 -1
- package/dist/member/service.js.map +1 -1
- package/dist/member/types.d.ts +37 -4
- package/dist/member/types.js.map +1 -1
- package/dist/member/valuation.d.ts +64 -8
- package/dist/member/valuation.js +110 -20
- package/dist/member/valuation.js.map +1 -1
- package/dist/post.d.ts +22 -29
- package/dist/post.js +14 -17
- package/dist/post.js.map +1 -1
- package/dist/sections/final-salary.d.ts +65 -47
- package/dist/sections/final-salary.js +127 -68
- package/dist/sections/final-salary.js.map +1 -1
- package/dist/take-home.d.ts +12 -6
- package/dist/take-home.js +12 -6
- package/dist/take-home.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -36,8 +36,8 @@ npm install @casomoltd/nhs-pay
|
|
|
36
36
|
|
|
37
37
|
Public on the npm registry — no auth or `.npmrc` config needed.
|
|
38
38
|
|
|
39
|
-
Requires `@casomoltd/paye-calc`
|
|
40
|
-
|
|
39
|
+
Requires `@casomoltd/paye-calc` as a peer dependency; the range it
|
|
40
|
+
accepts is `peerDependencies` in [`package.json`](package.json).
|
|
41
41
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
@@ -152,6 +152,7 @@ unpublished nation/year or grade rather than defaulting.
|
|
|
152
152
|
import {
|
|
153
153
|
PAST_YEARS, SECTIONS, isoDate, memberBenefits,
|
|
154
154
|
} from '@casomoltd/nhs-pay';
|
|
155
|
+
import {definedBenefitInput, taxYearEnd} from '@casomoltd/paye-calc';
|
|
155
156
|
|
|
156
157
|
// Built once from the member; `today` pins the date the figures
|
|
157
158
|
// are as at, so they reproduce.
|
|
@@ -192,6 +193,14 @@ for (const kind of ['legacy-basis', 'section-2015-basis'] as const) {
|
|
|
192
193
|
position.crystallised; // the pension and automatic lump sum, summed
|
|
193
194
|
position.cash; // the cash taken across the whole
|
|
194
195
|
}
|
|
196
|
+
|
|
197
|
+
// One tax year's pension input, for the annual allowance: 2027 is
|
|
198
|
+
// 2026-27 (paye-calc's `taxYearEnd`), for the same leaving and election,
|
|
199
|
+
// valued in that year's cash at 2% CPI.
|
|
200
|
+
const period = benefits.pensionInputPeriod(taxYearEnd(2027), {
|
|
201
|
+
leaving: isoDate('2039-09-30'), remedy: {kind: 'legacy-basis'},
|
|
202
|
+
}, 0.02);
|
|
203
|
+
const input = definedBenefitInput(period); // the year's input amount
|
|
195
204
|
```
|
|
196
205
|
|
|
197
206
|
Each section keeps its own rules — denominator, pay measure,
|
|
@@ -201,7 +210,9 @@ into one the scheme lacks. Pay comes from the member's pay path
|
|
|
201
210
|
does not model, such as a break, is refused with
|
|
202
211
|
`BenefitNotModelled` and a `code` to branch on; `NOT_MODELLED`
|
|
203
212
|
links each code to the issue tracking it. See
|
|
204
|
-
[*A member's benefits across sections*](docs/how-it-works.md#a-members-benefits-across-sections)
|
|
213
|
+
[*A member's benefits across sections*](docs/how-it-works.md#a-members-benefits-across-sections)
|
|
214
|
+
for the model. How each arrangement's pension input is valued is
|
|
215
|
+
[*A year's pension input*](docs/how-it-works.md#a-years-pension-input).
|
|
205
216
|
|
|
206
217
|
### Project a 2015 Section pension on flat pay
|
|
207
218
|
|
package/dist/dates.d.ts
CHANGED
|
@@ -64,3 +64,6 @@ export declare function yearsBetween(from: Date, to: Date): number;
|
|
|
64
64
|
export declare function npaDate(dateOfBirth: Date, npa: number): Date;
|
|
65
65
|
/** The earliest of some dates. */
|
|
66
66
|
export declare function earliest(...dates: readonly Date[]): Date;
|
|
67
|
+
/** Whole days from `from` to `to`, rounded to absorb the hour a clock
|
|
68
|
+
* change shifts local midnight by. */
|
|
69
|
+
export declare function daysBetween(from: Date, to: Date): number;
|
package/dist/dates.js
CHANGED
|
@@ -29,6 +29,7 @@ const HOURS_PER_DAY = 24;
|
|
|
29
29
|
const MINUTES_PER_HOUR = 60;
|
|
30
30
|
const SECONDS_PER_MINUTE = 60;
|
|
31
31
|
const MS_PER_SECOND = 1000;
|
|
32
|
+
/** Milliseconds in a calendar day, for counting days between two dates. */
|
|
32
33
|
const MS_PER_DAY = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
33
34
|
/** The Julian year: the mean year over a leap cycle, so compounding over a
|
|
34
35
|
* span crossing 29 February neither gains nor loses a day. */
|
|
@@ -72,8 +73,7 @@ export function periodInYearsMonths(from, to) {
|
|
|
72
73
|
totalMonths -= 1;
|
|
73
74
|
}
|
|
74
75
|
const anniversary = addMonthsClamped(from, totalMonths);
|
|
75
|
-
|
|
76
|
-
const days = Math.round((to.getTime() - anniversary.getTime()) / MS_PER_DAY);
|
|
76
|
+
const days = daysBetween(anniversary, to);
|
|
77
77
|
const years = Math.floor(totalMonths / MONTHS_PER_YEAR);
|
|
78
78
|
const months = totalMonths % MONTHS_PER_YEAR;
|
|
79
79
|
invariant(years >= 0 && months >= 0 && months < MONTHS_PER_YEAR
|
|
@@ -123,6 +123,11 @@ export function npaDate(dateOfBirth, npa) {
|
|
|
123
123
|
export function earliest(...dates) {
|
|
124
124
|
return new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
125
125
|
}
|
|
126
|
+
/** Whole days from `from` to `to`, rounded to absorb the hour a clock
|
|
127
|
+
* change shifts local midnight by. */
|
|
128
|
+
export function daysBetween(from, to) {
|
|
129
|
+
return Math.round((to.getTime() - from.getTime()) / MS_PER_DAY);
|
|
130
|
+
}
|
|
126
131
|
/** `date` plus `n` months, day-of-month clamped to the target
|
|
127
132
|
* month's length (31 Jan + 1mo = 28 Feb). */
|
|
128
133
|
function addMonthsClamped(date, n) {
|
package/dist/dates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.js","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,8CAA8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,UAAU,GACd,aAAa,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,aAAa,CAAC;AACxE;+DAC+D;AAC/D,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC;AAC/C;8CAC8C;AAC9C,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAU,EACV,EAAQ;IAER;;;;;;;;qCAQiC;IACjC,SAAS,CACP,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAC7B,mCAAmC,CACpC,CAAC;IACF,SAAS,CACP,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,EAC3B,iCAAiC,CAClC,CAAC;IACF,IAAI,WAAW,GACb,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,eAAe;UACvD,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtC,IAAI,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,CAAC;AAClE,CAAC;AAED;6CAC6C;AAC7C,SAAS,gBAAgB,CAAC,IAAU,EAAE,CAAS;IAC7C,MAAM,OAAO,GAAG,IAAI,IAAI,CACtB,IAAI,CAAC,WAAW,EAAE,EAClB,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,EACvB,CAAC,CACF,CAAC,OAAO,EAAE,CAAC;IACZ,OAAO,IAAI,IAAI,CACb,IAAI,CAAC,WAAW,EAAE,EAClB,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAClC,CAAC;AACJ,CAAC"}
|
package/dist/member/benefits.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A member's benefits across every section they hold: built once from
|
|
3
3
|
* what the member told us, then asked one question per set of
|
|
4
|
-
* retirement choices.
|
|
4
|
+
* retirement choices, and one per tax year for what it put in.
|
|
5
5
|
*
|
|
6
6
|
* Everything ABOUT the member goes in once, when the owner is built;
|
|
7
7
|
* each method takes only the question. So a caller never assembles the
|
|
@@ -18,22 +18,23 @@
|
|
|
18
18
|
* across that one total.
|
|
19
19
|
*
|
|
20
20
|
* Its parts sit beside it: the vocabulary in `types.ts`, the service
|
|
21
|
-
* check and the remedy's dates in `service.ts`,
|
|
22
|
-
* in `valuation.ts
|
|
21
|
+
* check and the remedy's dates in `service.ts`, each section's award
|
|
22
|
+
* in `valuation.ts`, and a tax year's pension input per arrangement in
|
|
23
|
+
* `input-period.ts`. This module owns the member; `index.ts` is the door
|
|
23
24
|
* a caller comes through.
|
|
24
25
|
*/
|
|
25
26
|
import { cashAt, nhsCommutationLimits } from '../commutation.js';
|
|
26
|
-
import { BenefitNotModelled, NOT_MODELLED } from '../errors.js';
|
|
27
|
+
import { BenefitNotModelled, invariant, NOT_MODELLED } from '../errors.js';
|
|
27
28
|
import { isoToDate } from '../iso-date.js';
|
|
28
29
|
import { drawingTest, firstJoinedOf, mayDrawOn, memberMinimumPensionAge, normalPensionAge, } from '../pension/ages.js';
|
|
29
30
|
import { buildPayPath } from '../pay-path.js';
|
|
30
31
|
import { npaDate } from '../dates.js';
|
|
31
32
|
import { sumMoney } from '../pension/money.js';
|
|
32
33
|
import { createPrices, createPublishedPrices, TODAYS_MONEY_CPI, } from '../pension/prices.js';
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import { PAST_YEARS,
|
|
34
|
+
import { periodsOf, refuseElectionMismatch, REMEDY, servicePeriods, } from './service.js';
|
|
35
|
+
import { careerAward, finalSalaryValued, holdings, legacyAward, refuseLeavingAfterDeclared, RULES, section2015, seed2015, walksWindow, windowSeed, } from './valuation.js';
|
|
36
|
+
import { inputPeriods } from './input-period.js';
|
|
37
|
+
import { PAST_YEARS, SECTIONS } from './types.js';
|
|
37
38
|
/** The price series each reading of the past is priced on. Total over
|
|
38
39
|
* `PastYears`, so a new reading fails the build until it has one. */
|
|
39
40
|
const CASH_SERIES = {
|
|
@@ -58,6 +59,7 @@ export function memberBenefits(member, assumptions, today) {
|
|
|
58
59
|
const history = {
|
|
59
60
|
born: member.dateOfBirth, firstJoined: firstJoinedOf(member),
|
|
60
61
|
};
|
|
62
|
+
const cashSeriesAt = (cpi) => CASH_SERIES[assumptions.pastYears](cpi, today);
|
|
61
63
|
const built = {
|
|
62
64
|
member,
|
|
63
65
|
history,
|
|
@@ -66,8 +68,9 @@ export function memberBenefits(member, assumptions, today) {
|
|
|
66
68
|
npaOn: npaDate(born, normalPensionAge(born)),
|
|
67
69
|
payPath: buildPayPath(member.dateOfBirth, member.pay),
|
|
68
70
|
legacy,
|
|
71
|
+
remedy,
|
|
69
72
|
ordinary2015,
|
|
70
|
-
cashPrices:
|
|
73
|
+
cashPrices: cashSeriesAt(assumptions.assumedCpi),
|
|
71
74
|
todaysPrices: createPrices(TODAYS_MONEY_CPI, today),
|
|
72
75
|
};
|
|
73
76
|
return {
|
|
@@ -78,13 +81,14 @@ export function memberBenefits(member, assumptions, today) {
|
|
|
78
81
|
minimumPensionAgeOn: (drawing) => memberMinimumPensionAge(history, drawing),
|
|
79
82
|
mayDrawOn: (drawing) => mayDrawOn(history, drawing),
|
|
80
83
|
now: () => holdings(built),
|
|
81
|
-
at: (choices) => position(built,
|
|
84
|
+
at: (choices) => position(built, choices),
|
|
85
|
+
pensionInputPeriod: inputPeriods(built, cashSeriesAt),
|
|
82
86
|
};
|
|
83
87
|
}
|
|
84
88
|
/** Every section's award at one set of choices, summed, with cash taken
|
|
85
89
|
* across the total. */
|
|
86
|
-
function position(b,
|
|
87
|
-
const dates = checked(b,
|
|
90
|
+
function position(b, choices) {
|
|
91
|
+
const dates = checked(b, choices);
|
|
88
92
|
const awards = b.legacy === null
|
|
89
93
|
? []
|
|
90
94
|
: legacyAwards(b, b.legacy, choices, dates);
|
|
@@ -109,18 +113,17 @@ function position(b, remedy, choices) {
|
|
|
109
113
|
* is final salary; on the 2015 basis the remedy window leaves it for a
|
|
110
114
|
* career average walk, paid from the legacy section. */
|
|
111
115
|
function legacyAwards(b, legacy, choices, dates) {
|
|
112
|
-
const {
|
|
116
|
+
const { window } = legacy;
|
|
117
|
+
const basis = choices.remedy.kind;
|
|
118
|
+
const finalSalary = legacyAward(b, finalSalaryValued(legacy, basis), dates);
|
|
119
|
+
if (!walksWindow(basis))
|
|
120
|
+
return [finalSalary];
|
|
113
121
|
// `checked` refused a 2015 basis for a member with no window.
|
|
114
|
-
|
|
115
|
-
if (!onThe2015Basis || window === null) {
|
|
116
|
-
return [legacyAward(b, legacy, legacyPeriodsOf(legacy), dates)];
|
|
117
|
-
}
|
|
122
|
+
invariant(window !== null, 'a 2015 basis with no remedy window valued');
|
|
118
123
|
return [
|
|
119
|
-
|
|
124
|
+
finalSalary,
|
|
120
125
|
careerAward(b, {
|
|
121
|
-
section: legacy.section,
|
|
122
|
-
window,
|
|
123
|
-
seedFor: () => seedFromJoinDate(isoToDate(window.from)),
|
|
126
|
+
section: legacy.section, window, seedFor: () => windowSeed(window),
|
|
124
127
|
}, dates).award,
|
|
125
128
|
];
|
|
126
129
|
}
|
|
@@ -152,22 +155,14 @@ function legacyOf(section) {
|
|
|
152
155
|
};
|
|
153
156
|
}
|
|
154
157
|
/** Refuse choices that cannot be valued, and return their dates. */
|
|
155
|
-
function checked(b,
|
|
158
|
+
function checked(b, choices) {
|
|
156
159
|
const leaving = isoToDate(choices.leaving);
|
|
157
160
|
const drawing = isoToDate(choices.drawing);
|
|
158
161
|
if (drawing < leaving) {
|
|
159
162
|
throw new RangeError('at: drawn before leaving');
|
|
160
163
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
const elects = choices.remedy.kind !== REMEDY_BASES.none;
|
|
165
|
-
const electionMismatch = remedy !== elects;
|
|
166
|
-
if (electionMismatch) {
|
|
167
|
-
throw new RangeError(remedy
|
|
168
|
-
? 'at: a remedy member needs an election'
|
|
169
|
-
: 'at: an election for a member with no remediable service');
|
|
170
|
-
}
|
|
164
|
+
refuseLeavingAfterDeclared('at', b, leaving);
|
|
165
|
+
refuseElectionMismatch('at', b.remedy, choices.remedy.kind);
|
|
171
166
|
// The scheme pays nothing before the minimum pension age outside ill
|
|
172
167
|
// health, so a figure there would be one no member could draw.
|
|
173
168
|
const { mayDraw, minimumAge } = drawingTest(b.history, choices.drawing);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"benefits.js","sourceRoot":"","sources":["../../src/member/benefits.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"benefits.js","sourceRoot":"","sources":["../../src/member/benefits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAC,MAAM,EAAE,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAE,YAAY,EAAC,MAAM,cAAc,CA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OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Prices } from '../pension/prices.js';
|
|
2
|
+
import type { MemberBenefits } from './types.js';
|
|
3
|
+
import type { Built } from './valuation.js';
|
|
4
|
+
/**
|
|
5
|
+
* Each tax year's pension input period for the member leaving on the date
|
|
6
|
+
* asked, in the cash of the price series `seriesAt` gives for an assumed
|
|
7
|
+
* CPI. Refuses a year before 2016-17, the first tax year that is a pension
|
|
8
|
+
* input period, a leaving after the one declared, an election for a member
|
|
9
|
+
* with no remedy window, and no election for one with a window. Under
|
|
10
|
+
* Finance Act 2004 s.238ZB an arrangement begun after 8 July 2015 has a
|
|
11
|
+
* first period from its start to the next 5 April
|
|
12
|
+
* (https://www.legislation.gov.uk/ukpga/2004/12/section/238ZB). It holds
|
|
13
|
+
* nothing at its start, so it reads as its tax year opening at nil, which
|
|
14
|
+
* `potAt` gives where the walk starts on the day the member joined. Not yet
|
|
15
|
+
* for a walk seeded from a statement: it holds the statement's balance on
|
|
16
|
+
* every date before it, so a year before the statement reads no growth
|
|
17
|
+
* (docs/how-it-works.md#a-years-pension-input).
|
|
18
|
+
*
|
|
19
|
+
* - **An arrangement per section paid from:** the legacy section, with its
|
|
20
|
+
* remedy window on either basis, since both are paid from it; and the
|
|
21
|
+
* 2015 Section. Our reading: Finance Act 2004 s.152 defines an
|
|
22
|
+
* arrangement only as "an arrangement relating to the member under the
|
|
23
|
+
* pension scheme", and no source read here splits the NHS scheme.
|
|
24
|
+
* - **Each value is held "as if" at the pension age** (PTM053301 step 1):
|
|
25
|
+
* before any early or late factor.
|
|
26
|
+
* - **The opening value** is what is held at the close of the day before
|
|
27
|
+
* the year, 5 April, and the closing value at the close of the 5 April
|
|
28
|
+
* ending it; a revaluation falls in the year its date does.
|
|
29
|
+
* - **A member serving the whole year** is valued in service at its end.
|
|
30
|
+
* The year the member leaves in closes on the leaving date instead, at the
|
|
31
|
+
* deferred value with the leaver adjustment. Our reading: no source read
|
|
32
|
+
* here dates a leaver's closing value, and the leaving date is when their
|
|
33
|
+
* rights stop accruing.
|
|
34
|
+
* - **The period's `cpi`** is the September CPI before the year, from the
|
|
35
|
+
* same series: the Order's figure where the series reads published ones.
|
|
36
|
+
*
|
|
37
|
+
* A caller reads year after year, so the walks are kept per CPI and
|
|
38
|
+
* leaving: a walk reads the same balance on a date whatever happens after
|
|
39
|
+
* it, so one walked to its last year's end values every year before it.
|
|
40
|
+
*/
|
|
41
|
+
export declare function inputPeriods(b: Built, seriesAt: (assumedCpi: number) => Prices): MemberBenefits['pensionInputPeriod'];
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A member's pension input period: one tax year's defined benefits per
|
|
3
|
+
* arrangement, at its start and its end, in cash, in the shape paye-calc's
|
|
4
|
+
* `definedBenefitInput` reads (HMRC PTM053301,
|
|
5
|
+
* https://www.gov.uk/hmrc-internal-manuals/pensions-tax-manual/ptm053301).
|
|
6
|
+
* What counts as one arrangement, and what each holds on a date, are the
|
|
7
|
+
* scheme's facts, so they are decided here and not by a caller.
|
|
8
|
+
*/
|
|
9
|
+
import { refuseBeforePensionInputPeriods, taxYearEndDate, taxYearEndFor, taxYearStartDate, } from '@casomoltd/paye-calc';
|
|
10
|
+
import { dayBefore } from '../dates.js';
|
|
11
|
+
import { invariant } from '../errors.js';
|
|
12
|
+
import { isoToDate } from '../iso-date.js';
|
|
13
|
+
import { schemeYearClosedBy, schemeYearEndFor } from '../pension/seed.js';
|
|
14
|
+
import { refuseElectionMismatch } from './service.js';
|
|
15
|
+
import { accruedLedger, finalSalaryHeldOn, finalSalaryValued, refuseLeavingAfterDeclared, seed2015, walkDates, walksWindow, windowSeed, } from './valuation.js';
|
|
16
|
+
/** The call a refusal names. */
|
|
17
|
+
const ASKED = 'pensionInputPeriod';
|
|
18
|
+
/** A `CpiEntry` is in percentage points; paye-calc's `cpi` a decimal. */
|
|
19
|
+
const POINTS_PER_UNIT = 100;
|
|
20
|
+
/**
|
|
21
|
+
* Each tax year's pension input period for the member leaving on the date
|
|
22
|
+
* asked, in the cash of the price series `seriesAt` gives for an assumed
|
|
23
|
+
* CPI. Refuses a year before 2016-17, the first tax year that is a pension
|
|
24
|
+
* input period, a leaving after the one declared, an election for a member
|
|
25
|
+
* with no remedy window, and no election for one with a window. Under
|
|
26
|
+
* Finance Act 2004 s.238ZB an arrangement begun after 8 July 2015 has a
|
|
27
|
+
* first period from its start to the next 5 April
|
|
28
|
+
* (https://www.legislation.gov.uk/ukpga/2004/12/section/238ZB). It holds
|
|
29
|
+
* nothing at its start, so it reads as its tax year opening at nil, which
|
|
30
|
+
* `potAt` gives where the walk starts on the day the member joined. Not yet
|
|
31
|
+
* for a walk seeded from a statement: it holds the statement's balance on
|
|
32
|
+
* every date before it, so a year before the statement reads no growth
|
|
33
|
+
* (docs/how-it-works.md#a-years-pension-input).
|
|
34
|
+
*
|
|
35
|
+
* - **An arrangement per section paid from:** the legacy section, with its
|
|
36
|
+
* remedy window on either basis, since both are paid from it; and the
|
|
37
|
+
* 2015 Section. Our reading: Finance Act 2004 s.152 defines an
|
|
38
|
+
* arrangement only as "an arrangement relating to the member under the
|
|
39
|
+
* pension scheme", and no source read here splits the NHS scheme.
|
|
40
|
+
* - **Each value is held "as if" at the pension age** (PTM053301 step 1):
|
|
41
|
+
* before any early or late factor.
|
|
42
|
+
* - **The opening value** is what is held at the close of the day before
|
|
43
|
+
* the year, 5 April, and the closing value at the close of the 5 April
|
|
44
|
+
* ending it; a revaluation falls in the year its date does.
|
|
45
|
+
* - **A member serving the whole year** is valued in service at its end.
|
|
46
|
+
* The year the member leaves in closes on the leaving date instead, at the
|
|
47
|
+
* deferred value with the leaver adjustment. Our reading: no source read
|
|
48
|
+
* here dates a leaver's closing value, and the leaving date is when their
|
|
49
|
+
* rights stop accruing.
|
|
50
|
+
* - **The period's `cpi`** is the September CPI before the year, from the
|
|
51
|
+
* same series: the Order's figure where the series reads published ones.
|
|
52
|
+
*
|
|
53
|
+
* A caller reads year after year, so the walks are kept per CPI and
|
|
54
|
+
* leaving: a walk reads the same balance on a date whatever happens after
|
|
55
|
+
* it, so one walked to its last year's end values every year before it.
|
|
56
|
+
*/
|
|
57
|
+
export function inputPeriods(b, seriesAt) {
|
|
58
|
+
const kept = new Map();
|
|
59
|
+
return (end, choices, assumedCpi) => {
|
|
60
|
+
const basis = choices.remedy.kind;
|
|
61
|
+
const leaving = isoToDate(choices.leaving);
|
|
62
|
+
refuseLeavingAfterDeclared(ASKED, b, leaving);
|
|
63
|
+
refuseElectionMismatch(ASKED, b.remedy, basis);
|
|
64
|
+
refuseBeforePensionInputPeriods(ASKED, end);
|
|
65
|
+
const closes = taxYearEndDate(end);
|
|
66
|
+
const key = `${String(assumedCpi)} ${choices.leaving}`;
|
|
67
|
+
const sofar = kept.get(key);
|
|
68
|
+
const walkedFarEnough = sofar !== undefined && closes <= sofar.reaches;
|
|
69
|
+
const walks = walkedFarEnough
|
|
70
|
+
? sofar
|
|
71
|
+
: walksTo(b, seriesAt(assumedCpi), leaving, closes);
|
|
72
|
+
kept.set(key, walks);
|
|
73
|
+
return periodRead(b, basis, {
|
|
74
|
+
// The close of the day before the year opens, 5 April.
|
|
75
|
+
opens: dayBefore(taxYearStartDate(end)),
|
|
76
|
+
closes,
|
|
77
|
+
left: leaving <= closes ? leaving : null,
|
|
78
|
+
walks,
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** The walks in `prices` for a member leaving on `leaving` that reach
|
|
83
|
+
* `closes`, and on to the pension age where that is later, so a caller
|
|
84
|
+
* reading year by year walks once. */
|
|
85
|
+
function walksTo(b, prices, leaving, closes) {
|
|
86
|
+
const reaches = closes < b.npaOn
|
|
87
|
+
? taxYearEndDate(taxYearEndFor(b.npaOn))
|
|
88
|
+
: closes;
|
|
89
|
+
const dates = walkDates(b, leaving);
|
|
90
|
+
// The scheme year `reaches` falls in, whose revaluation a 5 April reads
|
|
91
|
+
// where the Order was applied on 1 April.
|
|
92
|
+
const through = schemeYearEndFor(reaches);
|
|
93
|
+
const window = b.legacy?.window ?? null;
|
|
94
|
+
return {
|
|
95
|
+
prices,
|
|
96
|
+
reaches,
|
|
97
|
+
own: {
|
|
98
|
+
ledger: accruedLedger(b, {
|
|
99
|
+
window: b.ordinary2015, seed: seed2015(b, dates, prices), prices,
|
|
100
|
+
}, dates, through),
|
|
101
|
+
period: b.ordinary2015,
|
|
102
|
+
},
|
|
103
|
+
window: window === null
|
|
104
|
+
? null
|
|
105
|
+
: {
|
|
106
|
+
ledger: accruedLedger(b, {
|
|
107
|
+
window, seed: windowSeed(window), prices,
|
|
108
|
+
}, dates, through),
|
|
109
|
+
period: window,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** One tax year's period, read off the walks. */
|
|
114
|
+
function periodRead(b, basis, r) {
|
|
115
|
+
const arrangements = [];
|
|
116
|
+
if (b.legacy !== null) {
|
|
117
|
+
arrangements.push(legacyArrangement(b, b.legacy, basis, r));
|
|
118
|
+
}
|
|
119
|
+
const ownOpenedByClose = isoToDate(b.ordinary2015.from) <= r.closes;
|
|
120
|
+
if (ownOpenedByClose) {
|
|
121
|
+
arrangements.push(valuesOver((on) => ({
|
|
122
|
+
pension: potAt(r.walks.own, on), lumpSum: 0,
|
|
123
|
+
}), r));
|
|
124
|
+
}
|
|
125
|
+
// An Order is labelled by the scheme year that has just closed when it
|
|
126
|
+
// is applied, and its figure is the September CPI before the tax year.
|
|
127
|
+
const order = r.walks.prices.cpiFor(schemeYearClosedBy(r.opens));
|
|
128
|
+
return { arrangements, cpi: order.cpi / POINTS_PER_UNIT };
|
|
129
|
+
}
|
|
130
|
+
/** The legacy section: its final-salary service, and on the 2015 basis
|
|
131
|
+
* the remedy window's career average pot beside it. */
|
|
132
|
+
function legacyArrangement(b, legacy, basis, r) {
|
|
133
|
+
const walked = walksWindow(basis);
|
|
134
|
+
const pot = walked ? r.walks.window : null;
|
|
135
|
+
// `inputPeriods` refused the 2015 basis for a member with no window,
|
|
136
|
+
// and the walks hold one wherever the member has it.
|
|
137
|
+
invariant(!walked || pot !== null, 'a 2015 basis with no remedy window walked');
|
|
138
|
+
const valued = finalSalaryValued(legacy, basis);
|
|
139
|
+
return valuesOver((on) => {
|
|
140
|
+
const finalSalary = finalSalaryHeldOn(b, valued, on, r.left);
|
|
141
|
+
const career = pot === null ? 0 : potAt(pot, on);
|
|
142
|
+
return {
|
|
143
|
+
pension: r.walks.prices.payAt(finalSalary.pension, on) + career,
|
|
144
|
+
lumpSum: r.walks.prices.payAt(finalSalary.automaticLumpSum, on),
|
|
145
|
+
};
|
|
146
|
+
}, r);
|
|
147
|
+
}
|
|
148
|
+
/** A career average pot on `on`: nothing before its period opens. */
|
|
149
|
+
function potAt({ ledger, period }, on) {
|
|
150
|
+
return isoToDate(period.from) > on ? 0 : ledger.accruedAt(on);
|
|
151
|
+
}
|
|
152
|
+
/** One arrangement's values at the period's two ends: its close is the
|
|
153
|
+
* leaving date in the year the member leaves, and the year's own end in
|
|
154
|
+
* every other. */
|
|
155
|
+
function valuesOver(heldAt, { opens, closes, left }) {
|
|
156
|
+
const leftInYear = left !== null && left > opens;
|
|
157
|
+
const opening = heldAt(opens);
|
|
158
|
+
const closing = heldAt(leftInYear ? left : closes);
|
|
159
|
+
return {
|
|
160
|
+
pensionOpening: opening.pension,
|
|
161
|
+
pensionClosing: closing.pension,
|
|
162
|
+
lumpSumOpening: opening.lumpSum,
|
|
163
|
+
lumpSumClosing: closing.lumpSum,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=input-period.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-period.js","sourceRoot":"","sources":["../../src/member/input-period.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,+BAA+B,EAAE,cAAc,EAAE,aAAa,EAC9D,gBAAgB,GACjB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AAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC;AAED;;mBAEmB;AACnB,SAAS,UAAU,CACjB,MAAgC,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAU;IAEhE,MAAM,UAAU,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,GAAG,KAAK,CAAC;IACjD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,cAAc,EAAE,OAAO,CAAC,OAAO;KAChC,CAAC;AACJ,CAAC"}
|
package/dist/member/service.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeclaredPeriod, LegacySectionId, ServicePeriod } from './types.js';
|
|
1
|
+
import type { DeclaredPeriod, LegacySectionId, MemberBenefits, RemedyBasis, ServicePeriod } from './types.js';
|
|
2
2
|
/** A legacy holding: its section, its own service, and the remedy window
|
|
3
3
|
* held in it after that service where the member has one. */
|
|
4
4
|
export interface LegacyHolding {
|
|
@@ -62,4 +62,7 @@ export declare function legacyPeriodsOf({ own, window }: LegacyHolding): Service
|
|
|
62
62
|
/** The last day a period is valued to: its own end, or the leaving
|
|
63
63
|
* date where that comes first or the period is still open. */
|
|
64
64
|
export declare function until(p: ServicePeriod, leaving: Date): Date;
|
|
65
|
+
/** Refuse a remedy member with no election, or an election for anyone
|
|
66
|
+
* else: which basis applies is the caller's to say, never ours. */
|
|
67
|
+
export declare function refuseElectionMismatch(asked: keyof MemberBenefits, remedy: boolean, basis: RemedyBasis): void;
|
|
65
68
|
export {};
|
package/dist/member/service.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { dayAfter, dayBefore } from '../dates.js';
|
|
7
7
|
import { BenefitNotModelled, invariant, NOT_MODELLED } from '../errors.js';
|
|
8
8
|
import { isoDate, isoDateOf, isoToDate } from '../iso-date.js';
|
|
9
|
-
import { PERIOD_KINDS, SECTIONS } from './types.js';
|
|
9
|
+
import { PERIOD_KINDS, REMEDY_BASES, SECTIONS } from './types.js';
|
|
10
10
|
/** The remedy period, 1 April 2015 to 31 March 2022, as PSPJOA 2022
|
|
11
11
|
* s.1 defines it. The days either side are derived from it. */
|
|
12
12
|
const REMEDY_FROM = isoDate('2015-04-01');
|
|
@@ -84,6 +84,17 @@ export function legacyPeriodsOf({ own, window }) {
|
|
|
84
84
|
export function until(p, leaving) {
|
|
85
85
|
return p.to === null || isoToDate(p.to) > leaving ? leaving : isoToDate(p.to);
|
|
86
86
|
}
|
|
87
|
+
/** Refuse a remedy member with no election, or an election for anyone
|
|
88
|
+
* else: which basis applies is the caller's to say, never ours. */
|
|
89
|
+
export function refuseElectionMismatch(asked, remedy, basis) {
|
|
90
|
+
const elects = basis !== REMEDY_BASES.none;
|
|
91
|
+
const electionMatches = remedy === elects;
|
|
92
|
+
if (electionMatches)
|
|
93
|
+
return;
|
|
94
|
+
throw new RangeError(remedy
|
|
95
|
+
? `${asked}: a remedy member needs an election`
|
|
96
|
+
: `${asked}: an election for a member with no remediable service`);
|
|
97
|
+
}
|
|
87
98
|
/** The declared periods in date order, each running into the next. */
|
|
88
99
|
function contiguous(declared) {
|
|
89
100
|
if (declared.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/member/service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAE,YA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C,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI;YACzC,IAAI,EAAE,YAAY,CAAC,QAAQ;SAC5B;QACD,MAAM,EAAE,MAAM;YACZ,CAAC,CAAC;gBACA,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS;gBACvD,IAAI,EAAE,YAAY,CAAC,YAAY;aAChC;YACD,CAAC,CAAC,IAAI;KACT,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,OAAkB;IAClC,OAAO,OAAO,KAAK,QAAQ,CAAC,KAAK,CAAC;AACpC,CAAC"}
|
package/dist/member/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* and the ids they are keyed by only, so the service check, the valuation
|
|
5
5
|
* and the owner in `benefits.ts` all read one definition.
|
|
6
6
|
*/
|
|
7
|
+
import type { PensionInputPeriod, TaxYearEnd } from '@casomoltd/paye-calc';
|
|
7
8
|
import type { CashChoice, CommutationResult } from '../commutation.js';
|
|
8
9
|
import type { FactorOutcome } from '../factor-basis.js';
|
|
9
10
|
import type { IsoDate } from '../iso-date.js';
|
|
@@ -114,6 +115,7 @@ export declare const ACCRUALS: {
|
|
|
114
115
|
readonly finalSalary: "final-salary";
|
|
115
116
|
readonly careerAverage: "career-average";
|
|
116
117
|
};
|
|
118
|
+
export type Accrual = (typeof ACCRUALS)[keyof typeof ACCRUALS];
|
|
117
119
|
/**
|
|
118
120
|
* One section's benefit on one basis. A legacy section returns two
|
|
119
121
|
* when its remedy window is valued on the 2015 basis: that part is
|
|
@@ -125,15 +127,27 @@ export interface Award {
|
|
|
125
127
|
/** Where it is held and paid from. */
|
|
126
128
|
readonly section: SectionId;
|
|
127
129
|
readonly periods: readonly ServicePeriod[];
|
|
128
|
-
/** The
|
|
130
|
+
/** The PENSION at the drawing before its factor: final salary as
|
|
129
131
|
* measured, or the career average pot as revalued. */
|
|
130
|
-
readonly
|
|
132
|
+
readonly pensionBeforeFactor: ProjectionMoney;
|
|
131
133
|
/** After the factor: what is paid. */
|
|
132
134
|
readonly pension: ProjectionMoney;
|
|
133
135
|
/** Nil rather than absent where the rules pay none, so a caller
|
|
134
136
|
* cannot forget to ask. */
|
|
135
137
|
readonly automaticLumpSum: ProjectionMoney;
|
|
136
|
-
|
|
138
|
+
/** The automatic lump sum at the drawing before its early or late
|
|
139
|
+
* factor, on the same rulers as `pensionBeforeFactor`: the section's multiple
|
|
140
|
+
* of that pension. Nil where the rules pay none, as a career average
|
|
141
|
+
* award never does. */
|
|
142
|
+
readonly automaticLumpSumBeforeFactor: ProjectionMoney;
|
|
143
|
+
/** The PENSION's early or late factor. The lump sum is reduced by its
|
|
144
|
+
* own, `automaticLumpSumFactor`, so read the lump sum before it from
|
|
145
|
+
* `automaticLumpSumBeforeFactor`, never by dividing by this. */
|
|
146
|
+
readonly pensionFactor: FactorOutcome;
|
|
147
|
+
/** The automatic lump sum's own early or late factor; null where the
|
|
148
|
+
* rules pay no automatic lump sum, as a career average award never
|
|
149
|
+
* does. */
|
|
150
|
+
readonly automaticLumpSumFactor: FactorOutcome | null;
|
|
137
151
|
/** A career average award's year-by-year walk, in cash and in today's
|
|
138
152
|
* money; null for final salary, which keeps no balance to walk. */
|
|
139
153
|
readonly ledgers: {
|
|
@@ -233,9 +247,28 @@ export interface MemberBenefits {
|
|
|
233
247
|
* `minimumPensionAgeOn(drawing)`. `at()` refuses a drawing this
|
|
234
248
|
* refuses. */
|
|
235
249
|
mayDrawOn(drawing: IsoDate): boolean;
|
|
236
|
-
/** Worth today, before any drawing
|
|
250
|
+
/** Worth today, before any drawing: unreduced, with the remedy window on
|
|
251
|
+
* the legacy basis. A member who has left holds their deferred
|
|
252
|
+
* benefits, final pay measured at leaving. */
|
|
237
253
|
now(): Holdings;
|
|
238
254
|
/** Worth when drawn, for one set of choices. Throws RangeError for a
|
|
239
255
|
* drawing before the member reaches `minimumPensionAgeOn(drawing)`. */
|
|
240
256
|
at(choices: RetirementChoices): Position;
|
|
257
|
+
/**
|
|
258
|
+
* The pension input period for the tax year ending in `taxYearEnd` (2027
|
|
259
|
+
* for 2026-27; paye-calc's `taxYearEndFor` names the one a date falls in,
|
|
260
|
+
* and no scheme year passes for one), for a member leaving on
|
|
261
|
+
* `choices.leaving` on the McCloud election `choices.remedy`, both as
|
|
262
|
+
* `at()` takes them, for paye-calc's `definedBenefitInput`: each
|
|
263
|
+
* arrangement's pension and automatic lump sum at the year's start and
|
|
264
|
+
* end, before any early or late factor, in cash at `assumedCpi` (a
|
|
265
|
+
* decimal) on this member's reading of the past years, whatever CPI they
|
|
266
|
+
* were built at. The period's own `cpi` is read from that series, so on
|
|
267
|
+
* published past years it is the Order's figure. The year the member
|
|
268
|
+
* leaves in closes on the leaving date, and every year after holds the
|
|
269
|
+
* deferred benefits. Throws RangeError for a year before 2016-17, a
|
|
270
|
+
* leaving after the one declared, or an election `at()` would refuse
|
|
271
|
+
* (docs/how-it-works.md#a-years-pension-input).
|
|
272
|
+
*/
|
|
273
|
+
pensionInputPeriod(taxYearEnd: TaxYearEnd, choices: Pick<RetirementChoices, 'leaving' | 'remedy'>, assumedCpi: number): PensionInputPeriod;
|
|
241
274
|
}
|
package/dist/member/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/member/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/member/types.ts"],"names":[],"mappings":"AAkBA,uDAAuD;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;CACb,CAAC;AA+BX,8DAA8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,yDAAyD;IACzD,OAAO,EAAE,SAAS;IAClB;;;yDAGqD;IACrD,SAAS,EAAE,WAAW;CACd,CAAC;AAcX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,cAAc;IACtB,WAAW,EAAE,oBAAoB;CACzB,CAAC;AAmBX,uDAAuD;AAEvD;qEACqE;AACrE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,eAAe;CACrB,CAAC;AAYX,sEAAsE;AACtE,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,WAAW,EAAE,cAAc;IAC3B,aAAa,EAAE,gBAAgB;CACvB,CAAC"}
|