@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.
Files changed (132) hide show
  1. package/README.md +3 -3
  2. package/dist/additional-pension.d.ts +6 -4
  3. package/dist/additional-pension.js +22 -18
  4. package/dist/additional-pension.js.map +1 -1
  5. package/dist/circulars/ni-hsc-afc-06-2025.d.ts +1 -1
  6. package/dist/circulars/ni-hsc-afc-06-2025.js +1 -1
  7. package/dist/dates.d.ts +9 -5
  8. package/dist/dates.js.map +1 -1
  9. package/dist/errors.d.ts +58 -45
  10. package/dist/errors.js +63 -52
  11. package/dist/errors.js.map +1 -1
  12. package/dist/factor-basis.d.ts +95 -106
  13. package/dist/factor-basis.js +97 -108
  14. package/dist/factor-basis.js.map +1 -1
  15. package/dist/gad/additional-pension-0-703-2026-07-08.d.ts +185 -0
  16. package/dist/gad/additional-pension-0-703-2026-07-08.js +89 -0
  17. package/dist/gad/{additional-pension-0-703-2023-10-03.js.map → additional-pension-0-703-2026-07-08.js.map} +1 -1
  18. package/dist/gad/additional-pension-0-712-2026-07-08.d.ts +34 -0
  19. package/dist/gad/additional-pension-0-712-2026-07-08.js +172 -0
  20. package/dist/gad/additional-pension-0-712-2026-07-08.js.map +1 -0
  21. package/dist/gad/additional-pension-0-713-2026-07-08.d.ts +34 -0
  22. package/dist/gad/additional-pension-0-713-2026-07-08.js +175 -0
  23. package/dist/gad/additional-pension-0-713-2026-07-08.js.map +1 -0
  24. package/dist/gad/additional-pension-0-714-2026-07-08.d.ts +34 -0
  25. package/dist/gad/additional-pension-0-714-2026-07-08.js +178 -0
  26. package/dist/gad/additional-pension-0-714-2026-07-08.js.map +1 -0
  27. package/dist/gad/additional-pension-0-715-2026-07-08.d.ts +34 -0
  28. package/dist/gad/additional-pension-0-715-2026-07-08.js +181 -0
  29. package/dist/gad/additional-pension-0-715-2026-07-08.js.map +1 -0
  30. package/dist/gad/additional-pension-0-716-2026-07-08.d.ts +34 -0
  31. package/dist/gad/additional-pension-0-716-2026-07-08.js +172 -0
  32. package/dist/gad/additional-pension-0-716-2026-07-08.js.map +1 -0
  33. package/dist/gad/additional-pension-0-717-2026-07-08.d.ts +34 -0
  34. package/dist/gad/additional-pension-0-717-2026-07-08.js +175 -0
  35. package/dist/gad/additional-pension-0-717-2026-07-08.js.map +1 -0
  36. package/dist/gad/additional-pension-0-718-2026-07-08.d.ts +34 -0
  37. package/dist/gad/additional-pension-0-718-2026-07-08.js +178 -0
  38. package/dist/gad/additional-pension-0-718-2026-07-08.js.map +1 -0
  39. package/dist/gad/additional-pension-0-719-2026-07-08.d.ts +34 -0
  40. package/dist/gad/additional-pension-0-719-2026-07-08.js +181 -0
  41. package/dist/gad/additional-pension-0-719-2026-07-08.js.map +1 -0
  42. package/dist/gad/additional-pension-table.d.ts +4 -11
  43. package/dist/gad/additional-pension-table.js.map +1 -1
  44. package/dist/gad/erf-0-420-2026-07-08.d.ts +51 -0
  45. package/dist/gad/erf-0-420-2026-07-08.js +83 -0
  46. package/dist/gad/erf-0-420-2026-07-08.js.map +1 -0
  47. package/dist/gad/erf-1-401-2026-07-08.d.ts +42 -0
  48. package/dist/gad/erf-1-401-2026-07-08.js +67 -0
  49. package/dist/gad/erf-1-401-2026-07-08.js.map +1 -0
  50. package/dist/gad/erf-1-402-2026-07-08.d.ts +43 -0
  51. package/dist/gad/erf-1-402-2026-07-08.js +78 -0
  52. package/dist/gad/erf-1-402-2026-07-08.js.map +1 -0
  53. package/dist/gad/erf-1-407-2026-07-08.d.ts +42 -0
  54. package/dist/gad/erf-1-407-2026-07-08.js +67 -0
  55. package/dist/gad/erf-1-407-2026-07-08.js.map +1 -0
  56. package/dist/gad/factor-set.d.ts +54 -0
  57. package/dist/gad/factor-set.js +83 -0
  58. package/dist/gad/factor-set.js.map +1 -0
  59. package/dist/gad/factor-table.d.ts +31 -20
  60. package/dist/gad/factor-table.js +67 -37
  61. package/dist/gad/factor-table.js.map +1 -1
  62. package/dist/gad/lrf-0-421-2026-07-08.d.ts +46 -0
  63. package/dist/gad/lrf-0-421-2026-07-08.js +72 -0
  64. package/dist/gad/lrf-0-421-2026-07-08.js.map +1 -0
  65. package/dist/gad/lrf-0-422-2026-07-08.d.ts +43 -0
  66. package/dist/gad/lrf-0-422-2026-07-08.js +69 -0
  67. package/dist/gad/{lrf-0-422-2023-06-30.js.map → lrf-0-422-2026-07-08.js.map} +1 -1
  68. package/dist/gad/lrf-2-416-2026-07-08.d.ts +41 -0
  69. package/dist/gad/lrf-2-416-2026-07-08.js +66 -0
  70. package/dist/gad/lrf-2-416-2026-07-08.js.map +1 -0
  71. package/dist/index.d.ts +5 -3
  72. package/dist/index.js +8 -6
  73. package/dist/index.js.map +1 -1
  74. package/dist/pension-projection.d.ts +30 -44
  75. package/dist/pension-projection.js +37 -61
  76. package/dist/pension-projection.js.map +1 -1
  77. package/dist/sections/section-1995.d.ts +6 -6
  78. package/dist/sections/section-1995.js +34 -27
  79. package/dist/sections/section-1995.js.map +1 -1
  80. package/dist/sections/section-2008.d.ts +4 -4
  81. package/dist/sections/section-2008.js +19 -23
  82. package/dist/sections/section-2008.js.map +1 -1
  83. package/dist/sections/section-2015.d.ts +7 -7
  84. package/dist/sections/section-2015.js +3 -7
  85. package/dist/sections/section-2015.js.map +1 -1
  86. package/package.json +1 -1
  87. package/dist/gad/additional-pension-0-703-2023-10-03.d.ts +0 -180
  88. package/dist/gad/additional-pension-0-703-2023-10-03.js +0 -87
  89. package/dist/gad/additional-pension-0-712-2023-10-03.d.ts +0 -35
  90. package/dist/gad/additional-pension-0-712-2023-10-03.js +0 -170
  91. package/dist/gad/additional-pension-0-712-2023-10-03.js.map +0 -1
  92. package/dist/gad/additional-pension-0-713-2023-10-03.d.ts +0 -35
  93. package/dist/gad/additional-pension-0-713-2023-10-03.js +0 -173
  94. package/dist/gad/additional-pension-0-713-2023-10-03.js.map +0 -1
  95. package/dist/gad/additional-pension-0-714-2023-10-03.d.ts +0 -35
  96. package/dist/gad/additional-pension-0-714-2023-10-03.js +0 -176
  97. package/dist/gad/additional-pension-0-714-2023-10-03.js.map +0 -1
  98. package/dist/gad/additional-pension-0-715-2023-10-03.d.ts +0 -35
  99. package/dist/gad/additional-pension-0-715-2023-10-03.js +0 -179
  100. package/dist/gad/additional-pension-0-715-2023-10-03.js.map +0 -1
  101. package/dist/gad/additional-pension-0-716-2023-10-03.d.ts +0 -35
  102. package/dist/gad/additional-pension-0-716-2023-10-03.js +0 -170
  103. package/dist/gad/additional-pension-0-716-2023-10-03.js.map +0 -1
  104. package/dist/gad/additional-pension-0-717-2023-10-03.d.ts +0 -35
  105. package/dist/gad/additional-pension-0-717-2023-10-03.js +0 -173
  106. package/dist/gad/additional-pension-0-717-2023-10-03.js.map +0 -1
  107. package/dist/gad/additional-pension-0-718-2023-10-03.d.ts +0 -35
  108. package/dist/gad/additional-pension-0-718-2023-10-03.js +0 -176
  109. package/dist/gad/additional-pension-0-718-2023-10-03.js.map +0 -1
  110. package/dist/gad/additional-pension-0-719-2023-10-03.d.ts +0 -35
  111. package/dist/gad/additional-pension-0-719-2023-10-03.js +0 -179
  112. package/dist/gad/additional-pension-0-719-2023-10-03.js.map +0 -1
  113. package/dist/gad/erf-1-401-2023-06-30.d.ts +0 -47
  114. package/dist/gad/erf-1-401-2023-06-30.js +0 -73
  115. package/dist/gad/erf-1-401-2023-06-30.js.map +0 -1
  116. package/dist/gad/erf-1-402-2023-06-30.d.ts +0 -48
  117. package/dist/gad/erf-1-402-2023-06-30.js +0 -84
  118. package/dist/gad/erf-1-402-2023-06-30.js.map +0 -1
  119. package/dist/gad/erf-1-407-2023-06-30.d.ts +0 -47
  120. package/dist/gad/erf-1-407-2023-06-30.js +0 -73
  121. package/dist/gad/erf-1-407-2023-06-30.js.map +0 -1
  122. package/dist/gad/erf-2023-06-30.d.ts +0 -72
  123. package/dist/gad/erf-2023-06-30.js +0 -105
  124. package/dist/gad/erf-2023-06-30.js.map +0 -1
  125. package/dist/gad/lrf-0-422-2023-06-30.d.ts +0 -45
  126. package/dist/gad/lrf-0-422-2023-06-30.js +0 -70
  127. package/dist/gad/lrf-2-416-2023-06-30.d.ts +0 -46
  128. package/dist/gad/lrf-2-416-2023-06-30.js +0 -72
  129. package/dist/gad/lrf-2-416-2023-06-30.js.map +0 -1
  130. package/dist/gad/lrf-2023-06-30.d.ts +0 -72
  131. package/dist/gad/lrf-2023-06-30.js +0 -99
  132. package/dist/gad/lrf-2023-06-30.js.map +0 -1
