@casomoltd/nhs-pay 0.19.3 → 0.20.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 +69 -5
- package/dist/afc-scales.d.ts +14 -7
- package/dist/afc-scales.js +28 -23
- package/dist/afc-scales.js.map +1 -1
- package/dist/bands.d.ts +2 -2
- package/dist/commutation.d.ts +49 -5
- package/dist/commutation.js +124 -43
- package/dist/commutation.js.map +1 -1
- package/dist/dates.d.ts +2 -0
- package/dist/dates.js +4 -0
- package/dist/dates.js.map +1 -1
- package/dist/errors.d.ts +70 -12
- package/dist/errors.js +85 -19
- package/dist/errors.js.map +1 -1
- package/dist/factor-basis.d.ts +87 -0
- package/dist/factor-basis.js +99 -0
- package/dist/factor-basis.js.map +1 -0
- package/dist/gad/erf-1-401-2023-06-30.d.ts +47 -0
- package/dist/gad/erf-1-401-2023-06-30.js +73 -0
- package/dist/gad/erf-1-401-2023-06-30.js.map +1 -0
- package/dist/gad/erf-1-402-2023-06-30.d.ts +48 -0
- package/dist/gad/erf-1-402-2023-06-30.js +84 -0
- package/dist/gad/erf-1-402-2023-06-30.js.map +1 -0
- package/dist/gad/erf-1-407-2023-06-30.d.ts +47 -0
- package/dist/gad/erf-1-407-2023-06-30.js +73 -0
- package/dist/gad/erf-1-407-2023-06-30.js.map +1 -0
- package/dist/gad/erf-2023-06-30.d.ts +3 -0
- package/dist/gad/erf-2023-06-30.js +1 -0
- package/dist/gad/erf-2023-06-30.js.map +1 -1
- package/dist/gad/factor-table.d.ts +62 -31
- package/dist/gad/factor-table.js +67 -34
- package/dist/gad/factor-table.js.map +1 -1
- package/dist/gad/lrf-2-416-2023-06-30.d.ts +46 -0
- package/dist/gad/lrf-2-416-2023-06-30.js +72 -0
- package/dist/gad/lrf-2-416-2023-06-30.js.map +1 -0
- package/dist/gad/lrf-2023-06-30.d.ts +3 -0
- package/dist/gad/lrf-2023-06-30.js +1 -0
- package/dist/gad/lrf-2023-06-30.js.map +1 -1
- package/dist/gad/promotional-scale-2020.d.ts +37 -0
- package/dist/gad/promotional-scale-2020.js +38 -0
- package/dist/gad/promotional-scale-2020.js.map +1 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/dist/iso-date.d.ts +7 -0
- package/dist/iso-date.js +11 -0
- package/dist/iso-date.js.map +1 -1
- package/dist/member-benefits.d.ts +237 -0
- package/dist/member-benefits.js +440 -0
- package/dist/member-benefits.js.map +1 -0
- package/dist/pay-path.d.ts +70 -0
- package/dist/pay-path.js +155 -0
- package/dist/pay-path.js.map +1 -0
- package/dist/pension/curve.d.ts +74 -0
- package/dist/pension/curve.js +134 -0
- package/dist/pension/curve.js.map +1 -0
- package/dist/pension/history.js +3 -3
- package/dist/pension/history.js.map +1 -1
- package/dist/pension/ledger.d.ts +71 -31
- package/dist/pension/ledger.js +41 -6
- package/dist/pension/ledger.js.map +1 -1
- package/dist/pension/money.d.ts +23 -6
- package/dist/pension/money.js +23 -1
- package/dist/pension/money.js.map +1 -1
- package/dist/pension/uplift.d.ts +23 -0
- package/dist/pension/uplift.js +34 -1
- package/dist/pension/uplift.js.map +1 -1
- package/dist/pension-projection.d.ts +25 -31
- package/dist/pension-projection.js +40 -197
- package/dist/pension-projection.js.map +1 -1
- package/dist/scale-point.d.ts +11 -1
- package/dist/scales.d.ts +9 -9
- package/dist/scales.js +68 -67
- package/dist/scales.js.map +1 -1
- package/dist/sections/final-salary.d.ts +97 -0
- package/dist/sections/final-salary.js +99 -0
- package/dist/sections/final-salary.js.map +1 -0
- package/dist/sections/section-1995.d.ts +20 -0
- package/dist/sections/section-1995.js +52 -0
- package/dist/sections/section-1995.js.map +1 -0
- package/dist/sections/section-2008.d.ts +16 -0
- package/dist/sections/section-2008.js +44 -0
- package/dist/sections/section-2008.js.map +1 -0
- package/dist/sections/section-2015.d.ts +43 -0
- package/dist/sections/section-2015.js +57 -0
- package/dist/sections/section-2015.js.map +1 -0
- package/dist/sources.d.ts +14 -0
- package/dist/sources.js +21 -0
- package/dist/sources.js.map +1 -1
- package/dist/values.d.ts +4 -5
- package/dist/values.js +4 -5
- package/dist/values.js.map +1 -1
- package/package.json +8 -5
|
@@ -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;
|
|
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;AAQhD,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;AAmBnC;6DAC6D;AAC7D,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;CACJ,CAAC;AA+FX;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,OAAO,GAAG,EAAE,CAAC,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,EAAC,CAAC,CAAC;AACpD,CAAC;AAwCD,2CAA2C;AAC3C,SAAS,cAAc,CAAC,IAAU,EAAE,EAAQ;IAC1C,IAAI,EAAE,IAAI,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,MAAM,EAAC,KAAK,EAAE,MAAM,EA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;YACtB,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CACrB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,aAAa,CACzC,CAAC;YACF,SAAS,CACP,GAAG,KAAK,SAAS,EACjB,eAAe,aAAa,qBAAqB,CAClD,CAAC;YACF,OAAO,GAAG,CAAC,OAAO,CAAC;QACrB,CAAC;QACD,YAAY,EAAE,GAAG,EAAE,CACjB,MAAM,CAAC,MAAM,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"}
|
package/dist/pension/money.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
14
|
-
*
|
|
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.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
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 {};
|
package/dist/pension/money.js
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
|
|
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"}
|
package/dist/pension/uplift.d.ts
CHANGED
|
@@ -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;
|
package/dist/pension/uplift.js
CHANGED
|
@@ -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,
|
|
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,EACL,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AAmBnB;;;;;oBAKoB;AACpB,MAAM,UAAU,OAAO,CACrB,IAAY,EAAE,QAAgB,EAAE,UAAkB;IAElD,IAAI,IAAI,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACtC,OAAO,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;AACtD,CAAC;AAgCD;kEACkE;AAClE,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,GAAG,GAAG,sBAAsB,CAAC;AACtC,CAAC;AAED;;;;;;;;;;;;;;6BAc6B;AAC7B,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,UAAU,CACxB,KAAkB,EAClB,MAAiB;IAEjB,MAAM,OAAO,GAAG,KAAK,KAAK,QAAQ;QAChC,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,eAAe,CAAC;IAEpB,OAAO,CAAC,aAAa,EAAE,EAAE;QACvB,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;QACnC,OAAO;YACL,SAAS,EAAE,YAAY,CAAC,aAAa,C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 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
|
|
@@ -151,38 +151,17 @@
|
|
|
151
151
|
* back-computing CPI as rate − 1.5 would make the test of the
|
|
152
152
|
* +1.5 rule agree with itself.
|
|
153
153
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* at the cost described above.
|
|
154
|
+
* Compounding at a flat real 1.5% instead is the multiplicative
|
|
155
|
+
* reading of the same rule, and runs about 0.6% high over a full
|
|
156
|
+
* career at 2% CPI.
|
|
158
157
|
*/
|
|
159
158
|
import type { ProjectionMoney } from './pension/money.js';
|
|
160
159
|
import type { Prices } from './pension/prices.js';
|
|
161
160
|
import { ACCRUAL_RATE } from './pension/ledger.js';
|
|
162
161
|
import type { EstimatedHistory } from './pension/history.js';
|
|
163
162
|
import type { MemberLedger } from './pension/ledger.js';
|
|
164
|
-
import type {
|
|
163
|
+
import type { ProjectionPoint } from './pension/curve.js';
|
|
165
164
|
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
165
|
/** Input for statement path */
|
|
187
166
|
export interface PensionStatementInput {
|
|
188
167
|
kind: 'statement';
|
|
@@ -315,7 +294,8 @@ export interface PensionProjectionResult {
|
|
|
315
294
|
}
|
|
316
295
|
export { ACCRUAL_RATE };
|
|
317
296
|
/**
|
|
318
|
-
* Provenance of the in-force table behind a factor
|
|
297
|
+
* Provenance of the 2015 Section's in-force table behind a factor
|
|
298
|
+
* kind — the
|
|
319
299
|
* citation facts (table ref, guidance name, issue date, source
|
|
320
300
|
* PDF) consumers render instead of hand-typing them, so a page
|
|
321
301
|
* showing "GAD factors issued 30 June 2023" updates itself when
|
|
@@ -331,6 +311,13 @@ export declare function factorProvenance(kind: FactorTableKind): FactorProvenanc
|
|
|
331
311
|
* at NPA is not an early retirement with a factor of 1: naming
|
|
332
312
|
* a table there hands a consumer an ERF citation to render at a
|
|
333
313
|
* member who took no reduction.
|
|
314
|
+
*
|
|
315
|
+
* A second route to the factor `factor2015` reads through
|
|
316
|
+
* `factor-basis.ts`, kept because this public signature takes the
|
|
317
|
+
* pension-age date where that door takes a date of birth. It
|
|
318
|
+
* retires with `projectPension`
|
|
319
|
+
* (https://github.com/casomoltd/nhs-pay/issues/21), and until then
|
|
320
|
+
* `tests/section-factors.test.ts` holds the two routes equal.
|
|
334
321
|
*/
|
|
335
322
|
export declare function retirementFactor(retirementDate: Date, npDate: Date): {
|
|
336
323
|
factor: number;
|
|
@@ -340,7 +327,14 @@ export declare function retirementFactor(retirementDate: Date, npDate: Date): {
|
|
|
340
327
|
export declare function yearlyAccrual(pensionablePay: number): number;
|
|
341
328
|
/**
|
|
342
329
|
* Generate a full pension projection including curve
|
|
343
|
-
* data for both nominal and real
|
|
330
|
+
* data for both nominal and real views, the real one a second run
|
|
331
|
+
* at zero CPI rather than the nominal one deflated.
|
|
332
|
+
*
|
|
333
|
+
* @deprecated For the 2015 Section alone, on pay held flat.
|
|
334
|
+
* `memberBenefits` values a member across every section they
|
|
335
|
+
* hold; this stays for the flat-salary question until that can
|
|
336
|
+
* be asked of `memberBenefits` too:
|
|
337
|
+
* https://github.com/casomoltd/nhs-pay/issues/21
|
|
344
338
|
*
|
|
345
339
|
* `today` is the evaluation date — the anchor for the
|
|
346
340
|
* accrued/projected split and the real-terms deflator.
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Sources:
|
|
9
9
|
*
|
|
10
|
-
* GAD
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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
|
|
@@ -151,33 +151,32 @@
|
|
|
151
151
|
* back-computing CPI as rate − 1.5 would make the test of the
|
|
152
152
|
* +1.5 rule agree with itself.
|
|
153
153
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* at the cost described above.
|
|
154
|
+
* Compounding at a flat real 1.5% instead is the multiplicative
|
|
155
|
+
* reading of the same rule, and runs about 0.6% high over a full
|
|
156
|
+
* career at 2% CPI.
|
|
158
157
|
*/
|
|
159
|
-
import { npaDate, periodInYearsMonths,
|
|
158
|
+
import { earliest, npaDate, periodInYearsMonths, } from './dates.js';
|
|
160
159
|
import { createPrices } from './pension/prices.js';
|
|
161
|
-
import { ACCRUAL_RATE, buildLedger } from './pension/ledger.js';
|
|
160
|
+
import { ACCRUAL_RATE, atDrawing, buildLedger, flatPay, } from './pension/ledger.js';
|
|
162
161
|
import { estimateHistory } from './pension/history.js';
|
|
163
|
-
import {
|
|
164
|
-
import {
|
|
165
|
-
import {
|
|
166
|
-
import {
|
|
167
|
-
import { LRF_0_421 } from './gad/lrf-2023-06-30.js';
|
|
162
|
+
import { seedFromBalanceAt } from './pension/uplift.js';
|
|
163
|
+
import { buildCurve, walkThrough } from './pension/curve.js';
|
|
164
|
+
import { schemeYearEndDate, schemeYearEndFor, seedFromJoinDate, } from './pension/seed.js';
|
|
165
|
+
import { factorTable } from './factor-basis.js';
|
|
168
166
|
// ── Constants ───────────────────────────────────────
|
|
169
167
|
/* The accrual rate is owned by the ledger that applies it and
|
|
170
168
|
re-exported here, so the record and every figure read off it
|
|
171
169
|
cannot hold two different 1/54s. */
|
|
172
170
|
export { ACCRUAL_RATE };
|
|
173
171
|
// ── Factor Tables ───────────────────────────────────
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
const ERF1 =
|
|
178
|
-
const LRF1 =
|
|
172
|
+
// The 2015 Section's two tables, read through the one set every
|
|
173
|
+
// factor in the library comes from, so this and `memberBenefits`
|
|
174
|
+
// cannot round the same drawing two ways.
|
|
175
|
+
const ERF1 = factorTable('0-420');
|
|
176
|
+
const LRF1 = factorTable('0-421');
|
|
179
177
|
/**
|
|
180
|
-
* Provenance of the in-force table behind a factor
|
|
178
|
+
* Provenance of the 2015 Section's in-force table behind a factor
|
|
179
|
+
* kind — the
|
|
181
180
|
* citation facts (table ref, guidance name, issue date, source
|
|
182
181
|
* PDF) consumers render instead of hand-typing them, so a page
|
|
183
182
|
* showing "GAD factors issued 30 June 2023" updates itself when
|
|
@@ -198,6 +197,13 @@ export function factorProvenance(kind) {
|
|
|
198
197
|
* at NPA is not an early retirement with a factor of 1: naming
|
|
199
198
|
* a table there hands a consumer an ERF citation to render at a
|
|
200
199
|
* member who took no reduction.
|
|
200
|
+
*
|
|
201
|
+
* A second route to the factor `factor2015` reads through
|
|
202
|
+
* `factor-basis.ts`, kept because this public signature takes the
|
|
203
|
+
* pension-age date where that door takes a date of birth. It
|
|
204
|
+
* retires with `projectPension`
|
|
205
|
+
* (https://github.com/casomoltd/nhs-pay/issues/21), and until then
|
|
206
|
+
* `tests/section-factors.test.ts` holds the two routes equal.
|
|
201
207
|
*/
|
|
202
208
|
export function retirementFactor(retirementDate, npDate) {
|
|
203
209
|
if (retirementDate >= npDate) {
|
|
@@ -221,7 +227,14 @@ export function yearlyAccrual(pensionablePay) {
|
|
|
221
227
|
// ── Projection Orchestrator ─────────────────────────
|
|
222
228
|
/**
|
|
223
229
|
* Generate a full pension projection including curve
|
|
224
|
-
* data for both nominal and real
|
|
230
|
+
* data for both nominal and real views, the real one a second run
|
|
231
|
+
* at zero CPI rather than the nominal one deflated.
|
|
232
|
+
*
|
|
233
|
+
* @deprecated For the 2015 Section alone, on pay held flat.
|
|
234
|
+
* `memberBenefits` values a member across every section they
|
|
235
|
+
* hold; this stays for the flat-salary question until that can
|
|
236
|
+
* be asked of `memberBenefits` too:
|
|
237
|
+
* https://github.com/casomoltd/nhs-pay/issues/21
|
|
225
238
|
*
|
|
226
239
|
* `today` is the evaluation date — the anchor for the
|
|
227
240
|
* accrued/projected split and the real-terms deflator.
|
|
@@ -270,43 +283,6 @@ export function projectPension(input, today = new Date()) {
|
|
|
270
283
|
todaysMoneyLedger: todays.ledger,
|
|
271
284
|
};
|
|
272
285
|
}
|
|
273
|
-
/**
|
|
274
|
-
* A member's stated balance, on whatever date it is stated —
|
|
275
|
-
* the day they read it, or the day their statement prints. That
|
|
276
|
-
* is a position mid-scheme-year, and a seed is a year-end
|
|
277
|
-
* closing balance, so it has to be carried back to one.
|
|
278
|
-
*
|
|
279
|
-
* In November the April uplift has already been applied to the
|
|
280
|
-
* figure being read, so dividing it out lands on the last
|
|
281
|
-
* year-end closing balance and the walk re-applies it — no
|
|
282
|
-
* double count, and no year of accrual thrown away. On a date
|
|
283
|
-
* before that April the figure already IS the year-end balance
|
|
284
|
-
* and nothing is divided, which is why a statement printed on
|
|
285
|
-
* 31 March passes through untouched.
|
|
286
|
-
*
|
|
287
|
-
* ONE route for both the dated and the undated case, because
|
|
288
|
-
* there is only one question: what was the closing balance at
|
|
289
|
-
* the year end before this date? `seedFromStatement` stays
|
|
290
|
-
* strict about wanting a year end; this is what finds it.
|
|
291
|
-
* Statements print on arbitrary days — 7 November is a real
|
|
292
|
-
* one — so the strict form alone could not serve them.
|
|
293
|
-
*/
|
|
294
|
-
function seedFromBalanceAt(balance, asOf, exitDate, retirementDate, prices) {
|
|
295
|
-
const lastYearEnd = schemeYearClosedBy(asOf);
|
|
296
|
-
/* The uplift undone here is the one OPENING year
|
|
297
|
-
`lastYearEnd + 1`, and it is the very object `buildLedger`
|
|
298
|
-
re-applies to that year: inverting the walk exactly is this
|
|
299
|
-
function's only job, so both sides ask `openingUpliftFor`
|
|
300
|
-
rather than each naming the phase, the year and the CPI
|
|
301
|
-
series for themselves. */
|
|
302
|
-
const applied = openingUpliftFor(lastYearEnd, exitDate, retirementDate, prices);
|
|
303
|
-
const already = applied.appliedOn <= asOf;
|
|
304
|
-
return seedFromStatement(already ? balance / (1 + applied.percent / 100) : balance, schemeYearEndDate(lastYearEnd));
|
|
305
|
-
}
|
|
306
|
-
/** The earliest of some dates. */
|
|
307
|
-
function earliest(...dates) {
|
|
308
|
-
return new Date(Math.min(...dates.map((d) => d.getTime())));
|
|
309
|
-
}
|
|
310
286
|
function resolveProjection(input, today) {
|
|
311
287
|
const { currentSalary, dateOfBirth, exitDate, retirementDate, npa, assumedCpi, } = input;
|
|
312
288
|
/* The drawing date is used EXACTLY AS GIVEN, to the day.
|
|
@@ -334,13 +310,10 @@ function resolveProjection(input, today) {
|
|
|
334
310
|
? seedFromJoinDate(input.joinDate)
|
|
335
311
|
: seedFromBalanceAt(input.accruedPension, input.statementDate, exitDate, retirementDate, prices);
|
|
336
312
|
const { factor, type: factorType } = retirementFactor(retirementDate, npaDate(dateOfBirth, npa));
|
|
337
|
-
const
|
|
338
|
-
// Walk five years past the later of NPA and retirement, which
|
|
339
|
-
// is as far as the curve is ever asked to reach.
|
|
340
|
-
const through = Math.max(retireYear, schemeYearEndFor(npaDate(dateOfBirth, npa))) + 6;
|
|
313
|
+
const through = walkThrough(retirementDate, npaDate(dateOfBirth, npa));
|
|
341
314
|
const ledger = buildLedger({
|
|
342
315
|
seed,
|
|
343
|
-
|
|
316
|
+
payIn: flatPay(currentSalary),
|
|
344
317
|
exitDate,
|
|
345
318
|
retirementDate,
|
|
346
319
|
prices,
|
|
@@ -348,23 +321,12 @@ function resolveProjection(input, today) {
|
|
|
348
321
|
drawingFor: () => ({
|
|
349
322
|
on: retirementDate,
|
|
350
323
|
factor,
|
|
351
|
-
|
|
352
|
-
provenance: factorType === null
|
|
324
|
+
table: factorType === null
|
|
353
325
|
? null
|
|
354
|
-
: factorProvenance(factorType),
|
|
326
|
+
: { kind: factorType, provenance: factorProvenance(factorType) },
|
|
355
327
|
}),
|
|
356
328
|
});
|
|
357
|
-
|
|
358
|
-
// year end — a member handing over a balance and drawing it
|
|
359
|
-
// the same day. There is no row then, but there is still an
|
|
360
|
-
// answer: the balance they handed over.
|
|
361
|
-
const retireRow = ledger.years.find((r) => r.schemeYearEnd === retireYear);
|
|
362
|
-
const revalued = retireRow === undefined
|
|
363
|
-
? ledger.accruedAt(retirementDate)
|
|
364
|
-
: retireRow.revalued + retireRow.earned;
|
|
365
|
-
const drawn = retireRow === undefined
|
|
366
|
-
? revalued * factor
|
|
367
|
-
: retireRow.closing;
|
|
329
|
+
const { revalued, drawn } = atDrawing(ledger, retirementDate, factor);
|
|
368
330
|
/* Illustration only, and only where a statement leaves a gap:
|
|
369
331
|
an estimation path already walks from the join date, so
|
|
370
332
|
there is nothing to fill in. Calibrated to land exactly on
|
|
@@ -401,123 +363,4 @@ function resolveProjection(input, today) {
|
|
|
401
363
|
annualPension: drawn,
|
|
402
364
|
};
|
|
403
365
|
}
|
|
404
|
-
/**
|
|
405
|
-
* A member's age on a date, as WHOLE YEARS plus the fraction of
|
|
406
|
-
* the year since their birthday.
|
|
407
|
-
*
|
|
408
|
-
* The whole part is calendar arithmetic, so it is the age they
|
|
409
|
-
* would give if asked. The fraction only orders points within a
|
|
410
|
-
* year, which is all the chart needs it for.
|
|
411
|
-
*/
|
|
412
|
-
function ageAtYearEnd(dateOfBirth, on) {
|
|
413
|
-
const birthdayIn = (year) => new Date(year, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
414
|
-
const thisYear = birthdayIn(on.getFullYear());
|
|
415
|
-
const reached = thisYear <= on;
|
|
416
|
-
const whole = on.getFullYear() - dateOfBirth.getFullYear()
|
|
417
|
-
- (reached ? 0 : 1);
|
|
418
|
-
const last = reached ? thisYear : birthdayIn(on.getFullYear() - 1);
|
|
419
|
-
const next = reached ? birthdayIn(on.getFullYear() + 1) : thisYear;
|
|
420
|
-
return whole
|
|
421
|
-
+ (on.getTime() - last.getTime())
|
|
422
|
-
/ (next.getTime() - last.getTime());
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* The curve is the ledger's own steps, plotted ON THEM.
|
|
426
|
-
*
|
|
427
|
-
* **One point per scheme year, at its 31 March close** — the
|
|
428
|
-
* date an Annual Benefit Statement is drawn to, so every
|
|
429
|
-
* plotted value is a figure a member can lay beside paper.
|
|
430
|
-
*
|
|
431
|
-
* **Never at BIRTHDAYS**, which is the plotting the age axis
|
|
432
|
-
* invites. A birthday falls somewhere inside a scheme year:
|
|
433
|
-
* after the April uplift but before the year's slice lands, or
|
|
434
|
-
* the other way about. So a member born in January reads their
|
|
435
|
-
* 43rd-birthday point as "the 2026 figure" and gets a balance
|
|
436
|
-
* with neither the year's accrual in it nor any relation to a
|
|
437
|
-
* year end — values right for their dates and wrong for every
|
|
438
|
-
* question anyone asks of them, which surfaces as "the chart
|
|
439
|
-
* disagrees with my statement".
|
|
440
|
-
*
|
|
441
|
-
* The x-axis stays an AGE, because that is how people think
|
|
442
|
-
* about retiring. Age N is plotted at the close of the scheme
|
|
443
|
-
* year N's birthday falls in — the year that birthday belongs
|
|
444
|
-
* to — so the axis is unchanged and only the dates behind it
|
|
445
|
-
* move onto the scheme's own calendar.
|
|
446
|
-
*
|
|
447
|
-
* Nothing is drawn before the ledger's own start. For a
|
|
448
|
-
* statement that is the statement's date, and the reason is
|
|
449
|
-
* not tidiness: a member enters one figure, not their history,
|
|
450
|
-
* so anything earlier would be that figure run BACKWARDS
|
|
451
|
-
* through rates nobody checked. An inverse calculation drawn
|
|
452
|
-
* as history is a claim the tool cannot support.
|
|
453
|
-
*/
|
|
454
|
-
function buildCurve(cash, todays) {
|
|
455
|
-
const { today, dateOfBirth, retirementDate, npa } = cash;
|
|
456
|
-
const endAge = Math.max(npa + 5, yearsBetween(dateOfBirth, retirementDate) + 5);
|
|
457
|
-
/** The scheme year an age's birthday falls in. */
|
|
458
|
-
const yearOfAge = (age) => schemeYearEndFor(new Date(dateOfBirth.getFullYear() + age, dateOfBirth.getMonth(), dateOfBirth.getDate()));
|
|
459
|
-
/** The age whose birthday falls in a scheme year — the
|
|
460
|
-
* inverse, used once to find where the axis starts. */
|
|
461
|
-
const ageInYear = (schemeYearEnd) => {
|
|
462
|
-
const end = schemeYearEndDate(schemeYearEnd);
|
|
463
|
-
const birthday = new Date(schemeYearEnd, dateOfBirth.getMonth(), dateOfBirth.getDate());
|
|
464
|
-
return schemeYearEnd - dateOfBirth.getFullYear()
|
|
465
|
-
- (birthday > end ? 1 : 0);
|
|
466
|
-
};
|
|
467
|
-
const startAge = ageInYear(schemeYearEndFor(cash.curveFrom));
|
|
468
|
-
const points = [];
|
|
469
|
-
for (let label = startAge; label <= Math.ceil(endAge); label++) {
|
|
470
|
-
const year = yearOfAge(label);
|
|
471
|
-
const on = schemeYearEndDate(year);
|
|
472
|
-
/* The age the member actually IS on that 31 March, not the
|
|
473
|
-
whole age whose birthday the scheme year contains.
|
|
474
|
-
|
|
475
|
-
Those differ by anything from nought to twelve months —
|
|
476
|
-
the gap between a birthday and the following 31 March —
|
|
477
|
-
so plotting at the whole age put every value up to a year
|
|
478
|
-
early on the x-axis. Where "today" fell in that gap the
|
|
479
|
-
curve ran BACKWARDS: a member born in June read 7,738 at
|
|
480
|
-
39, 8,577 at 40, then 7,854 at 40.2 for today, then
|
|
481
|
-
9,429 at 41. Three of those are right; the axis was
|
|
482
|
-
wrong.
|
|
483
|
-
|
|
484
|
-
A January birthday hides it, being three months from the
|
|
485
|
-
year end. A June one puts nine months of accrual in the
|
|
486
|
-
wrong place.
|
|
487
|
-
|
|
488
|
-
Built as WHOLE AGE + fraction rather than as a span in
|
|
489
|
-
365.25-day years, so that `Math.floor(age)` is the age
|
|
490
|
-
the member actually is on that 31 March — by calendar
|
|
491
|
-
arithmetic, not within a rounding of it. Someone born on
|
|
492
|
-
1 April reads 42.997 at the year end before their 43rd
|
|
493
|
-
birthday, which floors correctly today and sits three
|
|
494
|
-
thousandths from flooring wrongly after enough leap
|
|
495
|
-
days. The fraction still orders the points; only the
|
|
496
|
-
whole part is now guaranteed. */
|
|
497
|
-
const age = ageAtYearEnd(dateOfBirth, on);
|
|
498
|
-
/* Two walks meet here, and the estimate owns everything up
|
|
499
|
-
to and including the statement's own year — its last row
|
|
500
|
-
IS the stated balance, so reading it there rather than
|
|
501
|
-
the main ledger changes nothing and keeps the join
|
|
502
|
-
seamless. */
|
|
503
|
-
const from = (r) => r.history !== null && year <= r.history.to
|
|
504
|
-
? r.history.ledger
|
|
505
|
-
: r.ledger;
|
|
506
|
-
const row = from(cash).years.find((r) => r.schemeYearEnd === year);
|
|
507
|
-
points.push({
|
|
508
|
-
age,
|
|
509
|
-
nominal: from(cash).atDate(on),
|
|
510
|
-
real: from(todays).atDate(on),
|
|
511
|
-
accrued: on <= today,
|
|
512
|
-
/* Off the row where there is one, and otherwise from the
|
|
513
|
-
SAME rule the row was built by — never a second copy of
|
|
514
|
-
it here. Compared by scheme YEAR, matching the ledger:
|
|
515
|
-
a point sits at a 31 March close, so a member who left
|
|
516
|
-
in January of that year would read as deferred on the
|
|
517
|
-
very year they were still paying in. */
|
|
518
|
-
phase: row?.phase ?? phaseAt(year, schemeYearEndFor(cash.exitDate), schemeYearEndFor(cash.retirementDate)),
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
return points;
|
|
522
|
-
}
|
|
523
366
|
//# sourceMappingURL=pension-projection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pension-projection.js","sourceRoot":"","sources":["../src/pension-projection.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pension-projection.js","sourceRoot":"","sources":["../src/pension-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4JG;AAEH,OAAO,EACL,QAAQ,EACR,OAAO,EACP,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EACL,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,GAC9C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAkJ9C,uDAAuD;AAEvD;;sCAEsC;AACtC,OAAO,EAAC,YAAY,EAAC,CAAC;AAEtB,uDAAuD;AAEvD,gEAAgE;AAChE,iEAAiE;AACjE,0CAA0C;AAC1C,MAAM,IAAI,GAAG,WAAW,CAAC,O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