@casomoltd/nhs-pay 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/additional-pension.js +56 -32
- package/dist/additional-pension.js.map +1 -1
- package/dist/dates.d.ts +2 -0
- package/dist/dates.js +17 -3
- package/dist/dates.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/iso-date.d.ts +4 -9
- package/dist/iso-date.js +10 -11
- package/dist/iso-date.js.map +1 -1
- package/dist/member/benefits.d.ts +11 -0
- package/dist/member/benefits.js +179 -0
- package/dist/member/benefits.js.map +1 -0
- package/dist/member/index.d.ts +9 -0
- package/dist/member/index.js +9 -0
- package/dist/member/index.js.map +1 -0
- package/dist/member/service.d.ts +65 -0
- package/dist/member/service.js +166 -0
- package/dist/member/service.js.map +1 -0
- package/dist/{member-benefits.d.ts → member/types.d.ts} +30 -41
- package/dist/member/types.js +46 -0
- package/dist/member/types.js.map +1 -0
- package/dist/member/valuation.d.ts +67 -0
- package/dist/member/valuation.js +157 -0
- package/dist/member/valuation.js.map +1 -0
- package/dist/pension/ages.d.ts +64 -31
- package/dist/pension/ages.js +66 -38
- package/dist/pension/ages.js.map +1 -1
- package/dist/sources.d.ts +13 -1
- package/dist/sources.js +25 -1
- package/dist/sources.js.map +1 -1
- package/package.json +3 -3
- package/dist/member-benefits.js +0 -462
- package/dist/member-benefits.js.map +0 -1
|
@@ -59,27 +59,21 @@ export const ADDITIONAL_PENSION_PAYMENTS = {
|
|
|
59
59
|
/** Monthly, from pay, for whole years ending before the pension age. */
|
|
60
60
|
instalments: 'instalments',
|
|
61
61
|
};
|
|
62
|
+
/** Pence in a pound, as a price is rounded to. The same figure and
|
|
63
|
+
* rounding as `@casomoltd/paye-calc`'s money module, held here because
|
|
64
|
+
* the paye-calc release this library builds against does not export
|
|
65
|
+
* them; import them from paye-calc once a release that does is the
|
|
66
|
+
* floor of its peer range. */
|
|
67
|
+
const PENCE_PER_POUND = 100;
|
|
62
68
|
/** Every instalment table. Looked up by the pension age and cover each
|
|
63
69
|
* carries, so a table can be found only by what it says it is. */
|
|
64
70
|
const INSTALMENT_TABLES = [
|
|
65
71
|
AP_0_712, AP_0_713, AP_0_714, AP_0_715,
|
|
66
72
|
AP_0_716, AP_0_717, AP_0_718, AP_0_719,
|
|
67
73
|
];
|
|
68
|
-
/** The first day both the tables and the limit hold for
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
: ADDITIONAL_PENSION_LIMIT.from;
|
|
72
|
-
const refuse = (code, detail) => {
|
|
73
|
-
throw new AdditionalPensionUnavailable(ADDITIONAL_PENSION_REFUSALS[code], detail);
|
|
74
|
-
};
|
|
75
|
-
const roundToPenny = (pounds) => Math.round(pounds * 100) / 100;
|
|
76
|
-
/** The factor at an age and column, or the refusal naming what is
|
|
77
|
-
* missing. */
|
|
78
|
-
function priceAt(rows, firstAge, age, read, what) {
|
|
79
|
-
const row = rows[age - firstAge];
|
|
80
|
-
const value = row === undefined ? undefined : read(row);
|
|
81
|
-
return value ?? refuse('outsideTable', `${what} prints no price at age ${age}`);
|
|
82
|
-
}
|
|
74
|
+
/** The first day both the tables and the limit hold for, compared as
|
|
75
|
+
* dates (see `isoToDate`). */
|
|
76
|
+
const PRICED_FROM = new Date(Math.max(isoToDate(AP_0_703.provenance.implemented).getTime(), isoToDate(ADDITIONAL_PENSION_LIMIT.from).getTime()));
|
|
83
77
|
/**
|
|
84
78
|
* The price of buying `annual` a year of additional pension, as a lump
|
|
85
79
|
* sum or monthly instalments, read from GAD's tables at the member's age
|
|
@@ -93,25 +87,16 @@ function priceAt(rows, firstAge, age, read, what) {
|
|
|
93
87
|
*/
|
|
94
88
|
export function additionalPensionCost(input) {
|
|
95
89
|
const { annual, cover, payment, election, dateOfBirth } = input;
|
|
96
|
-
|
|
97
|
-
if (!wholeUnits) {
|
|
98
|
-
refuse('offUnit', `additional pension is bought in £`
|
|
99
|
-
+ `${ADDITIONAL_PENSION_UNIT} units, not £${annual}`);
|
|
100
|
-
}
|
|
101
|
-
if (annual > ADDITIONAL_PENSION_LIMIT.annual) {
|
|
102
|
-
refuse('overLimit', `£${annual} a year is over the `
|
|
103
|
-
+ `£${ADDITIONAL_PENSION_LIMIT.annual} limit`);
|
|
104
|
-
}
|
|
105
|
-
const outsidePricedDates = election < isoToDate(PRICED_FROM)
|
|
106
|
-
|| election >= isoToDate(ADDITIONAL_PENSION_LIMIT.until);
|
|
107
|
-
if (outsidePricedDates) {
|
|
108
|
-
refuse('outsideDates', `no tables and limit for an election on `
|
|
109
|
-
+ election.toDateString());
|
|
110
|
-
}
|
|
90
|
+
refuseUnpriced(annual, election);
|
|
111
91
|
const units = annual / ADDITIONAL_PENSION_UNIT;
|
|
112
92
|
const age = periodInYearsMonths(dateOfBirth, election).years;
|
|
113
93
|
if (payment.kind === ADDITIONAL_PENSION_PAYMENTS.lumpSum) {
|
|
114
|
-
const factor = priceAt(
|
|
94
|
+
const factor = priceAt({
|
|
95
|
+
rows: AP_0_703.rows,
|
|
96
|
+
firstAge: AP_0_703.firstAge,
|
|
97
|
+
read: (row) => row[cover],
|
|
98
|
+
what: 'Table 0-703',
|
|
99
|
+
}, age);
|
|
115
100
|
return { annual, cover, payment, cost: roundToPenny(units * factor),
|
|
116
101
|
table: AP_0_703.provenance };
|
|
117
102
|
}
|
|
@@ -119,7 +104,12 @@ export function additionalPensionCost(input) {
|
|
|
119
104
|
const npa = normalPensionAge(dateOfBirth);
|
|
120
105
|
const table = INSTALMENT_TABLES.find((t) => t.npa === npa && t.cover === cover);
|
|
121
106
|
invariant(table !== undefined, `no instalment table for a Normal Pension Age of ${npa}`);
|
|
122
|
-
const factor = priceAt(
|
|
107
|
+
const factor = priceAt({
|
|
108
|
+
rows: table.rows,
|
|
109
|
+
firstAge: table.firstAge,
|
|
110
|
+
read: (row) => row[payment.years - 1],
|
|
111
|
+
what: `Table ${table.provenance.tableRef} over ${payment.years} years`,
|
|
112
|
+
}, age);
|
|
123
113
|
return { annual, cover, payment, cost: roundToPenny(units * factor),
|
|
124
114
|
table: table.provenance };
|
|
125
115
|
}
|
|
@@ -160,4 +150,38 @@ export function additionalPensionToBuy(input) {
|
|
|
160
150
|
}
|
|
161
151
|
return annual;
|
|
162
152
|
}
|
|
153
|
+
/** Refuse a purchase no table prices: an amount off the unit or over the
|
|
154
|
+
* limit, or an election outside the dates the tables and limit hold for. */
|
|
155
|
+
function refuseUnpriced(annual, election) {
|
|
156
|
+
const wholeUnits = annual > 0 && annual % ADDITIONAL_PENSION_UNIT === 0;
|
|
157
|
+
if (!wholeUnits) {
|
|
158
|
+
refuse('offUnit', `additional pension is bought in £`
|
|
159
|
+
+ `${ADDITIONAL_PENSION_UNIT} units, not £${annual}`);
|
|
160
|
+
}
|
|
161
|
+
if (annual > ADDITIONAL_PENSION_LIMIT.annual) {
|
|
162
|
+
refuse('overLimit', `£${annual} a year is over the `
|
|
163
|
+
+ `£${ADDITIONAL_PENSION_LIMIT.annual} limit`);
|
|
164
|
+
}
|
|
165
|
+
const outsidePricedDates = election < PRICED_FROM
|
|
166
|
+
|| election >= isoToDate(ADDITIONAL_PENSION_LIMIT.until);
|
|
167
|
+
if (outsidePricedDates) {
|
|
168
|
+
refuse('outsideDates', `no tables and limit for an election on `
|
|
169
|
+
+ election.toDateString());
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** The factor at an age in a table's column, or the refusal naming what
|
|
173
|
+
* is missing. */
|
|
174
|
+
function priceAt({ rows, firstAge, read, what }, age) {
|
|
175
|
+
const row = rows[age - firstAge];
|
|
176
|
+
const value = row === undefined ? undefined : read(row);
|
|
177
|
+
return value ?? refuse('outsideTable', `${what} prints no price at age ${age}`);
|
|
178
|
+
}
|
|
179
|
+
/** Refuse a purchase with the code's reason and what was asked. */
|
|
180
|
+
function refuse(code, detail) {
|
|
181
|
+
throw new AdditionalPensionUnavailable(ADDITIONAL_PENSION_REFUSALS[code], detail);
|
|
182
|
+
}
|
|
183
|
+
/** An amount of pounds rounded to the nearest penny. */
|
|
184
|
+
function roundToPenny(pounds) {
|
|
185
|
+
return Math.round(pounds * PENCE_PER_POUND) / PENCE_PER_POUND;
|
|
186
|
+
}
|
|
163
187
|
//# sourceMappingURL=additional-pension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"additional-pension.js","sourceRoot":"","sources":["../src/additional-pension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,8CAA8C,CAAC;AAMtE,OAAO,EAAC,OAAO,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,iBAAiB,EAAC,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AI,MAAM,CAAC,cAAc,EAAE,GAAG,IAAI,2BAA2B,GAAG,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,mEAAmE;AACnE,SAAS,MAAM,CACb,IAA8C,EAC9C,MAAc;IAEd,MAAM,IAAI,4BAA4B,CAAC,2BAA2B,CAAC,IAAI,CAAC,EACtE,MAAM,CAAC,CAAC;AACZ,CAAC;AAED,wDAAwD;AACxD,SAAS,YAAY,CAAC,MAAc;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC,GAAG,eAAe,CAAC;AAChE,CAAC"}
|
package/dist/dates.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export declare function periodInYearsMonths(from: Date, to: Date): {
|
|
|
47
47
|
export declare function monthsCountingPart(from: Date, to: Date): number;
|
|
48
48
|
/** The day after `date`: the end of a last day, as a period's end. */
|
|
49
49
|
export declare function dayAfter(date: Date): Date;
|
|
50
|
+
/** The day before `date`, as the last day of what ends before it. */
|
|
51
|
+
export declare function dayBefore(date: Date): Date;
|
|
50
52
|
/** Fractional years between two dates, in 365.25-day years —
|
|
51
53
|
* for compounding, never for factor-table lookups (see the
|
|
52
54
|
* module header). */
|
package/dist/dates.js
CHANGED
|
@@ -25,8 +25,18 @@
|
|
|
25
25
|
import { invariant } from './errors.js';
|
|
26
26
|
/** Months in a year, and in a scheme year. */
|
|
27
27
|
export const MONTHS_PER_YEAR = 12;
|
|
28
|
-
const
|
|
29
|
-
const
|
|
28
|
+
const HOURS_PER_DAY = 24;
|
|
29
|
+
const MINUTES_PER_HOUR = 60;
|
|
30
|
+
const SECONDS_PER_MINUTE = 60;
|
|
31
|
+
const MS_PER_SECOND = 1000;
|
|
32
|
+
const MS_PER_DAY = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
33
|
+
/** The Julian year: the mean year over a leap cycle, so compounding over a
|
|
34
|
+
* span crossing 29 February neither gains nor loses a day. */
|
|
35
|
+
const DAYS_PER_YEAR = 365.25;
|
|
36
|
+
const MS_PER_YEAR = DAYS_PER_YEAR * MS_PER_DAY;
|
|
37
|
+
/** The most days a calendar month has, and so the most a period's days
|
|
38
|
+
* can count once its months are complete. */
|
|
39
|
+
const MOST_DAYS_IN_A_MONTH = 31;
|
|
30
40
|
/**
|
|
31
41
|
* Days a part month must reach to count as a whole one: SI 2015/94
|
|
32
42
|
* Sch 9 para 3(3) counts "an incomplete month that consists of at
|
|
@@ -67,7 +77,7 @@ export function periodInYearsMonths(from, to) {
|
|
|
67
77
|
const years = Math.floor(totalMonths / MONTHS_PER_YEAR);
|
|
68
78
|
const months = totalMonths % MONTHS_PER_YEAR;
|
|
69
79
|
invariant(years >= 0 && months >= 0 && months < MONTHS_PER_YEAR
|
|
70
|
-
&& days >= 0 && days <=
|
|
80
|
+
&& days >= 0 && days <= MOST_DAYS_IN_A_MONTH, `periodInYearsMonths produced an invalid period `
|
|
71
81
|
+ `${years}yr ${months}mo ${days}d for `
|
|
72
82
|
+ `${from.toISOString()} → ${to.toISOString()}`);
|
|
73
83
|
return { years, months, days };
|
|
@@ -88,6 +98,10 @@ export function monthsCountingPart(from, to) {
|
|
|
88
98
|
export function dayAfter(date) {
|
|
89
99
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1);
|
|
90
100
|
}
|
|
101
|
+
/** The day before `date`, as the last day of what ends before it. */
|
|
102
|
+
export function dayBefore(date) {
|
|
103
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1);
|
|
104
|
+
}
|
|
91
105
|
/** Fractional years between two dates, in 365.25-day years —
|
|
92
106
|
* for compounding, never for factor-table lookups (see the
|
|
93
107
|
* module header). */
|
package/dist/dates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.js","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAA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AAC,OAAO,EAAE,CAAC;IACZ,OAAO,IAAI,IAAI,CACb,IAAI,CAAC,WAAW,EAAE,EAClB,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAClC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export { DocumentSource } from './document-source.js';
|
|
|
25
25
|
export { isoDate, isoMonth, monthOf, firstOfMonth, monthToDate, isoToDate, isoDateOf, } from './iso-date.js';
|
|
26
26
|
export type { IsoDate, IsoMonth } from './iso-date.js';
|
|
27
27
|
export type { DocumentSourceFields, SourceCurrency, } from './document-source.js';
|
|
28
|
-
export { AFC_ENGLAND_SCALES_2025, AFC_ENGLAND_SCALES_2026, AFC_NI_2025, AFC_SCOTLAND, AFC_SCOTLAND_36_HOUR_WEEK, AFC_W_01_2026, AFC_W_02_2025, AFC_W_02_2026, AP_FACTSHEET_2026, DHSC_PETITION_779519, HSC_TC8_05_2025, MD_W_01_2025, MD_W_01_2026, PC_MD_1_2026_R2, PCS_DD_2025_01, PCS_DD_2025_01_ADDENDUM, PCS_DD_2026_01, PCS_DD_2026_02, } from './sources.js';
|
|
28
|
+
export { AFC_ENGLAND_SCALES_2025, AFC_ENGLAND_SCALES_2026, AFC_NI_2025, AFC_SCOTLAND, AFC_SCOTLAND_36_HOUR_WEEK, AFC_W_01_2026, AFC_W_02_2025, AFC_W_02_2026, AP_FACTSHEET_2026, DHSC_PETITION_779519, FA2004_SCH36_PARA_23ZB, SPPA_NHS_CIRCULAR_2025_09, HSC_TC8_05_2025, MD_W_01_2025, MD_W_01_2026, PC_MD_1_2026_R2, PCS_DD_2025_01, PCS_DD_2025_01_ADDENDUM, PCS_DD_2026_01, PCS_DD_2026_02, } from './sources.js';
|
|
29
29
|
export { AWARD_FAMILIES, afcAward, anyNationSettled, awardFamilyFor, awardsFor, changesFor, } from './award.js';
|
|
30
30
|
export type { AwardFamily, ForthcomingChange, PayAward, PayChange, PayScaleId, } from './award.js';
|
|
31
31
|
export { payRound } from './pay-round.js';
|
|
@@ -36,10 +36,10 @@ export { ACTIVE_REVAL_BONUS_PCT, IN_SERVICE_REVALUATION, revaluationFor, } from
|
|
|
36
36
|
export type { RevaluationYear } from './revaluation.js';
|
|
37
37
|
export { buildPayPath, PAY_BASES, promotionalIndex } from './pay-path.js';
|
|
38
38
|
export type { PayBasis, PayPath, YearPay } from './pay-path.js';
|
|
39
|
-
export { ACCRUALS, memberBenefits, PAST_YEARS, PERIOD_KINDS, REMEDY, REMEDY_BASES, SECTION_OPENED, SECTIONS, } from './member
|
|
39
|
+
export { ACCRUALS, memberBenefits, PAST_YEARS, PERIOD_KINDS, REMEDY, REMEDY_BASES, SECTION_OPENED, SECTIONS, } from './member/index.js';
|
|
40
40
|
export { PAY_MEASURES } from './sections/final-salary.js';
|
|
41
41
|
export type { PayMeasure } from './sections/final-salary.js';
|
|
42
|
-
export type { Assumptions, Award, DeclaredPeriod, Holdings, LegacyRules, LegacySectionId, Member, MemberBenefits, PastYears, Position, RemedyBasis, RemedyElection, RetirementChoices, SectionId, ServicePeriod, } from './member
|
|
42
|
+
export type { Assumptions, Award, DeclaredPeriod, Holdings, LegacyRules, LegacySectionId, Member, MemberBenefits, PastYears, Position, RemedyBasis, RemedyElection, RetirementChoices, SectionId, ServicePeriod, } from './member/index.js';
|
|
43
43
|
export type { DeclaredPay, MemberPay } from './pay-path.js';
|
|
44
44
|
export { FACTOR_APPLIES, FACTOR_SOURCES } from './factor-basis.js';
|
|
45
45
|
export type { Applies2015, FactorOutcome } from './factor-basis.js';
|
|
@@ -50,7 +50,8 @@ export { ACCRUAL_RATE, erf2015For, factorProvenance, projectPension, retirementF
|
|
|
50
50
|
export { COMMUTATION_FACTOR, HMRC_LUMP_SUM_CAP_PCT, LUMP_SUM_ALLOWANCE, LUMP_SUM_CAPS, nhsCommutationLimits, VALUATION_FACTOR, commute, } from './commutation.js';
|
|
51
51
|
export type { CommutationLimits, CommutationResult, DatedAmount, LumpSumCap, LumpSumLimit, LumpSumLimits, } from './commutation.js';
|
|
52
52
|
export type { FactorProvenance, FactorTableKind, GadTableProvenance, } from './gad/factor-table.js';
|
|
53
|
-
export { memberMinimumPensionAge, MPA_KEPT_AGE, MPA_RISE_JOINED_AFTER, normalPensionAge, } from './pension/ages.js';
|
|
53
|
+
export { firstJoinedOf, LEGACY_PENSION_AGES, mayDrawOn, memberMinimumPensionAge, MPA_KEPT_AGE, MPA_RISE_JOINED_AFTER, normalPensionAge, } from './pension/ages.js';
|
|
54
|
+
export type { JoiningHistory } from './pension/ages.js';
|
|
54
55
|
export type { PensionEstimationInput, PensionProjectionInput, PensionProjectionResult, PensionStatementInput, } from './pension-projection.js';
|
|
55
56
|
export type { ProjectionPoint } from './pension/curve.js';
|
|
56
57
|
export type { ProjectionMoney } from './pension/money.js';
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export { ADDITIONAL_PENSION_REFUSALS, AdditionalPensionUnavailable, AmbiguousSca
|
|
|
20
20
|
// keeping its own copy of the url.
|
|
21
21
|
export { DocumentSource } from './document-source.js';
|
|
22
22
|
export { isoDate, isoMonth, monthOf, firstOfMonth, monthToDate, isoToDate, isoDateOf, } from './iso-date.js';
|
|
23
|
-
export { AFC_ENGLAND_SCALES_2025, AFC_ENGLAND_SCALES_2026, AFC_NI_2025, AFC_SCOTLAND, AFC_SCOTLAND_36_HOUR_WEEK, AFC_W_01_2026, AFC_W_02_2025, AFC_W_02_2026, AP_FACTSHEET_2026, DHSC_PETITION_779519, HSC_TC8_05_2025, MD_W_01_2025, MD_W_01_2026, PC_MD_1_2026_R2, PCS_DD_2025_01, PCS_DD_2025_01_ADDENDUM, PCS_DD_2026_01, PCS_DD_2026_02, } from './sources.js';
|
|
23
|
+
export { AFC_ENGLAND_SCALES_2025, AFC_ENGLAND_SCALES_2026, AFC_NI_2025, AFC_SCOTLAND, AFC_SCOTLAND_36_HOUR_WEEK, AFC_W_01_2026, AFC_W_02_2025, AFC_W_02_2026, AP_FACTSHEET_2026, DHSC_PETITION_779519, FA2004_SCH36_PARA_23ZB, SPPA_NHS_CIRCULAR_2025_09, HSC_TC8_05_2025, MD_W_01_2025, MD_W_01_2026, PC_MD_1_2026_R2, PCS_DD_2025_01, PCS_DD_2025_01_ADDENDUM, PCS_DD_2026_01, PCS_DD_2026_02, } from './sources.js';
|
|
24
24
|
// ── Pay awards ───────────────────────────────────
|
|
25
25
|
export { AWARD_FAMILIES, afcAward, anyNationSettled, awardFamilyFor, awardsFor, changesFor, } from './award.js';
|
|
26
26
|
// ── Pay rounds ───────────────────────────────────
|
|
@@ -39,7 +39,7 @@ export { buildPayPath, PAY_BASES, promotionalIndex } from './pay-path.js';
|
|
|
39
39
|
// A member's benefits across every section they hold: built once from
|
|
40
40
|
// the member, asked once per set of retirement choices. The sections
|
|
41
41
|
// themselves are internal.
|
|
42
|
-
export { ACCRUALS, memberBenefits, PAST_YEARS, PERIOD_KINDS, REMEDY, REMEDY_BASES, SECTION_OPENED, SECTIONS, } from './member
|
|
42
|
+
export { ACCRUALS, memberBenefits, PAST_YEARS, PERIOD_KINDS, REMEDY, REMEDY_BASES, SECTION_OPENED, SECTIONS, } from './member/index.js';
|
|
43
43
|
export { PAY_MEASURES } from './sections/final-salary.js';
|
|
44
44
|
export { FACTOR_APPLIES, FACTOR_SOURCES } from './factor-basis.js';
|
|
45
45
|
export { factor2015 } from './sections/section-2015.js';
|
|
@@ -58,7 +58,7 @@ export { ACCRUAL_RATE, erf2015For, factorProvenance, projectPension, retirementF
|
|
|
58
58
|
// the projection calls into it.
|
|
59
59
|
export { COMMUTATION_FACTOR, HMRC_LUMP_SUM_CAP_PCT, LUMP_SUM_ALLOWANCE, LUMP_SUM_CAPS, nhsCommutationLimits, VALUATION_FACTOR, commute, } from './commutation.js';
|
|
60
60
|
// ── Pension ages ─────────────────────────────────────
|
|
61
|
-
export { memberMinimumPensionAge, MPA_KEPT_AGE, MPA_RISE_JOINED_AFTER, normalPensionAge, } from './pension/ages.js';
|
|
61
|
+
export { firstJoinedOf, LEGACY_PENSION_AGES, mayDrawOn, memberMinimumPensionAge, MPA_KEPT_AGE, MPA_RISE_JOINED_AFTER, normalPensionAge, } from './pension/ages.js';
|
|
62
62
|
// ── The pension ledger ───────────────────────────────
|
|
63
63
|
// A consumer reads the ledger only when it wants the workings.
|
|
64
64
|
export { createPrices, createPublishedPrices, inflationFactor, TODAYS_MONEY_CPI, } from './pension/prices.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,eAAe,GAChB,MAAM,aAAa,CAAC;AASrB,oDAAoD;AACpD,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,cAAc,CAAC;AAUtB,oDAAoD;AACpD,OAAO,EAAC,IAAI,EAAE,cAAc,EAAC,MAAM,WAAW,CAAC;AAU/C,OAAO,EAAC,WAAW,EAAE,cAAc,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAS3E,oDAAoD;AACpD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAK5B,oDAAoD;AACpD,OAAO,EACL,wBAAwB,EACxB,2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AAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAUhD,oDAAoD;AACpD,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,WAAW,EACX,YAAY,GACb,MAAM,WAAW,CAAC;AAGnB,oDAAoD;AACpD,OAAO,EACL,WAAW,EACX,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAGxB,oDAAoD;AACpD,OAAO,EACL,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,cAAc,CAAC;AAMtB,oDAAoD;AACpD,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC;AAMpB,oDAAoD;AACpD,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE/D,iDAAiD;AACjD,OAAO,EAAC,cAAc,EAAE,cAAc,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/E,oDAAoD;AACpD,OAAO,EACL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,oDAAoD;AACpD,mDAAmD;AACnD,qDAAqD;AACrD,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC"}
|
package/dist/iso-date.d.ts
CHANGED
|
@@ -10,15 +10,10 @@
|
|
|
10
10
|
* right one is the worst failure this data has, so the type system
|
|
11
11
|
* carries the distinction.
|
|
12
12
|
*
|
|
13
|
-
* Lives here rather than in `@casomoltd/paye-calc
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* it
|
|
17
|
-
*
|
|
18
|
-
* The concrete cost of NOT having this, before it existed: a consumer
|
|
19
|
-
* bridged the two precisions by writing `` `${award.expectedInPay}-01` ``
|
|
20
|
-
* — a hand-rolled splice on a month field, in the same codebase whose
|
|
21
|
-
* production error log was carrying `RangeError: Invalid Date`.
|
|
13
|
+
* Lives here rather than in `@casomoltd/paye-calc` because these brands
|
|
14
|
+
* guard text entering this library: a member's declared dates arrive as
|
|
15
|
+
* JSON-safe strings. paye-calc takes no dates as text, only `Date` values
|
|
16
|
+
* a caller builds, so it has no such boundary to guard.
|
|
22
17
|
*/
|
|
23
18
|
/** A 'YYYY-MM' month. Precision is part of the type. */
|
|
24
19
|
export type IsoMonth = string & {
|
package/dist/iso-date.js
CHANGED
|
@@ -10,15 +10,10 @@
|
|
|
10
10
|
* right one is the worst failure this data has, so the type system
|
|
11
11
|
* carries the distinction.
|
|
12
12
|
*
|
|
13
|
-
* Lives here rather than in `@casomoltd/paye-calc
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* it
|
|
17
|
-
*
|
|
18
|
-
* The concrete cost of NOT having this, before it existed: a consumer
|
|
19
|
-
* bridged the two precisions by writing `` `${award.expectedInPay}-01` ``
|
|
20
|
-
* — a hand-rolled splice on a month field, in the same codebase whose
|
|
21
|
-
* production error log was carrying `RangeError: Invalid Date`.
|
|
13
|
+
* Lives here rather than in `@casomoltd/paye-calc` because these brands
|
|
14
|
+
* guard text entering this library: a member's declared dates arrive as
|
|
15
|
+
* JSON-safe strings. paye-calc takes no dates as text, only `Date` values
|
|
16
|
+
* a caller builds, so it has no such boundary to guard.
|
|
22
17
|
*/
|
|
23
18
|
import { invariant } from './errors.js';
|
|
24
19
|
/**
|
|
@@ -43,13 +38,17 @@ export function isoDate(value) {
|
|
|
43
38
|
invariant(/^\d{4}-\d{2}-\d{2}$/.test(value), `not a 'YYYY-MM-DD' date: ${value}`);
|
|
44
39
|
return value;
|
|
45
40
|
}
|
|
41
|
+
/** The characters of 'YYYY-MM', the month at the head of an ISO date. */
|
|
42
|
+
const ISO_MONTH_LENGTH = 'YYYY-MM'.length;
|
|
43
|
+
/** The digits of an ISO date's month and day. */
|
|
44
|
+
const ISO_PART_DIGITS = 'MM'.length;
|
|
46
45
|
/**
|
|
47
46
|
* The month a date falls in. The ONE place a day is deliberately
|
|
48
47
|
* dropped, named so the loss shows at the call site instead of inside
|
|
49
48
|
* a `String.slice` nobody reads.
|
|
50
49
|
*/
|
|
51
50
|
export function monthOf(date) {
|
|
52
|
-
return isoMonth(date.slice(0,
|
|
51
|
+
return isoMonth(date.slice(0, ISO_MONTH_LENGTH));
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
54
|
* A month read as its first day.
|
|
@@ -101,7 +100,7 @@ export function isoToDate(iso) {
|
|
|
101
100
|
* before for any local midnight east of Greenwich in summer time.
|
|
102
101
|
*/
|
|
103
102
|
export function isoDateOf(date) {
|
|
104
|
-
const pad = (n) => String(n).padStart(
|
|
103
|
+
const pad = (n) => String(n).padStart(ISO_PART_DIGITS, '0');
|
|
105
104
|
return isoDate(`${date.getFullYear()}-${pad(date.getMonth() + 1)}-`
|
|
106
105
|
+ pad(date.getDate()));
|
|
107
106
|
}
|
package/dist/iso-date.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iso-date.js","sourceRoot":"","sources":["../src/iso-date.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"iso-date.js","sourceRoot":"","sources":["../src/iso-date.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAQtC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,SAAS,CACP,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAC3B,0BAA0B,KAAK,EAAE,CAClC,CAAC;IACF,OAAO,KAAiB,CAAC;AAC3B,CAAC;AAED;;;;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,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IACpE,OAAO,OAAO,CACZ,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG;UAClD,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Assumptions, Member, MemberBenefits } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build a member's benefits. Throws `PayPathUnavailable` where there
|
|
4
|
+
* is no current pay to build pay from, `BenefitNotModelled` for service
|
|
5
|
+
* the library does not model, and RangeError for a declaration that
|
|
6
|
+
* cannot be true.
|
|
7
|
+
*
|
|
8
|
+
* `today` is required because it decides which answer comes back: it
|
|
9
|
+
* is the date the figures are as at, so a figure reproduces as at it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function memberBenefits(member: Member, assumptions: Assumptions, today: Date): MemberBenefits;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A member's benefits across every section they hold: built once from
|
|
3
|
+
* what the member told us, then asked one question per set of
|
|
4
|
+
* retirement choices.
|
|
5
|
+
*
|
|
6
|
+
* Everything ABOUT the member goes in once, when the owner is built;
|
|
7
|
+
* each method takes only the question. So a caller never assembles the
|
|
8
|
+
* member again per option, and no section, pay path or ledger is a
|
|
9
|
+
* thing it has to build.
|
|
10
|
+
*
|
|
11
|
+
* Rules come in two tiers. Each section's own — denominator, pay
|
|
12
|
+
* measure, pension age, lump sum, factors — belong to that section;
|
|
13
|
+
* the ones a caller reads are the legacy section's, through
|
|
14
|
+
* `MemberBenefits.legacy`. The rules over the whole set live
|
|
15
|
+
* here: which sections a member holds and whether their service is
|
|
16
|
+
* eligible for the McCloud remedy, then, at the drawing, summing every
|
|
17
|
+
* award into one pension and one automatic lump sum and taking cash
|
|
18
|
+
* across that one total.
|
|
19
|
+
*
|
|
20
|
+
* Its parts sit beside it: the vocabulary in `types.ts`, the service
|
|
21
|
+
* check and the remedy's dates in `service.ts`, and each section's award
|
|
22
|
+
* in `valuation.ts`. This module owns the member; `index.ts` is the door
|
|
23
|
+
* a caller comes through.
|
|
24
|
+
*/
|
|
25
|
+
import { cashAt, nhsCommutationLimits } from '../commutation.js';
|
|
26
|
+
import { BenefitNotModelled, NOT_MODELLED } from '../errors.js';
|
|
27
|
+
import { isoToDate } from '../iso-date.js';
|
|
28
|
+
import { drawingTest, firstJoinedOf, mayDrawOn, memberMinimumPensionAge, normalPensionAge, } from '../pension/ages.js';
|
|
29
|
+
import { buildPayPath } from '../pay-path.js';
|
|
30
|
+
import { npaDate } from '../dates.js';
|
|
31
|
+
import { sumMoney } from '../pension/money.js';
|
|
32
|
+
import { createPrices, createPublishedPrices, TODAYS_MONEY_CPI, } from '../pension/prices.js';
|
|
33
|
+
import { seedFromJoinDate } from '../pension/seed.js';
|
|
34
|
+
import { legacyPeriodsOf, periodsOf, REMEDY, servicePeriods, } from './service.js';
|
|
35
|
+
import { careerAward, holdings, legacyAward, RULES, section2015, seed2015, } from './valuation.js';
|
|
36
|
+
import { PAST_YEARS, REMEDY_BASES, SECTIONS } from './types.js';
|
|
37
|
+
/** The price series each reading of the past is priced on. Total over
|
|
38
|
+
* `PastYears`, so a new reading fails the build until it has one. */
|
|
39
|
+
const CASH_SERIES = {
|
|
40
|
+
[PAST_YEARS.assumed]: createPrices,
|
|
41
|
+
[PAST_YEARS.published]: createPublishedPrices,
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Build a member's benefits. Throws `PayPathUnavailable` where there
|
|
45
|
+
* is no current pay to build pay from, `BenefitNotModelled` for service
|
|
46
|
+
* the library does not model, and RangeError for a declaration that
|
|
47
|
+
* cannot be true.
|
|
48
|
+
*
|
|
49
|
+
* `today` is required because it decides which answer comes back: it
|
|
50
|
+
* is the date the figures are as at, so a figure reproduces as at it.
|
|
51
|
+
*/
|
|
52
|
+
export function memberBenefits(member, assumptions, today) {
|
|
53
|
+
const held = servicePeriods(member.service);
|
|
54
|
+
const { legacy, ordinary2015 } = held;
|
|
55
|
+
const remedy = legacy !== null && legacy.window !== null;
|
|
56
|
+
refuseUnmodelled(member, remedy, legacy);
|
|
57
|
+
const born = isoToDate(member.dateOfBirth);
|
|
58
|
+
const history = {
|
|
59
|
+
born: member.dateOfBirth, firstJoined: firstJoinedOf(member),
|
|
60
|
+
};
|
|
61
|
+
const built = {
|
|
62
|
+
member,
|
|
63
|
+
history,
|
|
64
|
+
today,
|
|
65
|
+
born,
|
|
66
|
+
npaOn: npaDate(born, normalPensionAge(born)),
|
|
67
|
+
payPath: buildPayPath(member.dateOfBirth, member.pay),
|
|
68
|
+
legacy,
|
|
69
|
+
ordinary2015,
|
|
70
|
+
cashPrices: CASH_SERIES[assumptions.pastYears](assumptions.assumedCpi, today),
|
|
71
|
+
todaysPrices: createPrices(TODAYS_MONEY_CPI, today),
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
periods: periodsOf(held),
|
|
75
|
+
remedy,
|
|
76
|
+
legacy: legacy === null ? null : legacyOf(legacy.section),
|
|
77
|
+
payPath: built.payPath,
|
|
78
|
+
minimumPensionAgeOn: (drawing) => memberMinimumPensionAge(history, drawing),
|
|
79
|
+
mayDrawOn: (drawing) => mayDrawOn(history, drawing),
|
|
80
|
+
now: () => holdings(built),
|
|
81
|
+
at: (choices) => position(built, remedy, choices),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Every section's award at one set of choices, summed, with cash taken
|
|
85
|
+
* across the total. */
|
|
86
|
+
function position(b, remedy, choices) {
|
|
87
|
+
const dates = checked(b, remedy, choices);
|
|
88
|
+
const awards = b.legacy === null
|
|
89
|
+
? []
|
|
90
|
+
: legacyAwards(b, b.legacy, choices, dates);
|
|
91
|
+
const own = careerAward(b, {
|
|
92
|
+
section: SECTIONS.s2015,
|
|
93
|
+
window: b.ordinary2015,
|
|
94
|
+
seedFor: (prices) => seed2015(b, dates, prices),
|
|
95
|
+
}, dates);
|
|
96
|
+
awards.push(own.award);
|
|
97
|
+
const pension = sumMoney(awards.map((a) => a.pension), dates.drawing);
|
|
98
|
+
const automaticLumpSum = sumMoney(awards.map((a) => a.automaticLumpSum), dates.drawing);
|
|
99
|
+
return {
|
|
100
|
+
choices,
|
|
101
|
+
awards,
|
|
102
|
+
crystallised: { pension, automaticLumpSum },
|
|
103
|
+
cash: cashAt(pension, automaticLumpSum, choices.cash, nhsCommutationLimits(b.cashPrices)),
|
|
104
|
+
prices: b.cashPrices,
|
|
105
|
+
...section2015(b, own, dates),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** The legacy section's awards: on the legacy basis every legacy period
|
|
109
|
+
* is final salary; on the 2015 basis the remedy window leaves it for a
|
|
110
|
+
* career average walk, paid from the legacy section. */
|
|
111
|
+
function legacyAwards(b, legacy, choices, dates) {
|
|
112
|
+
const { own, window } = legacy;
|
|
113
|
+
// `checked` refused a 2015 basis for a member with no window.
|
|
114
|
+
const onThe2015Basis = choices.remedy.kind === REMEDY_BASES.section2015;
|
|
115
|
+
if (!onThe2015Basis || window === null) {
|
|
116
|
+
return [legacyAward(b, legacy, legacyPeriodsOf(legacy), dates)];
|
|
117
|
+
}
|
|
118
|
+
return [
|
|
119
|
+
legacyAward(b, legacy, [own], dates),
|
|
120
|
+
careerAward(b, {
|
|
121
|
+
section: legacy.section,
|
|
122
|
+
window,
|
|
123
|
+
seedFor: () => seedFromJoinDate(isoToDate(window.from)),
|
|
124
|
+
}, dates).award,
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
/** Refuse a member whose service the library does not yet value. */
|
|
128
|
+
function refuseUnmodelled(member, remedy, legacy) {
|
|
129
|
+
// Deferred until the split of a pre-rollback balance is read:
|
|
130
|
+
// https://github.com/casomoltd/nhs-pay/issues/20
|
|
131
|
+
if (remedy && member.statement !== null
|
|
132
|
+
&& isoToDate(member.statement.asAt) < isoToDate(REMEDY.rollback)) {
|
|
133
|
+
throw new BenefitNotModelled(NOT_MODELLED.statementBeforeRollback, 'a statement from before rollback on 1 October 2023, which '
|
|
134
|
+
+ 'counts the remedy years in the 2015 Section');
|
|
135
|
+
}
|
|
136
|
+
// Deferred until part-time final-salary membership is modelled:
|
|
137
|
+
// https://github.com/casomoltd/nhs-pay/issues/26
|
|
138
|
+
if (member.pay.partTime === true && legacy !== null) {
|
|
139
|
+
throw new BenefitNotModelled(NOT_MODELLED.partTimeLegacy, 'part-time pay with 1995 or 2008 Section service, which counts '
|
|
140
|
+
+ 'part-time membership pro rata on whole-time final pay');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** A legacy section's rules, as `MemberBenefits.legacy` states them. */
|
|
144
|
+
function legacyOf(section) {
|
|
145
|
+
const rules = RULES[section];
|
|
146
|
+
return {
|
|
147
|
+
section,
|
|
148
|
+
pensionAge: rules.pensionAge,
|
|
149
|
+
denominator: rules.denominator,
|
|
150
|
+
automaticLumpSum: rules.automaticLumpSum?.multiple ?? null,
|
|
151
|
+
lateUplift: rules.lateUplift,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** Refuse choices that cannot be valued, and return their dates. */
|
|
155
|
+
function checked(b, remedy, choices) {
|
|
156
|
+
const leaving = isoToDate(choices.leaving);
|
|
157
|
+
const drawing = isoToDate(choices.drawing);
|
|
158
|
+
if (drawing < leaving) {
|
|
159
|
+
throw new RangeError('at: drawn before leaving');
|
|
160
|
+
}
|
|
161
|
+
if (b.ordinary2015.to !== null && isoToDate(b.ordinary2015.to) < leaving) {
|
|
162
|
+
throw new RangeError(`at: leaving after the member already left, on ${b.ordinary2015.to}`);
|
|
163
|
+
}
|
|
164
|
+
const elects = choices.remedy.kind !== REMEDY_BASES.none;
|
|
165
|
+
const electionMismatch = remedy !== elects;
|
|
166
|
+
if (electionMismatch) {
|
|
167
|
+
throw new RangeError(remedy
|
|
168
|
+
? 'at: a remedy member needs an election'
|
|
169
|
+
: 'at: an election for a member with no remediable service');
|
|
170
|
+
}
|
|
171
|
+
// The scheme pays nothing before the minimum pension age outside ill
|
|
172
|
+
// health, so a figure there would be one no member could draw.
|
|
173
|
+
const { mayDraw, minimumAge } = drawingTest(b.history, choices.drawing);
|
|
174
|
+
if (!mayDraw) {
|
|
175
|
+
throw new RangeError(`at: drawn before the minimum pension age, ${minimumAge}`);
|
|
176
|
+
}
|
|
177
|
+
return { leaving, drawing };
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=benefits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benefits.js","sourceRoot":"","sources":["../../src/member/benefits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAC,MAAM,EAAE,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAC,kBAAkB,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,uBAAuB,EAC9D,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACL,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,GACtD,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GACnD,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,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AAO,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,OAAO,GAAG,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,UAAU,CAAC,0BAA0B,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC;QACzE,MAAM,IAAI,UAAU,CAClB,iDAAiD,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,CACrE,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC;IACzD,MAAM,gBAAgB,GAAG,MAAM,KAAK,MAAM,CAAC;IAC3C,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,IAAI,UAAU,CAAC,MAAM;YACzB,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,yDAAyD,CAAC,CAAC;IACjE,CAAC;IACD,qEAAqE;IACrE,+DAA+D;IAC/D,MAAM,EAAC,OAAO,EAAE,UAAU,EAAC,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACtE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,UAAU,CAClB,6CAA6C,UAAU,EAAE,CAC1D,CAAC;IACJ,CAAC;IACD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A member's benefits across every section they hold: the directory's
|
|
3
|
+
* door. `memberBenefits` builds them (`benefits.ts`); the vocabulary is
|
|
4
|
+
* `types.ts`'s, and the remedy's dates are `service.ts`'s.
|
|
5
|
+
*/
|
|
6
|
+
export { memberBenefits } from './benefits.js';
|
|
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';
|
|
9
|
+
export { REMEDY, SECTION_OPENED } from './service.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A member's benefits across every section they hold: the directory's
|
|
3
|
+
* door. `memberBenefits` builds them (`benefits.ts`); the vocabulary is
|
|
4
|
+
* `types.ts`'s, and the remedy's dates are `service.ts`'s.
|
|
5
|
+
*/
|
|
6
|
+
export { memberBenefits } from './benefits.js';
|
|
7
|
+
export { ACCRUALS, PAST_YEARS, PERIOD_KINDS, REMEDY_BASES, SECTIONS, } from './types.js';
|
|
8
|
+
export { REMEDY, SECTION_OPENED } from './service.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/member/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,GAC3D,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC"}
|