@casomoltd/nhs-pay 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -22
- package/dist/afc-scales.d.ts +43 -10
- package/dist/afc-scales.js +50 -16
- package/dist/afc-scales.js.map +1 -1
- package/dist/allowances.js +11 -11
- package/dist/allowances.js.map +1 -1
- package/dist/award.d.ts +3 -3
- package/dist/award.js +21 -21
- package/dist/award.js.map +1 -1
- package/dist/circulars/england-md-1-2026-r2.d.ts +13 -0
- package/dist/circulars/england-md-1-2026-r2.js +13 -0
- package/dist/circulars/england-md-1-2026-r2.js.map +1 -1
- package/dist/circulars/ni-hsc-tc8-05-2025.d.ts +22 -0
- package/dist/circulars/ni-hsc-tc8-05-2025.js +22 -0
- package/dist/circulars/ni-hsc-tc8-05-2025.js.map +1 -1
- package/dist/circulars/scotland-pcs-dd-2025-01.d.ts +20 -0
- package/dist/circulars/scotland-pcs-dd-2025-01.js +20 -0
- package/dist/circulars/scotland-pcs-dd-2025-01.js.map +1 -1
- package/dist/circulars/scotland-pcs-dd-2026-01.d.ts +19 -0
- package/dist/circulars/scotland-pcs-dd-2026-01.js +30 -10
- package/dist/circulars/scotland-pcs-dd-2026-01.js.map +1 -1
- package/dist/circulars/scotland-pcs-dd-2026-02.d.ts +10 -0
- package/dist/circulars/scotland-pcs-dd-2026-02.js +10 -0
- package/dist/circulars/scotland-pcs-dd-2026-02.js.map +1 -1
- package/dist/circulars/wales-mdw-01-2025.d.ts +17 -0
- package/dist/circulars/wales-mdw-01-2025.js +17 -0
- package/dist/circulars/wales-mdw-01-2025.js.map +1 -1
- package/dist/circulars/wales-mdw-01-2026.d.ts +20 -0
- package/dist/circulars/wales-mdw-01-2026.js +20 -0
- package/dist/circulars/wales-mdw-01-2026.js.map +1 -1
- package/dist/commutation.js +3 -2
- package/dist/commutation.js.map +1 -1
- package/dist/dental-grades.d.ts +25 -0
- package/dist/dental-grades.js +25 -0
- package/dist/dental-grades.js.map +1 -0
- package/dist/dental-scales.d.ts +5 -21
- package/dist/dental-scales.js +73 -72
- package/dist/dental-scales.js.map +1 -1
- package/dist/document-source.d.ts +32 -23
- package/dist/document-source.js +32 -10
- package/dist/document-source.js.map +1 -1
- package/dist/errors.d.ts +12 -1
- package/dist/errors.js +18 -1
- package/dist/errors.js.map +1 -1
- package/dist/factor-basis.d.ts +9 -3
- package/dist/factor-basis.js +40 -28
- package/dist/factor-basis.js.map +1 -1
- package/dist/format.js +3 -2
- package/dist/format.js.map +1 -1
- package/dist/hcas-pcts.d.ts +1 -1
- package/dist/hcas-zone.d.ts +23 -0
- package/dist/hcas-zone.js +17 -0
- package/dist/hcas-zone.js.map +1 -0
- package/dist/hcas.d.ts +26 -18
- package/dist/hcas.js +45 -24
- package/dist/hcas.js.map +1 -1
- package/dist/index.d.ts +27 -18
- package/dist/index.js +17 -13
- package/dist/index.js.map +1 -1
- package/dist/medical-grades.d.ts +33 -0
- package/dist/medical-grades.js +33 -0
- package/dist/medical-grades.js.map +1 -0
- package/dist/medical-scales.d.ts +10 -33
- package/dist/medical-scales.js +104 -158
- package/dist/medical-scales.js.map +1 -1
- package/dist/member/benefits.js +9 -4
- package/dist/member/benefits.js.map +1 -1
- package/dist/member/input-period.d.ts +18 -5
- package/dist/member/input-period.js +24 -13
- package/dist/member/input-period.js.map +1 -1
- package/dist/member/valuation.js +3 -6
- package/dist/member/valuation.js.map +1 -1
- package/dist/pay-round.js +3 -3
- package/dist/pay-round.js.map +1 -1
- package/dist/pay-year.d.ts +17 -0
- package/dist/pay-year.js +20 -0
- package/dist/pay-year.js.map +1 -0
- package/dist/pension/ledger.d.ts +7 -0
- package/dist/pension/ledger.js +26 -18
- package/dist/pension/ledger.js.map +1 -1
- package/dist/pension/money.d.ts +2 -0
- package/dist/pension/money.js +4 -0
- package/dist/pension/money.js.map +1 -1
- package/dist/pension/uplift.d.ts +25 -21
- package/dist/pension/uplift.js +27 -12
- package/dist/pension/uplift.js.map +1 -1
- package/dist/pension.js +2 -1
- package/dist/pension.js.map +1 -1
- package/dist/post.d.ts +20 -21
- package/dist/post.js +54 -53
- package/dist/post.js.map +1 -1
- package/dist/published/england-afc.d.ts +29 -0
- package/dist/published/england-afc.js +142 -0
- package/dist/published/england-afc.js.map +1 -0
- package/dist/published/hcas-zones.d.ts +18 -0
- package/dist/published/hcas-zones.js +46 -0
- package/dist/published/hcas-zones.js.map +1 -0
- package/dist/published/wales-living-wage.d.ts +36 -0
- package/dist/published/wales-living-wage.js +30 -0
- package/dist/published/wales-living-wage.js.map +1 -0
- package/dist/regions.d.ts +25 -14
- package/dist/regions.js +61 -71
- package/dist/regions.js.map +1 -1
- package/dist/resolver.d.ts +46 -41
- package/dist/resolver.js +70 -142
- package/dist/resolver.js.map +1 -1
- package/dist/revaluation.d.ts +27 -11
- package/dist/revaluation.js +46 -32
- package/dist/revaluation.js.map +1 -1
- package/dist/role.d.ts +3 -3
- package/dist/scale-point.d.ts +11 -7
- package/dist/scale-point.js +29 -1
- package/dist/scale-point.js.map +1 -1
- package/dist/scale-tables.d.ts +42 -60
- package/dist/scale-tables.js +65 -105
- package/dist/scale-tables.js.map +1 -1
- package/dist/scale-translators.d.ts +90 -0
- package/dist/scale-translators.js +97 -0
- package/dist/scale-translators.js.map +1 -0
- package/dist/scales.d.ts +138 -101
- package/dist/scales.js +221 -457
- package/dist/scales.js.map +1 -1
- package/dist/sections/final-salary.js +3 -11
- package/dist/sections/final-salary.js.map +1 -1
- package/dist/sections/section-2015.d.ts +1 -3
- package/dist/sections/section-2015.js +1 -1
- package/dist/sections/section-2015.js.map +1 -1
- package/dist/sources.d.ts +12 -12
- package/dist/sources.js +13 -15
- package/dist/sources.js.map +1 -1
- package/dist/take-home.js +1 -2
- package/dist/take-home.js.map +1 -1
- package/dist/values.d.ts +10 -3
- package/dist/values.js +11 -4
- package/dist/values.js.map +1 -1
- package/dist/working-week.d.ts +23 -8
- package/dist/working-week.js +55 -25
- package/dist/working-week.js.map +1 -1
- package/package.json +3 -3
- package/dist/bands.d.ts +0 -63
- package/dist/bands.js +0 -78
- package/dist/bands.js.map +0 -1
package/dist/dental-scales.js
CHANGED
|
@@ -11,121 +11,122 @@
|
|
|
11
11
|
*
|
|
12
12
|
* One canonical point per source row; no pay step collapsed.
|
|
13
13
|
*/
|
|
14
|
-
import { NATION_KEYS,
|
|
14
|
+
import { NATION_KEYS, YEAR_LABELS } from '@casomoltd/paye-calc';
|
|
15
15
|
import { 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';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { combineScales, fromDocument, gradeFamily, } from './scale-tables.js';
|
|
17
|
+
import { byCode, byStage, bySpine, numbered, salariesOfCode, scaleSalaries, stepped, } from './scale-translators.js';
|
|
18
|
+
import { invariant } from './errors.js';
|
|
19
|
+
import { DENTAL_GRADE_IDS } from './dental-grades.js';
|
|
20
|
+
import { ENGLAND_MD_1_2026_R2 as ENG, ENGLAND_MD_1_2026_R2_CODES as ENG_CODES, } from './circulars/england-md-1-2026-r2.js';
|
|
18
21
|
import { SCOTLAND_PCS_DD_2026_01 as SCO } from './circulars/scotland-pcs-dd-2026-01.js';
|
|
19
22
|
import { SCOTLAND_PCS_DD_2025_01 as SCO25 } from './circulars/scotland-pcs-dd-2025-01.js';
|
|
20
23
|
import { SCOTLAND_PCS_DD_2026_02 as SCO2 } from './circulars/scotland-pcs-dd-2026-02.js';
|
|
21
|
-
import { WALES_MDW_01_2025 as WAL } from './circulars/wales-mdw-01-2025.js';
|
|
22
|
-
import { WALES_MDW_01_2026 as WAL26 } from './circulars/wales-mdw-01-2026.js';
|
|
23
|
-
import { NI_HSC_TC8_05_2025 as NI } from './circulars/ni-hsc-tc8-05-2025.js';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
salariedDental: 'salaried-dental',
|
|
27
|
-
dentalCoreTraining: 'dental-core-training',
|
|
28
|
-
dentalSpecialtyTraining: 'dental-specialty-training',
|
|
29
|
-
dentalEducator: 'dental-educator',
|
|
30
|
-
salariedDentist: 'salaried-dentist',
|
|
31
|
-
seniorSalariedDentist: 'senior-salaried-dentist',
|
|
32
|
-
assistantClinicalDirectorDentist: 'assistant-clinical-director-dentist',
|
|
33
|
-
clinicalDirectorDentist: 'clinical-director-dentist',
|
|
34
|
-
communityDentalOfficer: 'community-dental-officer',
|
|
35
|
-
seniorCommunityDentalOfficer: 'senior-community-dental-officer',
|
|
36
|
-
assistantCommunityDentalClinicalDirector: 'assistant-community-dental-clinical-director',
|
|
37
|
-
specialistCommunityDentist: 'specialist-community-dentist',
|
|
38
|
-
communityDentalClinicalDirector: 'community-dental-clinical-director',
|
|
39
|
-
};
|
|
40
|
-
/** Ordered grade IDs — stable iteration/enumeration. */
|
|
41
|
-
export const DENTAL_GRADE_IDS = Object.values(DENTAL_GRADES);
|
|
42
|
-
// England §1 dentists in training: CT1-3 = core, ST1-8 = specialty.
|
|
24
|
+
import { WALES_MDW_01_2025 as WAL, WALES_MDW_01_2025_CODES as WAL_CODES, } from './circulars/wales-mdw-01-2025.js';
|
|
25
|
+
import { WALES_MDW_01_2026 as WAL26, WALES_MDW_01_2026_CODES as WAL26_CODES, } from './circulars/wales-mdw-01-2026.js';
|
|
26
|
+
import { NI_HSC_TC8_05_2025 as NI, NI_HSC_TC8_05_2025_CODES as NI_CODES, } from './circulars/ni-hsc-tc8-05-2025.js';
|
|
27
|
+
// England §1 dentists in training: CT1-3 = core, ST1-8 = specialty, told
|
|
28
|
+
// apart by the stage each row prints.
|
|
43
29
|
const engDentists = ENG.dentistsInTraining;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
/** The printed stage prefixes of the two kinds of dental training row. */
|
|
31
|
+
const TRAINING_STAGE = { core: 'CT', specialty: 'ST' };
|
|
32
|
+
const trainingRows = (prefix) => engDentists.filter((r) => r.stage.startsWith(prefix));
|
|
33
|
+
/** The bands Northern Ireland's salaried dental table numbers. */
|
|
34
|
+
const NI_DENTAL_BANDS = {
|
|
35
|
+
salaried: 1, senior: 2, assistantDirector: 3, clinicalDirector: 4,
|
|
36
|
+
};
|
|
37
|
+
/** The bands England's salaried dental spine is printed in. */
|
|
38
|
+
const SPINE_BANDS = { a: 'A', b: 'B', c: 'C' };
|
|
47
39
|
const LD_BAND = {
|
|
48
|
-
|
|
40
|
+
[ENG_CODES.salariedDentalBandA]: SPINE_BANDS.a,
|
|
41
|
+
[ENG_CODES.salariedDentalBandB]: SPINE_BANDS.b,
|
|
42
|
+
[ENG_CODES.salariedDentalBandC]: SPINE_BANDS.c,
|
|
49
43
|
};
|
|
44
|
+
const isSpineCode = (code) => Object.hasOwn(LD_BAND, code);
|
|
50
45
|
const ldBand = (code) => {
|
|
51
|
-
|
|
52
|
-
if (!band) {
|
|
46
|
+
if (!isSpineCode(code)) {
|
|
53
47
|
throw new Error(`dental-scales: unknown spine code "${code}"`);
|
|
54
48
|
}
|
|
55
|
-
return
|
|
49
|
+
return LD_BAND[code];
|
|
56
50
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
// Every training row is core or specialty training by its printed stage,
|
|
52
|
+
// so a row with another stage fails at load rather than going unread.
|
|
53
|
+
invariant(engDentists.every((r) => Object.values(TRAINING_STAGE)
|
|
54
|
+
.some((prefix) => r.stage.startsWith(prefix))), 'dental-scales: a dentists-in-training stage is neither core nor specialty');
|
|
55
|
+
// Both ways: every row's code is a band (`ldBand`), and every band's code
|
|
56
|
+
// is printed on some row, so a code the circular drops fails at load.
|
|
57
|
+
for (const code of Object.keys(LD_BAND)) {
|
|
58
|
+
invariant(ENG.salariedDentalSpine.some((r) => r.code === code), `dental-scales: England's dental spine prints no ${code} row`);
|
|
59
|
+
}
|
|
60
|
+
const england2026 = fromDocument(PC_MD_1_2026_R2, {
|
|
61
|
+
'salaried-dental': bySpine(ENG.salariedDentalSpine.map((r) => ({
|
|
62
|
+
band: ldBand(r.code), point: r.point, salary: r.salary,
|
|
63
|
+
}))),
|
|
64
|
+
'dental-core-training': byStage(trainingRows(TRAINING_STAGE.core)),
|
|
65
|
+
'dental-specialty-training': byStage(trainingRows(TRAINING_STAGE.specialty)),
|
|
64
66
|
'dental-educator': byCode(ENG.dentalEducators),
|
|
65
67
|
});
|
|
66
68
|
// The Public Dental Service spine comes from PCS(DD)2026/02 Annex G,
|
|
67
69
|
// uplifted 3.75% (its para 3) rather than the 3.5% the rest of that
|
|
68
70
|
// circular carries; dental core training from PCS(DD)2026/01.
|
|
69
|
-
const
|
|
71
|
+
const scotland2026 = combineScales(fromDocument(PCS_DD_2026_02, {
|
|
70
72
|
'salaried-dental': bySpine(SCO2.salariedDentalSpine),
|
|
71
73
|
}), fromDocument(PCS_DD_2026_01, {
|
|
72
|
-
'dental-core-training': [
|
|
73
|
-
{
|
|
74
|
-
label: SCO.dentalCoreTraining.stage,
|
|
75
|
-
salary: SCO.dentalCoreTraining.salary,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
74
|
+
'dental-core-training': byStage([SCO.dentalCoreTraining]),
|
|
78
75
|
}));
|
|
79
|
-
const
|
|
76
|
+
const wales2025 = fromDocument(MD_W_01_2025, {
|
|
80
77
|
'salaried-dental': bySpine(WAL.salariedDentalSpine),
|
|
81
|
-
'dental-core-training': stepped(
|
|
78
|
+
'dental-core-training': stepped(salariesOfCode(WAL.trainingGrades, WAL_CODES.dentalCoreTraining)),
|
|
82
79
|
});
|
|
83
|
-
const
|
|
84
|
-
'salaried-dentist':
|
|
85
|
-
'senior-salaried-dentist':
|
|
86
|
-
'assistant-clinical-director-dentist':
|
|
87
|
-
'clinical-director-dentist':
|
|
88
|
-
'dental-core-training': stepped(
|
|
89
|
-
'community-dental-officer': numbered(
|
|
90
|
-
'senior-community-dental-officer': numbered(
|
|
91
|
-
'assistant-community-dental-clinical-director': numbered(
|
|
92
|
-
'specialist-community-dentist': numbered(
|
|
93
|
-
'community-dental-clinical-director': numbered(
|
|
80
|
+
const northernIreland2025 = fromDocument(HSC_TC8_05_2025, {
|
|
81
|
+
'salaried-dentist': niDentalBand(NI_DENTAL_BANDS.salaried),
|
|
82
|
+
'senior-salaried-dentist': niDentalBand(NI_DENTAL_BANDS.senior),
|
|
83
|
+
'assistant-clinical-director-dentist': niDentalBand(NI_DENTAL_BANDS.assistantDirector),
|
|
84
|
+
'clinical-director-dentist': niDentalBand(NI_DENTAL_BANDS.clinicalDirector),
|
|
85
|
+
'dental-core-training': stepped(salariesOfCode(NI.residentGrades, NI_CODES.coreTraining)),
|
|
86
|
+
'community-dental-officer': numbered(salariesOfCode(NI.communityDentalService, NI_CODES.communityDentalOfficer)),
|
|
87
|
+
'senior-community-dental-officer': numbered(salariesOfCode(NI.communityDentalService, NI_CODES.seniorCommunityDentalOfficer)),
|
|
88
|
+
'assistant-community-dental-clinical-director': numbered(salariesOfCode(NI.communityDentalService, NI_CODES.assistantCommunityDentalClinicalDirector)),
|
|
89
|
+
'specialist-community-dentist': numbered(salariesOfCode(NI.communityDentalService, NI_CODES.specialistCommunityDentist)),
|
|
90
|
+
'community-dental-clinical-director': numbered(salariesOfCode(NI.communityDentalService, NI_CODES.communityDentalClinicalDirector)),
|
|
94
91
|
});
|
|
95
92
|
// Wales 2026/27 — salaried dental spine + dental core training, uplifted.
|
|
96
93
|
const wales2026 = fromDocument(MD_W_01_2026, {
|
|
97
94
|
'salaried-dental': bySpine(WAL26.salariedDentalSpine),
|
|
98
|
-
'dental-core-training': stepped(
|
|
95
|
+
'dental-core-training': stepped(salariesOfCode(WAL26.trainingGrades, WAL26_CODES.dentalCoreTraining)),
|
|
99
96
|
});
|
|
100
97
|
// Scotland 2025/26 — the Public Dental Service spine (Annex G) and dental
|
|
101
98
|
// core training (addendum).
|
|
102
99
|
const scotland2025 = combineScales(fromDocument(PCS_DD_2025_01, {
|
|
103
100
|
'salaried-dental': bySpine(SCO25.salariedDentalSpine),
|
|
104
101
|
}), fromDocument(PCS_DD_2025_01_ADDENDUM, {
|
|
105
|
-
'dental-core-training': [
|
|
106
|
-
{ label: SCO25.dentalCoreTraining.stage, salary: SCO25.dentalCoreTraining.salary },
|
|
107
|
-
],
|
|
102
|
+
'dental-core-training': byStage([SCO25.dentalCoreTraining]),
|
|
108
103
|
}));
|
|
109
104
|
const DENTAL_SCALES = {
|
|
110
|
-
[
|
|
111
|
-
[NATION_KEYS.england]:
|
|
112
|
-
[NATION_KEYS.scotland]:
|
|
105
|
+
[YEAR_LABELS.Y2026_27]: {
|
|
106
|
+
[NATION_KEYS.england]: england2026,
|
|
107
|
+
[NATION_KEYS.scotland]: scotland2026,
|
|
113
108
|
[NATION_KEYS.wales]: wales2026,
|
|
114
109
|
},
|
|
115
|
-
[
|
|
116
|
-
[NATION_KEYS.wales]:
|
|
117
|
-
[NATION_KEYS.northernIreland]:
|
|
110
|
+
[YEAR_LABELS.Y2025_26]: {
|
|
111
|
+
[NATION_KEYS.wales]: wales2025,
|
|
112
|
+
[NATION_KEYS.northernIreland]: northernIreland2025,
|
|
118
113
|
[NATION_KEYS.scotland]: scotland2025,
|
|
119
114
|
},
|
|
120
115
|
};
|
|
116
|
+
/** Every read over the dental tables. */
|
|
117
|
+
export const DENTAL_FAMILY = gradeFamily(DENTAL_SCALES, DENTAL_GRADE_IDS);
|
|
121
118
|
/** Pay years this family publishes, newest first (derived from data). */
|
|
122
|
-
export const DENTAL_PAY_YEARS =
|
|
119
|
+
export const DENTAL_PAY_YEARS = DENTAL_FAMILY.years;
|
|
123
120
|
/**
|
|
124
|
-
* Published salaried dental grades for a nation and
|
|
121
|
+
* Published salaried dental grades for a nation and pay year, each with
|
|
125
122
|
* its scale points and salary range. Both args required; an absent
|
|
126
123
|
* combination throws `ScaleUnavailable`.
|
|
127
124
|
*/
|
|
128
125
|
export function getDentalScales(year, nation) {
|
|
129
|
-
return
|
|
126
|
+
return DENTAL_FAMILY.scalesFor(year, nation);
|
|
127
|
+
}
|
|
128
|
+
/** One band of Northern Ireland's salaried dental table, by number. */
|
|
129
|
+
function niDentalBand(band) {
|
|
130
|
+
return numbered(scaleSalaries(NI.salariedDental, (g) => g.band === band, `NI dental band ${band}`));
|
|
130
131
|
}
|
|
131
132
|
//# sourceMappingURL=dental-scales.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dental-scales.js","sourceRoot":"","sources":["../src/dental-scales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAC,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"dental-scales.js","sourceRoot":"","sources":["../src/dental-scales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAI9D,OAAO,EACL,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,QAAQ,EACR,cAAc,EACd,aAAa,EACb,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,oBAAoB,IAAI,GAAG,EAC3B,0BAA0B,IAAI,SAAS,GACxC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAC,uBAAuB,IAAI,GAAG,EAAC,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAC,uBAAuB,IAAI,KAAK,EAAC,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAC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,EAAE,SAAS;QAC9B,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,mBAAmB;QAClD,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,YAAY;KACrC;CACF,CAAC;AAEF,yCAAyC;AACzC,MAAM,CAAC,MAAM,aAAa,GACxB,WAAW,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAE/C,yEAAyE;AACzE,MAAM,CAAC,MAAM,gBAAgB,GAAuB,aAAa,CAAC,KAAK,CAAC;AAExE;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,uEAAuE;AACvE,SAAS,YAAY,CAAC,IAAkB;IACtC,OAAO,QAAQ,CAAC,aAAa,CAC3B,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE,kBAAkB,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The published document a figure in this library was read from.
|
|
3
3
|
*
|
|
4
|
-
* One record type for any cited document
|
|
5
|
-
*
|
|
4
|
+
* One record type for any dated cited document. The library cites five
|
|
5
|
+
* KINDS (listed in `sources.ts`), three of which are easily confused: the
|
|
6
6
|
* instrument that ENACTED an award, the circular that PUBLISHES a pay
|
|
7
7
|
* scale, and the letter that sets an allowance. They are different
|
|
8
8
|
* documents in every nation — England's 2026-27 medical award was
|
|
@@ -73,11 +73,27 @@ export interface DocumentSourceFields {
|
|
|
73
73
|
* CPI for the calendar year, so a revision was a scheduled
|
|
74
74
|
* contingency with a knowable date — CPI confirms in January — and
|
|
75
75
|
* it duly arrived on 23 January 2026, moving 4.25% to 4.4%. A
|
|
76
|
-
*
|
|
77
|
-
*
|
|
76
|
+
* scheduled revision with no date recorded lapses unseen, and every
|
|
77
|
+
* figure it moves stays wrong until someone happens to look.
|
|
78
78
|
*/
|
|
79
79
|
readonly nextExpectedReason?: string;
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* A publisher's web page that prints no issue date: what it is, and the
|
|
83
|
+
* day it was read. Its own type rather than a {@link DocumentSource},
|
|
84
|
+
* whose `issued` a consumer prints as the date of publication, so an
|
|
85
|
+
* undated page cannot be shown as published on the day it was read.
|
|
86
|
+
*/
|
|
87
|
+
export interface PageSource {
|
|
88
|
+
/** Who publishes it — 'NHSBSA'. */
|
|
89
|
+
readonly issuer: string;
|
|
90
|
+
/** The page's own title, as printed. */
|
|
91
|
+
readonly reference: string;
|
|
92
|
+
/** The page itself, for a consumer to link. */
|
|
93
|
+
readonly url: string;
|
|
94
|
+
/** ISO date the page was read; it prints no date of its own. */
|
|
95
|
+
readonly retrieved: IsoDate;
|
|
96
|
+
}
|
|
81
97
|
/**
|
|
82
98
|
* A document this library cites — not commentary about it. Held on the
|
|
83
99
|
* record so a consumer cites the document rather than keeping its own
|
|
@@ -117,9 +133,12 @@ export declare class DocumentSource {
|
|
|
117
133
|
* Takes `now` rather than reading the clock, and is a method rather
|
|
118
134
|
* than a stored flag, because currency is a question about a moment
|
|
119
135
|
* and not a property of the record. A boolean computed at module
|
|
120
|
-
* load would freeze the answer for the life of the process
|
|
121
|
-
* same shape as the year defect this round exists to fix — and a
|
|
136
|
+
* load would freeze the answer for the life of the process, and a
|
|
122
137
|
* caller could not ask "was this current when the page was built?".
|
|
138
|
+
*
|
|
139
|
+
* `now` is compared as the calendar day it falls on in the reader's
|
|
140
|
+
* own frame, never its UTC day, which is the day before for a local
|
|
141
|
+
* midnight in summer time.
|
|
123
142
|
*/
|
|
124
143
|
currencyAt(now: Date): SourceCurrency;
|
|
125
144
|
}
|
|
@@ -138,20 +157,10 @@ export declare class DocumentSource {
|
|
|
138
157
|
* position is to state the gap: an unchecked citation should not look
|
|
139
158
|
* identical to a fresh one.
|
|
140
159
|
*/
|
|
141
|
-
export
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
export interface PageSource {
|
|
149
|
-
/** Who publishes it — 'NHSBSA'. */
|
|
150
|
-
readonly issuer: string;
|
|
151
|
-
/** The page's own title, as printed. */
|
|
152
|
-
readonly reference: string;
|
|
153
|
-
/** The page itself, for a consumer to link. */
|
|
154
|
-
readonly url: string;
|
|
155
|
-
/** ISO date the page was read; it prints no date of its own. */
|
|
156
|
-
readonly retrieved: IsoDate;
|
|
157
|
-
}
|
|
160
|
+
export declare const SOURCE_CURRENCIES: {
|
|
161
|
+
readonly current: "current";
|
|
162
|
+
readonly lapsed: "lapsed";
|
|
163
|
+
readonly unknown: "unknown";
|
|
164
|
+
};
|
|
165
|
+
/** One of {@link SOURCE_CURRENCIES}. */
|
|
166
|
+
export type SourceCurrency = (typeof SOURCE_CURRENCIES)[keyof typeof SOURCE_CURRENCIES];
|
package/dist/document-source.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The published document a figure in this library was read from.
|
|
3
3
|
*
|
|
4
|
-
* One record type for any cited document
|
|
5
|
-
*
|
|
4
|
+
* One record type for any dated cited document. The library cites five
|
|
5
|
+
* KINDS (listed in `sources.ts`), three of which are easily confused: the
|
|
6
6
|
* instrument that ENACTED an award, the circular that PUBLISHES a pay
|
|
7
7
|
* scale, and the letter that sets an allowance. They are different
|
|
8
8
|
* documents in every nation — England's 2026-27 medical award was
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
* scale carries one too, and `award.ts` imports every scale module —
|
|
19
19
|
* so defining it there would make a scale citing its source a cycle.
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
const ISO_DATE_LENGTH = 10;
|
|
21
|
+
import { isoDateOf } from './iso-date.js';
|
|
23
22
|
/**
|
|
24
23
|
* A document this library cites — not commentary about it. Held on the
|
|
25
24
|
* record so a consumer cites the document rather than keeping its own
|
|
@@ -66,17 +65,40 @@ export class DocumentSource {
|
|
|
66
65
|
* Takes `now` rather than reading the clock, and is a method rather
|
|
67
66
|
* than a stored flag, because currency is a question about a moment
|
|
68
67
|
* and not a property of the record. A boolean computed at module
|
|
69
|
-
* load would freeze the answer for the life of the process
|
|
70
|
-
* same shape as the year defect this round exists to fix — and a
|
|
68
|
+
* load would freeze the answer for the life of the process, and a
|
|
71
69
|
* caller could not ask "was this current when the page was built?".
|
|
70
|
+
*
|
|
71
|
+
* `now` is compared as the calendar day it falls on in the reader's
|
|
72
|
+
* own frame, never its UTC day, which is the day before for a local
|
|
73
|
+
* midnight in summer time.
|
|
72
74
|
*/
|
|
73
75
|
currencyAt(now) {
|
|
74
76
|
if (!this.nextExpected) {
|
|
75
|
-
return
|
|
77
|
+
return SOURCE_CURRENCIES.unknown;
|
|
76
78
|
}
|
|
77
|
-
return this.nextExpected >= now
|
|
78
|
-
?
|
|
79
|
-
:
|
|
79
|
+
return this.nextExpected >= isoDateOf(now)
|
|
80
|
+
? SOURCE_CURRENCIES.current
|
|
81
|
+
: SOURCE_CURRENCIES.lapsed;
|
|
80
82
|
}
|
|
81
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Whether a source is still within the window in which it is the
|
|
86
|
+
* newest document expected to exist.
|
|
87
|
+
*
|
|
88
|
+
* `lapsed` means the date we expected a successor by has passed and
|
|
89
|
+
* we hold no successor — so either the publisher is late, or one
|
|
90
|
+
* exists and we have not transcribed it. Both are worth surfacing;
|
|
91
|
+
* the caller decides which it is.
|
|
92
|
+
*
|
|
93
|
+
* `unknown` where no `nextExpected` is recorded. Absence of a date is
|
|
94
|
+
* not evidence of currency, and a consumer must never render it as
|
|
95
|
+
* "current" — nor render nothing, which reads the same way. House
|
|
96
|
+
* position is to state the gap: an unchecked citation should not look
|
|
97
|
+
* identical to a fresh one.
|
|
98
|
+
*/
|
|
99
|
+
export const SOURCE_CURRENCIES = {
|
|
100
|
+
current: 'current',
|
|
101
|
+
lapsed: 'lapsed',
|
|
102
|
+
unknown: 'unknown',
|
|
103
|
+
};
|
|
82
104
|
//# sourceMappingURL=document-source.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-source.js","sourceRoot":"","sources":["../src/document-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"document-source.js","sourceRoot":"","sources":["../src/document-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAgFxC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAc;IACzB,8DAA8D;IACrD,MAAM,CAAS;IACxB,mEAAmE;IAC1D,SAAS,CAAS;IAC3B,+CAA+C;IACtC,GAAG,CAAS;IACrB,wCAAwC;IAC/B,MAAM,CAAU;IACzB,sDAAsD;IAC7C,YAAY,CAAW;IAChC;iCAC6B;IACpB,kBAAkB,CAAU;IAErC,YAAY,MAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;IACtD,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,GAAS;QAClB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,iBAAiB,CAAC,OAAO,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,IAAI,SAAS,CAAC,GAAG,CAAC;YACxC,CAAC,CAAC,iBAAiB,CAAC,OAAO;YAC3B,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC;IAC/B,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* ({@link PayPathUnavailable}), service it does not model
|
|
8
8
|
* ({@link BenefitNotModelled}, keyed by a {@link NOT_MODELLED}
|
|
9
9
|
* code), and a read before a member's statement, where no balance
|
|
10
|
-
* exists ({@link BeforeStatement}
|
|
10
|
+
* exists ({@link BeforeStatement}, its boundary
|
|
11
|
+
* {@link isBeforeStatement}, which a caller can check first).
|
|
11
12
|
* - RangeError, thrown where a caller's input cannot be true.
|
|
12
13
|
* - {@link invariant} — an internal consistency guard. Its failure
|
|
13
14
|
* is a library bug, not an input problem, so no caller catches it;
|
|
@@ -210,6 +211,16 @@ export declare class AdditionalPensionUnavailable extends Error {
|
|
|
210
211
|
readonly code: AdditionalPensionRefusal;
|
|
211
212
|
constructor(code: AdditionalPensionRefusal, detail: string);
|
|
212
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Whether a read on `on` falls before the first date a statement answers,
|
|
216
|
+
* and so is one {@link BeforeStatement} refuses. `answersFrom` is that date,
|
|
217
|
+
* the statement's 31 March (`MemberBenefits.statementAnswersFrom`), or null
|
|
218
|
+
* where there is no statement and every date is answered. The one
|
|
219
|
+
* definition of the boundary, so a caller checking its own dates first and
|
|
220
|
+
* the library refusing them cannot disagree on the day itself, which is
|
|
221
|
+
* answered.
|
|
222
|
+
*/
|
|
223
|
+
export declare function isBeforeStatement(on: Date, answersFrom: Date | null): boolean;
|
|
213
224
|
/**
|
|
214
225
|
* Assert a domain invariant that must ALWAYS hold. Throws a bare
|
|
215
226
|
* Error when `condition` is false. Unlike the absent-data errors
|
package/dist/errors.js
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* ({@link PayPathUnavailable}), service it does not model
|
|
8
8
|
* ({@link BenefitNotModelled}, keyed by a {@link NOT_MODELLED}
|
|
9
9
|
* code), and a read before a member's statement, where no balance
|
|
10
|
-
* exists ({@link BeforeStatement}
|
|
10
|
+
* exists ({@link BeforeStatement}, its boundary
|
|
11
|
+
* {@link isBeforeStatement}, which a caller can check first).
|
|
11
12
|
* - RangeError, thrown where a caller's input cannot be true.
|
|
12
13
|
* - {@link invariant} — an internal consistency guard. Its failure
|
|
13
14
|
* is a library bug, not an input problem, so no caller catches it;
|
|
@@ -221,6 +222,10 @@ export class BeforeStatement extends Error {
|
|
|
221
222
|
this.read = read;
|
|
222
223
|
this.on = on;
|
|
223
224
|
this.statementDate = statementDate;
|
|
225
|
+
// A read on or after the statement has a balance to answer with, so
|
|
226
|
+
// refusing one would be the library's own bug, not the caller's.
|
|
227
|
+
invariant(isBeforeStatement(on, statementDate), `BeforeStatement for ${on.toDateString()}, not before the `
|
|
228
|
+
+ `statement's ${statementDate.toDateString()}`);
|
|
224
229
|
this.name = 'BeforeStatement';
|
|
225
230
|
}
|
|
226
231
|
}
|
|
@@ -253,6 +258,18 @@ export class AdditionalPensionUnavailable extends Error {
|
|
|
253
258
|
this.name = 'AdditionalPensionUnavailable';
|
|
254
259
|
}
|
|
255
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Whether a read on `on` falls before the first date a statement answers,
|
|
263
|
+
* and so is one {@link BeforeStatement} refuses. `answersFrom` is that date,
|
|
264
|
+
* the statement's 31 March (`MemberBenefits.statementAnswersFrom`), or null
|
|
265
|
+
* where there is no statement and every date is answered. The one
|
|
266
|
+
* definition of the boundary, so a caller checking its own dates first and
|
|
267
|
+
* the library refusing them cannot disagree on the day itself, which is
|
|
268
|
+
* answered.
|
|
269
|
+
*/
|
|
270
|
+
export function isBeforeStatement(on, answersFrom) {
|
|
271
|
+
return answersFrom !== null && on < answersFrom;
|
|
272
|
+
}
|
|
256
273
|
/**
|
|
257
274
|
* Assert a domain invariant that must ALWAYS hold. Throws a bare
|
|
258
275
|
* Error when `condition` is false. Unlike the absent-data errors
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAeH;;;;;GAKG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAE9B;IAIA;IACA;IAEA;IARX,YACW,MAAc;IACvB;;8CAE0C;IACjC,IAAa,EACb,OAAgB;IACzB,6DAA6D;IACpD,UAAmB;QAE5B,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;QAT9C,WAAM,GAAN,MAAM,CAAQ;QAId,SAAI,GAAJ,IAAI,CAAS;QACb,YAAO,GAAP,OAAO,CAAS;QAEhB,eAAU,GAAV,UAAU,CAAS;QAG5B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAErC;IACA;IAFX,YACW,IAAa,EACb,MAAc;QAEvB,KAAK,CACH,sCAAsC,MAAM,IAAI,IAAI,EAAE,CACvD,CAAC;QALO,SAAI,GAAJ,IAAI,CAAS;QACb,WAAM,GAAN,MAAM,CAAQ;QAKvB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD,wDAAwD;IAC/C,WAAW,CAAS;IAC7B;gCAC4B;IACnB,QAAQ,CAAS;IACjB,OAAO,CAAmB;IAC1B,KAAK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CAAgC,MAAM,EAAE,CAAC,CAAC;QAD7B,SAAI,GAAJ,IAAI,CAA0B;QAEjD,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAQ,EAAE,WAAwB;IAElC,OAAO,WAAW,KAAK,IAAI,IAAI,EAAE,GAAG,WAAW,CAAC;AAClD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,SAAkB,EAClB,OAAe;IAEf,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;aACa;AACb,SAAS,YAAY,CACnB,MAAc,EACd,IAAa,EACb,OAAgB,EAChB,UAAmB;IAEnB,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,mBAAmB,UAAU,QAAQ;cACxC,GAAG,OAAO,OAAO,MAAM,IAAI,IAAI,EAAE,CAAC;IACxC,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,0BAA0B,OAAO,MAAM;cAC1C,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,8BAA8B,MAAM,IAAI,IAAI,EAAE,CAAC;AACxD,CAAC"}
|
package/dist/factor-basis.d.ts
CHANGED
|
@@ -55,9 +55,6 @@ declare const TABLES: {
|
|
|
55
55
|
readonly firstAge: 65;
|
|
56
56
|
}>;
|
|
57
57
|
};
|
|
58
|
-
/** Every table the library reads, by its GAD reference. The one set of
|
|
59
|
-
* instances, so two callers cannot read the same table two ways. */
|
|
60
|
-
export declare function factorTable<K extends keyof typeof TABLES>(ref: K): (typeof TABLES)[K];
|
|
61
58
|
/** Which benefit a factor applies to, where two benefits measured from
|
|
62
59
|
* one pension age read different tables: a 1995 Section pension and its
|
|
63
60
|
* automatic lump sum, and 2015 Section additional pension. */
|
|
@@ -136,10 +133,19 @@ export interface Factored<F extends FactorOutcome | null = FactorOutcome> {
|
|
|
136
133
|
readonly after: ProjectionMoney;
|
|
137
134
|
readonly factor: F;
|
|
138
135
|
}
|
|
136
|
+
/** Every table the library reads, by its GAD reference. The one set of
|
|
137
|
+
* instances, so two callers cannot read the same table two ways. */
|
|
138
|
+
export declare function factorTable<K extends keyof typeof TABLES>(ref: K): (typeof TABLES)[K];
|
|
139
139
|
/**
|
|
140
140
|
* Read the factor for a drawing. The date decides the direction as well
|
|
141
141
|
* as the cell, so a basis whose direction the dates contradict is a bug
|
|
142
142
|
* in the section that derived it and fails loud.
|
|
143
143
|
*/
|
|
144
144
|
export declare function readFactor(basis: FactorBasis, dateOfBirth: Date, drawn: Date): FactorOutcome;
|
|
145
|
+
/**
|
|
146
|
+
* A figure with its factor applied: the one place `after` is made, so it
|
|
147
|
+
* is always `beforeFactor` times the factor, in both rulers. No factor
|
|
148
|
+
* means the rules pay nothing, so nothing is paid after it.
|
|
149
|
+
*/
|
|
150
|
+
export declare function factored<F extends FactorOutcome | null>(beforeFactor: ProjectionMoney, factor: F): Factored<F>;
|
|
145
151
|
export {};
|
package/dist/factor-basis.js
CHANGED
|
@@ -20,6 +20,7 @@ import { periodInYearsMonths, npaDate } from './dates.js';
|
|
|
20
20
|
import { invariant } from './errors.js';
|
|
21
21
|
import { LEGACY_PENSION_AGES } from './pension/ages.js';
|
|
22
22
|
import { FactorTable } from './gad/factor-table.js';
|
|
23
|
+
import { timesMoney } from './pension/money.js';
|
|
23
24
|
import { ERF_0_420 } from './gad/erf-2023-06-30.js';
|
|
24
25
|
import { LRF_0_421 } from './gad/lrf-2023-06-30.js';
|
|
25
26
|
import { LRF_0_422 } from './gad/lrf-0-422-2023-06-30.js';
|
|
@@ -62,11 +63,6 @@ const TABLES = {
|
|
|
62
63
|
[FACTOR_TABLES.earlyAge65]: new FactorTable(ERF_1_402),
|
|
63
64
|
[FACTOR_TABLES.late2008]: new FactorTable(LRF_2_416),
|
|
64
65
|
};
|
|
65
|
-
/** Every table the library reads, by its GAD reference. The one set of
|
|
66
|
-
* instances, so two callers cannot read the same table two ways. */
|
|
67
|
-
export function factorTable(ref) {
|
|
68
|
-
return TABLES[ref];
|
|
69
|
-
}
|
|
70
66
|
/** Which benefit a factor applies to, where two benefits measured from
|
|
71
67
|
* one pension age read different tables: a 1995 Section pension and its
|
|
72
68
|
* automatic lump sum, and 2015 Section additional pension. */
|
|
@@ -95,30 +91,11 @@ export const FACTOR_SOURCES = {
|
|
|
95
91
|
atPensionAge: 'at-normal-pension-age',
|
|
96
92
|
noLateUplift: 'section-awards-no-late-uplift',
|
|
97
93
|
};
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const early = basis.direction === FACTOR_DIRECTIONS.early;
|
|
103
|
-
if (section2015) {
|
|
104
|
-
const additionalPension = basis.applies === FACTOR_APPLIES.additionalPension;
|
|
105
|
-
if (early)
|
|
106
|
-
return TABLES[FACTOR_TABLES.early2015];
|
|
107
|
-
return additionalPension
|
|
108
|
-
? TABLES[FACTOR_TABLES.late2015AdditionalPension]
|
|
109
|
-
: TABLES[FACTOR_TABLES.late2015];
|
|
110
|
-
}
|
|
111
|
-
if (section1995) {
|
|
112
|
-
const pension = basis.applies === FACTOR_APPLIES.pension;
|
|
113
|
-
return pension
|
|
114
|
-
? TABLES[FACTOR_TABLES.early1995Pension]
|
|
115
|
-
: TABLES[FACTOR_TABLES.early1995LumpSum];
|
|
116
|
-
}
|
|
117
|
-
return early
|
|
118
|
-
? TABLES[FACTOR_TABLES.earlyAge65]
|
|
119
|
-
: TABLES[FACTOR_TABLES.late2008];
|
|
94
|
+
/** Every table the library reads, by its GAD reference. The one set of
|
|
95
|
+
* instances, so two callers cannot read the same table two ways. */
|
|
96
|
+
export function factorTable(ref) {
|
|
97
|
+
return TABLES[ref];
|
|
120
98
|
}
|
|
121
|
-
const keyedByAge = (table) => table.index.by === 'age';
|
|
122
99
|
/**
|
|
123
100
|
* Read the factor for a drawing. The date decides the direction as well
|
|
124
101
|
* as the cell, so a basis whose direction the dates contradict is a bug
|
|
@@ -158,4 +135,39 @@ export function readFactor(basis, dateOfBirth, drawn) {
|
|
|
158
135
|
provenance: table.provenance,
|
|
159
136
|
};
|
|
160
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* A figure with its factor applied: the one place `after` is made, so it
|
|
140
|
+
* is always `beforeFactor` times the factor, in both rulers. No factor
|
|
141
|
+
* means the rules pay nothing, so nothing is paid after it.
|
|
142
|
+
*/
|
|
143
|
+
export function factored(beforeFactor, factor) {
|
|
144
|
+
const times = factor === null ? 0 : factor.factor;
|
|
145
|
+
return { beforeFactor, after: timesMoney(beforeFactor, times), factor };
|
|
146
|
+
}
|
|
147
|
+
/** The table a basis reads, and how it is keyed. */
|
|
148
|
+
function tableFor(basis) {
|
|
149
|
+
const section2015 = basis.against === MEMBERS_NPA;
|
|
150
|
+
const section1995 = basis.against === LEGACY_PENSION_AGES.section1995;
|
|
151
|
+
const early = basis.direction === FACTOR_DIRECTIONS.early;
|
|
152
|
+
if (section2015) {
|
|
153
|
+
const additionalPension = basis.applies === FACTOR_APPLIES.additionalPension;
|
|
154
|
+
if (early)
|
|
155
|
+
return TABLES[FACTOR_TABLES.early2015];
|
|
156
|
+
return additionalPension
|
|
157
|
+
? TABLES[FACTOR_TABLES.late2015AdditionalPension]
|
|
158
|
+
: TABLES[FACTOR_TABLES.late2015];
|
|
159
|
+
}
|
|
160
|
+
if (section1995) {
|
|
161
|
+
const pension = basis.applies === FACTOR_APPLIES.pension;
|
|
162
|
+
return pension
|
|
163
|
+
? TABLES[FACTOR_TABLES.early1995Pension]
|
|
164
|
+
: TABLES[FACTOR_TABLES.early1995LumpSum];
|
|
165
|
+
}
|
|
166
|
+
return early
|
|
167
|
+
? TABLES[FACTOR_TABLES.earlyAge65]
|
|
168
|
+
: TABLES[FACTOR_TABLES.late2008];
|
|
169
|
+
}
|
|
170
|
+
function keyedByAge(table) {
|
|
171
|
+
return table.index.by === 'age';
|
|
172
|
+
}
|
|
161
173
|
//# sourceMappingURL=factor-basis.js.map
|