@casomoltd/nhs-pay 0.19.4 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +95 -18
  2. package/dist/afc-scales.d.ts +14 -7
  3. package/dist/afc-scales.js +19 -19
  4. package/dist/afc-scales.js.map +1 -1
  5. package/dist/bands.d.ts +2 -2
  6. package/dist/commutation.d.ts +49 -5
  7. package/dist/commutation.js +124 -43
  8. package/dist/commutation.js.map +1 -1
  9. package/dist/dates.d.ts +2 -0
  10. package/dist/dates.js +4 -0
  11. package/dist/dates.js.map +1 -1
  12. package/dist/errors.d.ts +70 -12
  13. package/dist/errors.js +85 -19
  14. package/dist/errors.js.map +1 -1
  15. package/dist/factor-basis.d.ts +87 -0
  16. package/dist/factor-basis.js +99 -0
  17. package/dist/factor-basis.js.map +1 -0
  18. package/dist/gad/erf-1-401-2023-06-30.d.ts +47 -0
  19. package/dist/gad/erf-1-401-2023-06-30.js +73 -0
  20. package/dist/gad/erf-1-401-2023-06-30.js.map +1 -0
  21. package/dist/gad/erf-1-402-2023-06-30.d.ts +48 -0
  22. package/dist/gad/erf-1-402-2023-06-30.js +84 -0
  23. package/dist/gad/erf-1-402-2023-06-30.js.map +1 -0
  24. package/dist/gad/erf-1-407-2023-06-30.d.ts +47 -0
  25. package/dist/gad/erf-1-407-2023-06-30.js +73 -0
  26. package/dist/gad/erf-1-407-2023-06-30.js.map +1 -0
  27. package/dist/gad/erf-2023-06-30.d.ts +3 -0
  28. package/dist/gad/erf-2023-06-30.js +1 -0
  29. package/dist/gad/erf-2023-06-30.js.map +1 -1
  30. package/dist/gad/factor-table.d.ts +62 -31
  31. package/dist/gad/factor-table.js +67 -34
  32. package/dist/gad/factor-table.js.map +1 -1
  33. package/dist/gad/lrf-2-416-2023-06-30.d.ts +46 -0
  34. package/dist/gad/lrf-2-416-2023-06-30.js +72 -0
  35. package/dist/gad/lrf-2-416-2023-06-30.js.map +1 -0
  36. package/dist/gad/lrf-2023-06-30.d.ts +3 -0
  37. package/dist/gad/lrf-2023-06-30.js +1 -0
  38. package/dist/gad/lrf-2023-06-30.js.map +1 -1
  39. package/dist/gad/promotional-scale-2020.d.ts +37 -0
  40. package/dist/gad/promotional-scale-2020.js +38 -0
  41. package/dist/gad/promotional-scale-2020.js.map +1 -0
  42. package/dist/index.d.ts +17 -4
  43. package/dist/index.js +22 -13
  44. package/dist/index.js.map +1 -1
  45. package/dist/iso-date.d.ts +7 -0
  46. package/dist/iso-date.js +11 -0
  47. package/dist/iso-date.js.map +1 -1
  48. package/dist/member-benefits.d.ts +237 -0
  49. package/dist/member-benefits.js +440 -0
  50. package/dist/member-benefits.js.map +1 -0
  51. package/dist/pay-path.d.ts +70 -0
  52. package/dist/pay-path.js +155 -0
  53. package/dist/pay-path.js.map +1 -0
  54. package/dist/pension/curve.d.ts +74 -0
  55. package/dist/pension/curve.js +134 -0
  56. package/dist/pension/curve.js.map +1 -0
  57. package/dist/pension/history.js +3 -3
  58. package/dist/pension/history.js.map +1 -1
  59. package/dist/pension/ledger.d.ts +71 -31
  60. package/dist/pension/ledger.js +41 -6
  61. package/dist/pension/ledger.js.map +1 -1
  62. package/dist/pension/money.d.ts +23 -6
  63. package/dist/pension/money.js +23 -1
  64. package/dist/pension/money.js.map +1 -1
  65. package/dist/pension/uplift.d.ts +23 -0
  66. package/dist/pension/uplift.js +34 -1
  67. package/dist/pension/uplift.js.map +1 -1
  68. package/dist/pension-projection.d.ts +54 -52
  69. package/dist/pension-projection.js +65 -219
  70. package/dist/pension-projection.js.map +1 -1
  71. package/dist/scale-point.d.ts +11 -1
  72. package/dist/scales.d.ts +9 -9
  73. package/dist/scales.js +68 -67
  74. package/dist/scales.js.map +1 -1
  75. package/dist/sections/final-salary.d.ts +97 -0
  76. package/dist/sections/final-salary.js +99 -0
  77. package/dist/sections/final-salary.js.map +1 -0
  78. package/dist/sections/section-1995.d.ts +20 -0
  79. package/dist/sections/section-1995.js +52 -0
  80. package/dist/sections/section-1995.js.map +1 -0
  81. package/dist/sections/section-2008.d.ts +16 -0
  82. package/dist/sections/section-2008.js +44 -0
  83. package/dist/sections/section-2008.js.map +1 -0
  84. package/dist/sections/section-2015.d.ts +43 -0
  85. package/dist/sections/section-2015.js +57 -0
  86. package/dist/sections/section-2015.js.map +1 -0
  87. package/dist/values.d.ts +4 -5
  88. package/dist/values.js +4 -5
  89. package/dist/values.js.map +1 -1
  90. package/package.json +9 -5
