@casomoltd/nhs-pay 0.27.0 → 0.29.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 (44) hide show
  1. package/dist/additional-pension.js +56 -32
  2. package/dist/additional-pension.js.map +1 -1
  3. package/dist/dates.d.ts +2 -0
  4. package/dist/dates.js +17 -3
  5. package/dist/dates.js.map +1 -1
  6. package/dist/index.d.ts +5 -4
  7. package/dist/index.js +3 -3
  8. package/dist/index.js.map +1 -1
  9. package/dist/iso-date.d.ts +4 -9
  10. package/dist/iso-date.js +10 -11
  11. package/dist/iso-date.js.map +1 -1
  12. package/dist/member/benefits.d.ts +11 -0
  13. package/dist/member/benefits.js +179 -0
  14. package/dist/member/benefits.js.map +1 -0
  15. package/dist/member/index.d.ts +9 -0
  16. package/dist/member/index.js +9 -0
  17. package/dist/member/index.js.map +1 -0
  18. package/dist/member/service.d.ts +65 -0
  19. package/dist/member/service.js +166 -0
  20. package/dist/member/service.js.map +1 -0
  21. package/dist/{member-benefits.d.ts → member/types.d.ts} +39 -42
  22. package/dist/member/types.js +46 -0
  23. package/dist/member/types.js.map +1 -0
  24. package/dist/member/valuation.d.ts +67 -0
  25. package/dist/member/valuation.js +162 -0
  26. package/dist/member/valuation.js.map +1 -0
  27. package/dist/pension/ages.d.ts +64 -31
  28. package/dist/pension/ages.js +66 -38
  29. package/dist/pension/ages.js.map +1 -1
  30. package/dist/post.d.ts +22 -29
  31. package/dist/post.js +14 -17
  32. package/dist/post.js.map +1 -1
  33. package/dist/sections/final-salary.d.ts +1 -0
  34. package/dist/sections/final-salary.js +1 -0
  35. package/dist/sections/final-salary.js.map +1 -1
  36. package/dist/sources.d.ts +13 -1
  37. package/dist/sources.js +25 -1
  38. package/dist/sources.js.map +1 -1
  39. package/dist/take-home.d.ts +12 -6
  40. package/dist/take-home.js +12 -6
  41. package/dist/take-home.js.map +1 -1
  42. package/package.json +3 -3
  43. package/dist/member-benefits.js +0 -462
  44. package/dist/member-benefits.js.map +0 -1
