@casomoltd/nhs-pay 0.30.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 (77) hide show
  1. package/README.md +69 -251
  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/document-source.d.ts +16 -0
  6. package/dist/document-source.js +3 -1
  7. package/dist/document-source.js.map +1 -1
  8. package/dist/errors.d.ts +46 -11
  9. package/dist/errors.js +68 -28
  10. package/dist/errors.js.map +1 -1
  11. package/dist/factor-basis.d.ts +14 -0
  12. package/dist/factor-basis.js.map +1 -1
  13. package/dist/index.d.ts +13 -11
  14. package/dist/index.js +6 -5
  15. package/dist/index.js.map +1 -1
  16. package/dist/member/benefits.js +18 -11
  17. package/dist/member/benefits.js.map +1 -1
  18. package/dist/member/index.d.ts +1 -1
  19. package/dist/member/input-period.d.ts +4 -4
  20. package/dist/member/input-period.js +11 -9
  21. package/dist/member/input-period.js.map +1 -1
  22. package/dist/member/service.d.ts +4 -0
  23. package/dist/member/service.js +9 -3
  24. package/dist/member/service.js.map +1 -1
  25. package/dist/member/types.d.ts +81 -49
  26. package/dist/member/types.js.map +1 -1
  27. package/dist/member/valuation.d.ts +10 -8
  28. package/dist/member/valuation.js +17 -21
  29. package/dist/member/valuation.js.map +1 -1
  30. package/dist/pay-path.d.ts +21 -25
  31. package/dist/pay-path.js +85 -67
  32. package/dist/pay-path.js.map +1 -1
  33. package/dist/pension/ages.d.ts +6 -4
  34. package/dist/pension/ages.js +6 -4
  35. package/dist/pension/ages.js.map +1 -1
  36. package/dist/pension/curve.d.ts +2 -1
  37. package/dist/pension/curve.js +15 -7
  38. package/dist/pension/curve.js.map +1 -1
  39. package/dist/pension/history.d.ts +18 -3
  40. package/dist/pension/history.js +12 -5
  41. package/dist/pension/history.js.map +1 -1
  42. package/dist/pension/ledger.d.ts +15 -9
  43. package/dist/pension/ledger.js +91 -56
  44. package/dist/pension/ledger.js.map +1 -1
  45. package/dist/pension/prices.d.ts +11 -2
  46. package/dist/pension/prices.js +35 -14
  47. package/dist/pension/prices.js.map +1 -1
  48. package/dist/pension/scheme-year.d.ts +59 -0
  49. package/dist/pension/scheme-year.js +80 -0
  50. package/dist/pension/scheme-year.js.map +1 -0
  51. package/dist/pension/seed.d.ts +66 -50
  52. package/dist/pension/seed.js +111 -65
  53. package/dist/pension/seed.js.map +1 -1
  54. package/dist/pension/uplift.d.ts +13 -33
  55. package/dist/pension/uplift.js +11 -56
  56. package/dist/pension/uplift.js.map +1 -1
  57. package/dist/pension-projection.js +30 -22
  58. package/dist/pension-projection.js.map +1 -1
  59. package/dist/post.d.ts +1 -10
  60. package/dist/post.js +1 -12
  61. package/dist/post.js.map +1 -1
  62. package/dist/revaluation.d.ts +34 -35
  63. package/dist/revaluation.js +41 -41
  64. package/dist/revaluation.js.map +1 -1
  65. package/dist/scale-point.d.ts +6 -0
  66. package/dist/sections/final-salary.d.ts +3 -8
  67. package/dist/sections/final-salary.js +13 -9
  68. package/dist/sections/final-salary.js.map +1 -1
  69. package/dist/sections/section-2015.d.ts +2 -1
  70. package/dist/sections/section-2015.js.map +1 -1
  71. package/dist/sources.d.ts +10 -0
  72. package/dist/sources.js +20 -0
  73. package/dist/sources.js.map +1 -1
  74. package/dist/take-home.d.ts +4 -20
  75. package/dist/take-home.js +3 -23
  76. package/dist/take-home.js.map +1 -1
  77. package/package.json +3 -3
@@ -19,10 +19,16 @@
19
19
  * source on every call, never stored, and every row is frozen at
20
20
  * construction.