@@ -19,6 +19,7 @@
19
19
  * construction.
20
20
  */
21
21
  import type { FactorProvenance, FactorTableKind } from '../gad/factor-table.js';
22
+ import type { PayBasis, YearPay } from '../pay-path.js';
22
23
  import type { Prices } from './prices.js';
23
24
  import type { AppliedUplift, MemberPhase } from './uplift.js';
24
25
  import type { LedgerSeed } from './seed.js';
@@ -37,15 +38,23 @@ export interface AppliedDrawing {
37
38
  * years and months from NPA, not annual. */
38
39
  readonly on: Date;
39
40
  readonly factor: number;
40
- /** Which table the factor was read from, or null where none
41
- * was: retiring at NPA is neither early nor late, and naming
42
- * a table there would cite an early-retirement reduction to a
43
- * member who took none. */
44
- readonly kind: FactorTableKind | null;
45
- /** Which issue of that table the factor came from. Null
46
- * exactly when `kind` is — there is no issue to cite. */
47
- readonly provenance: FactorProvenance | null;
41
+ /** The table the factor was read from, and which issue of it; null
42
+ * where none was: retiring at NPA is neither early nor late, and
43
+ * naming a table there would cite an early-retirement reduction to
44
+ * a member who took none. One field, so a table cannot be named
45
+ * without the issue it was read from. */
46
+ readonly table: {
47
+ readonly kind: FactorTableKind;
48
+ readonly provenance: FactorProvenance;
49
+ } | null;
48
50
  }
51
+ /** What a ledger row's earnings rest on beyond a pay path's own bases:
52
+ * one flat figure the caller assumed, or nothing earned. */
53
+ declare const LEDGER_BASES: {
54
+ readonly assumed: "assumed";
55
+ readonly none: "none";
56
+ };
57
+ export type EarningsBasis = (typeof LEDGER_BASES)[keyof typeof LEDGER_BASES] | PayBasis;
49
58
  /** One scheme year, accounted for the way the scheme accounts
50
59
  * for it. Every field is nominal £/yr unless said otherwise. */
