@casomoltd/nhs-pay 0.30.0 → 0.32.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 +71 -252
- package/dist/bands.d.ts +9 -1
- package/dist/bands.js +20 -0
- package/dist/bands.js.map +1 -1
- package/dist/document-source.d.ts +32 -7
- package/dist/document-source.js +32 -8
- package/dist/document-source.js.map +1 -1
- package/dist/errors.d.ts +57 -11
- package/dist/errors.js +85 -28
- package/dist/errors.js.map +1 -1
- package/dist/factor-basis.d.ts +23 -3
- package/dist/factor-basis.js +40 -28
- package/dist/factor-basis.js.map +1 -1
- package/dist/index.d.ts +16 -14
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/member/benefits.js +25 -13
- package/dist/member/benefits.js.map +1 -1
- package/dist/member/index.d.ts +1 -1
- package/dist/member/input-period.d.ts +4 -4
- package/dist/member/input-period.js +11 -9
- package/dist/member/input-period.js.map +1 -1
- package/dist/member/service.d.ts +4 -0
- package/dist/member/service.js +9 -3
- package/dist/member/service.js.map +1 -1
- package/dist/member/types.d.ts +81 -49
- package/dist/member/types.js.map +1 -1
- package/dist/member/valuation.d.ts +10 -8
- package/dist/member/valuation.js +14 -21
- package/dist/member/valuation.js.map +1 -1
- package/dist/pay-path.d.ts +21 -25
- package/dist/pay-path.js +85 -67
- package/dist/pay-path.js.map +1 -1
- package/dist/pension/ages.d.ts +6 -4
- package/dist/pension/ages.js +6 -4
- package/dist/pension/ages.js.map +1 -1
- package/dist/pension/curve.d.ts +2 -1
- package/dist/pension/curve.js +15 -7
- package/dist/pension/curve.js.map +1 -1
- package/dist/pension/history.d.ts +18 -3
- package/dist/pension/history.js +12 -5
- package/dist/pension/history.js.map +1 -1
- package/dist/pension/ledger.d.ts +15 -9
- package/dist/pension/ledger.js +95 -59
- package/dist/pension/ledger.js.map +1 -1
- package/dist/pension/money.d.ts +2 -0
- package/dist/pension/money.js +4 -0
- package/dist/pension/money.js.map +1 -1
- package/dist/pension/prices.d.ts +11 -2
- package/dist/pension/prices.js +35 -14
- package/dist/pension/prices.js.map +1 -1
- package/dist/pension/scheme-year.d.ts +59 -0
- package/dist/pension/scheme-year.js +80 -0
- package/dist/pension/scheme-year.js.map +1 -0
- package/dist/pension/seed.d.ts +66 -50
- package/dist/pension/seed.js +111 -65
- package/dist/pension/seed.js.map +1 -1
- package/dist/pension/uplift.d.ts +38 -54
- package/dist/pension/uplift.js +38 -68
- package/dist/pension/uplift.js.map +1 -1
- package/dist/pension-projection.js +30 -22
- package/dist/pension-projection.js.map +1 -1
- package/dist/post.d.ts +1 -10
- package/dist/post.js +1 -12
- package/dist/post.js.map +1 -1
- package/dist/revaluation.d.ts +56 -41
- package/dist/revaluation.js +76 -62
- package/dist/revaluation.js.map +1 -1
- package/dist/scale-point.d.ts +6 -0
- package/dist/sections/final-salary.d.ts +3 -8
- package/dist/sections/final-salary.js +6 -10
- package/dist/sections/final-salary.js.map +1 -1
- package/dist/sections/section-2015.d.ts +3 -4
- package/dist/sections/section-2015.js +1 -1
- package/dist/sections/section-2015.js.map +1 -1
- package/dist/sources.d.ts +14 -0
- package/dist/sources.js +24 -0
- package/dist/sources.js.map +1 -1
- package/dist/take-home.d.ts +4 -20
- package/dist/take-home.js +3 -23
- package/dist/take-home.js.map +1 -1
- package/package.json +3 -3
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
* The owner in `benefits.ts` decides which awards a drawing has and sums
|
|
9
9
|
* them.
|
|
10
10
|
*/
|
|
11
|
-
import type { Award, Holdings, Member, MemberBenefits,
|
|
11
|
+
import type { Award, Holdings, Member, MemberBenefits, Section2015Walk, ServicePeriod } from './types.js';
|
|
12
12
|
import type { LegacySectionId, RemedyBasis, SectionId } from './types.js';
|
|
13
13
|
import type { LegacyHolding } from './service.js';
|
|
14
14
|
import type { JoiningHistory } from '../pension/ages.js';
|
|
15
15
|
import type { PayPath } from '../pay-path.js';
|
|
16
16
|
import type { MemberLedger } from '../pension/ledger.js';
|
|
17
17
|
import type { Prices } from '../pension/prices.js';
|
|
18
|
+
import type { SchemeYearEnd } from '../pension/scheme-year.js';
|
|
18
19
|
import type { LedgerSeed } from '../pension/seed.js';
|
|
19
20
|
import type { FinalSalaryRules, UnreducedPension } from '../sections/final-salary.js';
|
|
20
21
|
import { careerAverage } from '../sections/section-2015.js';
|
|
@@ -50,11 +51,11 @@ interface CareerAward {
|
|
|
50
51
|
readonly todays: CareerAverageRun;
|
|
51
52
|
}
|
|
52
53
|
/** What a career average award values: a window of one section, and the
|
|
53
|
-
* seed its walk starts from in
|
|
54
|
+
* seed its walk starts from, the same in both price series. */
|
|
54
55
|
interface CareerWindow {
|
|
55
56
|
readonly section: SectionId;
|
|
56
57
|
readonly window: ServicePeriod;
|
|
57
|
-
readonly
|
|
58
|
+
readonly seed: LedgerSeed;
|
|
58
59
|
}
|
|
59
60
|
/** One walk: a window, its seed, and the price series it walks in. */
|
|
60
61
|
interface Walk {
|
|
@@ -82,8 +83,9 @@ export declare function finalSalaryValued(legacy: LegacyHolding, basis: RemedyBa
|
|
|
82
83
|
/** A remedy window's seed on the 2015 basis: it walks from its first day,
|
|
83
84
|
* since no statement counts the remedy years in the 2015 Section. */
|
|
84
85
|
export declare function windowSeed(window: ServicePeriod): LedgerSeed;
|
|
85
|
-
/** The 2015 Section's own seed: its statement,
|
|
86
|
-
|
|
86
|
+
/** The 2015 Section's own seed: its statement, at the 31 March closing
|
|
87
|
+
* the year it runs to, or its first day. */
|
|
88
|
+
export declare function seed2015(b: Built): LedgerSeed;
|
|
87
89
|
/** What the member holds today, with the remedy window on the legacy
|
|
88
90
|
* basis: unreduced, since nothing is drawn. A member who has left holds
|
|
89
91
|
* their deferred benefits, final pay measured at leaving. */
|
|
@@ -92,10 +94,10 @@ export declare function holdings(b: Built): Holdings;
|
|
|
92
94
|
* final salary, which the election decides. */
|
|
93
95
|
export declare function legacyAward(b: Built, { section, valued }: FinalSalaryValued, dates: Drawing): Award;
|
|
94
96
|
/** A career average award over one window, walked in both rulers. */
|
|
95
|
-
export declare function careerAward(b: Built, { section, window,
|
|
97
|
+
export declare function careerAward(b: Built, { section, window, seed }: CareerWindow, dates: Drawing): CareerAward;
|
|
96
98
|
/** The 2015 Section's balance, with its estimated run-up before a
|
|
97
99
|
* statement, as the ledgers, history and curve a `Position` carries. */
|
|
98
|
-
export declare function section2015(b: Built, own: CareerAward, { leaving, drawing }: Drawing):
|
|
100
|
+
export declare function section2015(b: Built, own: CareerAward, { leaving, drawing }: Drawing): Section2015Walk;
|
|
99
101
|
/**
|
|
100
102
|
* The same walk as the ledger alone, with no drawing on it, through the
|
|
101
103
|
* scheme year ending in `through`: what the window holds on any date to
|
|
@@ -103,7 +105,7 @@ export declare function section2015(b: Built, own: CareerAward, { leaving, drawi
|
|
|
103
105
|
* no factor to read, and a factor read for a drawing far past the pension
|
|
104
106
|
* age is one GAD's tables may not price.
|
|
105
107
|
*/
|
|
106
|
-
export declare function accruedLedger(b: Built, { window, seed, prices }: Walk, { leaving, drawing }: Drawing, through:
|
|
108
|
+
export declare function accruedLedger(b: Built, { window, seed, prices }: Walk, { leaving, drawing }: Drawing, through: SchemeYearEnd): MemberLedger;
|
|
107
109
|
/** Refuse a leaving after the one the member declared, naming `asked`,
|
|
108
110
|
* the call a caller was answering: service that has ended cannot run on. */
|
|
109
111
|
export declare function refuseLeavingAfterDeclared(asked: keyof MemberBenefits, b: Built, leaving: Date): void;
|
package/dist/member/valuation.js
CHANGED
|
@@ -5,10 +5,11 @@ import { normalPensionAge } from '../pension/ages.js';
|
|
|
5
5
|
import { earliest } from '../dates.js';
|
|
6
6
|
import { buildCurve, walkThrough } from '../pension/curve.js';
|
|
7
7
|
import { buildLedger } from '../pension/ledger.js';
|
|
8
|
-
import { seedFromBalanceAt } from '../pension/uplift.js';
|
|
9
8
|
import { estimateHistory } from '../pension/history.js';
|
|
9
|
+
import { factored } from '../factor-basis.js';
|
|
10
10
|
import { moneyAt, sumMoney } from '../pension/money.js';
|
|
11
|
-
import { schemeYearEndDate, schemeYearEndFor,
|
|
11
|
+
import { schemeYearBefore, schemeYearEndDate, schemeYearEndFor, } from '../pension/scheme-year.js';
|
|
12
|
+
import { seedFromJoinDate, seedFromStatement } from '../pension/seed.js';
|
|
12
13
|
import { finalSalaryBenefit, unreducedPension, } from '../sections/final-salary.js';
|
|
13
14
|
import { RULES_1995 } from '../sections/section-1995.js';
|
|
14
15
|
import { RULES_2008 } from '../sections/section-2008.js';
|
|
@@ -45,12 +46,13 @@ export function finalSalaryValued(legacy, basis) {
|
|
|
45
46
|
export function windowSeed(window) {
|
|
46
47
|
return seedFromJoinDate(isoToDate(window.from));
|
|
47
48
|
}
|
|
48
|
-
/** The 2015 Section's own seed: its statement,
|
|
49
|
-
|
|
49
|
+
/** The 2015 Section's own seed: its statement, at the 31 March closing
|
|
50
|
+
* the year it runs to, or its first day. */
|
|
51
|
+
export function seed2015(b) {
|
|
50
52
|
const { statement } = b.member;
|
|
51
53
|
return statement === null
|
|
52
54
|
? seedFromJoinDate(isoToDate(b.ordinary2015.from))
|
|
53
|
-
:
|
|
55
|
+
: seedFromStatement(statement.accruedPension, statement.yearEnd);
|
|
54
56
|
}
|
|
55
57
|
/** What the member holds today, with the remedy window on the legacy
|
|
56
58
|
* basis: unreduced, since nothing is drawn. A member who has left holds
|
|
@@ -73,7 +75,7 @@ export function holdings(b) {
|
|
|
73
75
|
const dates = walkDates(b, left ?? b.npaOn);
|
|
74
76
|
const accrued = walk(b, {
|
|
75
77
|
window: b.ordinary2015,
|
|
76
|
-
seed: seed2015(b
|
|
78
|
+
seed: seed2015(b),
|
|
77
79
|
prices: b.todaysPrices,
|
|
78
80
|
}, dates).ledger.accruedAt(today);
|
|
79
81
|
bySection.push({
|
|
@@ -97,12 +99,8 @@ export function legacyAward(b, { section, valued }, dates) {
|
|
|
97
99
|
return {
|
|
98
100
|
section,
|
|
99
101
|
periods: valued,
|
|
100
|
-
pensionBeforeFactor: benefit.pensionBeforeFactor,
|
|
101
102
|
pension: benefit.pension,
|
|
102
103
|
automaticLumpSum: benefit.automaticLumpSum,
|
|
103
|
-
automaticLumpSumBeforeFactor: benefit.automaticLumpSumBeforeFactor,
|
|
104
|
-
pensionFactor: benefit.pensionFactor,
|
|
105
|
-
automaticLumpSumFactor: benefit.automaticLumpSumFactor,
|
|
106
104
|
ledgers: null,
|
|
107
105
|
provenance: {
|
|
108
106
|
accrual: ACCRUALS.finalSalary,
|
|
@@ -114,8 +112,8 @@ export function legacyAward(b, { section, valued }, dates) {
|
|
|
114
112
|
};
|
|
115
113
|
}
|
|
116
114
|
/** A career average award over one window, walked in both rulers. */
|
|
117
|
-
export function careerAward(b, { section, window,
|
|
118
|
-
const walkIn = (prices) => walk(b, { window, seed
|
|
115
|
+
export function careerAward(b, { section, window, seed }, dates) {
|
|
116
|
+
const walkIn = (prices) => walk(b, { window, seed, prices }, dates);
|
|
119
117
|
const cash = walkIn(b.cashPrices);
|
|
120
118
|
const todays = walkIn(b.todaysPrices);
|
|
121
119
|
// A career average award pays no automatic lump sum, before or after a
|
|
@@ -125,12 +123,8 @@ export function careerAward(b, { section, window, seedFor }, dates) {
|
|
|
125
123
|
award: {
|
|
126
124
|
section,
|
|
127
125
|
periods: [window],
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
automaticLumpSum: noLumpSum,
|
|
131
|
-
automaticLumpSumBeforeFactor: noLumpSum,
|
|
132
|
-
pensionFactor: cash.factor,
|
|
133
|
-
automaticLumpSumFactor: null,
|
|
126
|
+
pension: factored(moneyAt({ nominal: cash.revalued, real: todays.revalued }, dates.drawing), cash.factor),
|
|
127
|
+
automaticLumpSum: factored(noLumpSum, null),
|
|
134
128
|
ledgers: { cash: cash.ledger, todaysMoney: todays.ledger },
|
|
135
129
|
provenance: { accrual: ACCRUALS.careerAverage },
|
|
136
130
|
},
|
|
@@ -157,11 +151,10 @@ export function section2015(b, own, { leaving, drawing }) {
|
|
|
157
151
|
ledger: r.ledger, history,
|
|
158
152
|
curveFrom: earliest(b.today, leaving, schemeYearEndDate(history === null
|
|
159
153
|
? r.seed.atSchemeYearEnd
|
|
160
|
-
: history.from
|
|
154
|
+
: schemeYearBefore(history.from))),
|
|
161
155
|
});
|
|
162
156
|
return {
|
|
163
|
-
|
|
164
|
-
todaysMoneyLedger: own.todays.ledger,
|
|
157
|
+
ledgers: { cash: own.cash.ledger, todaysMoney: own.todays.ledger },
|
|
165
158
|
estimatedHistory: todaysHistory,
|
|
166
159
|
curve: buildCurve(run(own.cash, cashHistory), run(own.todays, todaysHistory)),
|
|
167
160
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valuation.js","sourceRoot":"","sources":["../../src/member/valuation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAI5D,OAAO,EAAC,eAAe,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"valuation.js","sourceRoot":"","sources":["../../src/member/valuation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAI5D,OAAO,EAAC,eAAe,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa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,EAAE,MAAM,EAAE,OAAO,CAAC;QACpC,WAAW,EAAE,CAAC,CAAC,IAAI;QACnB,OAAO;QACP,OAAO;QACP,MAAM;QACN,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC;KACvC,CAAC,CAAC;AACL,CAAC;AAED;kBACkB;AAClB,SAAS,SAAS,CAAC,CAAQ,EAAE,MAAqB,EAAE,OAAa;IAC/D,MAAM,KAAK,GAAG,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI;QAC7C,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;QACxB,CAAC,CAAC,IAAI,CAAC,CAAC;AACZ,CAAC;AAED,mEAAmE;AACnE,SAAS,YAAY,CACnB,MAAgC,EAAE,OAAa;IAE/C,OAAO,MAAM;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC;SAC3C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAC,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/pay-path.d.ts
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
import type { IsoDate } from './iso-date.js';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
* GAD's promotional pay index at an age: growth from promotion and
|
|
5
|
-
* progression over and above general pay awards, 100 at age 25,
|
|
6
|
-
* linear between the published five-year rows and flat beyond their
|
|
7
|
-
* ends.
|
|
8
|
-
*
|
|
9
|
-
* **The two non-manual columns, averaged.** GAD splits the index by
|
|
10
|
-
* sex and we do not ask a member's sex, nor infer it: averaging is
|
|
11
|
-
* the only version that encodes no guess about the member. It
|
|
12
|
-
* overstates progression for women and understates it for men, which a
|
|
13
|
-
* caller showing its figures should disclose. Non-manual is not a second
|
|
14
|
-
* assumption — every Agenda for Change band is non-manual in GAD's
|
|
15
|
-
* terms.
|
|
16
|
-
*/
|
|
17
|
-
export declare function promotionalIndex(age: number): number;
|
|
2
|
+
import type { SchemeYearEnd } from './pension/scheme-year.js';
|
|
3
|
+
import type { PayLadder } from './scale-point.js';
|
|
18
4
|
/**
|
|
19
5
|
* A year's pensionable pay the member gave us, in today's money, which
|
|
20
6
|
* the field's name says so a caller cannot pass a payslip's cash
|
|
@@ -24,7 +10,7 @@ export declare function promotionalIndex(age: number): number;
|
|
|
24
10
|
* https://github.com/casomoltd/nhs-pay/issues/22
|
|
25
11
|
*/
|
|
26
12
|
export interface DeclaredPay {
|
|
27
|
-
readonly schemeYearEnd:
|
|
13
|
+
readonly schemeYearEnd: SchemeYearEnd;
|
|
28
14
|
readonly todaysMoney: number;
|
|
29
15
|
}
|
|
30
16
|
/** What a member told us about their pay. */
|
|
@@ -38,13 +24,8 @@ export interface MemberPay {
|
|
|
38
24
|
readonly asAt: IsoDate;
|
|
39
25
|
};
|
|
40
26
|
/** The member's pay scale and where on it they are, while steps
|
|
41
|
-
* remain. Null off a stepped scale, or at its top.
|
|
42
|
-
|
|
43
|
-
* scale does not have. */
|
|
44
|
-
readonly ladder: {
|
|
45
|
-
readonly points: readonly SteppedPoint[];
|
|
46
|
-
readonly current: SteppedPoint;
|
|
47
|
-
} | null;
|
|
27
|
+
* remain. Null off a stepped scale, or at its top. */
|
|
28
|
+
readonly ladder: PayLadder | null;
|
|
48
29
|
/** Whether `declared` and `current` are actual pay for fewer than
|
|
49
30
|
* full-time hours. The 2015 Section accrues on actual pay, so it prices
|
|
50
31
|
* them as given; the final-salary sections need whole-time pay and
|
|
@@ -67,7 +48,7 @@ export interface YearPay {
|
|
|
67
48
|
}
|
|
68
49
|
/** A member's pensionable pay, every scheme year, in today's money. */
|
|
69
50
|
export interface PayPath {
|
|
70
|
-
payFor(schemeYearEnd:
|
|
51
|
+
payFor(schemeYearEnd: SchemeYearEnd): YearPay;
|
|
71
52
|
}
|
|
72
53
|
/**
|
|
73
54
|
* Build a member's pay path. Refuses only where there is nothing to
|
|
@@ -75,3 +56,18 @@ export interface PayPath {
|
|
|
75
56
|
* and labelled as filled.
|
|
76
57
|
*/
|
|
77
58
|
export declare function buildPayPath(dateOfBirth: IsoDate, pay: MemberPay): PayPath;
|
|
59
|
+
/**
|
|
60
|
+
* GAD's promotional pay index at an age: growth from promotion and
|
|
61
|
+
* progression over and above general pay awards, 100 at age 25,
|
|
62
|
+
* linear between the published five-year rows and flat beyond their
|
|
63
|
+
* ends.
|
|
64
|
+
*
|
|
65
|
+
* **The two non-manual columns, averaged.** GAD splits the index by
|
|
66
|
+
* sex and we do not ask a member's sex, nor infer it: averaging is
|
|
67
|
+
* the only version that encodes no guess about the member. It
|
|
68
|
+
* overstates progression for women and understates it for men, which a
|
|
69
|
+
* caller showing its figures should disclose. Non-manual is not a second
|
|
70
|
+
* assumption — every Agenda for Change band is non-manual in GAD's
|
|
71
|
+
* terms.
|
|
72
|
+
*/
|
|
73
|
+
export declare function promotionalIndex(age: number): number;
|
package/dist/pay-path.js
CHANGED
|
@@ -29,35 +29,7 @@
|
|
|
29
29
|
import { PROMOTIONAL_SCALE_2020 } from './gad/promotional-scale-2020.js';
|
|
30
30
|
import { invariant, PayPathUnavailable } from './errors.js';
|
|
31
31
|
import { isoToDate } from './iso-date.js';
|
|
32
|
-
import { schemeYearEndFor } from './pension/
|
|
33
|
-
/**
|
|
34
|
-
* GAD's promotional pay index at an age: growth from promotion and
|
|
35
|
-
* progression over and above general pay awards, 100 at age 25,
|
|
36
|
-
* linear between the published five-year rows and flat beyond their
|
|
37
|
-
* ends.
|
|
38
|
-
*
|
|
39
|
-
* **The two non-manual columns, averaged.** GAD splits the index by
|
|
40
|
-
* sex and we do not ask a member's sex, nor infer it: averaging is
|
|
41
|
-
* the only version that encodes no guess about the member. It
|
|
42
|
-
* overstates progression for women and understates it for men, which a
|
|
43
|
-
* caller showing its figures should disclose. Non-manual is not a second
|
|
44
|
-
* assumption — every Agenda for Change band is non-manual in GAD's
|
|
45
|
-
* terms.
|
|
46
|
-
*/
|
|
47
|
-
export function promotionalIndex(age) {
|
|
48
|
-
invariant(Number.isFinite(age), `promotionalIndex: age ${age}`);
|
|
49
|
-
const { ages, nonManual } = PROMOTIONAL_SCALE_2020;
|
|
50
|
-
const blend = (i) => (nonManual.male[i] + nonManual.female[i]) / 2;
|
|
51
|
-
const last = ages.length - 1;
|
|
52
|
-
if (age <= ages[0])
|
|
53
|
-
return blend(0);
|
|
54
|
-
if (age >= ages[last])
|
|
55
|
-
return blend(last);
|
|
56
|
-
const hi = ages.findIndex((a) => a > age);
|
|
57
|
-
const lo = hi - 1;
|
|
58
|
-
const through = (age - ages[lo]) / (ages[hi] - ages[lo]);
|
|
59
|
-
return blend(lo) + (blend(hi) - blend(lo)) * through;
|
|
60
|
-
}
|
|
32
|
+
import { schemeYearEnd, schemeYearEndFor } from './pension/scheme-year.js';
|
|
61
33
|
/** What a year's pay rests on: see the module header. */
|
|
62
34
|
export const PAY_BASES = {
|
|
63
35
|
declared: 'declared',
|
|
@@ -65,26 +37,8 @@ export const PAY_BASES = {
|
|
|
65
37
|
projected: 'projected',
|
|
66
38
|
reconstructed: 'reconstructed',
|
|
67
39
|
};
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
* first paid in, scaled to the member's own pay so a part-time
|
|
71
|
-
* member's steps stay in proportion to what they are actually paid.
|
|
72
|
-
*/
|
|
73
|
-
function contractualSteps(ladder, current, currentYear) {
|
|
74
|
-
const here = ladder.current;
|
|
75
|
-
if (!ladder.points.includes(here)) {
|
|
76
|
-
throw new RangeError(`pay ladder: current point "${here.label}" is not one of its points`);
|
|
77
|
-
}
|
|
78
|
-
const hereYears = here.yearsExperience;
|
|
79
|
-
const scale = current.todaysMoney / here.salary;
|
|
80
|
-
return ladder.points
|
|
81
|
-
.filter((p) => p.yearsExperience > hereYears)
|
|
82
|
-
.map((p) => ({
|
|
83
|
-
from: currentYear + p.yearsExperience - hereYears,
|
|
84
|
-
pay: p.salary * scale,
|
|
85
|
-
}))
|
|
86
|
-
.sort((a, b) => a.from - b.from);
|
|
87
|
-
}
|
|
40
|
+
/** The columns the index averages: GAD's non-manual male and female. */
|
|
41
|
+
const NON_MANUAL_COLUMNS = 2;
|
|
88
42
|
/**
|
|
89
43
|
* Build a member's pay path. Refuses only where there is nothing to
|
|
90
44
|
* build from: every other gap is filled, the same way for everybody,
|
|
@@ -92,11 +46,7 @@ function contractualSteps(ladder, current, currentYear) {
|
|
|
92
46
|
*/
|
|
93
47
|
export function buildPayPath(dateOfBirth, pay) {
|
|
94
48
|
const { current } = pay;
|
|
95
|
-
|
|
96
|
-
// stated balance still revalues. Only what is not a figure refuses.
|
|
97
|
-
if (!Number.isFinite(current.todaysMoney) || current.todaysMoney < 0) {
|
|
98
|
-
throw new PayPathUnavailable(`current pay ${current.todaysMoney} is not a pay figure`);
|
|
99
|
-
}
|
|
49
|
+
refuseNoCurrentPay(current);
|
|
100
50
|
const born = isoToDate(dateOfBirth);
|
|
101
51
|
/** The age whose birthday falls in a scheme year: the years since
|
|
102
52
|
* the scheme year the member was born in. */
|
|
@@ -104,26 +54,16 @@ export function buildPayPath(dateOfBirth, pay) {
|
|
|
104
54
|
const ageIn = (schemeYearEnd) => schemeYearEnd - bornIn;
|
|
105
55
|
const indexIn = (schemeYearEnd) => promotionalIndex(ageIn(schemeYearEnd));
|
|
106
56
|
const currentYear = schemeYearEndFor(isoToDate(current.asAt));
|
|
107
|
-
const declared =
|
|
108
|
-
for (const { schemeYearEnd, todaysMoney: figure } of pay.declared) {
|
|
109
|
-
if (declared.has(schemeYearEnd)) {
|
|
110
|
-
throw new RangeError(`pay path: ${schemeYearEnd} declared twice`);
|
|
111
|
-
}
|
|
112
|
-
if (!Number.isFinite(figure) || figure <= 0) {
|
|
113
|
-
throw new RangeError(`pay path: ${schemeYearEnd} declared as ${figure}`);
|
|
114
|
-
}
|
|
115
|
-
declared.set(schemeYearEnd, figure);
|
|
116
|
-
}
|
|
57
|
+
const declared = declaredByYear(pay.declared);
|
|
117
58
|
const steps = pay.ladder === null
|
|
118
59
|
? []
|
|
119
60
|
: contractualSteps(pay.ladder, current, currentYear);
|
|
120
|
-
const lastStep = steps.at(-1);
|
|
121
61
|
/** Where the curve takes over going forwards: the top of the
|
|
122
62
|
* ladder, or today where there is no ladder left to climb. */
|
|
123
|
-
const curveFrom =
|
|
63
|
+
const curveFrom = steps.at(-1)
|
|
64
|
+
?? { from: currentYear, pay: current.todaysMoney };
|
|
124
65
|
return {
|
|
125
66
|
payFor(schemeYearEnd) {
|
|
126
|
-
invariant(Number.isInteger(schemeYearEnd), `pay path: scheme year ${schemeYearEnd}`);
|
|
127
67
|
const given = declared.get(schemeYearEnd);
|
|
128
68
|
if (given !== undefined)
|
|
129
69
|
return { pay: given, basis: PAY_BASES.declared };
|
|
@@ -152,4 +92,82 @@ export function buildPayPath(dateOfBirth, pay) {
|
|
|
152
92
|
},
|
|
153
93
|
};
|
|
154
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* GAD's promotional pay index at an age: growth from promotion and
|
|
97
|
+
* progression over and above general pay awards, 100 at age 25,
|
|
98
|
+
* linear between the published five-year rows and flat beyond their
|
|
99
|
+
* ends.
|
|
100
|
+
*
|
|
101
|
+
* **The two non-manual columns, averaged.** GAD splits the index by
|
|
102
|
+
* sex and we do not ask a member's sex, nor infer it: averaging is
|
|
103
|
+
* the only version that encodes no guess about the member. It
|
|
104
|
+
* overstates progression for women and understates it for men, which a
|
|
105
|
+
* caller showing its figures should disclose. Non-manual is not a second
|
|
106
|
+
* assumption — every Agenda for Change band is non-manual in GAD's
|
|
107
|
+
* terms.
|
|
108
|
+
*/
|
|
109
|
+
export function promotionalIndex(age) {
|
|
110
|
+
invariant(Number.isFinite(age), `promotionalIndex: age ${age}`);
|
|
111
|
+
const { ages, nonManual } = PROMOTIONAL_SCALE_2020;
|
|
112
|
+
const blend = (i) => (nonManual.male[i] + nonManual.female[i]) / NON_MANUAL_COLUMNS;
|
|
113
|
+
const last = ages.length - 1;
|
|
114
|
+
if (age <= ages[0])
|
|
115
|
+
return blend(0);
|
|
116
|
+
if (age >= ages[last])
|
|
117
|
+
return blend(last);
|
|
118
|
+
const hi = ages.findIndex((a) => a > age);
|
|
119
|
+
const lo = hi - 1;
|
|
120
|
+
const through = (age - ages[lo]) / (ages[hi] - ages[lo]);
|
|
121
|
+
return blend(lo) + (blend(hi) - blend(lo)) * through;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Whether `figure` is a pay figure: finite and not negative. Nought is one,
|
|
125
|
+
* now or in a past year: a member paid nothing, as on unpaid leave, accrues
|
|
126
|
+
* nothing for it, and a stated balance still revalues. A year of nought is
|
|
127
|
+
* not a break in service. The one test both refusals below apply.
|
|
128
|
+
*/
|
|
129
|
+
function isPayFigure(figure) {
|
|
130
|
+
return Number.isFinite(figure) && figure >= 0;
|
|
131
|
+
}
|
|
132
|
+
/** Refuse a current pay that is not a pay figure. */
|
|
133
|
+
function refuseNoCurrentPay(current) {
|
|
134
|
+
if (!isPayFigure(current.todaysMoney)) {
|
|
135
|
+
throw new PayPathUnavailable(`current pay ${current.todaysMoney} is not a pay figure`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** The pay a member declared, by scheme year. Throws RangeError for a year
|
|
139
|
+
* declared twice or a figure that is not a pay figure. */
|
|
140
|
+
function declaredByYear(declared) {
|
|
141
|
+
const byYear = new Map();
|
|
142
|
+
for (const { schemeYearEnd, todaysMoney: figure } of declared) {
|
|
143
|
+
if (byYear.has(schemeYearEnd)) {
|
|
144
|
+
throw new RangeError(`pay path: ${schemeYearEnd} declared twice`);
|
|
145
|
+
}
|
|
146
|
+
if (!isPayFigure(figure)) {
|
|
147
|
+
throw new RangeError(`pay path: ${schemeYearEnd} declared as ${figure}`);
|
|
148
|
+
}
|
|
149
|
+
byYear.set(schemeYearEnd, figure);
|
|
150
|
+
}
|
|
151
|
+
return byYear;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The contractual steps still to come, as the scheme years each is
|
|
155
|
+
* first paid in, scaled to the member's own pay so a part-time
|
|
156
|
+
* member's steps stay in proportion to what they are actually paid.
|
|
157
|
+
*/
|
|
158
|
+
function contractualSteps(ladder, current, currentYear) {
|
|
159
|
+
const here = ladder.current;
|
|
160
|
+
if (!ladder.points.includes(here)) {
|
|
161
|
+
throw new RangeError(`pay ladder: current point "${here.label}" is not one of its points`);
|
|
162
|
+
}
|
|
163
|
+
const hereYears = here.yearsExperience;
|
|
164
|
+
const scale = current.todaysMoney / here.salary;
|
|
165
|
+
return ladder.points
|
|
166
|
+
.filter((p) => p.yearsExperience > hereYears)
|
|
167
|
+
.map((p) => ({
|
|
168
|
+
from: schemeYearEnd(currentYear + p.yearsExperience - hereYears),
|
|
169
|
+
pay: p.salary * scale,
|
|
170
|
+
}))
|
|
171
|
+
.sort((a, b) => a.from - b.from);
|
|
172
|
+
}
|
|
155
173
|
//# sourceMappingURL=pay-path.js.map
|
package/dist/pay-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pay-path.js","sourceRoot":"","sources":["../src/pay-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAC,sBAAsB,EAAC,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAC,SAAS,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC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BAA8B,IAAI,CAAC,KAAK,4BAA4B,CACrE,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IAChD,OAAO,MAAM,CAAC,MAAM;SACjB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,GAAG,SAAS,CAAC;SAC5C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,IAAI,EAAE,aAAa,CAAC,WAAW,GAAG,CAAC,CAAC,eAAe,GAAG,SAAS,CAAC;QAChE,GAAG,EAAE,CAAC,CAAC,MAAM,GAAG,KAAK;KACtB,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/pension/ages.d.ts
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
* NORMAL PENSION AGE in the 2015 Section = the member's State Pension age, with
|
|
7
7
|
* a floor of 65 (NHSBSA 2015 Members' Guide V13, May 2024, archived as SA-38 in
|
|
8
8
|
* docs/source-archive.md). The SPA timetable is legislated — Pensions Acts
|
|
9
|
-
* 1995/2007/2011/2014 — and reproduced in DWP's "State Pension age
|
|
10
|
-
* archived as SA-62 in docs/source-archive.md (last updated 15 May 2014
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* 1995/2007/2011/2014 — and reproduced in DWP's "State Pension age timetable",
|
|
10
|
+
* archived as SA-62 in docs/source-archive.md (last updated 15 May 2014, "following
|
|
11
|
+
* changes included in the Pensions Act 2014"). The legislated dates stand: the
|
|
12
|
+
* government's State Pension age Review 2023 (30 March 2023,
|
|
13
|
+
* https://www.gov.uk/government/publications/state-pension-age-review-2023-government-report)
|
|
14
|
+
* kept the rise to 67 for 2026-2028 and left the rise to 68 as legislated.
|
|
13
15
|
*
|
|
14
16
|
* Whole years only. The Acts phase each rise through narrow transitional birth
|
|
15
17
|
* cohorts whose exact SPA is 65/66/67 plus some months; `normalPensionAge`
|
package/dist/pension/ages.js
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
* NORMAL PENSION AGE in the 2015 Section = the member's State Pension age, with
|
|
7
7
|
* a floor of 65 (NHSBSA 2015 Members' Guide V13, May 2024, archived as SA-38 in
|
|
8
8
|
* docs/source-archive.md). The SPA timetable is legislated — Pensions Acts
|
|
9
|
-
* 1995/2007/2011/2014 — and reproduced in DWP's "State Pension age
|
|
10
|
-
* archived as SA-62 in docs/source-archive.md (last updated 15 May 2014
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* 1995/2007/2011/2014 — and reproduced in DWP's "State Pension age timetable",
|
|
10
|
+
* archived as SA-62 in docs/source-archive.md (last updated 15 May 2014, "following
|
|
11
|
+
* changes included in the Pensions Act 2014"). The legislated dates stand: the
|
|
12
|
+
* government's State Pension age Review 2023 (30 March 2023,
|
|
13
|
+
* https://www.gov.uk/government/publications/state-pension-age-review-2023-government-report)
|
|
14
|
+
* kept the rise to 67 for 2026-2028 and left the rise to 68 as legislated.
|
|
13
15
|
*
|
|
14
16
|
* Whole years only. The Acts phase each rise through narrow transitional birth
|
|
15
17
|
* cohorts whose exact SPA is 65/66/67 plus some months; `normalPensionAge`
|
package/dist/pension/ages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ages.js","sourceRoot":"","sources":["../../src/pension/ages.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ages.js","sourceRoot":"","sources":["../../src/pension/ages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,SAA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b,CAAC;AASD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAuB,EACvB,OAAgB;IAEhB,OAAO,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,UAAU,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,OAAuB,EAAE,OAAgB;IACjE,OAAO,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC;AAC/C,CAAC;AASD;8EAC8E;AAC9E,MAAM,UAAU,WAAW,CACzB,EAAC,IAAI,EAAE,WAAW,EAAiB,EACnC,OAAgB;IAEhB,MAAM,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,UAAU,GAAG,oBAAoB,CAAC;QACtC,YAAY,EAAE,YAAY;QAC1B,gBAAgB,EAAE,SAAS,CAAC,WAAW,CAAC,GAAG,yBAAyB,EAAE;KACvE,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,EAAC,UAAU,EAAE,OAAO,EAAE,EAAE,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,EAAC,CAAC;AAC3E,CAAC;AAED;yBACyB;AACzB,MAAM,UAAU,aAAa,CAC3B,MAAiE;IAEjE,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC"}
|
package/dist/pension/curve.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EstimatedHistory } from './history.js';
|
|
2
2
|
import type { MemberLedger } from './ledger.js';
|
|
3
|
+
import type { SchemeYearEnd } from './scheme-year.js';
|
|
3
4
|
import type { MemberPhase } from './uplift.js';
|
|
4
5
|
/** A point on the projection curve */
|
|
5
6
|
export interface ProjectionPoint {
|
|
@@ -39,7 +40,7 @@ interface CurveRun {
|
|
|
39
40
|
* the one the age is counted from, so five years of age can span six
|
|
40
41
|
* scheme years.
|
|
41
42
|
*/
|
|
42
|
-
export declare function walkThrough(drawing: Date, pensionAge: Date):
|
|
43
|
+
export declare function walkThrough(drawing: Date, pensionAge: Date): SchemeYearEnd;
|
|
43
44
|
/**
|
|
44
45
|
* The curve is the ledger's own steps, plotted ON THEM.
|
|
45
46
|
*
|
package/dist/pension/curve.js
CHANGED
|
@@ -7,8 +7,15 @@
|
|
|
7
7
|
* the same ledger and plot it the same way, so it belongs to neither.
|
|
8
8
|
*/
|
|
9
9
|
import { yearsBetween } from '../dates.js';
|
|
10
|
-
import { schemeYearEndDate, schemeYearEndFor } from './
|
|
10
|
+
import { schemeYearEnd, schemeYearEndDate, schemeYearEndFor } from './scheme-year.js';
|
|
11
11
|
import { phaseAt } from './uplift.js';
|
|
12
|
+
/** The years of age the curve draws beyond the later of the drawing and
|
|
13
|
+
* the pension age. */
|
|
14
|
+
const CURVE_AGES_BEYOND = 5;
|
|
15
|
+
/** The scheme years a walk reaches beyond that point: one more than the
|
|
16
|
+
* ages, since a birthday can fall in the scheme year after the one the
|
|
17
|
+
* age is counted from. */
|
|
18
|
+
const WALK_YEARS_BEYOND = CURVE_AGES_BEYOND + 1;
|
|
12
19
|
/**
|
|
13
20
|
* The last scheme year a walk reaches: six past the later of the
|
|
14
21
|
* drawing and the pension age. The curve draws five years of age
|
|
@@ -17,7 +24,7 @@ import { phaseAt } from './uplift.js';
|
|
|
17
24
|
* scheme years.
|
|
18
25
|
*/
|
|
19
26
|
export function walkThrough(drawing, pensionAge) {
|
|
20
|
-
return Math.max(schemeYearEndFor(drawing), schemeYearEndFor(pensionAge)) +
|
|
27
|
+
return schemeYearEnd(Math.max(schemeYearEndFor(drawing), schemeYearEndFor(pensionAge)) + WALK_YEARS_BEYOND);
|
|
21
28
|
}
|
|
22
29
|
/**
|
|
23
30
|
* A member's age on a date, as WHOLE YEARS plus the fraction of
|
|
@@ -71,15 +78,16 @@ function ageAtYearEnd(dateOfBirth, on) {
|
|
|
71
78
|
*/
|
|
72
79
|
export function buildCurve(cash, todays) {
|
|
73
80
|
const { today, dateOfBirth, retirementDate, npa } = cash;
|
|
74
|
-
const endAge =
|
|
81
|
+
const endAge = CURVE_AGES_BEYOND
|
|
82
|
+
+ Math.max(npa, yearsBetween(dateOfBirth, retirementDate));
|
|
75
83
|
/** The scheme year an age's birthday falls in. */
|
|
76
84
|
const yearOfAge = (age) => schemeYearEndFor(new Date(dateOfBirth.getFullYear() + age, dateOfBirth.getMonth(), dateOfBirth.getDate()));
|
|
77
85
|
/** The age whose birthday falls in a scheme year — the
|
|
78
86
|
* inverse, used once to find where the axis starts. */
|
|
79
|
-
const ageInYear = (
|
|
80
|
-
const end = schemeYearEndDate(
|
|
81
|
-
const birthday = new Date(
|
|
82
|
-
return
|
|
87
|
+
const ageInYear = (year) => {
|
|
88
|
+
const end = schemeYearEndDate(year);
|
|
89
|
+
const birthday = new Date(year, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
90
|
+
return year - dateOfBirth.getFullYear()
|
|
83
91
|
- (birthday > end ? 1 : 0);
|
|
84
92
|
};
|
|
85
93
|
const startAge = ageInYear(schemeYearEndFor(cash.curveFrom));
|