@@ -0,0 +1,65 @@
1
+ import type { DeclaredPeriod, LegacySectionId, ServicePeriod } from './types.js';
2
+ /** A legacy holding: its section, its own service, and the remedy window
3
+ * held in it after that service where the member has one. */
4
+ export interface LegacyHolding {
5
+ readonly section: LegacySectionId;
6
+ /** Its own service: to the day before the 2015 Section opened where a
7
+ * remedy window follows, else to the declared leaving. */
8
+ readonly own: ServicePeriod;
9
+ /** The McCloud remedy window; null where the member has none, which is
10
+ * the one record of whether they do. */
11
+ readonly window: ServicePeriod | null;
12
+ }
13
+ /** What a member holds: a legacy holding, if any, and the 2015 Section's
14
+ * own service after it. */
15
+ interface Held {
16
+ readonly legacy: LegacyHolding | null;
17
+ readonly ordinary2015: ServicePeriod;
18
+ }
19
+ /**
20
+ * The dates the McCloud remedy turns on, for a caller that has to read
21
+ * a member's answers against them before it can declare their service.
22
+ */
23
+ export declare const REMEDY: {
24
+ readonly eligibleBy: import("../iso-date.js").IsoDate;
25
+ readonly from: import("../iso-date.js").IsoDate;
26
+ readonly to: import("../iso-date.js").IsoDate;
27
+ readonly rollback: import("../iso-date.js").IsoDate;
28
+ };
29
+ /**
30
+ * The day each later section opened: the 2008 Section to new joiners
31
+ * under SI 2008/653, and the 2015 Section, which every member moved to
32
+ * for service from that day, under SI 2015/94. The 1995 Section is
33
+ * absent: no answer a member gives turns on its opening.
34
+ */
35
+ export declare const SECTION_OPENED: {
36
+ readonly "section-2008": import("../iso-date.js").IsoDate;
37
+ readonly "section-2015": import("../iso-date.js").IsoDate;
38
+ };
39
+ /**
40
+ * The periods a member holds, derived from what they declared and
41
+ * refused where it describes something the library does not model.
42
+ *
43
+ * Service is taken as continuous. A break — a gap between one period
44
+ * and the next — decides whether remedy service qualifies, and how a
45
+ * member comes to hold both legacy sections; both are deferred, so a
46
+ * declared break is refused rather than priced as though it were
47
+ * continuous: https://github.com/casomoltd/nhs-pay/issues/16
48
+ *
49
+ * A member with no 2015 Section service after rollback is refused
50
+ * too: https://github.com/casomoltd/nhs-pay/issues/19
51
+ *
52
+ * A declaration that cannot be true — nothing declared, leaving
53
+ * before joining, periods that overlap — is a caller's mistake and
54
+ * throws RangeError.
55
+ */
56
+ export declare function servicePeriods(declared: readonly DeclaredPeriod[]): Held;
57
+ /** Every period a member holds, in date order. */
58
+ export declare function periodsOf({ legacy, ordinary2015 }: Held): ServicePeriod[];
59
+ /** A legacy holding's periods in date order: its own service, then any
60
+ * remedy window. */
61
+ export declare function legacyPeriodsOf({ own, window }: LegacyHolding): ServicePeriod[];
62
+ /** The last day a period is valued to: its own end, or the leaving
63
+ * date where that comes first or the period is still open. */
64
+ export declare function until(p: ServicePeriod, leaving: Date): Date;
65
+ export {};
@@ -0,0 +1,166 @@
1
+ /**
2
+ * A member's service, checked: the periods they hold, derived from what
3
+ * they declared, with the McCloud remedy window split out of a legacy
4
+ * section where they have one, and the dates the remedy turns on.
5
+ */
6
+ import { dayAfter, dayBefore } from '../dates.js';
7
+ import { BenefitNotModelled, invariant, NOT_MODELLED } from '../errors.js';
8
+ import { isoDate, isoDateOf, isoToDate } from '../iso-date.js';
9
+ import { PERIOD_KINDS, SECTIONS } from './types.js';
10
+ /** The remedy period, 1 April 2015 to 31 March 2022, as PSPJOA 2022
11
+ * s.1 defines it. The days either side are derived from it. */
12
+ const REMEDY_FROM = isoDate('2015-04-01');
13
+ const REMEDY_TO = isoDate('2022-03-31');
14
+ /** PSPJOA 2022 s.1: in pensionable service "on 31 March 2012 or any
15
+ * earlier day". */
16
+ const ELIGIBLE_BY = isoDate('2012-03-31');
17
+ /** Rollback put remedy service back in the legacy section on this
18
+ * date (SI 2023/985), so a statement before it counts the remedy
19
+ * years in the 2015 Section. */
20
+ const ROLLBACK = isoDate('2023-10-01');
21
+ /**
22
+ * The dates the McCloud remedy turns on, for a caller that has to read
23
+ * a member's answers against them before it can declare their service.
24
+ */
25
+ export const REMEDY = {
26
+ eligibleBy: ELIGIBLE_BY,
27
+ from: REMEDY_FROM,
28
+ to: REMEDY_TO,
29
+ rollback: ROLLBACK,
30
+ };
31
+ /**
32
+ * The day each later section opened: the 2008 Section to new joiners
33
+ * under SI 2008/653, and the 2015 Section, which every member moved to
34
+ * for service from that day, under SI 2015/94. The 1995 Section is
35
+ * absent: no answer a member gives turns on its opening.
36
+ */
37
+ export const SECTION_OPENED = {
38
+ [SECTIONS.s2008]: isoDate('2008-04-01'),
39
+ [SECTIONS.s2015]: REMEDY_FROM,
40
+ };
41
+ const LAST_BEFORE_2015 = isoDateOf(dayBefore(isoToDate(REMEDY_FROM)));
42
+ const AFTER_REMEDY = isoDateOf(dayAfter(isoToDate(REMEDY_TO)));
43
+ /**
44
+ * The periods a member holds, derived from what they declared and
45
+ * refused where it describes something the library does not model.
46
+ *
47
+ * Service is taken as continuous. A break — a gap between one period
48
+ * and the next — decides whether remedy service qualifies, and how a
49
+ * member comes to hold both legacy sections; both are deferred, so a
50
+ * declared break is refused rather than priced as though it were
51
+ * continuous: https://github.com/casomoltd/nhs-pay/issues/16
52
+ *
53
+ * A member with no 2015 Section service after rollback is refused
54
+ * too: https://github.com/casomoltd/nhs-pay/issues/19
55
+ *
56
+ * A declaration that cannot be true — nothing declared, leaving
57
+ * before joining, periods that overlap — is a caller's mistake and
58
+ * throws RangeError.
59
+ */
60
+ export function servicePeriods(declared) {
61
+ const sections = sectionsOf(contiguous(declared));
62
+ const remedy = remedyApplies(sections);
63
+ return {
64
+ legacy: legacyHolding(sections.legacy, remedy),
65
+ ordinary2015: {
66
+ section: SECTIONS.s2015,
67
+ from: remedy ? AFTER_REMEDY : sections.current.joined,
68
+ to: sections.current.left,
69
+ kind: PERIOD_KINDS.ordinary,
70
+ },
71
+ };
72
+ }
73
+ /** Every period a member holds, in date order. */
74
+ export function periodsOf({ legacy, ordinary2015 }) {
75
+ return [...(legacy === null ? [] : legacyPeriodsOf(legacy)), ordinary2015];
76
+ }
77
+ /** A legacy holding's periods in date order: its own service, then any
78
+ * remedy window. */
79
+ export function legacyPeriodsOf({ own, window }) {
80
+ return window === null ? [own] : [own, window];
81
+ }
82
+ /** The last day a period is valued to: its own end, or the leaving
83
+ * date where that comes first or the period is still open. */
84
+ export function until(p, leaving) {
85
+ return p.to === null || isoToDate(p.to) > leaving ? leaving : isoToDate(p.to);
86
+ }
87
+ /** The declared periods in date order, each running into the next. */
88
+ function contiguous(declared) {
89
+ if (declared.length === 0) {
90
+ throw new RangeError('member: no service declared');
91
+ }
92
+ const sorted = [...declared].sort((a, b) => isoToDate(a.joined).getTime() - isoToDate(b.joined).getTime());
93
+ sorted.forEach((p, i) => {
94
+ checkFollowedBy(p, sorted.at(i + 1));
95
+ });
96
+ return sorted;
97
+ }
98
+ /** Refuse a period that cannot be true, or that leaves a gap before
99
+ * the one after it. */
100
+ function checkFollowedBy(p, next) {
101
+ if (p.left !== null && isoToDate(p.left) < isoToDate(p.joined)) {
102
+ throw new RangeError(`member: ${p.section} left before it was joined`);
103
+ }
104
+ if (next === undefined)
105
+ return;
106
+ if (p.left === null || isoToDate(next.joined) <= isoToDate(p.left)) {
107
+ throw new RangeError(`member: ${p.section} overlaps the next period`);
108
+ }
109
+ if (dayAfter(isoToDate(p.left)).getTime() !== isoToDate(next.joined).getTime()) {
110
+ throw new BenefitNotModelled(NOT_MODELLED.breakInService, 'a break in pensionable service');
111
+ }
112
+ }
113
+ /** At most one legacy period and exactly one 2015 Section period, or
114
+ * the service is not one the library models. */
115
+ function sectionsOf(sorted) {
116
+ const legacy = sorted.filter((p) => isLegacy(p.section));
117
+ const reformed = sorted.filter((p) => p.section === SECTIONS.s2015);
118
+ if (legacy.length > 1) {
119
+ throw new BenefitNotModelled(NOT_MODELLED.bothLegacySections, 'service in both legacy sections');
120
+ }
121
+ const current = reformed.at(0);
122
+ if (current === undefined || reformed.length > 1) {
123
+ throw new BenefitNotModelled(NOT_MODELLED.no2015Section, 'service without the 2015 Section');
124
+ }
125
+ return { legacy: legacy.at(0), current };
126
+ }
127
+ /** Whether the member has a remedy window: legacy service by the
128
+ * eligibility date, and 2015 Section service into the remedy period. */
129
+ function remedyApplies({ legacy, current }) {
130
+ const end = current.left;
131
+ const remedy = legacy !== undefined
132
+ && isoToDate(legacy.joined) <= isoToDate(ELIGIBLE_BY)
133
+ && (end === null || isoToDate(end) >= isoToDate(REMEDY_FROM));
134
+ if (remedy && end !== null && isoToDate(end) <= isoToDate(REMEDY_TO)) {
135
+ throw new BenefitNotModelled(NOT_MODELLED.remedyMemberLeftEarly, 'a remedy member who left before 1 April 2022');
136
+ }
137
+ return remedy;
138
+ }
139
+ /** The legacy section's periods: its own service, and the remedy
140
+ * window after it where the member has one. */
141
+ function legacyHolding(held, remedy) {
142
+ if (held === undefined || !isLegacy(held.section))
143
+ return null;
144
+ // A legacy period before a 2015 one has a leaving date: the
145
+ // contiguity check refused an open one.
146
+ invariant(held.left !== null, 'a legacy period with no end');
147
+ return {
148
+ section: held.section,
149
+ own: {
150
+ section: held.section,
151
+ from: held.joined,
152
+ to: remedy ? LAST_BEFORE_2015 : held.left,
153
+ kind: PERIOD_KINDS.ordinary,
154
+ },
155
+ window: remedy
156
+ ? {
157
+ section: held.section, from: REMEDY_FROM, to: REMEDY_TO,
158
+ kind: PERIOD_KINDS.remedyWindow,
159
+ }
160
+ : null,
161
+ };
162
+ }
163
+ function isLegacy(section) {
164
+ return section !== SECTIONS.s2015;
165
+ }
166
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/member/service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,kBAAkB,EAAE,SAAS,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AACzE,OAAO,EAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AA8BlD;g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,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/D,4DAA4D;IAC5D,wCAAwC;IACxC,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,6BAA6B,CAAC,CAAC;IAC7D,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,GAAG,EAAE;YACH,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,MAAM;YACjB,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI;YACzC,IAAI,EAAE,YAAY,CAAC,QAAQ;SAC5B;QACD,MAAM,EAAE,MAAM;YACZ,CAAC,CAAC;gBACA,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS;gBACvD,IAAI,EAAE,YAAY,CAAC,YAAY;aAChC;YACD,CAAC,CAAC,IAAI;KACT,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,OAAkB;IAClC,OAAO,OAAO,KAAK,QAAQ,CAAC,KAAK,CAAC;AACpC,CAAC"}
@@ -1,13 +1,19 @@
1
- import type { CashChoice, CommutationResult } from './commutation.js';
2
- import type { FactorOutcome } from './factor-basis.js';
3
- import type { IsoDate } from './iso-date.js';
4
- import type { MemberPay, PayPath } from './pay-path.js';
5
- import type { ProjectionPoint } from './pension/curve.js';
6
- import type { MemberLedger } from './pension/ledger.js';
7
- import type { EstimatedHistory } from './pension/history.js';
8
- import type { ProjectionMoney } from './pension/money.js';
9
- import type { Prices } from './pension/prices.js';
10
- import type { FinalSalaryRules, PayMeasure } from './sections/final-salary.js';
1
+ /**
2
+ * The vocabulary of a member's benefits: what a caller tells the library
3
+ * about a member and their choices, and the shapes it answers with. Types
4
+ * and the ids they are keyed by only, so the service check, the valuation
5
+ * and the owner in `benefits.ts` all read one definition.
6
+ */
7
+ import type { CashChoice, CommutationResult } from '../commutation.js';
8
+ import type { FactorOutcome } from '../factor-basis.js';
9
+ import type { IsoDate } from '../iso-date.js';
10
+ import type { MemberPay, PayPath } from '../pay-path.js';
11
+ import type { ProjectionPoint } from '../pension/curve.js';
12
+ import type { EstimatedHistory } from '../pension/history.js';
13
+ import type { MemberLedger } from '../pension/ledger.js';
14
+ import type { ProjectionMoney } from '../pension/money.js';
15
+ import type { Prices } from '../pension/prices.js';
16
+ import type { FinalSalaryRules, PayMeasure } from '../sections/final-salary.js';
11
17
  /**
12
18
  * One scheme, the NHS Pension Scheme, in three sections. "Scheme" only
13
19
  * ever means the whole; each part is a section, as a member's own
@@ -119,7 +125,7 @@ export interface Award {
119
125
  /** Where it is held and paid from. */