21
21
  */
22
- import { invariant } from '../errors.js';
22
+ import { uplift } from '@casomoltd/paye-calc';
23
+ import { BeforeStatement, invariant, STATEMENT_READS } from '../errors.js';
23
24
  import { dayAfter, monthsCountingPart, MONTHS_PER_YEAR } from '../dates.js';
25
+ import { pointsToDecimal } from './prices.js';
24
26
  import { openingUpliftFor, phaseAt, upliftsFor } from './uplift.js';
25
- import { firstWalkedYear, schemeYearEndDate, schemeYearEndFor, schemeYearStartDate, } from './seed.js';
27
+ import { schemeYearAfter, schemeYearBefore, schemeYearEndDate, schemeYearEndFor, schemeYearStartDate, } from './scheme-year.js';
28
+ import { answersFrom, firstWalkedYear } from './seed.js';
29
+ /** The 2015 Section's accrual denominator: a year's pension is its
30
+ * pensionable pay over 54. */
31
+ const ACCRUAL_DENOMINATOR = 54;
26
32
  /**
27
33
  * 1/54 of pensionable pay, the 2015 CARE accrual rate — NHSBSA
28
34
  * 2015 Members' Guide (V13) p.6.
@@ -31,7 +37,7 @@ import { firstWalkedYear, schemeYearEndDate, schemeYearEndFor, schemeYearStartDa
31
37
  * slice and every figure a consumer reads come from one constant
32
38
  * rather than a literal here and a name somewhere else.
33
39
  */
34
- export const ACCRUAL_RATE = 1 / 54;
40
+ export const ACCRUAL_RATE = 1 / ACCRUAL_DENOMINATOR;
35
41
  /** What a ledger row's earnings rest on beyond a pay path's own bases:
36
42
  * one flat figure the caller assumed, or nothing earned. */