@@ -1,60 +1,51 @@
1
+ import type { Period } from './dates.js';
1
2
  import { LEGACY_PENSION_AGES } from './pension/ages.js';
2
- import { FactorTable } from './gad/factor-table.js';
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
- * The factor tables the library reads, named for what each is for. The
7
- * value is GAD's own table reference, which is how the table is found in
8
- * the workbook and the NHSBSA extract to check it; the name is how code
9
- * picks one, so no branch below reads a reference it has to decode.
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 declare const FACTOR_TABLES: {
12
- /** 2015 Section, taken before its Normal Pension Age: main and
13
- * additional pension alike (ERF1). */
14
- readonly early2015: "0-420";
15
- /** 2015 Section main pension, taken after its Normal Pension Age from
16
- * active service (LRF1). */
17
- readonly late2015: "0-421";
18
- /** 2015 Section additional pension, taken after its Normal Pension Age
19
- * from active service (LRF2). */
20
- readonly late2015AdditionalPension: "0-422";
21
- /** 1995 Section pension, taken before 60. */
22
- readonly early1995Pension: "1-401";
23
- /** 1995 Section automatic lump sum, taken before 60. */
24
- readonly early1995LumpSum: "1-407";
25
- /** 2008 Section, taken before 65. GAD prints it for any benefit
26
- * with a pension age of 65, hence the name. */
27
- readonly earlyAge65: "1-402";
28
- /** 2008 Section, taken after 65. */
29
- readonly late2008: "2-416";
30
- };
31
- declare const TABLES: {
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 basis cannot name a benefit its section does not have. */
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
- /** Which side of the pension age a drawing falls. */
73
- export declare const FACTOR_DIRECTIONS: {
74
- readonly early: "early";
75
- readonly late: "late";
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
- /** A factor and where it came from, discriminated on `source`. */
111
- export type FactorOutcome = {
112
- readonly source: typeof FACTOR_SOURCES.table;
113
- readonly factor: number;
114
- readonly tableKind: FactorTableKind;
115
- readonly provenance: FactorProvenance;
116
- } | {
117
- readonly source: typeof FACTOR_SOURCES.atPensionAge;
118
- readonly factor: 1;
119
- } | {
120
- readonly source: typeof FACTOR_SOURCES.noLateUplift;
121
- readonly factor: 1;
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
- * A figure before and after its early or late factor, and the factor.
125
- * Read the figure before it from `beforeFactor`, never by dividing `after`
126
- * by `factor`: a pension and its lump sum each have their own factor.
127
- * `F` is `FactorOutcome | null` where the rules may apply no factor
128
- * because they pay nothing.
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 interface Factored<F extends FactorOutcome | null = FactorOutcome> {
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 date decides the direction as well
141
- * as the cell, so a basis whose direction the dates contradict is a bug
142
- * in the section that derived it and fails loud.
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
- export {};
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;
@@ -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, and the direction. That is how GAD segments the tables: 1-402
6
- * serves any benefit with a pension age of 65, whichever section holds
7
- * it. So the key is the pension age, not the section — and each section
8
- * derives its key privately from its own rules, which is what keeps the
9
- * 1995 Section from reading 1-402 although the type would allow it.
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 pays none; a 2008 Section pension is
14
- * late against 65 and reads 2-416; a 2015 Section pension with a Normal
15
- * Pension Age of 67 is early and reads 0-420. Early or late is always
16
- * judged against the pension age the section names, never the member's
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 { invariant } from './errors.js';
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
- /** Every table the library reads, by its GAD reference. The one set of
95
- * instances, so two callers cannot read the same table two ways. */
96
- export function factorTable(ref) {
97
- return TABLES[ref];
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 date decides the direction as well
101
- * as the cell, so a basis whose direction the dates contradict is a bug
102
- * in the section that derived it and fails loud.
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 section2015 = basis.against === MEMBERS_NPA;
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 drawnEarly = drawn < at;
113
- invariant(drawnEarly === (basis.direction === FACTOR_DIRECTIONS.early), `factor basis says ${basis.direction} for a drawing on `
114
- + `${drawn.toDateString()} against ${at.toDateString()}`);
115
- const table = tableFor(basis);
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 readAtMembersAge = keyedByAge(table);
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: table.factorFor(period),
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
- /** The table a basis reads, and how it is keyed. */
148
- function tableFor(basis) {
149
- const section2015 = basis.against === MEMBERS_NPA;
150
- const section1995 = basis.against === LEGACY_PENSION_AGES.section1995;
151
- const early = basis.direction === FACTOR_DIRECTIONS.early;
152
- if (section2015) {
153
- const additionalPension = basis.applies === FACTOR_APPLIES.additionalPension;
154
- if (early)
155
- return TABLES[FACTOR_TABLES.early2015];
156
- return additionalPension
157
- ? TABLES[FACTOR_TABLES.late2015AdditionalPension]
158
- : TABLES[FACTOR_TABLES.late2015];
159
- }
160
- if (section1995) {
161
- const pension = basis.applies === FACTOR_APPLIES.pension;
162
- return pension
163
- ? TABLES[FACTOR_TABLES.early1995Pension]
164
- : TABLES[FACTOR_TABLES.early1995LumpSum];
165
- }
166
- return early
167
- ? TABLES[FACTOR_TABLES.earlyAge65]
168
- : TABLES[FACTOR_TABLES.late2008];
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';
@@ -1 +1 @@
1
- {"version":3,"file":"factor-basis.js","sourceRoot":"","sources":["../src/factor-basis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAC,mBAAmB,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAQ9C,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxD,OA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