@casomoltd/nhs-pay 0.29.0 → 0.31.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 (80) hide show
  1. package/README.md +78 -249
  2. package/dist/bands.d.ts +9 -1
  3. package/dist/bands.js +20 -0
  4. package/dist/bands.js.map +1 -1
  5. package/dist/dates.d.ts +3 -0
  6. package/dist/dates.js +7 -2
  7. package/dist/dates.js.map +1 -1
  8. package/dist/document-source.d.ts +16 -0
  9. package/dist/document-source.js +3 -1
  10. package/dist/document-source.js.map +1 -1
  11. package/dist/errors.d.ts +46 -11
  12. package/dist/errors.js +68 -28
  13. package/dist/errors.js.map +1 -1
  14. package/dist/factor-basis.d.ts +14 -0
  15. package/dist/factor-basis.js.map +1 -1
  16. package/dist/index.d.ts +13 -11
  17. package/dist/index.js +6 -5
  18. package/dist/index.js.map +1 -1
  19. package/dist/member/benefits.js +41 -39
  20. package/dist/member/benefits.js.map +1 -1
  21. package/dist/member/index.d.ts +1 -1
  22. package/dist/member/input-period.d.ts +41 -0
  23. package/dist/member/input-period.js +168 -0
  24. package/dist/member/input-period.js.map +1 -0
  25. package/dist/member/service.d.ts +8 -1
  26. package/dist/member/service.js +18 -1
  27. package/dist/member/service.js.map +1 -1
  28. package/dist/member/types.d.ts +101 -44
  29. package/dist/member/types.js.map +1 -1
  30. package/dist/member/valuation.d.ts +72 -14
  31. package/dist/member/valuation.js +115 -34
  32. package/dist/member/valuation.js.map +1 -1
  33. package/dist/pay-path.d.ts +21 -25
  34. package/dist/pay-path.js +85 -67
  35. package/dist/pay-path.js.map +1 -1
  36. package/dist/pension/ages.d.ts +6 -4
  37. package/dist/pension/ages.js +6 -4
  38. package/dist/pension/ages.js.map +1 -1
  39. package/dist/pension/curve.d.ts +2 -1
  40. package/dist/pension/curve.js +15 -7
  41. package/dist/pension/curve.js.map +1 -1
  42. package/dist/pension/history.d.ts +18 -3
  43. package/dist/pension/history.js +12 -5
  44. package/dist/pension/history.js.map +1 -1
  45. package/dist/pension/ledger.d.ts +15 -9
  46. package/dist/pension/ledger.js +91 -56
  47. package/dist/pension/ledger.js.map +1 -1
  48. package/dist/pension/prices.d.ts +11 -2
  49. package/dist/pension/prices.js +35 -14
  50. package/dist/pension/prices.js.map +1 -1
  51. package/dist/pension/scheme-year.d.ts +59 -0
  52. package/dist/pension/scheme-year.js +80 -0
  53. package/dist/pension/scheme-year.js.map +1 -0
  54. package/dist/pension/seed.d.ts +66 -50
  55. package/dist/pension/seed.js +111 -65
  56. package/dist/pension/seed.js.map +1 -1
  57. package/dist/pension/uplift.d.ts +13 -33
  58. package/dist/pension/uplift.js +11 -56
  59. package/dist/pension/uplift.js.map +1 -1
  60. package/dist/pension-projection.js +30 -22
  61. package/dist/pension-projection.js.map +1 -1
  62. package/dist/post.d.ts +1 -10
  63. package/dist/post.js +1 -12
  64. package/dist/post.js.map +1 -1
  65. package/dist/revaluation.d.ts +34 -35
  66. package/dist/revaluation.js +41 -41
  67. package/dist/revaluation.js.map +1 -1
  68. package/dist/scale-point.d.ts +6 -0
  69. package/dist/sections/final-salary.d.ts +64 -52
  70. package/dist/sections/final-salary.js +131 -69
  71. package/dist/sections/final-salary.js.map +1 -1
  72. package/dist/sections/section-2015.d.ts +2 -1
  73. package/dist/sections/section-2015.js.map +1 -1
  74. package/dist/sources.d.ts +10 -0
  75. package/dist/sources.js +20 -0
  76. package/dist/sources.js.map +1 -1
  77. package/dist/take-home.d.ts +4 -20
  78. package/dist/take-home.js +3 -23
  79. package/dist/take-home.js.map +1 -1
  80. package/package.json +3 -3
