@casomoltd/nhs-pay 0.34.0 → 0.35.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 +3 -3
- package/dist/additional-pension.d.ts +6 -4
- package/dist/additional-pension.js +22 -18
- package/dist/additional-pension.js.map +1 -1
- package/dist/circulars/ni-hsc-afc-06-2025.d.ts +1 -1
- package/dist/circulars/ni-hsc-afc-06-2025.js +1 -1
- package/dist/dates.d.ts +9 -5
- package/dist/dates.js.map +1 -1
- package/dist/errors.d.ts +58 -45
- package/dist/errors.js +63 -52
- package/dist/errors.js.map +1 -1
- package/dist/factor-basis.d.ts +95 -106
- package/dist/factor-basis.js +97 -108
- package/dist/factor-basis.js.map +1 -1
- package/dist/gad/additional-pension-0-703-2026-07-08.d.ts +185 -0
- package/dist/gad/additional-pension-0-703-2026-07-08.js +89 -0
- package/dist/gad/{additional-pension-0-703-2023-10-03.js.map → additional-pension-0-703-2026-07-08.js.map} +1 -1
- package/dist/gad/additional-pension-0-712-2026-07-08.d.ts +34 -0
- package/dist/gad/additional-pension-0-712-2026-07-08.js +172 -0
- package/dist/gad/additional-pension-0-712-2026-07-08.js.map +1 -0
- package/dist/gad/additional-pension-0-713-2026-07-08.d.ts +34 -0
- package/dist/gad/additional-pension-0-713-2026-07-08.js +175 -0
- package/dist/gad/additional-pension-0-713-2026-07-08.js.map +1 -0
- package/dist/gad/additional-pension-0-714-2026-07-08.d.ts +34 -0
- package/dist/gad/additional-pension-0-714-2026-07-08.js +178 -0
- package/dist/gad/additional-pension-0-714-2026-07-08.js.map +1 -0
- package/dist/gad/additional-pension-0-715-2026-07-08.d.ts +34 -0
- package/dist/gad/additional-pension-0-715-2026-07-08.js +181 -0
- package/dist/gad/additional-pension-0-715-2026-07-08.js.map +1 -0
- package/dist/gad/additional-pension-0-716-2026-07-08.d.ts +34 -0
- package/dist/gad/additional-pension-0-716-2026-07-08.js +172 -0
- package/dist/gad/additional-pension-0-716-2026-07-08.js.map +1 -0
- package/dist/gad/additional-pension-0-717-2026-07-08.d.ts +34 -0
- package/dist/gad/additional-pension-0-717-2026-07-08.js +175 -0
- package/dist/gad/additional-pension-0-717-2026-07-08.js.map +1 -0
- package/dist/gad/additional-pension-0-718-2026-07-08.d.ts +34 -0
- package/dist/gad/additional-pension-0-718-2026-07-08.js +178 -0
- package/dist/gad/additional-pension-0-718-2026-07-08.js.map +1 -0
- package/dist/gad/additional-pension-0-719-2026-07-08.d.ts +34 -0
- package/dist/gad/additional-pension-0-719-2026-07-08.js +181 -0
- package/dist/gad/additional-pension-0-719-2026-07-08.js.map +1 -0
- package/dist/gad/additional-pension-table.d.ts +4 -11
- package/dist/gad/additional-pension-table.js.map +1 -1
- package/dist/gad/erf-0-420-2026-07-08.d.ts +51 -0
- package/dist/gad/erf-0-420-2026-07-08.js +83 -0
- package/dist/gad/erf-0-420-2026-07-08.js.map +1 -0
- package/dist/gad/erf-1-401-2026-07-08.d.ts +42 -0
- package/dist/gad/erf-1-401-2026-07-08.js +67 -0
- package/dist/gad/erf-1-401-2026-07-08.js.map +1 -0
- package/dist/gad/erf-1-402-2026-07-08.d.ts +43 -0
- package/dist/gad/erf-1-402-2026-07-08.js +78 -0
- package/dist/gad/erf-1-402-2026-07-08.js.map +1 -0
- package/dist/gad/erf-1-407-2026-07-08.d.ts +42 -0
- package/dist/gad/erf-1-407-2026-07-08.js +67 -0
- package/dist/gad/erf-1-407-2026-07-08.js.map +1 -0
- package/dist/gad/factor-set.d.ts +54 -0
- package/dist/gad/factor-set.js +83 -0
- package/dist/gad/factor-set.js.map +1 -0
- package/dist/gad/factor-table.d.ts +31 -20
- package/dist/gad/factor-table.js +67 -37
- package/dist/gad/factor-table.js.map +1 -1
- package/dist/gad/lrf-0-421-2026-07-08.d.ts +46 -0
- package/dist/gad/lrf-0-421-2026-07-08.js +72 -0
- package/dist/gad/lrf-0-421-2026-07-08.js.map +1 -0
- package/dist/gad/lrf-0-422-2026-07-08.d.ts +43 -0
- package/dist/gad/lrf-0-422-2026-07-08.js +69 -0
- package/dist/gad/{lrf-0-422-2023-06-30.js.map → lrf-0-422-2026-07-08.js.map} +1 -1
- package/dist/gad/lrf-2-416-2026-07-08.d.ts +41 -0
- package/dist/gad/lrf-2-416-2026-07-08.js +66 -0
- package/dist/gad/lrf-2-416-2026-07-08.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/pension-projection.d.ts +30 -44
- package/dist/pension-projection.js +37 -61
- package/dist/pension-projection.js.map +1 -1
- package/dist/sections/section-1995.d.ts +6 -6
- package/dist/sections/section-1995.js +34 -27
- package/dist/sections/section-1995.js.map +1 -1
- package/dist/sections/section-2008.d.ts +4 -4
- package/dist/sections/section-2008.js +19 -23
- package/dist/sections/section-2008.js.map +1 -1
- package/dist/sections/section-2015.d.ts +7 -7
- package/dist/sections/section-2015.js +3 -7
- package/dist/sections/section-2015.js.map +1 -1
- package/package.json +1 -1
- package/dist/gad/additional-pension-0-703-2023-10-03.d.ts +0 -180
- package/dist/gad/additional-pension-0-703-2023-10-03.js +0 -87
- package/dist/gad/additional-pension-0-712-2023-10-03.d.ts +0 -35
- package/dist/gad/additional-pension-0-712-2023-10-03.js +0 -170
- package/dist/gad/additional-pension-0-712-2023-10-03.js.map +0 -1
- package/dist/gad/additional-pension-0-713-2023-10-03.d.ts +0 -35
- package/dist/gad/additional-pension-0-713-2023-10-03.js +0 -173
- package/dist/gad/additional-pension-0-713-2023-10-03.js.map +0 -1
- package/dist/gad/additional-pension-0-714-2023-10-03.d.ts +0 -35
- package/dist/gad/additional-pension-0-714-2023-10-03.js +0 -176
- package/dist/gad/additional-pension-0-714-2023-10-03.js.map +0 -1
- package/dist/gad/additional-pension-0-715-2023-10-03.d.ts +0 -35
- package/dist/gad/additional-pension-0-715-2023-10-03.js +0 -179
- package/dist/gad/additional-pension-0-715-2023-10-03.js.map +0 -1
- package/dist/gad/additional-pension-0-716-2023-10-03.d.ts +0 -35
- package/dist/gad/additional-pension-0-716-2023-10-03.js +0 -170
- package/dist/gad/additional-pension-0-716-2023-10-03.js.map +0 -1
- package/dist/gad/additional-pension-0-717-2023-10-03.d.ts +0 -35
- package/dist/gad/additional-pension-0-717-2023-10-03.js +0 -173
- package/dist/gad/additional-pension-0-717-2023-10-03.js.map +0 -1
- package/dist/gad/additional-pension-0-718-2023-10-03.d.ts +0 -35
- package/dist/gad/additional-pension-0-718-2023-10-03.js +0 -176
- package/dist/gad/additional-pension-0-718-2023-10-03.js.map +0 -1
- package/dist/gad/additional-pension-0-719-2023-10-03.d.ts +0 -35
- package/dist/gad/additional-pension-0-719-2023-10-03.js +0 -179
- package/dist/gad/additional-pension-0-719-2023-10-03.js.map +0 -1
- package/dist/gad/erf-1-401-2023-06-30.d.ts +0 -47
- package/dist/gad/erf-1-401-2023-06-30.js +0 -73
- package/dist/gad/erf-1-401-2023-06-30.js.map +0 -1
- package/dist/gad/erf-1-402-2023-06-30.d.ts +0 -48
- package/dist/gad/erf-1-402-2023-06-30.js +0 -84
- package/dist/gad/erf-1-402-2023-06-30.js.map +0 -1
- package/dist/gad/erf-1-407-2023-06-30.d.ts +0 -47
- package/dist/gad/erf-1-407-2023-06-30.js +0 -73
- package/dist/gad/erf-1-407-2023-06-30.js.map +0 -1
- package/dist/gad/erf-2023-06-30.d.ts +0 -72
- package/dist/gad/erf-2023-06-30.js +0 -105
- package/dist/gad/erf-2023-06-30.js.map +0 -1
- package/dist/gad/lrf-0-422-2023-06-30.d.ts +0 -45
- package/dist/gad/lrf-0-422-2023-06-30.js +0 -70
- package/dist/gad/lrf-2-416-2023-06-30.d.ts +0 -46
- package/dist/gad/lrf-2-416-2023-06-30.js +0 -72
- package/dist/gad/lrf-2-416-2023-06-30.js.map +0 -1
- package/dist/gad/lrf-2023-06-30.d.ts +0 -72
- package/dist/gad/lrf-2023-06-30.js +0 -99
- package/dist/gad/lrf-2023-06-30.js.map +0 -1
package/dist/factor-basis.d.ts
CHANGED
|
@@ -1,60 +1,51 @@
|
|
|
1
|
+
import type { Period } from './dates.js';
|
|
1
2
|
import { LEGACY_PENSION_AGES } from './pension/ages.js';
|
|
2
|
-
import {
|
|
3
|
+
import { factorTable } from './gad/factor-set.js';
|
|
4
|
+
import type { PurposeOf } from './gad/factor-set.js';
|
|
3
5
|
import type { ProjectionMoney } from './pension/money.js';
|
|
4
6
|
import type { FactorProvenance, FactorTableKind } from './gad/factor-table.js';
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* What a factor is measured against, and the table read on each side of
|
|
9
|
+
* it. A 1995 Section drawing before 60 reduces its pension and its
|
|
10
|
+
* automatic lump sum by two tables, and its late arm is a declared
|
|
11
|
+
* absence rather than a table; a late 2015 Section drawing uplifts main
|
|
12
|
+
* and additional pension by two.
|
|
10
13
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
readonly
|
|
23
|
-
|
|
24
|
-
readonly
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
readonly
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
readonly "0-420": FactorTable<{
|
|
33
|
-
readonly by: "period";
|
|
34
|
-
}>;
|
|
35
|
-
readonly "0-421": FactorTable<{
|
|
36
|
-
readonly by: "period";
|
|
37
|
-
}>;
|
|
38
|
-
readonly "0-422": FactorTable<{
|
|
39
|
-
readonly by: "period";
|
|
40
|
-
}>;
|
|
41
|
-
readonly "1-401": FactorTable<{
|
|
42
|
-
readonly by: "age";
|
|
43
|
-
readonly firstAge: 50;
|
|
44
|
-
}>;
|
|
45
|
-
readonly "1-407": FactorTable<{
|
|
46
|
-
readonly by: "age";
|
|
47
|
-
readonly firstAge: 50;
|
|
48
|
-
}>;
|
|
49
|
-
readonly "1-402": FactorTable<{
|
|
50
|
-
readonly by: "age";
|
|
51
|
-
readonly firstAge: 50;
|
|
52
|
-
}>;
|
|
53
|
-
readonly "2-416": FactorTable<{
|
|
54
|
-
readonly by: "age";
|
|
55
|
-
readonly firstAge: 65;
|
|
56
|
-
}>;
|
|
14
|
+
export type FactorBasis = {
|
|
15
|
+
readonly against: typeof LEGACY_PENSION_AGES.section1995;
|
|
16
|
+
readonly early: PurposeOf<'early1995Pension' | 'early1995LumpSum'>;
|
|
17
|
+
readonly late: typeof FACTOR_SOURCES.noLateUplift;
|
|
18
|
+
} | {
|
|
19
|
+
readonly against: typeof LEGACY_PENSION_AGES.section2008;
|
|
20
|
+
readonly early: PurposeOf<'earlyAge65'>;
|
|
21
|
+
readonly late: PurposeOf<'late2008'>;
|
|
22
|
+
} | Basis2015;
|
|
23
|
+
/** A factor and where it came from, discriminated on `source`. */
|
|
24
|
+
export type FactorOutcome = {
|
|
25
|
+
readonly source: typeof FACTOR_SOURCES.table;
|
|
26
|
+
readonly factor: number;
|
|
27
|
+
readonly tableKind: FactorTableKind;
|
|
28
|
+
readonly provenance: FactorProvenance;
|
|
29
|
+
} | {
|
|
30
|
+
readonly source: typeof FACTOR_SOURCES.atPensionAge;
|
|
31
|
+
readonly factor: 1;
|
|
32
|
+
} | {
|
|
33
|
+
readonly source: typeof FACTOR_SOURCES.noLateUplift;
|
|
34
|
+
readonly factor: 1;
|
|
57
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* A figure before and after its early or late factor, and the factor.
|
|
38
|
+
* Read the figure before it from `beforeFactor`, never by dividing `after`
|
|
39
|
+
* by `factor`: a pension and its lump sum each have their own factor.
|
|
40
|
+
* `F` is `FactorOutcome | null` where the rules may apply no factor
|
|
41
|
+
* because they pay nothing.
|
|
42
|
+
*/
|
|
43
|
+
export interface Factored<F extends FactorOutcome | null = FactorOutcome> {
|
|
44
|
+
readonly beforeFactor: ProjectionMoney;
|
|
45
|
+
/** After the factor: what is paid. */
|
|
46
|
+
readonly after: ProjectionMoney;
|
|
47
|
+
readonly factor: F;
|
|
48
|
+
}
|
|
58
49
|
/** Which benefit a factor applies to, where two benefits measured from
|
|
59
50
|
* one pension age read different tables: a 1995 Section pension and its
|
|
60
51
|
* automatic lump sum, and 2015 Section additional pension. */
|
|
@@ -66,36 +57,19 @@ export declare const FACTOR_APPLIES: {
|
|
|
66
57
|
readonly additionalPension: "additional-pension";
|
|
67
58
|
};
|
|
68
59
|
/** The benefits each section splits its tables by: typed per section,
|
|
69
|
-
* so a
|
|
60
|
+
* so a section cannot name a benefit it does not have. */
|
|
70
61
|
export type Applies1995 = typeof FACTOR_APPLIES.pension | typeof FACTOR_APPLIES.lumpSum;
|
|
71
62
|
export type Applies2015 = typeof FACTOR_APPLIES.pension | typeof FACTOR_APPLIES.additionalPension;
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
readonly
|
|
63
|
+
/** A 2015 Section basis: the member's own pension age, one early table
|
|
64
|
+
* for every benefit, and a late table per benefit. */
|
|
65
|
+
type Basis2015 = {
|
|
66
|
+
readonly against: typeof MEMBERS_NPA;
|
|
67
|
+
readonly npa: number;
|
|
68
|
+
readonly early: PurposeOf<'early2015'>;
|
|
69
|
+
readonly late: PurposeOf<'late2015' | 'late2015AdditionalPension'>;
|
|
76
70
|
};
|
|
77
|
-
export type FactorDirection = (typeof FACTOR_DIRECTIONS)[keyof typeof FACTOR_DIRECTIONS];
|
|
78
71
|
/** The 2015 Section's pension age is the member's own, not a fixed one. */
|
|
79
72
|
export declare const MEMBERS_NPA = "npa";
|
|
80
|
-
/**
|
|
81
|
-
* What a factor is measured against, and for which benefit where the
|
|
82
|
-
* tables differ by benefit: a 1995 Section drawing before 60 reduces its
|
|
83
|
-
* pension and its automatic lump sum by two tables, and a late 2015
|
|
84
|
-
* Section drawing uplifts main and additional pension by two.
|
|
85
|
-
*/
|
|
86
|
-
export type FactorBasis = {
|
|
87
|
-
against: typeof LEGACY_PENSION_AGES.section1995;
|
|
88
|
-
direction: typeof FACTOR_DIRECTIONS.early;
|
|
89
|
-
applies: Applies1995;
|
|
90
|
-
} | {
|
|
91
|
-
against: typeof LEGACY_PENSION_AGES.section2008;
|
|
92
|
-
direction: FactorDirection;
|
|
93
|
-
} | {
|
|
94
|
-
against: typeof MEMBERS_NPA;
|
|
95
|
-
npa: number;
|
|
96
|
-
direction: FactorDirection;
|
|
97
|
-
applies: Applies2015;
|
|
98
|
-
};
|
|
99
73
|
/**
|
|
100
74
|
* Where a factor came from: a table, or one of the two reasons a drawing
|
|
101
75
|
* reads none. Every 1.000 says why it is 1.000, because "drawn exactly
|
|
@@ -107,39 +81,35 @@ export declare const FACTOR_SOURCES: {
|
|
|
107
81
|
readonly atPensionAge: "at-normal-pension-age";
|
|
108
82
|
readonly noLateUplift: "section-awards-no-late-uplift";
|
|
109
83
|
};
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
readonly
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
readonly
|
|
84
|
+
/**
|
|
85
|
+
* The 2015 Section's table on each side of its pension age, by benefit.
|
|
86
|
+
* Held at the door rather than in the section because the citation
|
|
87
|
+
* accessors below name the main pension's tables too, and one statement
|
|
88
|
+
* of the choice serves both.
|
|
89
|
+
*/
|
|
90
|
+
export declare const TABLES_2015: {
|
|
91
|
+
readonly pension: {
|
|
92
|
+
readonly early: "early2015";
|
|
93
|
+
readonly late: "late2015";
|
|
94
|
+
};
|
|
95
|
+
readonly "additional-pension": {
|
|
96
|
+
readonly early: "early2015";
|
|
97
|
+
readonly late: "late2015AdditionalPension";
|
|
98
|
+
};
|
|
122
99
|
};
|
|
100
|
+
export { factorTable };
|
|
123
101
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* `
|
|
128
|
-
*
|
|
102
|
+
* Whether a drawing falls before the pension age a basis is measured
|
|
103
|
+
* from: the judgement of early or late that `readFactor` and a section
|
|
104
|
+
* refusing an early drawing both take from here. Only the deprecated
|
|
105
|
+
* `retirementFactor` route judges its own, until it retires
|
|
106
|
+
* (https://github.com/casomoltd/nhs-pay/issues/21).
|
|
129
107
|
*/
|
|
130
|
-
export
|
|
131
|
-
readonly beforeFactor: ProjectionMoney;
|
|
132
|
-
/** After the factor: what is paid. */
|
|
133
|
-
readonly after: ProjectionMoney;
|
|
134
|
-
readonly factor: F;
|
|
135
|
-
}
|
|
136
|
-
/** Every table the library reads, by its GAD reference. The one set of
|
|
137
|
-
* instances, so two callers cannot read the same table two ways. */
|
|
138
|
-
export declare function factorTable<K extends keyof typeof TABLES>(ref: K): (typeof TABLES)[K];
|
|
108
|
+
export declare function drawnEarly(basis: FactorBasis, dateOfBirth: Date, drawn: Date): boolean;
|
|
139
109
|
/**
|
|
140
|
-
* Read the factor for a drawing. The
|
|
141
|
-
*
|
|
142
|
-
*
|
|
110
|
+
* Read the factor for a drawing. The dates decide the direction, once,
|
|
111
|
+
* and the basis's arm for that direction names the table or declares
|
|
112
|
+
* that none is read.
|
|
143
113
|
*/
|
|
144
114
|
export declare function readFactor(basis: FactorBasis, dateOfBirth: Date, drawn: Date): FactorOutcome;
|
|
145
115
|
/**
|
|
@@ -148,4 +118,23 @@ export declare function readFactor(basis: FactorBasis, dateOfBirth: Date, drawn:
|
|
|
148
118
|
* means the rules pay nothing, so nothing is paid after it.
|
|
149
119
|
*/
|
|
150
120
|
export declare function factored<F extends FactorOutcome | null>(beforeFactor: ProjectionMoney, factor: F): Factored<F>;
|
|
151
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Provenance of the **2015 Section main pension's** table behind a factor
|
|
123
|
+
* kind: `erf` is 0-420 and `lrf` is 0-421. These are the citation facts
|
|
124
|
+
* (table ref, guidance name, issue and implementation dates, source)
|
|
125
|
+
* consumers render instead of hand-typing them.
|
|
126
|
+
*
|
|
127
|
+
* The additional-pension late table, 0-422, has no accessor here: a
|
|
128
|
+
* drawing that read it carries its provenance on its `FactorOutcome`.
|
|
129
|
+
*/
|
|
130
|
+
export declare function factorProvenance(kind: FactorTableKind): FactorProvenance;
|
|
131
|
+
/**
|
|
132
|
+
* The **2015 Section's** early retirement factor for drawing a whole
|
|
133
|
+
* period before its pension age, for a caller that holds the period
|
|
134
|
+
* rather than the two dates it spans. The 1995 and 2008 Sections are
|
|
135
|
+
* keyed by age and are not read here. A whole period has no part-month
|
|
136
|
+
* to round, so the table is read at exactly that row. Months are 0 to
|
|
137
|
+
* 11; a period past the last printed row raises
|
|
138
|
+
* `RetirementFactorOutOfRange`.
|
|
139
|
+
*/
|
|
140
|
+
export declare function erf2015For(period: Omit<Period, 'days'>): number;
|
package/dist/factor-basis.js
CHANGED
|
@@ -1,68 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The one door every early or late retirement factor is read through
|
|
2
|
+
* The one door every early or late retirement factor is read through,
|
|
3
|
+
* and the citations of the tables behind them.
|
|
3
4
|
*
|
|
4
5
|
* A factor is read against the pension age the reduction is measured
|
|
5
|
-
* from
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* from. That is how GAD segments the tables: 1-402 serves any benefit
|
|
7
|
+
* with a pension age of 65, whichever section holds it. So a basis is
|
|
8
|
+
* keyed by the pension age, and states the table each side of it reads:
|
|
9
|
+
* each section declares its own, and the type ties every table to the
|
|
10
|
+
* pension age it is printed against, so the 1995 Section, measured from
|
|
11
|
+
* 60, has no way to name 1-402.
|
|
10
12
|
*
|
|
11
13
|
* So one drawing age means different things in different sections. Drawn
|
|
12
14
|
* at 66, a 1995 Section pension is late (its pension age is 60) but takes
|
|
13
|
-
* no uplift, because that section
|
|
14
|
-
* late against 65 and reads 2-416; a 2015 Section pension with
|
|
15
|
-
* Pension Age of 67 is early and reads 0-420. Early or late is
|
|
16
|
-
* judged against the pension age the
|
|
17
|
-
* age alone.
|
|
15
|
+
* no uplift, because that section's basis declares none; a 2008 Section
|
|
16
|
+
* pension is late against 65 and reads 2-416; a 2015 Section pension with
|
|
17
|
+
* a Normal Pension Age of 67 is early and reads 0-420. Early or late is
|
|
18
|
+
* judged here, from the dates against the pension age the basis names,
|
|
19
|
+
* never the member's age alone. The one other judgement is the
|
|
20
|
+
* deprecated `retirementFactor` route, which takes a pension-age date
|
|
21
|
+
* rather than a date of birth and so judges its own side until it
|
|
22
|
+
* retires (https://github.com/casomoltd/nhs-pay/issues/21).
|
|
18
23
|
*/
|
|
19
24
|
import { periodInYearsMonths, npaDate } from './dates.js';
|
|
20
|
-
import {
|
|
21
|
-
import { LEGACY_PENSION_AGES } from './pension/ages.js';
|
|
22
|
-
import { FactorTable } from './gad/factor-table.js';
|
|
25
|
+
import { factorTable } from './gad/factor-set.js';
|
|
23
26
|
import { timesMoney } from './pension/money.js';
|
|
24
|
-
import { ERF_0_420 } from './gad/erf-2023-06-30.js';
|
|
25
|
-
import { LRF_0_421 } from './gad/lrf-2023-06-30.js';
|
|
26
|
-
import { LRF_0_422 } from './gad/lrf-0-422-2023-06-30.js';
|
|
27
|
-
import { ERF_1_401 } from './gad/erf-1-401-2023-06-30.js';
|
|
28
|
-
import { ERF_1_402 } from './gad/erf-1-402-2023-06-30.js';
|
|
29
|
-
import { ERF_1_407 } from './gad/erf-1-407-2023-06-30.js';
|
|
30
|
-
import { LRF_2_416 } from './gad/lrf-2-416-2023-06-30.js';
|
|
31
|
-
/**
|
|
32
|
-
* The factor tables the library reads, named for what each is for. The
|
|
33
|
-
* value is GAD's own table reference, which is how the table is found in
|
|
34
|
-
* the workbook and the NHSBSA extract to check it; the name is how code
|
|
35
|
-
* picks one, so no branch below reads a reference it has to decode.
|
|
36
|
-
*/
|
|
37
|
-
export const FACTOR_TABLES = {
|
|
38
|
-
/** 2015 Section, taken before its Normal Pension Age: main and
|
|
39
|
-
* additional pension alike (ERF1). */
|
|
40
|
-
early2015: '0-420',
|
|
41
|
-
/** 2015 Section main pension, taken after its Normal Pension Age from
|
|
42
|
-
* active service (LRF1). */
|
|
43
|
-
late2015: '0-421',
|
|
44
|
-
/** 2015 Section additional pension, taken after its Normal Pension Age
|
|
45
|
-
* from active service (LRF2). */
|
|
46
|
-
late2015AdditionalPension: '0-422',
|
|
47
|
-
/** 1995 Section pension, taken before 60. */
|
|
48
|
-
early1995Pension: '1-401',
|
|
49
|
-
/** 1995 Section automatic lump sum, taken before 60. */
|
|
50
|
-
early1995LumpSum: '1-407',
|
|
51
|
-
/** 2008 Section, taken before 65. GAD prints it for any benefit
|
|
52
|
-
* with a pension age of 65, hence the name. */
|
|
53
|
-
earlyAge65: '1-402',
|
|
54
|
-
/** 2008 Section, taken after 65. */
|
|
55
|
-
late2008: '2-416',
|
|
56
|
-
};
|
|
57
|
-
const TABLES = {
|
|
58
|
-
[FACTOR_TABLES.early2015]: new FactorTable(ERF_0_420),
|
|
59
|
-
[FACTOR_TABLES.late2015]: new FactorTable(LRF_0_421),
|
|
60
|
-
[FACTOR_TABLES.late2015AdditionalPension]: new FactorTable(LRF_0_422),
|
|
61
|
-
[FACTOR_TABLES.early1995Pension]: new FactorTable(ERF_1_401),
|
|
62
|
-
[FACTOR_TABLES.early1995LumpSum]: new FactorTable(ERF_1_407),
|
|
63
|
-
[FACTOR_TABLES.earlyAge65]: new FactorTable(ERF_1_402),
|
|
64
|
-
[FACTOR_TABLES.late2008]: new FactorTable(LRF_2_416),
|
|
65
|
-
};
|
|
66
27
|
/** Which benefit a factor applies to, where two benefits measured from
|
|
67
28
|
* one pension age read different tables: a 1995 Section pension and its
|
|
68
29
|
* automatic lump sum, and 2015 Section additional pension. */
|
|
@@ -73,11 +34,6 @@ export const FACTOR_APPLIES = {
|
|
|
73
34
|
* own late factor (0-422) and the main pension's early one. */
|
|
74
35
|
additionalPension: 'additional-pension',
|
|
75
36
|
};
|
|
76
|
-
/** Which side of the pension age a drawing falls. */
|
|
77
|
-
export const FACTOR_DIRECTIONS = {
|
|
78
|
-
early: 'early',
|
|
79
|
-
late: 'late',
|
|
80
|
-
};
|
|
81
37
|
/** The 2015 Section's pension age is the member's own, not a fixed one. */
|
|
82
38
|
export const MEMBERS_NPA = 'npa';
|
|
83
39
|
/**
|
|
@@ -91,46 +47,73 @@ export const FACTOR_SOURCES = {
|
|
|
91
47
|
atPensionAge: 'at-normal-pension-age',
|
|
92
48
|
noLateUplift: 'section-awards-no-late-uplift',
|
|
93
49
|
};
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
50
|
+
/**
|
|
51
|
+
* The 2015 Section's table on each side of its pension age, by benefit.
|
|
52
|
+
* Held at the door rather than in the section because the citation
|
|
53
|
+
* accessors below name the main pension's tables too, and one statement
|
|
54
|
+
* of the choice serves both.
|
|
55
|
+
*/
|
|
56
|
+
export const TABLES_2015 = {
|
|
57
|
+
[FACTOR_APPLIES.pension]: { early: 'early2015', late: 'late2015' },
|
|
58
|
+
[FACTOR_APPLIES.additionalPension]: {
|
|
59
|
+
early: 'early2015', late: 'late2015AdditionalPension',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
/** Which side of the pension age a drawing falls, and the name of the
|
|
63
|
+
* arm of a basis it reads. */
|
|
64
|
+
const FACTOR_DIRECTIONS = {
|
|
65
|
+
early: 'early',
|
|
66
|
+
late: 'late',
|
|
67
|
+
};
|
|
68
|
+
/** The 2015 Section main pension's table for each factor kind: an ERF is
|
|
69
|
+
* its early table, an LRF its late one. */
|
|
70
|
+
const MAIN_2015_OF_KIND = {
|
|
71
|
+
erf: TABLES_2015[FACTOR_APPLIES.pension].early,
|
|
72
|
+
lrf: TABLES_2015[FACTOR_APPLIES.pension].late,
|
|
73
|
+
};
|
|
74
|
+
/* Every table is read from the one set (`factor-set.ts`); re-exported
|
|
75
|
+
so the deprecated `retirementFactor` route reads it through this door
|
|
76
|
+
too, and two callers cannot read one table two ways. */
|
|
77
|
+
export { factorTable };
|
|
78
|
+
/**
|
|
79
|
+
* Whether a drawing falls before the pension age a basis is measured
|
|
80
|
+
* from: the judgement of early or late that `readFactor` and a section
|
|
81
|
+
* refusing an early drawing both take from here. Only the deprecated
|
|
82
|
+
* `retirementFactor` route judges its own, until it retires
|
|
83
|
+
* (https://github.com/casomoltd/nhs-pay/issues/21).
|
|
84
|
+
*/
|
|
85
|
+
export function drawnEarly(basis, dateOfBirth, drawn) {
|
|
86
|
+
return drawn < pensionAgeDate(basis, dateOfBirth);
|
|
98
87
|
}
|
|
99
88
|
/**
|
|
100
|
-
* Read the factor for a drawing. The
|
|
101
|
-
*
|
|
102
|
-
*
|
|
89
|
+
* Read the factor for a drawing. The dates decide the direction, once,
|
|
90
|
+
* and the basis's arm for that direction names the table or declares
|
|
91
|
+
* that none is read.
|
|
103
92
|
*/
|
|
104
93
|
export function readFactor(basis, dateOfBirth, drawn) {
|
|
105
|
-
const
|
|
106
|
-
const pensionAge = section2015 ? basis.npa : basis.against;
|
|
107
|
-
const at = npaDate(dateOfBirth, pensionAge);
|
|
94
|
+
const at = pensionAgeDate(basis, dateOfBirth);
|
|
108
95
|
const drawnAtPensionAge = drawn.getTime() === at.getTime();
|
|
109
96
|
if (drawnAtPensionAge) {
|
|
110
97
|
return { source: FACTOR_SOURCES.atPensionAge, factor: 1 };
|
|
111
98
|
}
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
99
|
+
const early = drawnEarly(basis, dateOfBirth, drawn);
|
|
100
|
+
const reads = basis[early ? FACTOR_DIRECTIONS.early : FACTOR_DIRECTIONS.late];
|
|
101
|
+
if (reads === FACTOR_SOURCES.noLateUplift) {
|
|
102
|
+
return { source: FACTOR_SOURCES.noLateUplift, factor: 1 };
|
|
103
|
+
}
|
|
104
|
+
const table = factorTable(reads);
|
|
116
105
|
// The 1995 and 2008 Sections' tables are read at the member's age on
|
|
117
106
|
// the day they draw; the 2015 Section's at the time to or after its
|
|
118
107
|
// Normal Pension Age.
|
|
119
|
-
const
|
|
120
|
-
if (readAtMembersAge) {
|
|
121
|
-
return {
|
|
122
|
-
source: FACTOR_SOURCES.table,
|
|
123
|
-
factor: table.factorAtAge(periodInYearsMonths(dateOfBirth, drawn)),
|
|
124
|
-
tableKind: table.kind,
|
|
125
|
-
provenance: table.provenance,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
const period = drawnEarly
|
|
108
|
+
const fromPensionAge = early
|
|
129
109
|
? periodInYearsMonths(drawn, at)
|
|
130
110
|
: periodInYearsMonths(at, drawn);
|
|
111
|
+
const factor = keyedByAge(table)
|
|
112
|
+
? table.factorAtAge(periodInYearsMonths(dateOfBirth, drawn))
|
|
113
|
+
: table.factorFor(fromPensionAge);
|
|
131
114
|
return {
|
|
132
115
|
source: FACTOR_SOURCES.table,
|
|
133
|
-
factor
|
|
116
|
+
factor,
|
|
134
117
|
tableKind: table.kind,
|
|
135
118
|
provenance: table.provenance,
|
|
136
119
|
};
|
|
@@ -144,28 +127,34 @@ export function factored(beforeFactor, factor) {
|
|
|
144
127
|
const times = factor === null ? 0 : factor.factor;
|
|
145
128
|
return { beforeFactor, after: timesMoney(beforeFactor, times), factor };
|
|
146
129
|
}
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Provenance of the **2015 Section main pension's** table behind a factor
|
|
132
|
+
* kind: `erf` is 0-420 and `lrf` is 0-421. These are the citation facts
|
|
133
|
+
* (table ref, guidance name, issue and implementation dates, source)
|
|
134
|
+
* consumers render instead of hand-typing them.
|
|
135
|
+
*
|
|
136
|
+
* The additional-pension late table, 0-422, has no accessor here: a
|
|
137
|
+
* drawing that read it carries its provenance on its `FactorOutcome`.
|
|
138
|
+
*/
|
|
139
|
+
export function factorProvenance(kind) {
|
|
140
|
+
return factorTable(MAIN_2015_OF_KIND[kind]).provenance;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The **2015 Section's** early retirement factor for drawing a whole
|
|
144
|
+
* period before its pension age, for a caller that holds the period
|
|
145
|
+
* rather than the two dates it spans. The 1995 and 2008 Sections are
|
|
146
|
+
* keyed by age and are not read here. A whole period has no part-month
|
|
147
|
+
* to round, so the table is read at exactly that row. Months are 0 to
|
|
148
|
+
* 11; a period past the last printed row raises
|
|
149
|
+
* `RetirementFactorOutOfRange`.
|
|
150
|
+
*/
|
|
151
|
+
export function erf2015For(period) {
|
|
152
|
+
return factorTable(MAIN_2015_OF_KIND.erf).factorFor({ ...period, days: 0 });
|
|
153
|
+
}
|
|
154
|
+
/** The day a basis's pension age falls for a member. */
|
|
155
|
+
function pensionAgeDate(basis, dateOfBirth) {
|
|
156
|
+
const pensionAge = basis.against === MEMBERS_NPA ? basis.npa : basis.against;
|
|
157
|
+
return npaDate(dateOfBirth, pensionAge);
|
|
169
158
|
}
|
|
170
159
|
function keyedByAge(table) {
|
|
171
160
|
return table.index.by === 'age';
|
package/dist/factor-basis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factor-basis.js","sourceRoot":"","sources":["../src/factor-basis.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"factor-basis.js","sourceRoot":"","sources":["../src/factor-basis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAC,mBAAmB,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAGxD,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AA6D9C;;+DAE+D;AAC/D,M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