51
60
  export interface LedgerYear {
@@ -70,15 +79,13 @@ export interface LedgerYear {
70
79
  * `uplift.from.si` is null on every row and no row is the
71
80
  * scheme's own record — the seed is the last figure that was.
72
81
  *
73
- * Always `assumed` where anything was earned: the library has
74
- * no route to a member's actual year-by-year pay, so every
75
- * non-zero figure derives from the single pay the caller gave,
76
- * held flat in real terms. `none` where the member was not
77
- * accruing, which is the only case with nothing to be wrong
78
- * about. A statement's own earnings history would add a
79
- * `given` here, and is the reason this field exists now.
82
+ * `assumed` where the caller gave one pay held flat in real terms,
83
+ * which is `projectPension`'s case; a ledger reading a member's pay
84
+ * path carries that year's basis instead — declared, contractual,
85
+ * projected or reconstructed. `none` where nothing was earned,
86
+ * which is the only case with nothing to be wrong about.
80
87
  */
81
- readonly earningsBasis: 'assumed' | 'none';
88
+ readonly earningsBasis: EarningsBasis;
82
89
  /** Brought INTO this year — last year's closing balance,
83
90
  * untouched. The whole banked pot, not a slice. */
84
91
  readonly opening: number;
@@ -122,27 +129,46 @@ export interface MemberLedger {
122
129
  * beside the paper. */
123
130
  earningsRows(): readonly LedgerYear[];
124
131
  }
132
+ /**
133
+ * A year's pensionable pay for a ledger that reads a pay path: the
134
+ * figure in today's money and what it rests on, or null for an active
135
+ * year this ledger does not accrue in — the years after a remedy
136
+ * window, when the member is still in service and their pot is still
137
+ * revalued at the in-service rate, but their accrual belongs to
138
+ * another ledger.
139
+ */
140
+ export type PayIn = (schemeYearEnd: number) => YearPay | {
141
+ readonly pay: number;
142
+ readonly basis: typeof LEDGER_BASES.assumed;
143
+ } | null;
144
+ /**
145
+ * One figure held flat every year, in today's money: no promotion, no
146
+ * progression, and every row saying its pay was assumed.
147
+ */
148
+ export declare function flatPay(pay: number): PayIn;
125
149
  export interface LedgerRequest {
126
150
  readonly seed: LedgerSeed;
127
151
  /**
128
- * Pensionable pay in TODAY'S MONEY, held flat.
152
+ * Pensionable pay in TODAY'S MONEY, per scheme year: `flatPay` holds
153
+ * one figure every year, or a member's pay path gives each its own.
129
154
  *
130
- * **This is the base case and the only one built.** Every
131
- * year's slice is the same figure in today's money; what
132
- * varies is only its expression in each year's own cash,
133
- * because a nominal model that froze pay in CASH while
134
- * revaluing the pot above CPI would count inflation twice.
155
+ * Either way a year's slice is that year's pay / 54 in today's
156
+ * money; what varies is only its expression in each year's own cash,
157
+ * because a nominal model that froze pay in CASH while revaluing the
158
+ * pot above CPI would count inflation twice.
135
159
  *
136
- * Pay progression is a deliberate non-feature — issue #11.
137
- * Anything that makes a year's slice differ from
138
- * `pensionableEarnings / 54` in today's money is that unbuilt
139
- * feature arriving by accident: quote the figure at the
140
- * statement date and hold it flat in real terms FROM there,
141
- * and the member collects a 5.6% real pay rise. Held to a
142
- * date, `earnings in today's money are pay / 54, every year`
143
- * is the invariant that catches it.
160
+ * **Flat pay** is `projectPension`'s case: no
161
+ * promotion, no progression. Anything that makes a year's slice
162
+ * differ from the flat figure / 54 there is pay growth
163
+ * arriving by accident — quote the figure at the statement date and
164
+ * hold it flat in real terms FROM there, and the member collects a
165
+ * 5.6% real pay rise. `earnings in today's money are pay / 54, every
166
+ * year` is the invariant that catches it.
167
+ *
168
+ * **A pay path** is `memberBenefits`'s: each year's figure is the
169
+ * path's, with its basis on the row.
144
170
  */
145
- readonly pensionableEarnings: number;
171
+ readonly payIn: PayIn;
146
172
  /**
147
173
  * A date in the last scheme year of service. Only the year it
148
174
  * names is read: the member is active for all of it and the
@@ -158,3 +184,17 @@ export interface LedgerRequest {
158
184
  readonly through: number;
159
185
  }
160
186
  export declare function buildLedger(req: LedgerRequest): MemberLedger;
187
+ /**
188
+ * The pension at the drawing, before and after its factor, read off
189
+ * the row the drawing falls in.
190
+ *
191
+ * There is no such row when the drawing falls at or before the seed's
192
+ * own year end — a member handing over a balance and drawing it the
193
+ * same day — and there is still an answer: the balance they handed
194
+ * over, with the factor applied here instead of on a row.
195
+ */
196
+ export declare function atDrawing(ledger: MemberLedger, drawing: Date, factor: number): {
197
+ revalued: number;
198
+ drawn: number;
199
+ };
200
+ export {};
@@ -31,6 +31,19 @@ import { firstWalkedYear, schemeYearEndDate, schemeYearEndFor, schemeYearStartDa
31
31
  * rather than a literal here and a name somewhere else.
32
32
  */
33
33
  export const ACCRUAL_RATE = 1 / 54;
34
+ /** What a ledger row's earnings rest on beyond a pay path's own bases:
35
+ * one flat figure the caller assumed, or nothing earned. */
36
+ const LEDGER_BASES = {
37
+ assumed: 'assumed',
38
+ none: 'none',
39
+ };
40
+ /**
41
+ * One figure held flat every year, in today's money: no promotion, no
42
+ * progression, and every row saying its pay was assumed.
43
+ */
44
+ export function flatPay(pay) {
45
+ return () => ({ pay, basis: LEDGER_BASES.assumed });
46
+ }
34
47
  /** Complete months from `from` to `to`. */
35
48
  function completeMonths(from, to) {
36
49
  if (to <= from)
@@ -91,13 +104,16 @@ function rowFor(ctx) {
91
104
  const revalued = uplift === null
92
105
  ? opening
93
106
  : opening * (1 + uplift.percent / 100);
94
- const pensionableEarnings = phase === 'active'
95
- ? payFor({
107
+ const given = phase === 'active'
108
+ ? req.payIn(year)
109
+ : null;
110
+ const pensionableEarnings = given === null
111
+ ? null
112
+ : payFor({
96
113
  year, prices, first: ctx.first,
97
114
  accruingFrom: seed.accruingFrom,
98
- annualPay: req.pensionableEarnings,
99
- })
100
- : null;
115
+ annualPay: given.pay,
116
+ });
101
117
  const earned = pensionableEarnings === null
102
118
  ? 0
103
119
  : pensionableEarnings * ACCRUAL_RATE;
@@ -115,7 +131,9 @@ function rowFor(ctx) {
115
131
  phase,
116
132
  pensionableEarnings,
117
133
  earned,
118
- earningsBasis: earned === 0 ? 'none' : 'assumed',
134
+ earningsBasis: earned === 0 || given === null
135
+ ? LEDGER_BASES.none
136
+ : given.basis,
119
137
  opening,
120
138
  uplift: uplift === null ? null : Object.freeze(uplift),
121
139
  revalued,
@@ -204,4 +222,21 @@ function readerOver(frozen, seed) {
204
222
  earningsRows: () => frozen.filter((row) => row.pensionableEarnings !== null),
205
223
  });
206
224
  }
225
+ /**
226
+ * The pension at the drawing, before and after its factor, read off
227
+ * the row the drawing falls in.
228
+ *
229
+ * There is no such row when the drawing falls at or before the seed's
230
+ * own year end — a member handing over a balance and drawing it the
231
+ * same day — and there is still an answer: the balance they handed
232
+ * over, with the factor applied here instead of on a row.
233
+ */
234
+ export function atDrawing(ledger, drawing, factor) {
235
+ const row = ledger.years.find((r) => r.schemeYearEnd === schemeYearEndFor(drawing));
236
+ if (row === undefined) {
237
+ const revalued = ledger.accruedAt(drawing);
238
+ return { revalued, drawn: revalued * factor };
239
+ }
240
+ return { revalued: row.revalued + row.earned, drawn: row.closing };
241
+ }
207
242
  //# sourceMappingURL=ledger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/pension/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAOhD,OAAO,EAAC,gBAAgB,EAAE,OAAO,EAAC,MAAM,aAAa,CAAC;AAEtD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,CAAC;AAoInC,2CAA2C;AAC3C,SAAS,cAAc,CAAC,IAAU,EAAE,EAAQ;IAC1C,IAAI,EAAE,IAAI,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,MAAM,EAAC,KAAK,EAAE,MAAM,EAAC,GAAG,mBAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACtD,OAAO,KAAK,GAAG,EAAE,GAAG,MAAM,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAS,MAAM,CAAC,EACd,I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M,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,mBAAmB,KAAK,IAAI,CAAC;KAC3D,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,MAAoB,EACpB,OAAa,EACb,MAAc;IAEd,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAC3B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,gBAAgB,CAAC,OAAO,CAAC,CACrD,CAAC;IACF,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC3C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,EAAC,CAAC;IAC9C,CAAC;IACD,OAAO,EAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAC,CAAC;AACnE,CAAC"}
@@ -10,8 +10,8 @@
10
10
  * `real` is not `nominal` deflated, and dividing one by the
11
11
  * other does not give the assumption back.
12
12
  *
13
- * That distinction is the whole of a long-running disagreement
14
- * about a third of a percent. Deflating a CPI + 1.5 projection
13
+ * The difference is about a third of a percent a year, and it is
14
+ * the whole reason for the distinction. Deflating a CPI + 1.5 projection
15
15
  * leaves 1.5 / (1 + cpi) of real growth — 1.47% at 2% — because
16
16
  * the 1.5 points are added before the growth and eaten into by
17
17
  * the same year's inflation. Running the model at zero gives
@@ -26,9 +26,26 @@ export interface ProjectionMoney {
26
26
  * ignored, so 1.5% a year while accruing and flat once
27
27
  * deferred. */
28
28
  readonly real: number;
29
- /** The date the figure falls on. Its absence is how a
30
- * consumer once deflated an exit figure over the horizon to
31
- * retirement: a figure that does not carry its own date
32
- * cannot defend itself. */
29
+ /** The date the figure falls on. A figure that does not
30
+ * carry its own date can be deflated over the wrong horizon
31
+ * by a consumer with no way to tell. */
33
32
  readonly asAt: Date;
34
33
  }
34
+ /** The two readings of one figure, before a date is attached. */
35
+ interface Readings {
36
+ readonly nominal: number;
37
+ readonly real: number;
38
+ }
39
+ /**
40
+ * A figure at a date. Takes the readings as one object, never two
41
+ * same-typed positional numbers, so a transposition cannot swap the
42
+ * rulers silently.
43
+ */
44
+ export declare function moneyAt(readings: Readings, asAt: Date): ProjectionMoney;
45
+ /** Several figures added, each ruler on its own, at one date. */
46
+ export declare function sumMoney(xs: readonly Readings[], asAt: Date): ProjectionMoney;
47
+ /** `a` less `b`, each ruler on its own, at `a`'s date. */
48
+ export declare function minusMoney(a: ProjectionMoney, b: Readings): ProjectionMoney;
49
+ /** A figure divided by a scalar, both rulers, at its own date. */
50
+ export declare function divideMoney(m: ProjectionMoney, by: number): ProjectionMoney;
51
+ export {};
@@ -1,2 +1,24 @@
1
- export {};
1
+ /**
2
+ * A figure at a date. Takes the readings as one object, never two
3
+ * same-typed positional numbers, so a transposition cannot swap the
4
+ * rulers silently.
5
+ */
6
+ export function moneyAt(readings, asAt) {
7
+ return { nominal: readings.nominal, real: readings.real, asAt };
8
+ }
9
+ /** Several figures added, each ruler on its own, at one date. */
10
+ export function sumMoney(xs, asAt) {
11
+ return moneyAt({
12
+ nominal: xs.reduce((n, x) => n + x.nominal, 0),
13
+ real: xs.reduce((n, x) => n + x.real, 0),
14
+ }, asAt);
15
+ }
16
+ /** `a` less `b`, each ruler on its own, at `a`'s date. */
17
+ export function minusMoney(a, b) {
18
+ return moneyAt({ nominal: a.nominal - b.nominal, real: a.real - b.real }, a.asAt);
19
+ }
20
+ /** A figure divided by a scalar, both rulers, at its own date. */
21
+ export function divideMoney(m, by) {
22
+ return moneyAt({ nominal: m.nominal / by, real: m.real / by }, m.asAt);
23
+ }
2
24
  //# sourceMappingURL=money.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"money.js","sourceRoot":"","sources":["../../src/pension/money.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"money.js","sourceRoot":"","sources":["../../src/pension/money.ts"],"names":[],"mappings":"AAwCA;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,QAAkB,EAAE,IAAU;IACpD,OAAO,EAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAC,CAAC;AAChE,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,QAAQ,CACtB,EAAuB,EAAE,IAAU;IAEnC,OAAO,OAAO,CAAC;QACb,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9C,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;KACzC,EAAE,IAAI,CAAC,CAAC;AACX,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,UAAU,CACxB,CAAkB,EAAE,CAAW;IAE/B,OAAO,OAAO,CAAC,EAAC,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAC,EACpE,CAAC,CAAC,IAAI,CAAC,CAAC;AACZ,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,WAAW,CACzB,CAAkB,EAAE,EAAU;IAE9B,OAAO,OAAO,CAAC,EAAC,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,EAAE,EAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACvE,CAAC"}
@@ -22,6 +22,7 @@
22
22
  * make the test of the +1.5 rule agree with itself.
23
23
  */
24
24
  import type { CpiEntry, CpiSource, Prices } from './prices.js';
25
+ import type { LedgerSeed } from './seed.js';
25
26
  /**
26
27
  * The three phases. Ordered by date and DERIVED from the member's
27
28
  * own dates: a phase is never "entered", so there are no
@@ -149,3 +150,25 @@ export declare function upliftsFor(phase: MemberPhase, cpiFor: CpiSource): Uplif
149
150
  * Decided at https://github.com/casomoltd/nhs-pay/issues/13
150
151
  */
151
152
  export declare function openingUpliftFor(seedSchemeYearEnd: number, exitDate: Date, retirementDate: Date, prices: Prices): AppliedUplift;
153
+ /**
154
+ * A member's stated balance, on whatever date it is stated —
155
+ * the day they read it, or the day their statement prints. That
156
+ * is a position mid-scheme-year, and a seed is a year-end
157
+ * closing balance, so it has to be carried back to one.
158
+ *
159
+ * In November the April uplift has already been applied to the
160
+ * figure being read, so dividing it out lands on the last
161
+ * year-end closing balance and the walk re-applies it — no
162
+ * double count, and no year of accrual thrown away. On a date
163
+ * before that April the figure already IS the year-end balance
164
+ * and nothing is divided, which is why a statement printed on
165
+ * 31 March passes through untouched.
166
+ *
167
+ * ONE route for both the dated and the undated case, because
168
+ * there is only one question: what was the closing balance at
169
+ * the year end before this date? `seedFromStatement` stays
170
+ * strict about wanting a year end; this is what finds it.
171
+ * Statements print on arbitrary days — 7 November is a real
172
+ * one — so the strict form alone could not serve them.
173
+ */
174
+ export declare function seedFromBalanceAt(balance: number, asOf: Date, exitDate: Date, retirementDate: Date, prices: Prices): LedgerSeed;
@@ -22,7 +22,7 @@
22
22
  * make the test of the +1.5 rule agree with itself.
23
23
  */
24
24
  import { ACTIVE_REVAL_BONUS_PCT, appliedOnFor, } from '../revaluation.js';
25
- import { schemeYearEndFor } from './seed.js';
25
+ import { schemeYearClosedBy, schemeYearEndDate, schemeYearEndFor, seedFromStatement, } from './seed.js';
26
26
  /** Active until the member leaves, deferred until they draw, in
27
27
  * payment after. Derived from dates; never entered.
28
28
  *
@@ -132,4 +132,37 @@ export function openingUpliftFor(seedSchemeYearEnd, exitDate, retirementDate, pr
132
132
  const phase = phaseAt(seedSchemeYearEnd + 1, schemeYearEndFor(exitDate), schemeYearEndFor(retirementDate));
133
133
  return upliftsFor(phase, prices.assumedFor)(seedSchemeYearEnd);
134
134
  }
135
+ /**
136
+ * A member's stated balance, on whatever date it is stated —
137
+ * the day they read it, or the day their statement prints. That
138
+ * is a position mid-scheme-year, and a seed is a year-end
139
+ * closing balance, so it has to be carried back to one.
140
+ *
141
+ * In November the April uplift has already been applied to the
142
+ * figure being read, so dividing it out lands on the last
143
+ * year-end closing balance and the walk re-applies it — no
144
+ * double count, and no year of accrual thrown away. On a date
145
+ * before that April the figure already IS the year-end balance
146
+ * and nothing is divided, which is why a statement printed on
147
+ * 31 March passes through untouched.
148
+ *
149
+ * ONE route for both the dated and the undated case, because
150
+ * there is only one question: what was the closing balance at
151
+ * the year end before this date? `seedFromStatement` stays
152
+ * strict about wanting a year end; this is what finds it.
153
+ * Statements print on arbitrary days — 7 November is a real
154
+ * one — so the strict form alone could not serve them.
155
+ */
156
+ export function seedFromBalanceAt(balance, asOf, exitDate, retirementDate, prices) {
157
+ const lastYearEnd = schemeYearClosedBy(asOf);
158
+ /* The uplift undone here is the one OPENING year
159
+ `lastYearEnd + 1`, and it is the very object `buildLedger`
160
+ re-applies to that year: inverting the walk exactly is this
161
+ function's only job, so both sides ask `openingUpliftFor`
162
+ rather than each naming the phase, the year and the CPI
163
+ series for themselves. */
164
+ const applied = openingUpliftFor(lastYearEnd, exitDate, retirementDate, prices);
165
+ const already = applied.appliedOn <= asOf;
166
+ return seedFromStatement(already ? balance / (1 + applied.percent / 100) : balance, schemeYearEndDate(lastYearEnd));
167
+ }
135
168
  //# sourceMappingURL=uplift.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uplift.js","sourceRoot":"","sources":["../../src/pension/uplift.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,sBAAsB,EACtB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,gB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AAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,gBAAgB,CAC9B,iBAAyB,EACzB,QAAc,EACd,cAAoB,EACpB,MAAc;IAEd,MAAM,KAAK,GAAG,OAAO,CACnB,iBAAiB,GAAG,CAAC,EACrB,gBAAgB,CAAC,QAAQ,CAAC,EAC1B,gBAAgB,CAAC,cAAc,CAAC,CACjC,CAAC;IACF,OAAO,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,iBAAiB,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAe,EACf,IAAU,EACV,QAAc,EACd,cAAoB,EACpB,MAAc;IAEd,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC7C;;;;;gCAK4B;IAC5B,MAAM,OAAO,GAAG,gBAAgB,CAC9B,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,CAC9C,CAAC;IACF,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;IAC1C,OAAO,iBAAiB,CACtB,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EACzD,iBAAiB,CAAC,WAAW,CAAC,CAC/B,CAAC;AACJ,CAAC"}
@@ -7,10 +7,10 @@
7
7
  *
8
8
  * Sources:
9
9
  *
10
- * GAD Consolidated Factor Spreadsheet (NHS EW Consolidated
11
- * Factors 2023-03), issued 30 June 2023
12
- * → ERF1/LRF1 values (see src/gad/ issue files for the
13
- * verbatim transcriptions + per-table provenance)
10
+ * GAD consolidated factor workbook
11
+ * → ERF1/LRF1 values: src/gad/ holds the verbatim
12
+ * transcriptions, and each carries its own issue, version
13
+ * and provenance
14
14
  *
15
15
  * GAD "NHSPS 2015 E&W — Early and late retirement in normal
16
16
  * health — Factors and guidance", 7 August 2019 — methodology
@@ -83,10 +83,6 @@
83
83
  * that uplift produced. `pension/ledger.ts` holds one row per
84
84
  * scheme year; this module is the orchestrator over it.
85
85
  *
86
- * NHSBSA Key Notes — 2015 Scheme Estimates (V2), March 2025
87
- * → Commutation rate: £12 lump sum per £1 pension
88
- * → HMRC 25% cap on lump sum
89
- *
90
86
  * ── One rate after the seed ─────────────────────────
91
87
  *
92
88
  * A projection reads no published Revaluation Order. Every
@@ -151,38 +147,17 @@
151
147
  * back-computing CPI as rate − 1.5 would make the test of the
152
148
  * +1.5 rule agree with itself.
153
149
  *
154
- * This module used to compound instead, at a flat real 1.5%:
155
- * the multiplicative reading of the same rule, running about
156
- * 0.6% high over a full career at 2% CPI. That is now fixed,
157
- * at the cost described above.
150
+ * Compounding at a flat real 1.5% instead is the multiplicative
151
+ * reading of the same rule, and runs about 0.6% high over a full
152
+ * career at 2% CPI.
158
153
  */
159
154
  import type { ProjectionMoney } from './pension/money.js';
160
155
  import type { Prices } from './pension/prices.js';
161
156
  import { ACCRUAL_RATE } from './pension/ledger.js';
162
157
  import type { EstimatedHistory } from './pension/history.js';
163
158
  import type { MemberLedger } from './pension/ledger.js';
164
- import type { MemberPhase } from './pension/uplift.js';
159
+ import type { ProjectionPoint } from './pension/curve.js';
165
160
  import type { FactorProvenance, FactorTableKind } from './gad/factor-table.js';
166
- /** A point on the projection curve */
167
- export interface ProjectionPoint {
168
- /** Age in years (can be fractional) */
169
- age: number;
170
- /** Annual pension in actual £ of that year. Below today's
171
- * age this is SMALLER than `real`: past pounds bought more. */
172
- nominal: number;
173
- /** Annual pension in today's £ — what the projection
174
- * computes; `nominal` is this scaled by CPI. */
175
- real: number;
176
- /** Whether this is accrued (known) or projected — i.e.
177
- * whether the point falls on or before today. Deliberately
178
- * NOT `phase === 'active'`: a consumer uses this to separate
179
- * history from forecast, and a future working year is
180
- * forecast. */
181
- accrued: boolean;
182
- /** Which lifecycle phase the point falls in. Additive: the
183
- * three fields above keep their names and meanings. */
184
- phase: MemberPhase;
185
- }
186
161
  /** Input for statement path */
187
162
  export interface PensionStatementInput {
188
163
  kind: 'statement';
@@ -213,8 +188,7 @@ export interface PensionStatementInput {
213
188
  * it, and the estimate is calibrated to land exactly on the
214
189
  * stated balance rather than near it.
215
190
  *
216
- * Omit and the chart simply starts at the statement, which
217
- * is what it did before this existed.
191
+ * Omit it and the curve starts at the statement.
218
192
  */
219
193
  joinDate?: Date;
220
194
  dateOfBirth: Date;
@@ -261,9 +235,8 @@ export interface PensionProjectionResult {
261
235
  * Reported here rather than left to a consumer reading the
262
236
  * curve, because the curve is sampled at scheme year ends: a
263
237
  * reader looking for "what have I got now" off the nearest
264
- * plotted point gets a figure up to a year stale. One did,
265
- * and showed a member the balance from before both the year
266
- * end and the April uplift. */
238
+ * plotted point gets a figure up to a year stale, from before
239
+ * both the year end and the April uplift. */
267
240
  accruedNow: ProjectionMoney;
268
241
  /** ERF or LRF factor applied */
269
242
  factor: number;
@@ -274,21 +247,10 @@ export interface PensionProjectionResult {
274
247
  factorType: FactorTableKind | null;
275
248
  /** Gap between revalued and drawn pension, at retirement */
276
249
  adjustmentAmount: ProjectionMoney;
277
- /** Curve data for chart (both views) */
250
+ /** One point per scheme year end, in both readings */
278
251
  curve: ProjectionPoint[];
279
252
  /** Whether estimation path was used */
280
253
  isEstimation: boolean;
281
- /**
282
- * The year-by-year record every figure above was read off.
283
- *
284
- * Additive, and the point of it is that a consumer showing
285
- * its working cannot disagree with the headline: the rows ARE
286
- * the derivation, not a re-derivation. A panel that recomputed
287
- * "statement plus the Orders since" from the published CPI
288
- * alone missed the in-service 1.5 points and the leaver's
289
- * part-year blend, so it printed a sum that did not reach the
290
- * number beside it.
291
- */
292
254
  /**
293
255
  * The illustrative years before the statement, or null when
294
256
  * there are none to draw. Its `impliedPay` is in TODAY'S
@@ -296,6 +258,15 @@ export interface PensionProjectionResult {
296
258
  * entered, and the one to caption with.
297
259
  */
298
260
  estimatedHistory: EstimatedHistory | null;
261
+ /**
262
+ * The year-by-year record every figure above was read off.
263
+ *
264
+ * A consumer showing its working reads these rows rather than
265
+ * re-deriving them, because they ARE the derivation. "Statement
266
+ * plus the Orders since", recomputed from the published CPI
267
+ * alone, misses the in-service 1.5 points and the leaver's
268
+ * part-year blend, and so cannot reach the headline beside it.
269
+ */
299
270
  ledger: MemberLedger;
300
271
  /**
301
272
  * The price series this run used.
@@ -315,7 +286,8 @@ export interface PensionProjectionResult {
315
286
  }
316
287
  export { ACCRUAL_RATE };
317
288
  /**
318
- * Provenance of the in-force table behind a factor kind — the
289
+ * Provenance of the 2015 Section's in-force table behind a factor
290
+ * kind — the
319
291
  * citation facts (table ref, guidance name, issue date, source
320
292
  * PDF) consumers render instead of hand-typing them, so a page
321
293
  * showing "GAD factors issued 30 June 2023" updates itself when
@@ -331,16 +303,46 @@ export declare function factorProvenance(kind: FactorTableKind): FactorProvenanc
331
303
  * at NPA is not an early retirement with a factor of 1: naming
332
304
  * a table there hands a consumer an ERF citation to render at a
333
305
  * member who took no reduction.
306
+ *
307
+ * A second route to the factor `factor2015` reads through
308
+ * `factor-basis.ts`, kept because this public signature takes the
309
+ * pension-age date where that door takes a date of birth. It
310
+ * retires with `projectPension`
311
+ * (https://github.com/casomoltd/nhs-pay/issues/21), and until then
312
+ * `tests/section-factors.test.ts` holds the two routes equal.
334
313
  */
335
314
  export declare function retirementFactor(retirementDate: Date, npDate: Date): {
336
315
  factor: number;
337
316
  type: FactorTableKind | null;
338
317
  };
318
+ /**
319
+ * The **2015 Section's** early retirement factor for drawing a
320
+ * whole period before its pension age: {@link retirementFactor} for
321
+ * a caller that holds the period rather than the two dates it
322
+ * spans. The 1995 and 2008 Sections are keyed by age and are not
323
+ * read here. A whole period has no part-month to round, so the
324
+ * table is read at exactly that row. Months are 0 to 11; a period
325
+ * past the last printed row raises
326
+ * {@link RetirementFactorOutOfRange}. It stays when
327
+ * `projectPension` retires: a caller holding a period is not a
328
+ * projection.
329
+ */
330
+ export declare function erf2015For(period: {
331
+ years: number;
332
+ months: number;
333
+ }): number;
339
334
  /** Annual pension accrual for one year of service */
340
335
  export declare function yearlyAccrual(pensionablePay: number): number;
341
336
  /**
342
337
  * Generate a full pension projection including curve
343
- * data for both nominal and real (CPI-deflated) views.
338
+ * data for both nominal and real views, the real one a second run
339
+ * at zero CPI rather than the nominal one deflated.
340
+ *
341
+ * @deprecated For the 2015 Section alone, on pay held flat.
342
+ * `memberBenefits` values a member across every section they
343
+ * hold; this stays for the flat-salary question until that can
344
+ * be asked of `memberBenefits` too:
345
+ * https://github.com/casomoltd/nhs-pay/issues/21
344
346
  *
345
347
  * `today` is the evaluation date — the anchor for the
346
348
  * accrued/projected split and the real-terms deflator.