@@ -5,5 +5,5 @@
5
5
  */
6
6
  export { memberBenefits } from './benefits.js';
7
7
  export { ACCRUALS, PAST_YEARS, PERIOD_KINDS, REMEDY_BASES, SECTIONS, } from './types.js';
8
- export type { Assumptions, Award, DeclaredPeriod, Holdings, LegacyRules, LegacySectionId, Member, MemberBenefits, PastYears, Position, RemedyBasis, RemedyElection, RetirementChoices, SectionId, ServicePeriod, } from './types.js';
8
+ export type { Assumptions, Award, DeclaredPeriod, Holdings, LegacyRules, LegacySectionId, Member, MemberBenefits, PastYears, Position, RemedyBasis, RemedyElection, RetirementChoices, RulerLedgers, Section2015Walk, SectionId, ServicePeriod, StatementBalance, } from './types.js';
9
9
  export { REMEDY, SECTION_OPENED } from './service.js';
@@ -0,0 +1,41 @@
1
+ import type { Prices } from '../pension/prices.js';
2
+ import type { MemberBenefits } from './types.js';
3
+ import type { Built } from './valuation.js';
4
+ /**
5
+ * Each tax year's pension input period for the member leaving on the date
6
+ * asked, in the cash of the price series `seriesAt` gives for an assumed
7
+ * CPI. Refuses a year before 2016-17, the first tax year that is a pension
8
+ * input period, a leaving after the one declared, an election for a member
9
+ * with no remedy window, and no election for one with a window. Under
10
+ * Finance Act 2004 s.238ZB an arrangement begun after 8 July 2015 has a
11
+ * first period from its start to the next 5 April
12
+ * (https://www.legislation.gov.uk/ukpga/2004/12/section/238ZB). It holds
13
+ * nothing at its start, so it reads as its tax year opening at nil, which
14
+ * `potAt` gives where the walk starts on the day the member joined. A
15
+ * member's statement is as at 31 March, and a year opening before it, or a
16
+ * leaving before it, throws `BeforeStatement`: the statement gives no
17
+ * balance there (docs/how-it-works.md#where-the-2015-sections-ledger-starts).
18
+ *
19
+ * - **An arrangement per section paid from:** the legacy section, with its
20
+ * remedy window on either basis, since both are paid from it; and the
21
+ * 2015 Section. Our reading: Finance Act 2004 s.152 defines an
22
+ * arrangement only as "an arrangement relating to the member under the
23
+ * pension scheme", and no source read here splits the NHS scheme.
24
+ * - **Each value is held "as if" at the pension age** (PTM053301 step 1):
25
+ * before any early or late factor.
26
+ * - **The opening value** is what is held at the close of the day before
27
+ * the year, 5 April, and the closing value at the close of the 5 April
28
+ * ending it; a revaluation falls in the year its date does.
29
+ * - **A member serving the whole year** is valued in service at its end.
30
+ * The year the member leaves in closes on the leaving date instead, at the
31
+ * deferred value with the leaver adjustment. Our reading: no source read
32
+ * here dates a leaver's closing value, and the leaving date is when their
33
+ * rights stop accruing.
34
+ * - **The period's `cpi`** is the September CPI before the year, from the
35
+ * same series: the Order's figure where the series reads published ones.
36
+ *
37
+ * A caller reads year after year, so the walks are kept per CPI and
38
+ * leaving: a walk reads the same balance on a date whatever happens after
39
+ * it, so one walked to its last year's end values every year before it.
40
+ */
41
+ export declare function inputPeriods(b: Built, seriesAt: (assumedCpi: number) => Prices): MemberBenefits['pensionInputPeriod'];
@@ -0,0 +1,168 @@
1
+ /**
2
+ * A member's pension input period: one tax year's defined benefits per
3
+ * arrangement, at its start and its end, in cash, in the shape paye-calc's
4
+ * `definedBenefitInput` reads (HMRC PTM053301,
5
+ * https://www.gov.uk/hmrc-internal-manuals/pensions-tax-manual/ptm053301).
6
+ * What counts as one arrangement, and what each holds on a date, are the
7
+ * scheme's facts, so they are decided here and not by a caller.
8
+ */
9
+ import { refuseBeforePensionInputPeriods, taxYearEndDate, taxYearEndFor, taxYearStartDate, } from '@casomoltd/paye-calc';
10
+ import { dayBefore } from '../dates.js';
11
+ import { invariant } from '../errors.js';
12
+ import { isoToDate } from '../iso-date.js';
13
+ import { pointsToDecimal } from '../pension/prices.js';
14
+ import { schemeYearClosedBy, schemeYearEndFor } from '../pension/scheme-year.js';
15
+ import { refuseElectionMismatch } from './service.js';
16
+ import { accruedLedger, finalSalaryHeldOn, finalSalaryValued, refuseLeavingAfterDeclared, seed2015, walkDates, walksWindow, windowSeed, } from './valuation.js';
17
+ /** The call a refusal names. */
18
+ const ASKED = 'pensionInputPeriod';
19
+ /**
20
+ * Each tax year's pension input period for the member leaving on the date
21
+ * asked, in the cash of the price series `seriesAt` gives for an assumed
22
+ * CPI. Refuses a year before 2016-17, the first tax year that is a pension
23
+ * input period, a leaving after the one declared, an election for a member
24
+ * with no remedy window, and no election for one with a window. Under
25
+ * Finance Act 2004 s.238ZB an arrangement begun after 8 July 2015 has a
26
+ * first period from its start to the next 5 April
27
+ * (https://www.legislation.gov.uk/ukpga/2004/12/section/238ZB). It holds
28
+ * nothing at its start, so it reads as its tax year opening at nil, which
29
+ * `potAt` gives where the walk starts on the day the member joined. A
30
+ * member's statement is as at 31 March, and a year opening before it, or a
31
+ * leaving before it, throws `BeforeStatement`: the statement gives no
32
+ * balance there (docs/how-it-works.md#where-the-2015-sections-ledger-starts).
33
+ *
34
+ * - **An arrangement per section paid from:** the legacy section, with its
35
+ * remedy window on either basis, since both are paid from it; and the
36
+ * 2015 Section. Our reading: Finance Act 2004 s.152 defines an
37
+ * arrangement only as "an arrangement relating to the member under the
38
+ * pension scheme", and no source read here splits the NHS scheme.
39
+ * - **Each value is held "as if" at the pension age** (PTM053301 step 1):
40
+ * before any early or late factor.
41
+ * - **The opening value** is what is held at the close of the day before
42
+ * the year, 5 April, and the closing value at the close of the 5 April
43
+ * ending it; a revaluation falls in the year its date does.
44
+ * - **A member serving the whole year** is valued in service at its end.
45
+ * The year the member leaves in closes on the leaving date instead, at the
46
+ * deferred value with the leaver adjustment. Our reading: no source read
47
+ * here dates a leaver's closing value, and the leaving date is when their
48
+ * rights stop accruing.
49
+ * - **The period's `cpi`** is the September CPI before the year, from the
50
+ * same series: the Order's figure where the series reads published ones.
51
+ *
52
+ * A caller reads year after year, so the walks are kept per CPI and
53
+ * leaving: a walk reads the same balance on a date whatever happens after
54
+ * it, so one walked to its last year's end values every year before it.
55
+ */
56
+ export function inputPeriods(b, seriesAt) {
57
+ const kept = new Map();
58
+ return (end, choices, assumedCpi) => {
59
+ const basis = choices.remedy.kind;
60
+ const leaving = isoToDate(choices.leaving);
61
+ refuseLeavingAfterDeclared(ASKED, b, leaving);
62
+ refuseElectionMismatch(ASKED, b.remedy, basis);
63
+ refuseBeforePensionInputPeriods(ASKED, end);
64
+ const closes = taxYearEndDate(end);
65
+ const key = `${String(assumedCpi)} ${choices.leaving}`;
66
+ const sofar = kept.get(key);
67
+ const walkedFarEnough = sofar !== undefined && closes <= sofar.reaches;
68
+ const walks = walkedFarEnough
69
+ ? sofar
70
+ : walksTo(b, seriesAt(assumedCpi), leaving, closes);
71
+ kept.set(key, walks);
72
+ return periodRead(b, basis, {
73
+ taxYearEnd: end,
74
+ // The close of the day before the year opens, 5 April.
75
+ opens: dayBefore(taxYearStartDate(end)),
76
+ closes,
77
+ left: leaving <= closes ? leaving : null,
78
+ walks,
79
+ });
80
+ };
81
+ }
82
+ /** The walks in `prices` for a member leaving on `leaving` that reach
83
+ * `closes`, and on to the pension age where that is later, so a caller
84
+ * reading year by year walks once. */
85
+ function walksTo(b, prices, leaving, closes) {
86
+ const reaches = closes < b.npaOn
87
+ ? taxYearEndDate(taxYearEndFor(b.npaOn))
88
+ : closes;
89
+ const dates = walkDates(b, leaving);
90
+ // The scheme year `reaches` falls in, whose revaluation a 5 April reads
91
+ // where the Order was applied on 1 April.
92
+ const through = schemeYearEndFor(reaches);
93
+ const window = b.legacy?.window ?? null;
94
+ return {
95
+ prices,
96
+ reaches,
97
+ own: {
98
+ ledger: accruedLedger(b, {
99
+ window: b.ordinary2015, seed: seed2015(b), prices,
100
+ }, dates, through),
101
+ period: b.ordinary2015,
102
+ },
103
+ window: window === null
104
+ ? null
105
+ : {
106
+ ledger: accruedLedger(b, {
107
+ window, seed: windowSeed(window), prices,
108
+ }, dates, through),
109
+ period: window,
110
+ },
111
+ };
112
+ }
113
+ /** One tax year's period, read off the walks. */
114
+ function periodRead(b, basis, r) {
115
+ const arrangements = [];
116
+ if (b.legacy !== null) {
117
+ arrangements.push(legacyArrangement(b, b.legacy, basis, r));
118
+ }
119
+ const ownOpenedByClose = isoToDate(b.ordinary2015.from) <= r.closes;
120
+ if (ownOpenedByClose) {
121
+ arrangements.push(valuesOver((on) => ({
122
+ pension: potAt(r.walks.own, on), lumpSum: 0,
123
+ }), r));
124
+ }
125
+ // An Order is labelled by the scheme year that has just closed when it
126
+ // is applied, and its figure is the September CPI before the tax year.
127
+ const order = r.walks.prices.cpiFor(schemeYearClosedBy(r.opens));
128
+ return {
129
+ taxYearEnd: r.taxYearEnd, arrangements, cpi: pointsToDecimal(order.cpi),
130
+ };
131
+ }
132
+ /** The legacy section: its final-salary service, and on the 2015 basis
133
+ * the remedy window's career average pot beside it. */
134
+ function legacyArrangement(b, legacy, basis, r) {
135
+ const walked = walksWindow(basis);
136
+ const pot = walked ? r.walks.window : null;
137
+ // `inputPeriods` refused the 2015 basis for a member with no window,
138
+ // and the walks hold one wherever the member has it.
139
+ invariant(!walked || pot !== null, 'a 2015 basis with no remedy window walked');
140
+ const valued = finalSalaryValued(legacy, basis);
141
+ return valuesOver((on) => {
142
+ const finalSalary = finalSalaryHeldOn(b, valued, on, r.left);
143
+ const career = pot === null ? 0 : potAt(pot, on);
144
+ return {
145
+ pension: r.walks.prices.payAt(finalSalary.pension, on) + career,
146
+ lumpSum: r.walks.prices.payAt(finalSalary.automaticLumpSum, on),
147
+ };
148
+ }, r);
149
+ }
150
+ /** A career average pot on `on`: nothing before its period opens. */
151
+ function potAt({ ledger, period }, on) {
152
+ return isoToDate(period.from) > on ? 0 : ledger.accruedAt(on);
153
+ }
154
+ /** One arrangement's values at the period's two ends: its close is the
155
+ * leaving date in the year the member leaves, and the year's own end in
156
+ * every other. */
157
+ function valuesOver(heldAt, { opens, closes, left }) {
158
+ const leftInYear = left !== null && left > opens;
159
+ const opening = heldAt(opens);
160
+ const closing = heldAt(leftInYear ? left : closes);
161
+ return {
162
+ pensionOpening: opening.pension,
163
+ pensionClosing: closing.pension,
164
+ lumpSumOpening: opening.lumpSum,
165
+ lumpSumClosing: closing.lumpSum,
166
+ };
167
+ }
168
+ //# sourceMappingURL=input-period.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-period.js","sourceRoot":"","sources":["../../src/member/input-period.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,+BAA+B,EAAE,cAAc,EAAE,aAAa,EAC9D,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,SAAS,EAAC,MAAM,c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,SAAS,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC;AAED;;mBAEmB;AACnB,SAAS,UAAU,CACjB,MAAgC,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAU;IAEhE,MAAM,UAAU,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,GAAG,KAAK,CAAC;IACjD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,cAAc,EAAE,OAAO,CAAC,OAAO;KAChC,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { DeclaredPeriod, LegacySectionId, ServicePeriod } from './types.js';
1
+ import type { DeclaredPeriod, LegacySectionId, MemberBenefits, RemedyBasis, ServicePeriod } from './types.js';
2
2
  /** A legacy holding: its section, its own service, and the remedy window
3
3
  * held in it after that service where the member has one. */