37
43
  const LEDGER_BASES = {
@@ -47,12 +53,15 @@ export function flatPay(pay) {
47
53
  }
48
54
  export function buildLedger(req) {
49
55
  const { seed, exitDate, retirementDate, through } = req;
56
+ // Refused here, where every walk is built, rather than by each caller:
57
+ // a leaving before the seed's close is never walked.
58
+ refuseBeforeStatement(seed, exitDate, STATEMENT_READS.leaving);
50
59
  const exitYear = schemeYearEndFor(exitDate);
51
60
  const retireYear = schemeYearEndFor(retirementDate);
52
61
  const first = firstWalkedYear(seed);
53
62
  const years = [];
54
63
  let opening = seed.opening;
55
- for (let year = first; year <= through; year++) {
64
+ for (let year = first; year <= through; year = schemeYearAfter(year)) {
56
65
  const row = rowFor({
57
66
  year,
58
67
  opening,
@@ -62,7 +71,7 @@ export function buildLedger(req) {
62
71
  begins inside the first walked year — never off which
63
72
  route produced it, which the seed's own doc forbids
64
73
  anything downstream from asking. */
65
- isFirst: years.length === 0 && seed.accruingFrom !== null,
74
+ opensMembership: years.length === 0 && seed.accruingFrom !== null,
66
75
  req, first, exitYear, retireYear,
67
76
  });
68
77
  years.push(row);
@@ -109,7 +118,7 @@ function monthsServedIn(year, req, first) {
109
118
  return monthsCountingPart(from, dayAfter(req.exitDate));
110
119
  }
111
120
  if (joinedThisYear !== null) {
112
- return monthsCountingPart(joinedThisYear, schemeYearStartDate(year + 1));
121
+ return monthsCountingPart(joinedThisYear, schemeYearStartDate(schemeYearAfter(year)));
113
122
  }
114
123
  return MONTHS_PER_YEAR;
115
124
  }
@@ -125,65 +134,81 @@ function payFor({ year, prices, annualPay, months, }) {
125
134
  const whole = prices.payAt(annualPay, schemeYearEndDate(year));
126
135
  return (whole * months) / MONTHS_PER_YEAR;
127
136
  }
137
+ /** `amount` grown by a rate in percentage points. */
138
+ function grownBy(amount, points) {
139
+ return uplift(amount, pointsToDecimal(points));
140
+ }
128
141
  /** One row: revalue the pot, add the year's slice, then apply
129
142
  * the retirement transform if this is the year it falls in. */
130
143
  function rowFor(ctx) {
131
- const { year, opening, req, exitYear, retireYear } = ctx;
132
- const { prices } = req;
133
- const phase = phaseAt(year, exitYear, retireYear);
144
+ const { year, opening, req } = ctx;
145
+ const phase = phaseAt(year, ctx.exitYear, ctx.retireYear);
146
+ const uplift = upliftOpening(ctx);
147
+ const revalued = grownBy(opening, uplift?.percent ?? 0);
148
+ const monthsServed = monthsServedIn(year, req, ctx.first);
149
+ const earnings = earningsIn(ctx, phase, monthsServed);
150
+ const leaverAdjustment = leaverAdjustmentIn(ctx, monthsServed);
151
+ const accrued = grownBy(revalued + earnings.earned, leaverAdjustment?.percent ?? 0);
152
+ const drawing = year === ctx.retireYear ? req.drawingFor() : null;
153
+ return Object.freeze({
154
+ schemeYearEnd: year,
155
+ phase,
156
+ pensionableEarnings: earnings.pensionableEarnings,
157
+ earned: earnings.earned,
158
+ earningsBasis: basisOf(earnings),
159
+ opening,
160
+ uplift: frozenOrNull(uplift),
161
+ revalued,
162
+ leaverAdjustment: frozenOrNull(leaverAdjustment),
163
+ accrued,
164
+ drawing: frozenOrNull(drawing),
165
+ closing: accrued * (drawing?.factor ?? 1),
166
+ });
167
+ }
168
+ /** The uplift opening a row's year; null on the first row of a walk
169
+ * that opens the membership. */
170
+ function upliftOpening({ opensMembership, year, req }) {
134
171
  /* The rate is `openingUpliftFor`'s answer, never assembled
135
172
  here: the seed inverts this exact step, and the two must ask
136
173
  one function rather than each name the phase, the year and
137
174
  the series for themselves. */
138
- const uplift = ctx.isFirst
175
+ return opensMembership
139
176
  ? null
140
- : openingUpliftFor(year - 1, req.exitDate, req.retirementDate, prices);
141
- const revalued = uplift === null
142
- ? opening
143
- : opening * (1 + uplift.percent / 100);
144
- const monthsServed = monthsServedIn(year, req, ctx.first);
145
- const given = phase === 'active'
146
- ? req.payIn(year)
177
+ : openingUpliftFor(schemeYearBefore(year), req.exitDate, req.retirementDate, req.prices);
178
+ }
179
+ /** The leaver index adjustment on the row the member leaves in; null on
180
+ * every other. */
181
+ function leaverAdjustmentIn({ year, exitYear, req }, monthsServed) {
182
+ return year === exitYear
183
+ ? leaverAdjustmentFor(year, req.prices, req.exitDate, monthsServed)
147
184
  : null;
185
+ }
186
+ /** A row's part, frozen, so it cannot be rewritten through the row. */
187
+ function frozenOrNull(part) {
188
+ return part === null ? null : Object.freeze(part);
189
+ }
190
+ /** A year's pensionable pay and its slice: pay only while active. */
191
+ function earningsIn({ year, req }, phase, months) {
192
+ const given = phase === 'active' ? req.payIn(year) : null;
148
193
  const pensionableEarnings = given === null
149
194
  ? null
150
- : payFor({ year, prices, annualPay: given.pay, months: monthsServed });
151
- const earned = pensionableEarnings === null
152
- ? 0
153
- : pensionableEarnings * ACCRUAL_RATE;
154
- const leftThisYear = year === exitYear;
155
- const leaverAdjustment = leftThisYear
156
- ? leaverAdjustmentFor(year, prices, req.exitDate, monthsServed)
157
- : null;
158
- const accrued = (revalued + earned)
159
- * (1 + (leaverAdjustment?.percent ?? 0) / 100);
160
- const drawing = year === retireYear
161
- ? req.drawingFor()
162
- : null;
163
- const factor = drawing?.factor ?? 1;
195
+ : payFor({ year, prices: req.prices, annualPay: given.pay, months });
164
196
  // The one nonsense the shape still permits. An invariant
165
197
  // rather than three row subtypes: nothing about a row's
166
198
  // BEHAVIOUR differs by phase, so there is nothing to dispatch
167
199
  // and subtypes would override nothing.
168
200
  invariant(phase === 'active' || pensionableEarnings === null, `${phase} year ${year} carries pensionable earnings`);
169
- return Object.freeze({
170
- schemeYearEnd: year,
171
- phase,
201
+ return {
202
+ given,
172
203
  pensionableEarnings,
173
- earned,
174
- earningsBasis: earned === 0 || given === null
175
- ? LEDGER_BASES.none
176
- : given.basis,
177
- opening,
178
- uplift: uplift === null ? null : Object.freeze(uplift),
179
- revalued,
180
- leaverAdjustment: leaverAdjustment === null
181
- ? null
182
- : Object.freeze(leaverAdjustment),
183
- accrued,
184
- drawing: drawing === null ? null : Object.freeze(drawing),
185
- closing: accrued * factor,
186
- });
204
+ earned: pensionableEarnings === null
205
+ ? 0
206
+ : pensionableEarnings * ACCRUAL_RATE,
207
+ };
208
+ }
209
+ /** What a row's earnings rest on: nothing, where nothing was earned. */
210
+ function basisOf({ given, earned }) {
211
+ return earned === 0 || given === null ? LEDGER_BASES.none : given.basis;
187
212
  }
188
213
  /**
189
214
  * The leaver index adjustment for the year the member leaves in
@@ -215,6 +240,16 @@ function settlementOf(row) {
215
240
  const upliftOn = row.uplift?.appliedOn;
216
241
  return upliftOn !== undefined && upliftOn > leftOn ? upliftOn : leftOn;
217
242
  }
243
+ /** Refuse `read` on `date` where it falls before a statement's 31 March,
244
+ * which gives no balance there: the one estimate of those years is
245
+ * `estimateHistory`'s, never this walk's. A seed that answers before
246
+ * itself refuses nothing. */
247
+ function refuseBeforeStatement(seed, date, read) {
248
+ const from = answersFrom(seed);
249
+ const beforeStatement = from !== null && date < from;
250
+ if (beforeStatement)
251
+ throw new BeforeStatement(read, date, from);
252
+ }
218
253
  /**
219
254
  * The read side, over rows already walked.
220
255
  *
@@ -227,15 +262,14 @@ function readerOver(frozen, seed) {
227
262
  * the year its seed sits at. */
228
263
  const startsAt = schemeYearEndDate(seed.atSchemeYearEnd);
229
264
  /**
230
- * Asked about a date BEFORE the ledger begins, answer at the
231
- * beginning instead — the balance is the seed's, and the seed
232
- * is a figure at a stated date.
233
- *
234
- * So a date before the seed reads the seed's own year end, and
235
- * an earlier leaving date cannot read higher off the same
236
- * statement than a later one.
265
+ * Asked about a date BEFORE the ledger begins, a walk that
266
+ * opens the membership answers at its beginning, where it held
267
+ * nothing; a statement's walk refuses, per the seed.
237
268
  */
238
- const answerableAt = (date) => date < startsAt ? startsAt : date;
269
+ const answerableAt = (date) => {
270
+ refuseBeforeStatement(seed, date, STATEMENT_READS.balance);
271
+ return date < startsAt ? startsAt : date;
272
+ };
239
273
  /** Replay the steps up to `date`. `preDrawing` reads the row
240
274
  * carrying the retirement event at its pre-factor value. A row
241
275
  * the member leaves in settles on the last day of service, not
@@ -259,6 +293,7 @@ function readerOver(frozen, seed) {
259
293
  accruedAt: (date) => walkTo(answerableAt(date), true),
260
294
  closingAt(schemeYearEnd) {
261
295
  if (schemeYearEnd <= seed.atSchemeYearEnd) {
296
+ refuseBeforeStatement(seed, schemeYearEndDate(schemeYearEnd), STATEMENT_READS.yearClose);
262
297
  return seed.opening;
263
298
  }
264
299
  const row = frozen.find((r) => r.schemeYearEnd === schemeYearEnd);
@@ -1 +1 @@
1
- {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/pension/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAQ1E,OAAO,EAAC,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAElE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AA6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AAE,iBAAiB,CAAC,aAAa,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;gBACrE,OAAO,IAAI,CAAC,OAAO,CAAC;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"}
@@ -36,10 +36,11 @@
36
36
  * in the money it was written for. Beyond the published record
37
37
  * it is the assumption, as above.
38
38
  */
39
+ import type { SchemeYearEnd } from './scheme-year.js';
39
40
  /** One year of the September CPI series, and where it came from. */
40
41
  export interface CpiEntry {
41
42
  /** Scheme year END, e.g. 2016 for the 2015/16 year. */
42
- readonly schemeYearEnd: number;
43
+ readonly schemeYearEnd: SchemeYearEnd;
43
44
  /** Percentage points. Negative is legal: September 2015 was
44
45
  * -0.1, which is the scheme's very first uplift. */
45
46
  readonly cpi: number;
@@ -57,7 +58,7 @@ export interface CpiEntry {
57
58
  * CHOICE rather than a table and a condition — WHICH series
58
59
  * stays the caller's question and never the rule's. A projection
59
60
  * makes that choice exactly once, in `openingUpliftFor`. */
60
- export type CpiSource = (schemeYearEnd: number) => CpiEntry;
61
+ export type CpiSource = (schemeYearEnd: SchemeYearEnd) => CpiEntry;
61
62
  /** The CPI a projection revalues at, and the money readings
62
63
  * that follow from it. The published record itself is
63
64
  * `revaluation.ts`'s: a series here reads it through
@@ -110,6 +111,14 @@ export interface Prices {
110
111
  /** The CPI a today's-money run assumes, as a decimal: none, so every
111
112
  * figure is read in the money of the run date. */
112
113
  export declare const TODAYS_MONEY_CPI = 0;
114
+ /**
115
+ * A CPI or revaluation rate in percentage points as a decimal: 3.8 points
116
+ * is 0.038. A `CpiEntry`, an Order and every rate a ledger row carries are
117
+ * in points, as the Orders print them; an assumption, a growth factor and
118
+ * paye-calc's `cpi` are decimals. Every crossing of a CPI-derived rate
119
+ * between the two goes through here or {@link decimalToPoints}.
120
+ */
121
+ export declare function pointsToDecimal(points: number): number;
113
122
  /**
114
123
  * How much more a pound of `asAt` money is than a pound of
115
124
  * `from` money, under the caller's assumption.
@@ -38,9 +38,27 @@
38
38
  */
39
39
  import { invariant } from '../errors.js';
40
40
  import { appliedOnFor, IN_SERVICE_REVALUATION, revaluationFor, } from '../revaluation.js';
41
+ import { schemeYearEnd } from './scheme-year.js';
41
42
  /** The CPI a today's-money run assumes, as a decimal: none, so every
42
43
  * figure is read in the money of the run date. */
43
44
  export const TODAYS_MONEY_CPI = 0;
45
+ /** Percentage points in one unit of a decimal rate. */
46
+ const POINTS_PER_UNIT = 100;
47
+ /**
48
+ * A CPI or revaluation rate in percentage points as a decimal: 3.8 points
49
+ * is 0.038. A `CpiEntry`, an Order and every rate a ledger row carries are
50
+ * in points, as the Orders print them; an assumption, a growth factor and
51
+ * paye-calc's `cpi` are decimals. Every crossing of a CPI-derived rate
52
+ * between the two goes through here or {@link decimalToPoints}.
53
+ */
54
+ export function pointsToDecimal(points) {
55
+ return points / POINTS_PER_UNIT;
56
+ }
57
+ /** A decimal rate in percentage points: 0.02 is 2 points. The inverse of
58
+ * {@link pointsToDecimal}. */
59
+ function decimalToPoints(decimal) {
60
+ return decimal * POINTS_PER_UNIT;
61
+ }
44
62
  /**
45
63
  * How much more a pound of `asAt` money is than a pound of
46
64
  * `from` money, under the caller's assumption.
@@ -74,7 +92,9 @@ export function inflationFactor(asAt, from, assumedCpi) {
74
92
  function aprilsBetween(from, to) {
75
93
  let count = 0;
76
94
  for (let year = from.getFullYear(); year <= to.getFullYear(); year++) {
77
- const applied = appliedOnFor(year);
95
+ // The Order labelled by the scheme year ending in `year` is applied
96
+ // in that year's April.
97
+ const applied = appliedOnFor(schemeYearEnd(year));
78
98
  if (applied > from && applied <= to)
79
99
  count += 1;
80
100
  }
@@ -91,7 +111,7 @@ function aprilsBetween(from, to) {
91
111
  * date the module needs.
92
112
  */
93
113
  export function createPrices(assumedCpi, asOf) {
94
- const assumedPct = assumedCpi * 100;
114
+ const assumedPct = decimalToPoints(assumedCpi);
95
115
  const valueAt = (amount, from, to) => amount * inflationFactor(to, from, assumedCpi);
96
116
  return {
97
117
  /* Frozen at the mint. A `CpiEntry` is the provenance a
@@ -133,7 +153,7 @@ export function createPrices(assumedCpi, asOf) {
133
153
  */
134
154
  export function createPublishedPrices(assumedCpi, asOf) {
135
155
  const assumed = createPrices(assumedCpi, asOf);
136
- const cpiFor = (schemeYearEnd) => publishedCpiFor(schemeYearEnd, assumedCpi * 100);
156
+ const cpiFor = (year) => publishedCpiFor(year, decimalToPoints(assumedCpi));
137
157
  return {
138
158
  ...assumed,
139
159
  cpiFor,
@@ -146,25 +166,25 @@ export function createPublishedPrices(assumedCpi, asOf) {
146
166
  * record ends. A year before the scheme's first Order, or a gap
147
167
  * inside the record, has no honest answer and is refused.
148
168
  */
149
- function publishedCpiFor(schemeYearEnd, assumedPct) {
150
- const order = revaluationFor(schemeYearEnd);
169
+ function publishedCpiFor(year, assumedPct) {
170
+ const order = revaluationFor(year);
151
171
  if (order !== null) {
152
172
  return Object.freeze({
153
- schemeYearEnd, cpi: order.septemberCpiPct, si: order.si,
173
+ schemeYearEnd: year, cpi: order.septemberCpiPct, si: order.si,
154
174
  });
155
175
  }
156
- const first = IN_SERVICE_REVALUATION[0];
176
+ const first = IN_SERVICE_REVALUATION.at(0);
157
177
  const last = IN_SERVICE_REVALUATION.at(-1);
158
178
  invariant(first !== undefined && last !== undefined, 'the Revaluation Order table is empty');
159
- if (schemeYearEnd < first.yearEnd) {
160
- throw new Error(`No Revaluation Order for ${schemeYearEnd}: `
179
+ if (year < first.yearEnd) {
180
+ throw new Error(`No Revaluation Order for ${year}: `
161
181
  + `the scheme's first is ${first.si}, for ${first.yearEnd}`);
162
182
  }
163
- if (schemeYearEnd <= last.yearEnd) {
183
+ if (year <= last.yearEnd) {
164
184
  throw new Error(`No Revaluation Order recorded for `
165
- + `${schemeYearEnd}, inside the published record`);
185
+ + `${year}, inside the published record`);
166
186
  }
167
- return Object.freeze({ schemeYearEnd, cpi: assumedPct, si: null });
187
+ return Object.freeze({ schemeYearEnd: year, cpi: assumedPct, si: null });
168
188
  }
169
189
  /**
170
190
  * How much more a pound of `to` money is than a pound of `from`
@@ -176,9 +196,10 @@ function pricesBetween(from, to, cpiFor) {
176
196
  const [lo, hi] = ahead ? [from, to] : [to, from];
177
197
  let factor = 1;
178
198
  for (let year = lo.getFullYear(); year <= hi.getFullYear(); year++) {
179
- const applied = appliedOnFor(year);
199
+ const labelled = schemeYearEnd(year);
200
+ const applied = appliedOnFor(labelled);
180
201
  if (applied > lo && applied <= hi) {
181
- factor *= 1 + cpiFor(year).cpi / 100;
202
+ factor *= 1 + pointsToDecimal(cpiFor(labelled).cpi);
182
203
  }
183
204
  }
184
205
  return ahead ? factor : 1 / factor;
@@ -1 +1 @@
1
- {"version":3,"file":"prices.js","sourceRoot":"","sources":["../../src/pension/prices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,mBAAmB,CAAC;AA4E3B;mDACmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAU,EACV,IAAU,EACV,UAAkB;IAElB,MAAM,KAAK,GAAG,IAAI,IAAI,IAAI,CAAC;IAC3B,MAA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I,IAAI,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;QACnE,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,OAAO,GAAG,EAAE,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;YAClC,MAAM,IAAI,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AACrC,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The scheme year: the NHS Pension Scheme's own 1 April to 31 March cycle,
3
+ * the one an Annual Benefit Statement closes on and a ledger walks.
4
+ *
5
+ * Named by the calendar year its 31 March falls in, as paye-calc's
6
+ * `taxYearEnd.ts` names a tax year by its 5 April. Imports nothing, so
7
+ * every module that dates a pension can read it without a cycle.
8
+ */
9
+ declare const SCHEME_YEAR_END: unique symbol;
10
+ /**
11
+ * A scheme year, named by the calendar year its 31 March falls in: 2026
12
+ * means 1 April 2025 to 31 March 2026.
13
+ *
14
+ * Branded because the number has a twin: paye-calc's `TaxYearEnd` names a
15
+ * tax year by the year its 5 April falls in, a bare number of the same
16
+ * size, and passing one for the other moves every date by five days. Each
17
+ * brand makes the other a compile error. A `SchemeYearEnd` comes only from
18
+ * {@link schemeYearEnd} or a function here that returns one; arithmetic on
19
+ * one gives a plain number, which is minted again to be used as one.
20
+ */
21
+ export type SchemeYearEnd = number & {
22
+ readonly [SCHEME_YEAR_END]: 'scheme-year-end';
23
+ };
24
+ /** Read `year` as the calendar year a scheme year ends in — the only way
25
+ * to mint a {@link SchemeYearEnd} from a number. Throws RangeError for a
26
+ * year that is not a whole four-digit year. */
27
+ export declare function schemeYearEnd(year: number): SchemeYearEnd;
28
+ /** The scheme year after `year`. */
29
+ export declare function schemeYearAfter(year: SchemeYearEnd): SchemeYearEnd;
30
+ /** The scheme year before `year`. */
31
+ export declare function schemeYearBefore(year: SchemeYearEnd): SchemeYearEnd;
32
+ /**
33
+ * The scheme year a date falls in, named by the year it ENDS.
34
+ *
35
+ * The cycle is the scheme's own — 1 April to 31 March — and it
36
+ * is the same one an Annual Benefit Statement closes on: a
37
+ * statement marked *Updated To 31/03/2025* reports scheme year
38
+ * 2025, so its figure seeds that row's close untouched. 1 Apr
39
+ * 2025 and 31 Mar 2026 are both scheme year 2026.
40
+ */
41
+ export declare function schemeYearEndFor(date: Date): SchemeYearEnd;
42
+ /** 31 March of the given scheme year. */
43
+ export declare function schemeYearEndDate(year: SchemeYearEnd): Date;
44
+ /** 1 April opening the given scheme year. */
45
+ export declare function schemeYearStartDate(year: SchemeYearEnd): Date;
46
+ /** Whether `date` is a 31 March, the close of the scheme year it falls
47
+ * in and the date an Annual Benefit Statement runs to. */
48
+ export declare function isSchemeYearEnd(date: Date): boolean;
49
+ /**
50
+ * The scheme year that had already CLOSED by `date` — the year
51
+ * a balance stated on that date belongs to.
52
+ *
53
+ * Taking the day after makes 31 March land on the year it ends
54
+ * rather than the one before it. Shared with the caller that
55
+ * picks the real-terms anchor, which has to know the seed's year
56
+ * BEFORE a `Prices` exists to build the seed with.
57
+ */
58
+ export declare function schemeYearClosedBy(date: Date): SchemeYearEnd;
59
+ export {};
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The scheme year: the NHS Pension Scheme's own 1 April to 31 March cycle,
3
+ * the one an Annual Benefit Statement closes on and a ledger walks.
4
+ *
5
+ * Named by the calendar year its 31 March falls in, as paye-calc's
6
+ * `taxYearEnd.ts` names a tax year by its 5 April. Imports nothing, so
7
+ * every module that dates a pension can read it without a cycle.
8
+ */
9
+ /** The month a scheme year ends in, as `Date` counts months from nought:
10
+ * March. */
11
+ const MARCH_MONTH_INDEX = 2;
12
+ /** The month a scheme year opens in: April. */
13
+ const APRIL_MONTH_INDEX = 3;
14
+ /** The day of March a scheme year ends on. */
15
+ const LAST_DAY_OF_SCHEME_YEAR = 31;
16
+ /** The day of April a scheme year opens on. */
17
+ const FIRST_DAY_OF_SCHEME_YEAR = 1;
18
+ /** The years a mint accepts: four digits, since `Date` reads a year below
19
+ * 100 as one in the 1900s. */
20
+ const FIRST_YEAR = 1000;
21
+ const LAST_YEAR = 9999;
22
+ /** Read `year` as the calendar year a scheme year ends in — the only way
23
+ * to mint a {@link SchemeYearEnd} from a number. Throws RangeError for a
24
+ * year that is not a whole four-digit year. */
25
+ export function schemeYearEnd(year) {
26
+ if (!Number.isInteger(year) || year < FIRST_YEAR || year > LAST_YEAR) {
27
+ throw new RangeError(`schemeYearEnd: ${year} is not a whole four-digit year`);
28
+ }
29
+ return year;
30
+ }
31
+ /** The scheme year after `year`. */
32
+ export function schemeYearAfter(year) {
33
+ return schemeYearEnd(year + 1);
34
+ }
35
+ /** The scheme year before `year`. */
36
+ export function schemeYearBefore(year) {
37
+ return schemeYearEnd(year - 1);
38
+ }
39
+ /**
40
+ * The scheme year a date falls in, named by the year it ENDS.
41
+ *
42
+ * The cycle is the scheme's own — 1 April to 31 March — and it
43
+ * is the same one an Annual Benefit Statement closes on: a
44
+ * statement marked *Updated To 31/03/2025* reports scheme year
45
+ * 2025, so its figure seeds that row's close untouched. 1 Apr
46
+ * 2025 and 31 Mar 2026 are both scheme year 2026.
47
+ */
48
+ export function schemeYearEndFor(date) {
49
+ return schemeYearEnd(date.getMonth() >= APRIL_MONTH_INDEX
50
+ ? date.getFullYear() + 1
51
+ : date.getFullYear());
52
+ }
53
+ /** 31 March of the given scheme year. */
54
+ export function schemeYearEndDate(year) {
55
+ return new Date(year, MARCH_MONTH_INDEX, LAST_DAY_OF_SCHEME_YEAR);
56
+ }
57
+ /** 1 April opening the given scheme year. */
58
+ export function schemeYearStartDate(year) {
59
+ return new Date(year - 1, APRIL_MONTH_INDEX, FIRST_DAY_OF_SCHEME_YEAR);
60
+ }
61
+ /** Whether `date` is a 31 March, the close of the scheme year it falls
62
+ * in and the date an Annual Benefit Statement runs to. */
63
+ export function isSchemeYearEnd(date) {
64
+ return date.getMonth() === MARCH_MONTH_INDEX
65
+ && date.getDate() === LAST_DAY_OF_SCHEME_YEAR;
66
+ }
67
+ /**
68
+ * The scheme year that had already CLOSED by `date` — the year
69
+ * a balance stated on that date belongs to.
70
+ *
71
+ * Taking the day after makes 31 March land on the year it ends
72
+ * rather than the one before it. Shared with the caller that
73
+ * picks the real-terms anchor, which has to know the seed's year
74
+ * BEFORE a `Prices` exists to build the seed with.
75
+ */
76
+ export function schemeYearClosedBy(date) {
77
+ const dayAfter = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1);
78
+ return schemeYearBefore(schemeYearEndFor(dayAfter));
79
+ }
80
+ //# sourceMappingURL=scheme-year.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheme-year.js","sourceRoot":"","sources":["../../src/pension/scheme-year.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH;aACa;AACb,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,+CAA+C;AAC/C,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,8CAA8C;AAC9C,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,+CAA+C;AAC/C,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC;+BAC+B;AAC/B,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB;;gDAEgD;AAChD,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,UAAU,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;QACrE,MAAM,IAAI,UAAU,CAClB,kBAAkB,IAAI,iCAAiC,CAAC,CAAC;I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