120
126
  readonly section: SectionId;
121
127
  readonly periods: readonly ServicePeriod[];
122
- /** The pension at the drawing before its factor: final salary as
128
+ /** The PENSION at the drawing before its factor: final salary as
123
129
  * measured, or the career average pot as revalued. */
124
130
  readonly beforeFactor: ProjectionMoney;
125
131
  /** After the factor: what is paid. */
@@ -127,6 +133,14 @@ export interface Award {
127
133
  /** Nil rather than absent where the rules pay none, so a caller
128
134
  * cannot forget to ask. */
129
135
  readonly automaticLumpSum: ProjectionMoney;
136
+ /** The automatic lump sum at the drawing before its early or late
137
+ * factor, on the same rulers as `beforeFactor`: the section's multiple
138
+ * of that pension. Nil where the rules pay none, as a career average
139
+ * award never does. */
140
+ readonly automaticLumpSumBeforeFactor: ProjectionMoney;
141
+ /** The PENSION's early or late factor. A lump sum is reduced by a
142
+ * factor of its own, which this does not carry, so read the lump sum
143
+ * before it from `automaticLumpSumBeforeFactor`, never by dividing. */
130
144
  readonly factor: FactorOutcome;
131
145
  /** A career average award's year-by-year walk, in cash and in today's
132
146
  * money; null for final salary, which keeps no balance to walk. */
@@ -215,38 +229,21 @@ export interface MemberBenefits {
215
229
  readonly legacy: LegacyRules | null;
216
230
  /** The pay every section reads, built once for the member. */
217
231
  readonly payPath: PayPath;
232
+ /** The earliest age this member may draw every section they hold on
233
+ * `drawing`, other than through ill health: the law's minimum pension
234
+ * age on that day, or the protected age they keep. A 1995 Section age
235
+ * below it is that section's alone and is not modelled
236
+ * (docs/how-it-works.md#minimum-pension-age). `at()` refuses a drawing
237
+ * before they reach it. */
238
+ minimumPensionAgeOn(drawing: IsoDate): number;
239
+ /** Whether this member may draw on `drawing`, other than through ill
240
+ * health: on or after the birthday at which they reach
241
+ * `minimumPensionAgeOn(drawing)`. `at()` refuses a drawing this
242
+ * refuses. */
243
+ mayDrawOn(drawing: IsoDate): boolean;
218
244
  /** Worth today, before any drawing. */
219
245
  now(): Holdings;
220
- /** Worth when drawn, for one set of choices. */
246
+ /** Worth when drawn, for one set of choices. Throws RangeError for a
247
+ * drawing before the member reaches `minimumPensionAgeOn(drawing)`. */
221
248
  at(choices: RetirementChoices): Position;
222
249
  }
223
- /**
224
- * The dates the McCloud remedy turns on, for a caller that has to read
225
- * a member's answers against them before it can declare their service.
226
- */
227
- export declare const REMEDY: {
228
- readonly eligibleBy: IsoDate;
229
- readonly from: IsoDate;
230
- readonly to: IsoDate;
231
- readonly rollback: IsoDate;
232
- };
233
- /**
234
- * The day each later section opened: the 2008 Section to new joiners
235
- * under SI 2008/653, and the 2015 Section, which every member moved to
236
- * for service from that day, under SI 2015/94. The 1995 Section is
237
- * absent: no answer a member gives turns on its opening.
238
- */
239
- export declare const SECTION_OPENED: {
240
- readonly "section-2008": IsoDate;
241
- readonly "section-2015": IsoDate;
242
- };
243
- /**
244
- * Build a member's benefits. Throws `PayPathUnavailable` where there
245
- * is no current pay to build pay from, `BenefitNotModelled` for service
246
- * the library does not model, and RangeError for a declaration that
247
- * cannot be true.
248
- *
249
- * `today` is required because it decides which answer comes back: it
250
- * is the date the figures are as at, so a figure reproduces as at it.
251
- */
252
- export declare function memberBenefits(member: Member, assumptions: Assumptions, today: Date): MemberBenefits;
@@ -0,0 +1,46 @@
1
+ // ── Vocabulary ──────────────────────────────────────
2
+ /**
3
+ * One scheme, the NHS Pension Scheme, in three sections. "Scheme" only
4
+ * ever means the whole; each part is a section, as a member's own
5
+ * Annual Benefit Statement prints it.
6
+ */
7
+ export const SECTIONS = {
8
+ s1995: 'section-1995',
9
+ s2008: 'section-2008',
10
+ s2015: 'section-2015',
11
+ };
12
+ /** How the cash ruler reads the years behind the run date. */
13
+ export const PAST_YEARS = {
14
+ /** The assumption throughout, as for the years ahead. */
15
+ assumed: 'assumed',
16
+ /** The published record: each year's Revaluation Order, and pay
17
+ * carried into each year's cash by the same Orders' CPI, an
18
+ * approximation to the pay awards — the ledger an Annual Benefit
19
+ * Statement prints. See `createPublishedPrices`. */
20
+ published: 'published',
21
+ };
22
+ /**
23
+ * How the remedy window is valued, for a member who has one: as more
24
+ * service in their legacy section, or under the 2015 Section's rules
25
+ * while still paid from the legacy section. There is no default and no
26
+ * preferred answer: which pays more depends on the choices a caller
27
+ * compares, and the library cannot see them.
28
+ */
29
+ export const REMEDY_BASES = {
30
+ none: 'none',
31
+ legacy: 'legacy-basis',
32
+ section2015: 'section-2015-basis',
33
+ };
34
+ // ── What the library answers with ───────────────────
35
+ /** What a period is: service in its own right, or the McCloud remedy
36
+ * window, held in the legacy section and valued on either basis. */
37
+ export const PERIOD_KINDS = {
38
+ ordinary: 'ordinary',
39
+ remedyWindow: 'remedy-window',
40
+ };
41
+ /** How a section accrues: on final salary, or on a career average. */
42
+ export const ACCRUALS = {
43
+ finalSalary: 'final-salary',
44
+ careerAverage: 'career-average',
45
+ };
46
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/member/types.ts"],"names":[],"mappings":"AAiBA,uDAAuD;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;CACb,CAAC;AA+BX,8DAA8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,yDAAyD;IACzD,OAAO,EAAE,SAAS;IAClB;;;yDAGqD;IACrD,SAAS,EAAE,WAAW;CACd,CAAC;AAcX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,cAAc;IACtB,WAAW,EAAE,oBAAoB;CACzB,CAAC;AAmBX,uDAAuD;AAEvD;qEACqE;AACrE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,eAAe;CACrB,CAAC;AAYX,sEAAsE;AACtE,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,WAAW,EAAE,cAAc;IAC3B,aAAa,EAAE,gBAAgB;CACvB,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Each section's award for a member, valued at one set of dates: the
3
+ * legacy section on final salary, the 2015 Section and a remedy window
4
+ * on its basis as career average walks, and today's holdings. The
5
+ * owner in `benefits.ts` decides which awards a drawing has and
6
+ * sums them.
7
+ */
8
+ import type { Award, Holdings, Member, Position, ServicePeriod } from './types.js';
9
+ import type { LegacySectionId, SectionId } from './types.js';
10
+ import type { LegacyHolding } from './service.js';
11
+ import type { JoiningHistory } from '../pension/ages.js';
12
+ import type { PayPath } from '../pay-path.js';
13
+ import type { Prices } from '../pension/prices.js';
14
+ import type { LedgerSeed } from '../pension/seed.js';
15
+ import type { FinalSalaryRules } from '../sections/final-salary.js';
16
+ import { careerAverage } from '../sections/section-2015.js';
17
+ /** Everything about the member, derived once, that every question
18
+ * asked of them reads. */
19
+ export interface Built {
20
+ readonly member: Member;
21
+ /** The dates the member's minimum pension age turns on. */
22
+ readonly history: JoiningHistory;
23
+ readonly today: Date;
24
+ readonly born: Date;
25
+ readonly npaOn: Date;
26
+ readonly payPath: PayPath;
27
+ readonly legacy: LegacyHolding | null;
28
+ readonly ordinary2015: ServicePeriod;
29
+ readonly cashPrices: Prices;
30
+ readonly todaysPrices: Prices;
31
+ }
32
+ /** The dates one set of choices is valued at. */
33
+ export interface Drawing {
34
+ readonly leaving: Date;
35
+ readonly drawing: Date;
36
+ }
37
+ /** A career average run: one window walked in one price series. */
38
+ type CareerAverageRun = ReturnType<typeof careerAverage>;
39
+ /** A career average award and the two runs it was read from. */
40
+ interface CareerAward {
41
+ readonly award: Award;
42
+ readonly cash: CareerAverageRun;
43
+ readonly todays: CareerAverageRun;
44
+ }
45
+ /** What a career average award values: a window of one section, and the
46
+ * seed its walk starts from in each price series. */
47
+ interface CareerWindow {
48
+ readonly section: SectionId;
49
+ readonly window: ServicePeriod;
50
+ readonly seedFor: (prices: Prices) => LedgerSeed;
51
+ }
52
+ /** Each legacy section's statute. */
53
+ export declare const RULES: Record<LegacySectionId, FinalSalaryRules>;
54
+ /** The 2015 Section's own seed: its statement, or its first day. */
55
+ export declare function seed2015(b: Built, { leaving, drawing }: Drawing, prices: Prices): LedgerSeed;
56
+ /** What the member holds today, with the remedy window on the legacy
57
+ * basis: unreduced, since nothing is drawn. */
58
+ export declare function holdings(b: Built): Holdings;
59
+ /** The legacy section's final-salary award over the periods valued on
60
+ * final salary, which the election decides. */
61
+ export declare function legacyAward(b: Built, legacy: LegacyHolding, valued: readonly ServicePeriod[], dates: Drawing): Award;
62
+ /** A career average award over one window, walked in both rulers. */
63
+ export declare function careerAward(b: Built, { section, window, seedFor }: CareerWindow, dates: Drawing): CareerAward;
64
+ /** The 2015 Section's balance, with its estimated run-up before a
65
+ * statement, as the ledgers, history and curve a `Position` carries. */
66
+ export declare function section2015(b: Built, own: CareerAward, { leaving, drawing }: Drawing): Pick<Position, 'ledger' | 'todaysMoneyLedger' | 'estimatedHistory' | 'curve'>;
67
+ export {};
@@ -0,0 +1,162 @@
1
+ import { ACCRUALS, SECTIONS } from './types.js';
2
+ import { legacyPeriodsOf, until } from './service.js';
3
+ import { isoToDate } from '../iso-date.js';
4
+ import { normalPensionAge } from '../pension/ages.js';
5
+ import { earliest } from '../dates.js';
6
+ import { buildCurve, walkThrough } from '../pension/curve.js';
7
+ import { seedFromBalanceAt } from '../pension/uplift.js';
8
+ import { estimateHistory } from '../pension/history.js';
9
+ import { moneyAt, sumMoney } from '../pension/money.js';
10
+ import { schemeYearEndDate, schemeYearEndFor, seedFromJoinDate, } from '../pension/seed.js';
11
+ import { finalSalaryBenefit, unreducedPension, } from '../sections/final-salary.js';
12
+ import { RULES_1995 } from '../sections/section-1995.js';
13
+ import { RULES_2008 } from '../sections/section-2008.js';
14
+ import { careerAverage } from '../sections/section-2015.js';
15
+ /** Each legacy section's statute. */
16
+ export const RULES = {
17
+ [SECTIONS.s1995]: RULES_1995,
18
+ [SECTIONS.s2008]: RULES_2008,
19
+ };
20
+ /** The 2015 Section's own seed: its statement, or its first day. */
21
+ export function seed2015(b, { leaving, drawing }, prices) {
22
+ const { statement } = b.member;
23
+ return statement === null
24
+ ? seedFromJoinDate(isoToDate(b.ordinary2015.from))
25
+ : seedFromBalanceAt(statement.accruedPension, isoToDate(statement.asAt), leaving, drawing, prices);
26
+ }
27
+ /** What the member holds today, with the remedy window on the legacy
28
+ * basis: unreduced, since nothing is drawn. */
29
+ export function holdings(b) {
30
+ const { today } = b;
31
+ const bySection = [];
32
+ const flat = (x) => moneyAt({ nominal: x, real: x }, today);
33
+ if (b.legacy !== null) {
34
+ const { pension, automaticLumpSum } = unreducedPension(RULES[b.legacy.section], membershipOf(legacyPeriodsOf(b.legacy), today), b.payPath, schemeYearEndFor(today));
35
+ bySection.push({
36
+ section: b.legacy.section,
37
+ pension: flat(pension),
38
+ automaticLumpSum: flat(automaticLumpSum),
39
+ });
40
+ }
41
+ // Any leaving and drawing after today give the same balance today;
42
+ // these are only where the walk has to stop.
43
+ const leaving = b.ordinary2015.to === null
44
+ ? b.npaOn
45
+ : isoToDate(b.ordinary2015.to);
46
+ const dates = { leaving, drawing: leaving < b.npaOn ? b.npaOn : leaving };
47
+ const accrued = walk(b, {
48
+ window: b.ordinary2015,
49
+ seed: seed2015(b, dates, b.todaysPrices),
50
+ prices: b.todaysPrices,
51
+ }, dates).ledger.accruedAt(today);
52
+ bySection.push({
53
+ section: SECTIONS.s2015,
54
+ pension: flat(accrued),
55
+ automaticLumpSum: flat(0),
56
+ });
57
+ return {
58
+ bySection, total: sumMoney(bySection.map((x) => x.pension), today),
59
+ };
60
+ }
61
+ /** The legacy section's final-salary award over the periods valued on
62
+ * final salary, which the election decides. */
63
+ export function legacyAward(b, legacy, valued, dates) {
64
+ const rules = RULES[legacy.section];
65
+ const benefit = finalSalaryBenefit(rules, {
66
+ windows: membershipOf(valued, dates.leaving),
67
+ payPath: b.payPath, dateOfBirth: b.born, ...dates,
68
+ prices: b.cashPrices,
69
+ });
70
+ return {
71
+ section: legacy.section,
72
+ periods: valued,
73
+ beforeFactor: benefit.beforeFactor,
74
+ pension: benefit.pension,
75
+ automaticLumpSum: benefit.automaticLumpSum,
76
+ automaticLumpSumBeforeFactor: benefit.automaticLumpSumBeforeFactor,
77
+ factor: benefit.factor,
78
+ ledgers: null,
79
+ provenance: {
80
+ accrual: ACCRUALS.finalSalary,
81
+ denominator: rules.denominator,
82
+ payMeasure: rules.payMeasure,
83
+ membership: benefit.membership,
84
+ finalPay: benefit.finalPay,
85
+ },
86
+ };
87
+ }
88
+ /** A career average award over one window, walked in both rulers. */
89
+ export function careerAward(b, { section, window, seedFor }, dates) {
90
+ const walkIn = (prices) => walk(b, { window, seed: seedFor(prices), prices }, dates);
91
+ const cash = walkIn(b.cashPrices);
92
+ const todays = walkIn(b.todaysPrices);
93
+ // A career average award pays no automatic lump sum, before or after a
94
+ // factor.
95
+ const noLumpSum = moneyAt({ nominal: 0, real: 0 }, dates.drawing);
96
+ return {
97
+ award: {
98
+ section,
99
+ periods: [window],
100
+ beforeFactor: moneyAt({ nominal: cash.revalued, real: todays.revalued }, dates.drawing),
101
+ pension: moneyAt({ nominal: cash.drawn, real: todays.drawn }, dates.drawing),
102
+ automaticLumpSum: noLumpSum,
103
+ automaticLumpSumBeforeFactor: noLumpSum,
104
+ factor: cash.factor,
105
+ ledgers: { cash: cash.ledger, todaysMoney: todays.ledger },
106
+ provenance: { accrual: ACCRUALS.careerAverage },
107
+ },
108
+ cash,
109
+ todays,
110
+ };
111
+ }
112
+ /** The 2015 Section's balance, with its estimated run-up before a
113
+ * statement, as the ledgers, history and curve a `Position` carries. */
114
+ export function section2015(b, own, { leaving, drawing }) {
115
+ const historyIn = (r, prices) => b.member.statement === null
116
+ ? null
117
+ : estimateHistory({
118
+ joinDate: isoToDate(b.ordinary2015.from),
119
+ statedBalance: r.seed.opening,
120
+ statementSchemeYearEnd: r.seed.atSchemeYearEnd,
121
+ prices,
122
+ });
123
+ const cashHistory = historyIn(own.cash, b.cashPrices);
124
+ const todaysHistory = historyIn(own.todays, b.todaysPrices);
125
+ const run = (r, history) => ({
126
+ today: b.today, dateOfBirth: b.born, exitDate: leaving,
127
+ retirementDate: drawing, npa: normalPensionAge(b.born),
128
+ ledger: r.ledger, history,
129
+ curveFrom: earliest(b.today, leaving, schemeYearEndDate(history === null
130
+ ? r.seed.atSchemeYearEnd
131
+ : history.from - 1)),
132
+ });
133
+ return {
134
+ ledger: own.cash.ledger,
135
+ todaysMoneyLedger: own.todays.ledger,
136
+ estimatedHistory: todaysHistory,
137
+ curve: buildCurve(run(own.cash, cashHistory), run(own.todays, todaysHistory)),
138
+ };
139
+ }
140
+ /** A career average walk over `window`, accruing only inside it. */
141
+ function walk(b, { window, seed, prices }, { leaving, drawing }) {
142
+ const first = schemeYearEndFor(isoToDate(window.from));
143
+ const last = schemeYearEndFor(until(window, leaving));
144
+ return careerAverage({
145
+ seed,
146
+ payIn: (year) => (year >= first && year <= last
147
+ ? b.payPath.payFor(year)
148
+ : null),
149
+ dateOfBirth: b.born,
150
+ leaving,
151
+ drawing,
152
+ prices,
153
+ through: walkThrough(drawing, b.npaOn),
154
+ });
155
+ }
156
+ /** The legacy windows as final-salary membership, to `leaving`. */
157
+ function membershipOf(valued, leaving) {
158
+ return valued
159
+ .filter((p) => isoToDate(p.from) <= leaving)
160
+ .map((p) => ({ from: isoToDate(p.from), to: until(p, leaving) }));
161
+ }
162
+ //# sourceMappingURL=valuation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valuation.js","sourceRoot":"","sources":["../../src/member/valuation.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAC,eAAe,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAiD1D,qCAAqC;AACrC,MAAM,CAAC,MAAM,KAAK,GAA8C;IAC9D,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU;IAC5B,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU;CAC7B,CAAC;AAEF,oEAAoE;AACpE,MAAM,UAAU,QAAQ,CACtB,CAAQ,EAAE,EAAC,OAAO,EAAE,OAAO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