4
4
  export interface LegacyHolding {
@@ -62,4 +62,11 @@ export declare function legacyPeriodsOf({ own, window }: LegacyHolding): Service
62
62
  /** The last day a period is valued to: its own end, or the leaving
63
63
  * date where that comes first or the period is still open. */
64
64
  export declare function until(p: ServicePeriod, leaving: Date): Date;
65
+ /** The elections a member may be valued on: both bases for a remedy
66
+ * member, `none` alone for anyone else. The one place that rule lives,
67
+ * read by `MemberBenefits.elections` and by the refusal below. */
68
+ export declare function electionsFor(remedy: boolean): readonly RemedyBasis[];
69
+ /** Refuse a remedy member with no election, or an election for anyone
70
+ * else: which basis applies is the caller's to say, never ours. */
71
+ export declare function refuseElectionMismatch(asked: keyof MemberBenefits, remedy: boolean, basis: RemedyBasis): void;
65
72
  export {};
@@ -6,7 +6,7 @@
6
6
  import { dayAfter, dayBefore } from '../dates.js';
7
7
  import { BenefitNotModelled, invariant, NOT_MODELLED } from '../errors.js';
8
8
  import { isoDate, isoDateOf, isoToDate } from '../iso-date.js';
9
- import { PERIOD_KINDS, SECTIONS } from './types.js';
9
+ import { PERIOD_KINDS, REMEDY_BASES, SECTIONS } from './types.js';
10
10
  /** The remedy period, 1 April 2015 to 31 March 2022, as PSPJOA 2022
11
11
  * s.1 defines it. The days either side are derived from it. */
12
12
  const REMEDY_FROM = isoDate('2015-04-01');
@@ -84,6 +84,23 @@ export function legacyPeriodsOf({ own, window }) {
84
84
  export function until(p, leaving) {
85
85
  return p.to === null || isoToDate(p.to) > leaving ? leaving : isoToDate(p.to);
86
86
  }
87
+ /** The elections a member may be valued on: both bases for a remedy
88
+ * member, `none` alone for anyone else. The one place that rule lives,
89
+ * read by `MemberBenefits.elections` and by the refusal below. */
90
+ export function electionsFor(remedy) {
91
+ return remedy
92
+ ? [REMEDY_BASES.legacy, REMEDY_BASES.section2015]
93
+ : [REMEDY_BASES.none];
94
+ }
95
+ /** Refuse a remedy member with no election, or an election for anyone
96
+ * else: which basis applies is the caller's to say, never ours. */
97
+ export function refuseElectionMismatch(asked, remedy, basis) {
98
+ if (electionsFor(remedy).includes(basis))
99
+ return;
100
+ throw new RangeError(remedy
101
+ ? `${asked}: a remedy member needs an election`
102
+ : `${asked}: an election for a member with no remediable service`);
103
+ }
87
104
  /** The declared periods in date order, each running into the next. */
88
105
  function contiguous(declared) {
89
106
  if (declared.length === 0) {
@@ -1 +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,C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5
  * and the owner in `benefits.ts` all read one definition.
6
6
  */
7
+ import type { PensionInputPeriod, TaxYearEnd } from '@casomoltd/paye-calc';
7
8
  import type { CashChoice, CommutationResult } from '../commutation.js';
8
- import type { FactorOutcome } from '../factor-basis.js';
9
+ import type { Factored, FactorOutcome } from '../factor-basis.js';
9
10
  import type { IsoDate } from '../iso-date.js';
10
11
  import type { MemberPay, PayPath } from '../pay-path.js';
11
12
  import type { ProjectionPoint } from '../pension/curve.js';
@@ -13,6 +14,7 @@ import type { EstimatedHistory } from '../pension/history.js';
13
14
  import type { MemberLedger } from '../pension/ledger.js';
14
15
  import type { ProjectionMoney } from '../pension/money.js';
15
16
  import type { Prices } from '../pension/prices.js';
17
+ import type { SchemeYearEnd } from '../pension/scheme-year.js';
16
18
  import type { FinalSalaryRules, PayMeasure } from '../sections/final-salary.js';
17
19
  /**
18
20
  * One scheme, the NHS Pension Scheme, in three sections. "Scheme" only
@@ -39,13 +41,40 @@ export interface Member {
39
41
  readonly dateOfBirth: IsoDate;
40
42
  readonly service: readonly DeclaredPeriod[];
41
43
  readonly pay: MemberPay;
42
- /** A 2015 Section balance read off an Annual Benefit Statement,
43
- * which seeds its ledger at the statement's date. Null where the
44
- * member gave none. */
45
- readonly statement: {
46
- readonly accruedPension: number;
47
- readonly asAt: IsoDate;
48
- } | null;
44
+ /** The 2015 Section balance off the member's Annual Benefit Statement;
45
+ * null where they gave none. */
46
+ readonly statement: StatementBalance | null;
47
+ }
48
+ /**
49
+ * A 2015 Section balance read off an Annual Benefit Statement, which seeds
50
+ * its ledger at the close of `yearEnd`.
51
+ *
52
+ * A scheme year rather than a date, because an Annual Benefit Statement is
53
+ * always as at 31 March, so a mid-year date cannot be stated. NHSBSA says
54
+ * so in the two pages `sources.ts` exports as `NHSBSA_STATEMENT_GUIDE` and
55
+ * `NHSBSA_ESTIMATE_GUIDE` (SA-63 and SA-64 in docs/source-archive.md). The
56
+ * Scottish and Northern Irish administrators say the same of theirs: SPPA's
57
+ * statement "estimates your pension benefits accrued up to the end of the
58
+ * most recent financial year" (SA-65), its practitioners' running "12 months
59
+ * in arrears", so to the end of the financial year before (SA-66); HSC's
60
+ * is "a snapshot of your pension benefits up to 31st March that year"
61
+ * (SA-67).
62
+ *
63
+ * Out of scope: a deferred member's statement valued at the date of
64
+ * leaving, which NHSBSA's estimate request also offers; a retirement
65
+ * estimate on any other date; and the projection to normal pension age an
66
+ * active member's statement shows from 2026, which is not the accrued
67
+ * balance and is never passed here. NHSBSA: "From 2026, if you're an
68
+ * active member in the 2015 Scheme" the figure "is a projection" (SA-68).
69
+ *
70
+ * Nothing is read before the statement: a read on an earlier date, or a
71
+ * leaving before it, throws `BeforeStatement`.
72
+ */
73
+ export interface StatementBalance {
74
+ readonly accruedPension: number;
75
+ /** The scheme year the statement runs to; its balance is at that
76
+ * year's 31 March. */
77
+ readonly yearEnd: SchemeYearEnd;
49
78
  }
50
79
  /** How the cash ruler reads the years behind the run date. */
51
80
  export declare const PAST_YEARS: {
@@ -114,6 +143,7 @@ export declare const ACCRUALS: {
114
143
  readonly finalSalary: "final-salary";
115
144
  readonly careerAverage: "career-average";
116
145
  };
146
+ export type Accrual = (typeof ACCRUALS)[keyof typeof ACCRUALS];
117
147
  /**
118
148
  * One section's benefit on one basis. A legacy section returns two
119
149
  * when its remedy window is valued on the 2015 basis: that part is
@@ -125,29 +155,18 @@ export interface Award {
125
155
  /** Where it is held and paid from. */
126
156
  readonly section: SectionId;
127
157
  readonly periods: readonly ServicePeriod[];
128
- /** The PENSION at the drawing before its factor: final salary as
129
- * measured, or the career average pot as revalued. */
130
- readonly beforeFactor: ProjectionMoney;
131
- /** After the factor: what is paid. */
132
- readonly pension: ProjectionMoney;
133
- /** Nil rather than absent where the rules pay none, so a caller
134
- * cannot forget to ask. */
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. */
144
- readonly factor: FactorOutcome;
145
- /** A career average award's year-by-year walk, in cash and in today's
146
- * money; null for final salary, which keeps no balance to walk. */
147
- readonly ledgers: {
148
- readonly cash: MemberLedger;
149
- readonly todaysMoney: MemberLedger;
150
- } | null;
158
+ /** The PENSION at the drawing: before its factor, final salary as
159
+ * measured or the career average pot as revalued; and after it. */
160
+ readonly pension: Factored;
161
+ /** The automatic lump sum at the drawing, on the same rulers: before its
162
+ * own factor it is the section's multiple of the pension before
163
+ * factor. Nil rather than absent where the rules pay none, as a career
164
+ * average award never does, so a caller cannot forget to ask; its
165
+ * factor is then null. */
166
+ readonly automaticLumpSum: Factored<FactorOutcome | null>;
167
+ /** A career average award's year-by-year walk; null for final salary,
168
+ * which keeps no balance to walk. */
169
+ readonly ledgers: RulerLedgers | null;
151
170
  readonly provenance: {
152
171
  readonly accrual: typeof ACCRUALS.finalSalary;
153
172
  readonly denominator: FinalSalaryRules['denominator'];
@@ -177,21 +196,30 @@ export interface Position {
177
196
  /** The price series the cash reading walked with, for converting an
178
197
  * outside figure — a cap, a target — into the same rulers. */
179
198
  readonly prices: Prices;
180
- /** The 2015 Section's ledger as the member reads it on a statement,
181
- * in cash; and the same walk in today's money. The same objects as
182
- * the 2015 Section award's own `ledgers`, named here because a
183
- * statement is read against this one section. */
184
- readonly ledger: MemberLedger;
185
- readonly todaysMoneyLedger: MemberLedger;
186
- /** The 2015 Section's years before a stated balance, estimated in
187
- * today's money; null where the member gave no statement, or joined
188
- * in its own year. Calibrated to land exactly on the stated
189
- * balance. */
199
+ /** The 2015 Section's own walk: a final-salary section keeps no
200
+ * year-by-year balance to walk. */
201
+ readonly section2015: Section2015Walk;
202
+ }
203
+ /** The 2015 Section's balance as `at()` walked it, read against a
204
+ * statement, which covers this one section. */
205
+ export interface Section2015Walk {
206
+ /** The walk as the member reads it on a statement, in cash, and the
207
+ * same walk in today's money: the same objects as the 2015 Section
208
+ * award's own `ledgers`. */
209
+ readonly ledgers: RulerLedgers;
210
+ /** The years before a stated balance, estimated in today's money; null
211
+ * where the member gave no statement, or joined in its own year.
212
+ * Calibrated to land exactly on the stated balance. */
190
213
  readonly estimatedHistory: EstimatedHistory | null;
191
- /** The 2015 Section's balance at each scheme year end, both
192
- * rulers. */
214
+ /** The balance at each scheme year end, both rulers. */
193
215
  readonly curve: readonly ProjectionPoint[];
194
216
  }
217
+ /** One career average walk on both rulers: in cash, and in today's
218
+ * money. */
219
+ export interface RulerLedgers {
220
+ readonly cash: MemberLedger;
221
+ readonly todaysMoney: MemberLedger;
222
+ }
195
223
  /** A legacy section's rules, read from its statute. */
196
224
  export interface LegacyRules {
197
225
  readonly section: LegacySectionId;
@@ -224,11 +252,20 @@ export interface MemberBenefits {
224
252
  /** Whether they have a remedy window, and so must pass an election
225
253
  * to `at()`. */
226
254
  readonly remedy: boolean;
255
+ /** The McCloud elections this member is compared on, each one `at()`
256
+ * and `pensionInputPeriod` accept: both bases for a remedy member, in
257
+ * `REMEDY_BASES` order, and `none` alone otherwise. */
258
+ readonly elections: readonly RemedyBasis[];
227
259
  /** The legacy section they hold and its rules; null where they hold
228
260
  * the 2015 Section alone. */
229
261
  readonly legacy: LegacyRules | null;
230
262
  /** The pay every section reads, built once for the member. */
231
263
  readonly payPath: PayPath;
264
+ /** The statement's 31 March, the first date the 2015 Section balance is
265
+ * answered on: a read before it, or a leaving before it, throws
266
+ * `BeforeStatement`, so a caller can check its own dates first. Null
267
+ * where the member gave no statement and every date is answered. */
268
+ readonly statementAnswersFrom: Date | null;
232
269
  /** The earliest age this member may draw every section they hold on
233
270
  * `drawing`, other than through ill health: the law's minimum pension
234
271
  * age on that day, or the protected age they keep. A 1995 Section age
@@ -241,9 +278,29 @@ export interface MemberBenefits {
241
278
  * `minimumPensionAgeOn(drawing)`. `at()` refuses a drawing this
242
279
  * refuses. */
243
280
  mayDrawOn(drawing: IsoDate): boolean;
244
- /** Worth today, before any drawing. */
281
+ /** Worth today, before any drawing: unreduced, with the remedy window on
282
+ * the legacy basis. A member who has left holds their deferred
283
+ * benefits, final pay measured at leaving. */
245
284
  now(): Holdings;
246
285
  /** Worth when drawn, for one set of choices. Throws RangeError for a
247
286
  * drawing before the member reaches `minimumPensionAgeOn(drawing)`. */
248
287
  at(choices: RetirementChoices): Position;
288
+ /**
289
+ * The pension input period for the tax year ending in `taxYearEnd` (2027
290
+ * for 2026-27; paye-calc's `taxYearEndFor` names the one a date falls in,
291
+ * and no scheme year passes for one), for a member leaving on
292
+ * `choices.leaving` on the McCloud election `choices.remedy`, both as
293
+ * `at()` takes them, for paye-calc's `definedBenefitInput`: each
294
+ * arrangement's pension and automatic lump sum at the year's start and
295
+ * end, before any early or late factor, in cash at `assumedCpi` (a
296
+ * decimal) on this member's reading of the past years, whatever CPI they
297
+ * were built at. The period carries `taxYearEnd` as its own, and its
298
+ * `cpi` is read from that series, so on published past years it is the
299
+ * Order's figure. The year the member
300
+ * leaves in closes on the leaving date, and every year after holds the
301
+ * deferred benefits. Throws RangeError for a year before 2016-17, a
302
+ * leaving after the one declared, or an election `at()` would refuse
303
+ * (docs/how-it-works.md#a-years-pension-input).
304
+ */
305
+ pensionInputPeriod(taxYearEnd: TaxYearEnd, choices: Pick<RetirementChoices, 'leaving' | 'remedy'>, assumedCpi: number): PensionInputPeriod;
249
306
  }
@@ -1 +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,yD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