@casomoltd/nhs-pay 0.28.0 → 0.30.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 +14 -3
- package/dist/dates.d.ts +3 -0
- package/dist/dates.js +7 -2
- package/dist/dates.js.map +1 -1
- package/dist/member/benefits.js +27 -32
- package/dist/member/benefits.js.map +1 -1
- package/dist/member/input-period.d.ts +41 -0
- package/dist/member/input-period.js +166 -0
- package/dist/member/input-period.js.map +1 -0
- package/dist/member/service.d.ts +4 -1
- package/dist/member/service.js +12 -1
- package/dist/member/service.js.map +1 -1
- package/dist/member/types.d.ts +37 -4
- package/dist/member/types.js.map +1 -1
- package/dist/member/valuation.d.ts +64 -8
- package/dist/member/valuation.js +110 -20
- package/dist/member/valuation.js.map +1 -1
- package/dist/post.d.ts +22 -29
- package/dist/post.js +14 -17
- package/dist/post.js.map +1 -1
- package/dist/sections/final-salary.d.ts +65 -47
- package/dist/sections/final-salary.js +127 -68
- package/dist/sections/final-salary.js.map +1 -1
- package/dist/take-home.d.ts +12 -6
- package/dist/take-home.js +12 -6
- package/dist/take-home.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The final-salary engine the 1995 and 2008 Sections share. What
|
|
3
|
-
* differs between them is statute — the denominator, the pay measure,
|
|
4
|
-
* the lump sum, which factors apply — and each section holds its own
|
|
5
|
-
* rules privately, so no caller can compose a combination the scheme
|
|
6
|
-
* lacks, such as a 60 denominator on best-single-year pay.
|
|
7
|
-
*/
|
|
8
1
|
import type { FactorOutcome } from '../factor-basis.js';
|
|
9
2
|
import type { PayPath } from '../pay-path.js';
|
|
10
3
|
import type { ProjectionMoney } from '../pension/money.js';
|
|
11
4
|
import type { Prices } from '../pension/prices.js';
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/** The last day of service in it, inclusive. */
|
|
16
|
-
readonly to: Date;
|
|
17
|
-
}
|
|
18
|
-
/** How a section measures final pay, named for an award's provenance.
|
|
19
|
-
* The measuring itself is each section's own `finalPay`. */
|
|
20
|
-
export declare const PAY_MEASURES: {
|
|
21
|
-
readonly bestSingleOf3: "best-single-of-3";
|
|
22
|
-
readonly meanOf3ConsecutiveIn10: "mean-of-3-consecutive-in-10";
|
|
23
|
-
};
|
|
24
|
-
export type PayMeasure = (typeof PAY_MEASURES)[keyof typeof PAY_MEASURES];
|
|
25
|
-
/** A factor for a final-salary benefit drawn on `drawn`. */
|
|
26
|
-
type FactorFor = (dateOfBirth: Date, leaving: Date, drawn: Date) => FactorOutcome;
|
|
5
|
+
/** The fraction of final pay a year of membership earns: an 80th in the
|
|
6
|
+
* 1995 Section, a 60th in the 2008. */
|
|
7
|
+
type Denominator = 80 | 60;
|
|
27
8
|
/** One section's statute, private to that section: each rule is the
|
|
28
9
|
* section's own behaviour, so the engine never branches on which
|
|
29
10
|
* section it is valuing. */
|
|
30
11
|
export interface FinalSalaryRules {
|
|
31
|
-
readonly denominator:
|
|
12
|
+
readonly denominator: Denominator;
|
|
32
13
|
readonly payMeasure: PayMeasure;
|
|
33
14
|
/** The age the section's pension is payable unreduced, in whole
|
|
34
15
|
* years: what its early and late factors are measured from. */
|
|
@@ -37,9 +18,8 @@ export interface FinalSalaryRules {
|
|
|
37
18
|
* section's `pensionFactor` must agree, which
|
|
38
19
|
* `section-factors.test.ts` asserts. */
|
|
39
20
|
readonly lateUplift: boolean;
|
|
40
|
-
/** Final pay in today's money
|
|
41
|
-
|
|
42
|
-
finalPay(payPath: PayPath, lastYear: number): number;
|
|
21
|
+
/** Final pay in today's money, measured back from `leaving`. */
|
|
22
|
+
finalPay(payPath: PayPath, leaving: Date): number;
|
|
43
23
|
readonly pensionFactor: FactorFor;
|
|
44
24
|
/** The automatic lump sum, as a multiple of the unreduced pension,
|
|
45
25
|
* and the factor it is reduced by; null where the section pays
|
|
@@ -49,34 +29,40 @@ export interface FinalSalaryRules {
|
|
|
49
29
|
readonly factor: FactorFor;
|
|
50
30
|
} | null;
|
|
51
31
|
}
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
pension: number;
|
|
69
|
-
automaticLumpSum: number;
|
|
70
|
-
};
|
|
32
|
+
/** A factor for a final-salary benefit drawn on `drawn`. */
|
|
33
|
+
type FactorFor = (dateOfBirth: Date, leaving: Date, drawn: Date) => FactorOutcome;
|
|
34
|
+
/** A window of service valued on final salary, as dates. */
|
|
35
|
+
export interface Membership {
|
|
36
|
+
readonly from: Date;
|
|
37
|
+
/** The last day of service in it, inclusive. */
|
|
38
|
+
readonly to: Date;
|
|
39
|
+
}
|
|
40
|
+
/** A final-salary pension before any factor, and what it is measured
|
|
41
|
+
* from, in today's money. */
|
|
42
|
+
export interface UnreducedPension {
|
|
43
|
+
readonly membership: number;
|
|
44
|
+
readonly finalPay: number;
|
|
45
|
+
readonly pension: number;
|
|
46
|
+
readonly automaticLumpSum: number;
|
|
47
|
+
}
|
|
71
48
|
/** A final-salary pension and lump sum, before and after factors. */
|
|
72
49
|
interface FinalSalaryBenefit {
|
|
73
|
-
readonly
|
|
50
|
+
readonly pensionBeforeFactor: ProjectionMoney;
|
|
74
51
|
readonly pension: ProjectionMoney;
|
|
75
52
|
readonly automaticLumpSum: ProjectionMoney;
|
|
76
|
-
readonly
|
|
53
|
+
readonly automaticLumpSumBeforeFactor: ProjectionMoney;
|
|
54
|
+
readonly pensionFactor: FactorOutcome;
|
|
55
|
+
readonly automaticLumpSumFactor: FactorOutcome | null;
|
|
77
56
|
readonly membership: number;
|
|
78
57
|
readonly finalPay: number;
|
|
79
58
|
}
|
|
59
|
+
/** How a section measures final pay, named for an award's provenance.
|
|
60
|
+
* The measuring itself is each section's own `finalPay`. */
|
|
61
|
+
export declare const PAY_MEASURES: {
|
|
62
|
+
readonly bestSingleOf3: "best-single-of-3";
|
|
63
|
+
readonly meanOf3ConsecutiveIn10: "mean-of-3-consecutive-in-10";
|
|
64
|
+
};
|
|
65
|
+
export type PayMeasure = (typeof PAY_MEASURES)[keyof typeof PAY_MEASURES];
|
|
80
66
|
/**
|
|
81
67
|
* Value final-salary membership at a drawing.
|
|
82
68
|
*
|
|
@@ -94,4 +80,36 @@ export declare function finalSalaryBenefit(rules: FinalSalaryRules, { windows, p
|
|
|
94
80
|
readonly drawing: Date;
|
|
95
81
|
readonly prices: Prices;
|
|
96
82
|
}): FinalSalaryBenefit;
|
|
83
|
+
/**
|
|
84
|
+
* A final-salary pension before any factor, in today's money: the
|
|
85
|
+
* membership, over the denominator, times final pay measured back from
|
|
86
|
+
* `leaving`. The one place the formula is written, so the pension
|
|
87
|
+
* held today and the pension drawn cannot come to disagree.
|
|
88
|
+
*/
|
|
89
|
+
export declare function unreducedPension(rules: FinalSalaryRules, windows: readonly Membership[], payPath: PayPath, leaving: Date): UnreducedPension;
|
|
90
|
+
/**
|
|
91
|
+
* The 1995 Section's measure: the best single year of the last three,
|
|
92
|
+
* each year the 12 months ending on a leaving anniversary. SI 1995/300
|
|
93
|
+
* reg C1(6): "final year's pensionable pay" is "pensionable pay in
|
|
94
|
+
* respect of the member's last year of pensionable employment, ending on
|
|
95
|
+
* the date the member ceases to be in such employment", unless "pensionable
|
|
96
|
+
* pay was greater in either or both of the 2 consecutive years immediately
|
|
97
|
+
* preceding the last year".
|
|
98
|
+
*/
|
|
99
|
+
export declare function bestSingleOf3(payPath: PayPath, leaving: Date): number;
|
|
100
|
+
/**
|
|
101
|
+
* The 2008 Section's measure: the best average of three consecutive
|
|
102
|
+
* years in the last ten, measured back from leaving, each "revalued to
|
|
103
|
+
* current terms", which a path already in today's money is. SI 2008/653
|
|
104
|
+
* reg 2.A.10(5)(b) compares "the period of 1095 days immediately
|
|
105
|
+
* preceding the relevant day (Period 1)", then "the period of 1095 days
|
|
106
|
+
* which overlaps Period 1 by 730 days (Period 2)", "and so on", and
|
|
107
|
+
* 2.A.10(6) takes the one that begins "within the period of 10 years
|
|
108
|
+
* ending with the relevant day" with the highest pay; for a leaver,
|
|
109
|
+
* 2.A.10(5)(a)(i) makes the relevant day "the day on which the member's
|
|
110
|
+
* active membership ceases". The short-service rule of 2.A.10(7), for
|
|
111
|
+
* under 1095 days' service in the ten years, is not modelled: it moves
|
|
112
|
+
* only a member with less than three years' service before leaving.
|
|
113
|
+
*/
|
|
114
|
+
export declare function meanOf3ConsecutiveIn10(payPath: PayPath, leaving: Date): number;
|
|
97
115
|
export {};
|
|
@@ -1,12 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The final-salary engine the 1995 and 2008 Sections share. What
|
|
3
|
+
* differs between them is statute — the denominator, the pay measure,
|
|
4
|
+
* the lump sum, which factors apply — and each section holds its own
|
|
5
|
+
* rules privately, so no caller can compose a combination the scheme
|
|
6
|
+
* lacks, such as a 60 denominator on best-single-year pay.
|
|
7
|
+
*/
|
|
8
|
+
import { dayAfter, daysBetween } from '../dates.js';
|
|
1
9
|
import { moneyAt } from '../pension/money.js';
|
|
2
|
-
import { schemeYearEndFor } from '../pension/seed.js';
|
|
10
|
+
import { schemeYearEndFor, schemeYearStartDate } from '../pension/seed.js';
|
|
3
11
|
/** How a section measures final pay, named for an award's provenance.
|
|
4
12
|
* The measuring itself is each section's own `finalPay`. */
|
|
5
13
|
export const PAY_MEASURES = {
|
|
6
14
|
bestSingleOf3: 'best-single-of-3',
|
|
7
15
|
meanOf3ConsecutiveIn10: 'mean-of-3-consecutive-in-10',
|
|
8
16
|
};
|
|
9
|
-
|
|
17
|
+
/** The years the 1995 Section's best single year is chosen from: the
|
|
18
|
+
* last three. */
|
|
19
|
+
const BEST_SINGLE_OF_YEARS = 3;
|
|
20
|
+
/** The consecutive years the 2008 Section's measure averages. */
|
|
21
|
+
const CONSECUTIVE_YEARS = 3;
|
|
22
|
+
/** The last years those consecutive years must fall inside. */
|
|
23
|
+
const CONSECUTIVE_WITHIN_YEARS = 10;
|
|
24
|
+
/** The divisor for membership's odd days: see `membershipYears`. */
|
|
25
|
+
const DAYS_PER_MEMBERSHIP_YEAR = 365;
|
|
26
|
+
/**
|
|
27
|
+
* Value final-salary membership at a drawing.
|
|
28
|
+
*
|
|
29
|
+
* The pension is measured once, on the pay at leaving — final salary
|
|
30
|
+
* linkage: membership may have frozen years earlier, but the pay
|
|
31
|
+
* measure did not. In today's money that is the figure; in cash it is
|
|
32
|
+
* the same figure carried to the drawing date at the assumption, since
|
|
33
|
+
* pay and a deferred legacy pension both move with prices.
|
|
34
|
+
*/
|
|
35
|
+
export function finalSalaryBenefit(rules, { windows, payPath, dateOfBirth, leaving, drawing, prices }) {
|
|
36
|
+
const { membership, finalPay: pay, pension: unreduced, automaticLumpSum: unreducedLump, } = unreducedPension(rules, windows, payPath, leaving);
|
|
37
|
+
const pensionFactor = rules.pensionFactor(dateOfBirth, leaving, drawing);
|
|
38
|
+
const lump = rules.automaticLumpSum;
|
|
39
|
+
const lumpFactor = lump === null
|
|
40
|
+
? null
|
|
41
|
+
: lump.factor(dateOfBirth, leaving, drawing);
|
|
42
|
+
const lumpSum = lumpFactor === null ? 0 : unreducedLump * lumpFactor.factor;
|
|
43
|
+
const money = (real) => moneyAt({ real, nominal: prices.payAt(real, drawing) }, drawing);
|
|
44
|
+
return {
|
|
45
|
+
pensionBeforeFactor: money(unreduced),
|
|
46
|
+
pension: money(unreduced * pensionFactor.factor),
|
|
47
|
+
automaticLumpSum: money(lumpSum),
|
|
48
|
+
automaticLumpSumBeforeFactor: money(unreducedLump),
|
|
49
|
+
pensionFactor,
|
|
50
|
+
automaticLumpSumFactor: lumpFactor,
|
|
51
|
+
membership,
|
|
52
|
+
finalPay: pay,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A final-salary pension before any factor, in today's money: the
|
|
57
|
+
* membership, over the denominator, times final pay measured back from
|
|
58
|
+
* `leaving`. The one place the formula is written, so the pension
|
|
59
|
+
* held today and the pension drawn cannot come to disagree.
|
|
60
|
+
*/
|
|
61
|
+
export function unreducedPension(rules, windows, payPath, leaving) {
|
|
62
|
+
const membership = membershipYears(windows);
|
|
63
|
+
const pay = rules.finalPay(payPath, leaving);
|
|
64
|
+
const pension = (membership / rules.denominator) * pay;
|
|
65
|
+
return {
|
|
66
|
+
membership,
|
|
67
|
+
finalPay: pay,
|
|
68
|
+
pension,
|
|
69
|
+
automaticLumpSum: (rules.automaticLumpSum?.multiple ?? 0) * pension,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The 1995 Section's measure: the best single year of the last three,
|
|
74
|
+
* each year the 12 months ending on a leaving anniversary. SI 1995/300
|
|
75
|
+
* reg C1(6): "final year's pensionable pay" is "pensionable pay in
|
|
76
|
+
* respect of the member's last year of pensionable employment, ending on
|
|
77
|
+
* the date the member ceases to be in such employment", unless "pensionable
|
|
78
|
+
* pay was greater in either or both of the 2 consecutive years immediately
|
|
79
|
+
* preceding the last year".
|
|
80
|
+
*/
|
|
81
|
+
export function bestSingleOf3(payPath, leaving) {
|
|
82
|
+
return Math.max(...yearsTo(payPath, leaving, BEST_SINGLE_OF_YEARS));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The 2008 Section's measure: the best average of three consecutive
|
|
86
|
+
* years in the last ten, measured back from leaving, each "revalued to
|
|
87
|
+
* current terms", which a path already in today's money is. SI 2008/653
|
|
88
|
+
* reg 2.A.10(5)(b) compares "the period of 1095 days immediately
|
|
89
|
+
* preceding the relevant day (Period 1)", then "the period of 1095 days
|
|
90
|
+
* which overlaps Period 1 by 730 days (Period 2)", "and so on", and
|
|
91
|
+
* 2.A.10(6) takes the one that begins "within the period of 10 years
|
|
92
|
+
* ending with the relevant day" with the highest pay; for a leaver,
|
|
93
|
+
* 2.A.10(5)(a)(i) makes the relevant day "the day on which the member's
|
|
94
|
+
* active membership ceases". The short-service rule of 2.A.10(7), for
|
|
95
|
+
* under 1095 days' service in the ten years, is not modelled: it moves
|
|
96
|
+
* only a member with less than three years' service before leaving.
|
|
97
|
+
*/
|
|
98
|
+
export function meanOf3ConsecutiveIn10(payPath, leaving) {
|
|
99
|
+
// Three consecutive years starting inside the last ten can begin at any
|
|
100
|
+
// of the eight latest offsets back from leaving.
|
|
101
|
+
const windowsInside = CONSECUTIVE_WITHIN_YEARS - CONSECUTIVE_YEARS + 1;
|
|
102
|
+
const years = yearsTo(payPath, leaving, CONSECUTIVE_WITHIN_YEARS);
|
|
103
|
+
let best = 0;
|
|
104
|
+
for (let back = 0; back < windowsInside; back++) {
|
|
105
|
+
const sum = years.slice(back, back + CONSECUTIVE_YEARS)
|
|
106
|
+
.reduce((a, b) => a + b, 0);
|
|
107
|
+
best = Math.max(best, sum / CONSECUTIVE_YEARS);
|
|
108
|
+
}
|
|
109
|
+
return best;
|
|
110
|
+
}
|
|
10
111
|
/**
|
|
11
112
|
* Membership in years: whole years from the first day, then the days
|
|
12
113
|
* left over as a fraction of 365. The legacy sections count
|
|
@@ -20,80 +121,38 @@ const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
|
20
121
|
function membershipYears(windows) {
|
|
21
122
|
let total = 0;
|
|
22
123
|
for (const { from, to } of windows) {
|
|
23
|
-
const end =
|
|
124
|
+
const end = dayAfter(to);
|
|
24
125
|
let years = end.getFullYear() - from.getFullYear();
|
|
25
126
|
const anniversary = (n) => new Date(from.getFullYear() + n, from.getMonth(), from.getDate());
|
|
26
127
|
if (anniversary(years) > end)
|
|
27
128
|
years -= 1;
|
|
28
|
-
const days =
|
|
29
|
-
total += years + days /
|
|
129
|
+
const days = daysBetween(anniversary(years), end);
|
|
130
|
+
total += years + days / DAYS_PER_MEMBERSHIP_YEAR;
|
|
30
131
|
}
|
|
31
132
|
return total;
|
|
32
133
|
}
|
|
33
|
-
/** Each year's pay on the path, in today's money. */
|
|
34
|
-
const payIn = (payPath, year) => payPath.payFor(year).pay;
|
|
35
|
-
/** The 1995 Section's measure: the best single year of the last
|
|
36
|
-
* three. */
|
|
37
|
-
export function bestSingleOf3(payPath, lastYear) {
|
|
38
|
-
return Math.max(payIn(payPath, lastYear), payIn(payPath, lastYear - 1), payIn(payPath, lastYear - 2));
|
|
39
|
-
}
|
|
40
|
-
/** The 2008 Section's measure: the best average of three consecutive
|
|
41
|
-
* years in the last ten, each "revalued to current terms", which a
|
|
42
|
-
* path already in today's money is. */
|
|
43
|
-
export function meanOf3ConsecutiveIn10(payPath, lastYear) {
|
|
44
|
-
// Three consecutive years inside the last ten can end in any of the
|
|
45
|
-
// last eight: the eighth-last is the latest window that still starts
|
|
46
|
-
// inside the ten.
|
|
47
|
-
const WINDOWS_IN_TEN = 10 - 3 + 1;
|
|
48
|
-
let best = 0;
|
|
49
|
-
for (let end = lastYear; end > lastYear - WINDOWS_IN_TEN; end--) {
|
|
50
|
-
const mean = (payIn(payPath, end) + payIn(payPath, end - 1)
|
|
51
|
-
+ payIn(payPath, end - 2)) / 3;
|
|
52
|
-
best = Math.max(best, mean);
|
|
53
|
-
}
|
|
54
|
-
return best;
|
|
55
|
-
}
|
|
56
134
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
135
|
+
* The pay of the `count` years of 12 months ending on `leaving`, then on
|
|
136
|
+
* each anniversary before it, latest first, in today's money. Both
|
|
137
|
+
* regulations measure from the leaving date, while the path holds pay by
|
|
138
|
+
* scheme year (1 April to 31 March), so each measured year takes the
|
|
139
|
+
* share of the scheme year it ends in that has run by the leaving date
|
|
140
|
+
* and the rest from the scheme year before, pay being even across a
|
|
141
|
+
* year. The share counts the scheme year's own days, 365 or 366, so a
|
|
142
|
+
* leaving on 31 March takes that scheme year whole and the year before
|
|
143
|
+
* is not read at all. Two parts are this library's reading, each at most
|
|
144
|
+
* a day in a year: anniversary years where 2.A.10 counts 1095-day
|
|
145
|
+
* periods, and one share, from the leaving year, for every year back.
|
|
61
146
|
*/
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Value final-salary membership at a drawing.
|
|
75
|
-
*
|
|
76
|
-
* The pension is measured once, on the pay at leaving — final salary
|
|
77
|
-
* linkage: membership may have frozen years earlier, but the pay
|
|
78
|
-
* measure did not. In today's money that is the figure; in cash it is
|
|
79
|
-
* the same figure carried to the drawing date at the assumption, since
|
|
80
|
-
* pay and a deferred legacy pension both move with prices.
|
|
81
|
-
*/
|
|
82
|
-
export function finalSalaryBenefit(rules, { windows, payPath, dateOfBirth, leaving, drawing, prices }) {
|
|
83
|
-
const { membership, finalPay: pay, pension: unreduced, automaticLumpSum: unreducedLump, } = unreducedPension(rules, windows, payPath, schemeYearEndFor(leaving));
|
|
84
|
-
const factor = rules.pensionFactor(dateOfBirth, leaving, drawing);
|
|
85
|
-
const lump = rules.automaticLumpSum;
|
|
86
|
-
const lumpSum = lump === null
|
|
87
|
-
? 0
|
|
88
|
-
: unreducedLump * lump.factor(dateOfBirth, leaving, drawing).factor;
|
|
89
|
-
const money = (real) => moneyAt({ real, nominal: prices.payAt(real, drawing) }, drawing);
|
|
90
|
-
return {
|
|
91
|
-
beforeFactor: money(unreduced),
|
|
92
|
-
pension: money(unreduced * factor.factor),
|
|
93
|
-
automaticLumpSum: money(lumpSum),
|
|
94
|
-
factor,
|
|
95
|
-
membership,
|
|
96
|
-
finalPay: pay,
|
|
97
|
-
};
|
|
147
|
+
function yearsTo(payPath, leaving, count) {
|
|
148
|
+
const last = schemeYearEndFor(leaving);
|
|
149
|
+
const opened = schemeYearStartDate(last);
|
|
150
|
+
const daysIn = daysBetween(opened, schemeYearStartDate(last + 1));
|
|
151
|
+
const share = (daysBetween(opened, leaving) + 1) / daysIn;
|
|
152
|
+
const pay = (year) => payPath.payFor(year).pay;
|
|
153
|
+
const leftOnYearEnd = share === 1;
|
|
154
|
+
return Array.from({ length: count }, (_, back) => (leftOnYearEnd
|
|
155
|
+
? pay(last - back)
|
|
156
|
+
: share * pay(last - back) + (1 - share) * pay(last - back - 1)));
|
|
98
157
|
}
|
|
99
158
|
//# sourceMappingURL=final-salary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"final-salary.js","sourceRoot":"","sources":["../../src/sections/final-salary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"final-salary.js","sourceRoot":"","sources":["../../src/sections/final-salary.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAC,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAG5C,OAAO,EAAC,gBAAgB,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAgEzE;6DAC6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,aAAa,EAAE,kBAAkB;IACjC,sBAAsB,EAAE,6BAA6B;CAC7C,CAAC;AAIX;kBACkB;AAClB,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,iEAAiE;AACjE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,+DAA+D;AAC/D,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,oEAAoE;AACpE,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAuB,EACvB,EAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAOvD;IAED,MAAM,EACJ,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAC7C,gBAAgB,EAAE,aAAa,GAChC,GAAG,gBAA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CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,aAAa;QAC5D,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/take-home.d.ts
CHANGED
|
@@ -48,12 +48,18 @@ export interface NhsTakeHomeOptions {
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function nhsTakeHome(salary: number, pensionRate: number, taxYear: TaxYear, taxRegion: TaxRegion, options?: NhsTakeHomeOptions): TakeHomePay;
|
|
50
50
|
/**
|
|
51
|
-
* The pension annual allowance an NHS member's year meets
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* contribution paid;
|
|
55
|
-
*
|
|
56
|
-
*
|
|
51
|
+
* The pension annual allowance an NHS member's year meets, estimated from
|
|
52
|
+
* this year's 2015 Section accrual alone. The scheme is defined benefit,
|
|
53
|
+
* so the pension input is paye-calc's DB multiple of the year's accrual,
|
|
54
|
+
* not the contribution paid; without it adjusted income omits the scheme
|
|
55
|
+
* and the taper never bites for high earners. An opted-out member (rate
|
|
56
|
+
* 0) has no input.
|
|
57
|
+
*
|
|
58
|
+
* It takes no member history, so the input is a floor for anyone with
|
|
59
|
+
* pension already built up: that pension's revaluation beyond the CPI
|
|
60
|
+
* uplift, and any legacy section's growth, are inputs too, and are not
|
|
61
|
+
* counted here.
|
|
62
|
+
*
|
|
57
63
|
* Source: HMRC PTM053301 (DB pension input amount), the citation
|
|
58
64
|
* paye-calc's `DB_PENSION_INPUT_MULTIPLIER` carries.
|
|
59
65
|
*/
|
package/dist/take-home.js
CHANGED
|
@@ -79,12 +79,18 @@ export function nhsTakeHome(salary, pensionRate, taxYear, taxRegion, options = {
|
|
|
79
79
|
return thp;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* The pension annual allowance an NHS member's year meets
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* contribution paid;
|
|
86
|
-
*
|
|
87
|
-
*
|
|
82
|
+
* The pension annual allowance an NHS member's year meets, estimated from
|
|
83
|
+
* this year's 2015 Section accrual alone. The scheme is defined benefit,
|
|
84
|
+
* so the pension input is paye-calc's DB multiple of the year's accrual,
|
|
85
|
+
* not the contribution paid; without it adjusted income omits the scheme
|
|
86
|
+
* and the taper never bites for high earners. An opted-out member (rate
|
|
87
|
+
* 0) has no input.
|
|
88
|
+
*
|
|
89
|
+
* It takes no member history, so the input is a floor for anyone with
|
|
90
|
+
* pension already built up: that pension's revaluation beyond the CPI
|
|
91
|
+
* uplift, and any legacy section's growth, are inputs too, and are not
|
|
92
|
+
* counted here.
|
|
93
|
+
*
|
|
88
94
|
* Source: HMRC PTM053301 (DB pension input amount), the citation
|
|
89
95
|
* paye-calc's `DB_PENSION_INPUT_MULTIPLIER` carries.
|
|
90
96
|
*/
|
package/dist/take-home.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"take-home.js","sourceRoot":"","sources":["../src/take-home.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,WAAW,EACX,WAAW,EACX,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,KAAK,GACN,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qEAAqE;AACrE,MAAM,QAAQ,GAAG,GAAG,CAAC;AAerB;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,WAAmB,EACnB,OAAgB,EAChB,SAAoB,EACpB,UAA8B,EAAE;IAEhC,MAAM,GAAG,GAAG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|
"description": "NHS pay scales and take-home pay, and a member's NHS pension across the 1995, 2008 and 2015 Sections",
|
|
5
5
|
"homepage": "https://casomo.co.uk",
|
|
6
6
|
"bugs": "https://github.com/casomoltd/nhs-pay/issues",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"provenance": true
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@casomoltd/paye-calc": ">=0.
|
|
70
|
+
"@casomoltd/paye-calc": ">=0.14.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@casomoltd/paye-calc": "^0.
|
|
73
|
+
"@casomoltd/paye-calc": "^0.14.0",
|
|
74
74
|
"@casomoltd/tooling": "^0.37.0",
|
|
75
75
|
"@commitlint/cli": "^20.0.0",
|
|
76
76
|
"@js-temporal/polyfill": "^0.5.1",
|