@casomoltd/nhs-pay 0.4.7

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/format.js ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * GBP and percentage formatting helpers for NHS
3
+ * pay data. Consolidates formatters previously split
4
+ * across afc-format.ts and calculator format.ts.
5
+ */
6
+ // ── Intl formatters (reused across calls) ───────
7
+ const gbpFormat = new Intl.NumberFormat('en-GB', {
8
+ style: 'currency',
9
+ currency: 'GBP',
10
+ maximumFractionDigits: 0,
11
+ });
12
+ const gbpPreciseFormat = new Intl.NumberFormat('en-GB', {
13
+ style: 'currency',
14
+ currency: 'GBP',
15
+ minimumFractionDigits: 2,
16
+ maximumFractionDigits: 2,
17
+ });
18
+ const pctFormat = new Intl.NumberFormat('en-GB', {
19
+ style: 'percent',
20
+ minimumFractionDigits: 1,
21
+ maximumFractionDigits: 1,
22
+ });
23
+ // ── Currency ────────────────────────────────────
24
+ /** Exact salary with £ sign — £31,049 */
25
+ export function fmtSalary(n) {
26
+ return ('\u00A3'
27
+ + n.toLocaleString('en-GB'));
28
+ }
29
+ /** Format as £35,000 (no decimals, Intl). */
30
+ export function formatGBP(n) {
31
+ return gbpFormat.format(n);
32
+ }
33
+ /** Format as £35,000.00 (with pence). */
34
+ export function formatGBPPrecise(n) {
35
+ return gbpPreciseFormat.format(n);
36
+ }
37
+ /** Rounded money — £31,049 */
38
+ export function fmtMoney(n) {
39
+ return ('\u00A3'
40
+ + Math.round(n).toLocaleString('en-GB'));
41
+ }
42
+ // ── Percentages ─────────────────────────────────
43
+ /** Percentage from a number — 5.8% */
44
+ export function fmtPct(n) {
45
+ return n.toFixed(1) + '%';
46
+ }
47
+ /** Format as 8.3% (Intl, input is whole %). */
48
+ export function formatPct(n) {
49
+ return pctFormat.format(n / 100);
50
+ }
51
+ // ── Tax year labels ─────────────────────────────
52
+ /** '2025-26' → '2025/26' */
53
+ export function yearLabel(year) {
54
+ return year.replace('-', '/');
55
+ }
56
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,mDAAmD;AAEnD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;IAC/C,KAAK,EAAE,UAAU;IACjB,QAAQ,EAAE,KAAK;IACf,qBAAqB,EAAE,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,IAAI,IAAI,CAAC,YAAY,CAC5C,OAAO,EACP;IACE,KAAK,EAAE,UAAU;IACjB,QAAQ,EAAE,KAAK;IACf,qBAAqB,EAAE,CAAC;IACxB,qBAAqB,EAAE,CAAC;CACzB,CACF,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;IAC/C,KAAK,EAAE,SAAS;IAChB,qBAAqB,EAAE,CAAC;IACxB,qBAAqB,EAAE,CAAC;CACzB,CAAC,CAAC;AAEH,mDAAmD;AAEnD,yCAAyC;AACzC,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,CACL,QAAQ;UACN,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAC5B,CAAC;AACJ,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,gBAAgB,CAC9B,CAAS;IAET,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO,CACL,QAAQ;UACN,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CACxC,CAAC;AACJ,CAAC;AAED,mDAAmD;AAEnD,sCAAsC;AACtC,MAAM,UAAU,MAAM,CAAC,CAAS;IAC9B,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAC5B,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,mDAAmD;AAEnD,4BAA4B;AAC5B,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * PCT-to-HCAS-zone reference data.
3
+ *
4
+ * Zones use 2005 PCT boundaries — do not substitute
5
+ * London boroughs or modern trust names. Spellings
6
+ * preserved verbatim from NHS Employers source
7
+ * (e.g. "Forrest", "Harpendon").
8
+ *
9
+ * Browser-safe — no node:fs dependency.
10
+ */
11
+ import type { HcasZoneId } from './hcas.js';
12
+ export interface HcasPct {
13
+ zone: HcasZoneId;
14
+ pct: string;
15
+ }
16
+ /** Look up which HCAS zone a PCT belongs to. */
17
+ export declare function getHcasZone(pct: string): HcasZoneId | null;
18
+ /** All PCTs with their zone, in canonical order. */
19
+ export declare function getHcasPcts(): HcasPct[];
@@ -0,0 +1,97 @@
1
+ /**
2
+ * PCT-to-HCAS-zone reference data.
3
+ *
4
+ * Zones use 2005 PCT boundaries — do not substitute
5
+ * London boroughs or modern trust names. Spellings
6
+ * preserved verbatim from NHS Employers source
7
+ * (e.g. "Forrest", "Harpendon").
8
+ *
9
+ * Browser-safe — no node:fs dependency.
10
+ */
11
+ // ── PCT data (from NHS Employers Annex 8) ───────
12
+ const INNER_LONDON_PCTS = [
13
+ 'Hammersmith & Fulham',
14
+ 'Kensington & Chelsea',
15
+ 'Westminster',
16
+ 'Camden',
17
+ 'Islington',
18
+ 'City & Hackney',
19
+ 'Tower Hamlets',
20
+ 'Lambeth',
21
+ 'Lewisham',
22
+ 'Southwark',
23
+ 'Wandsworth',
24
+ ];
25
+ const OUTER_LONDON_PCTS = [
26
+ 'Brent',
27
+ 'Ealing',
28
+ 'Harrow',
29
+ 'Hillingdon',
30
+ 'Hounslow',
31
+ 'Barnet',
32
+ 'Enfield',
33
+ 'Haringey',
34
+ 'Barking & Dagenham',
35
+ 'Havering',
36
+ 'Newham',
37
+ 'Redbridge',
38
+ 'Waltham Forrest',
39
+ 'Bexley',
40
+ 'Bromley',
41
+ 'Greenwich',
42
+ 'Croydon',
43
+ 'Kingston',
44
+ 'Richmond & Twickenham',
45
+ 'Sutton & Merton',
46
+ ];
47
+ const FRINGE_PCTS = [
48
+ 'Dartford, Gravesham & Swanley',
49
+ 'Basildon',
50
+ 'Billericay, Brentwood & Wickford',
51
+ 'Epping Forrest',
52
+ 'Harlow',
53
+ 'Thurrock',
54
+ 'Dacorum',
55
+ 'Hertsmere',
56
+ 'Royston, Buntingford & Bishop Stortford',
57
+ 'South East Hertfordshire',
58
+ 'St Albans & Harpendon',
59
+ 'Watford & Three Rivers',
60
+ 'Welwyn, Hatfield',
61
+ 'Bracknell Forrest',
62
+ 'Slough',
63
+ 'Windsor, Ascot & Maidenhead',
64
+ 'Wokingham',
65
+ 'East Elmbridge & Mid Surrey',
66
+ 'East Surrey',
67
+ 'Guildford & Waverley',
68
+ 'North Surrey',
69
+ 'Surrey Heath and Woking',
70
+ ];
71
+ const ZONE_PCTS = [
72
+ { zone: 'inner-london', pcts: INNER_LONDON_PCTS },
73
+ { zone: 'outer-london', pcts: OUTER_LONDON_PCTS },
74
+ { zone: 'fringe', pcts: FRINGE_PCTS },
75
+ ];
76
+ // ── Case-insensitive lookup map ─────────────────
77
+ const pctToZone = new Map();
78
+ for (const { zone, pcts } of ZONE_PCTS) {
79
+ for (const pct of pcts) {
80
+ pctToZone.set(pct.toLowerCase(), zone);
81
+ }
82
+ }
83
+ /** Look up which HCAS zone a PCT belongs to. */
84
+ export function getHcasZone(pct) {
85
+ return pctToZone.get(pct.toLowerCase()) ?? null;
86
+ }
87
+ /** All PCTs with their zone, in canonical order. */
88
+ export function getHcasPcts() {
89
+ const result = [];
90
+ for (const { zone, pcts } of ZONE_PCTS) {
91
+ for (const pct of pcts) {
92
+ result.push({ zone, pct });
93
+ }
94
+ }
95
+ return result;
96
+ }
97
+ //# sourceMappingURL=hcas-pcts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hcas-pcts.js","sourceRoot":"","sources":["../src/hcas-pcts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,mDAAmD;AAEnD,MAAM,iBAAiB,GAAsB;IAC3C,sBAAsB;IACtB,sBAAsB;IACtB,aAAa;IACb,QAAQ;IACR,WAAW;IACX,gBAAgB;IAChB,eAAe;IACf,SAAS;IACT,UAAU;IACV,WAAW;IACX,YAAY;CACb,CAAC;AAEF,MAAM,iBAAiB,GAAsB;IAC3C,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,SAAS;IACT,UAAU;IACV,oBAAoB;IACpB,UAAU;IACV,QAAQ;IACR,WAAW;IACX,iBAAiB;IACjB,QAAQ;IACR,SAAS;IACT,WAAW;IACX,SAAS;IACT,UAAU;IACV,uBAAuB;IACvB,iBAAiB;CAClB,CAAC;AAEF,MAAM,WAAW,GAAsB;IACrC,+BAA+B;IAC/B,UAAU;IACV,kCAAkC;IAClC,gBAAgB;IAChB,QAAQ;IACR,UAAU;IACV,SAAS;IACT,WAAW;IACX,yCAAyC;IACzC,0BAA0B;IAC1B,uBAAuB;IACvB,wBAAwB;IACxB,kBAAkB;IAClB,mBAAmB;IACnB,QAAQ;IACR,6BAA6B;IAC7B,WAAW;IACX,6BAA6B;IAC7B,aAAa;IACb,sBAAsB;IACtB,cAAc;IACd,yBAAyB;CAC1B,CAAC;AAEF,MAAM,SAAS,GAGT;IACJ,EAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,EAAC;IAC/C,EAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,EAAC;IAC/C,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAC;CACpC,CAAC;AAEF,mDAAmD;AAEnD,MAAM,SAAS,GACb,IAAI,GAAG,EAAE,CAAC;AAEZ,KAAK,MAAM,EAAC,IAAI,EAAE,IAAI,EAAC,IAAI,SAAS,EAAE,CAAC;IACrC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AASD,gDAAgD;AAChD,MAAM,UAAU,WAAW,CACzB,GAAW;IAEX,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,IAAI,CAAC;AAClD,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,WAAW;IACzB,MAAM,MAAM,GAAc,EAAE,CAAC;IAC7B,KAAK,MAAM,EAAC,IAAI,EAAE,IAAI,EAAC,IAAI,SAAS,EAAE,CAAC;QACrC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,GAAG,EAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/hcas.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * HCAS (High Cost Area Supplement) zone identifiers,
3
+ * supplement calculation, and gross salary.
4
+ *
5
+ * Browser-safe — no node:fs dependency.
6
+ */
7
+ import type { TaxYear } from '@casomoltd/paye-calc';
8
+ import type { HcasZones } from './scales.js';
9
+ import type { AfcRegionId } from './regions.js';
10
+ export declare const HCAS_ZONE_IDS: {
11
+ readonly INNER_LONDON: "inner-london";
12
+ readonly OUTER_LONDON: "outer-london";
13
+ readonly FRINGE: "fringe";
14
+ };
15
+ export type HcasZoneId = (typeof HCAS_ZONE_IDS)[keyof typeof HCAS_ZONE_IDS];
16
+ /** Type guard — is this string a valid zone ID? */
17
+ export declare function isHcasZoneId(value: string): value is HcasZoneId;
18
+ /**
19
+ * Calculate HCAS supplement for a base salary.
20
+ * Applies percentage rate clamped between min/max.
21
+ */
22
+ export declare function calculateHcasSupplement(baseSalary: number, zone: {
23
+ rate: number;
24
+ min: number;
25
+ max: number;
26
+ }): number;
27
+ /** Base salary + Wales floor + HCAS supplement. */
28
+ export declare function grossSalary(base: number, region: AfcRegionId, hcas: HcasZones, year: TaxYear): number;
package/dist/hcas.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * HCAS (High Cost Area Supplement) zone identifiers,
3
+ * supplement calculation, and gross salary.
4
+ *
5
+ * Browser-safe — no node:fs dependency.
6
+ */
7
+ import { resolveRegion } from './regions.js';
8
+ import { applyWalesFloor } from './scales.js';
9
+ export const HCAS_ZONE_IDS = {
10
+ INNER_LONDON: 'inner-london',
11
+ OUTER_LONDON: 'outer-london',
12
+ FRINGE: 'fringe',
13
+ };
14
+ const ZONE_ID_LIST = Object.values(HCAS_ZONE_IDS);
15
+ /** Type guard — is this string a valid zone ID? */
16
+ export function isHcasZoneId(value) {
17
+ return ZONE_ID_LIST.includes(value);
18
+ }
19
+ /**
20
+ * Calculate HCAS supplement for a base salary.
21
+ * Applies percentage rate clamped between min/max.
22
+ */
23
+ export function calculateHcasSupplement(baseSalary, zone) {
24
+ const raw = baseSalary * (zone.rate / 100);
25
+ return Math.round(Math.min(Math.max(raw, zone.min), zone.max));
26
+ }
27
+ /** Base salary + Wales floor + HCAS supplement. */
28
+ export function grossSalary(base, region, hcas, year) {
29
+ const resolved = resolveRegion(region);
30
+ let salary = base;
31
+ if (resolved.isWales) {
32
+ salary = applyWalesFloor(salary, year);
33
+ }
34
+ if (resolved.hcasProp) {
35
+ salary += calculateHcasSupplement(salary, hcas[resolved.hcasProp]);
36
+ }
37
+ return salary;
38
+ }
39
+ //# sourceMappingURL=hcas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hcas.js","sourceRoot":"","sources":["../src/hcas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,MAAM,EAAE,QAAQ;CACR,CAAC;AAOX,MAAM,YAAY,GAChB,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AAE/B,mDAAmD;AACnD,MAAM,UAAU,YAAY,CAC1B,KAAa;IAEb,OACE,YACD,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAAkB,EAClB,IAA8C;IAE9C,MAAM,GAAG,GAAG,UAAU,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC,KAAK,CACf,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,MAAmB,EACnB,IAAe,EACf,IAAa;IAEb,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,MAAM,IAAI,uBAAuB,CAC/B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAChC,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,18 @@
1
+ export { AFC_BANDS, AFC_BAND_IDS, AFC_HOURS_PER_YEAR, AFC_TAX_YEARS, NLW_HOURLY, WALES_LW_FLOOR, annualiseHourly, applyWalesFloor, } from './scales.js';
2
+ export type { AfcBandId, HcasZone, HcasZones, ScalePoint, } from './scales.js';
3
+ export { getEmployerPensionRate, getPensionTiers, lookupPensionTier, pensionTierRate, } from './pension.js';
4
+ export type { EmployerPensionRate, PensionTier, } from './pension.js';
5
+ export { ACCRUAL_RATE, COMMUTATION_FACTOR, commute, lookupErf1, lookupLrf1, maxLumpSum, npaDate, periodInYearsMonths, projectPension, retirementFactor, revalue, yearlyAccrual, } from './pension-projection.js';
6
+ export type { CommutationResult, PensionEstimationInput, PensionProjectionInput, PensionProjectionResult, PensionStatementInput, ProjectionPoint, } from './pension-projection.js';
7
+ export { HCAS_ZONE_IDS, calculateHcasSupplement, grossSalary, isHcasZoneId, } from './hcas.js';
8
+ export type { HcasZoneId } from './hcas.js';
9
+ export { getHcasPcts, getHcasZone, } from './hcas-pcts.js';
10
+ export type { HcasPct } from './hcas-pcts.js';
11
+ export { AFC_REGIONS, ZONE_LABELS, ZONE_TO_REGION, afcRegionToHcasZone, afcRegionToNation, isAfcRegionId, isNation, resolveRegion, } from './regions.js';
12
+ export type { AfcRegionId, ResolvedRegion, } from './regions.js';
13
+ export { AFC_BAND_INFO, AFC_CURRENT_YEAR, AFC_PREVIOUS_YEAR, getAfcScales, } from './bands.js';
14
+ export type { AfcBandInfo, AfcBandMeta, AfcScaleData, } from './bands.js';
15
+ export { nhsTakeHome } from './take-home.js';
16
+ export { fmtMoney, fmtPct, fmtSalary, formatGBP, formatGBPPrecise, formatPct, yearLabel, } from './format.js';
17
+ export { TAX_REGIONS, TAX_YEARS, NATIONS, NATION_KEYS, TakeHomePay, GrossAnnual, PensionBasis, PensionPercent, StudentLoanPlan, nationToTaxRegion, getTaxYearConfig, hoursPerYear, } from '@casomoltd/paye-calc';
18
+ export type { Nation, TaxRegion, TaxYear, } from '@casomoltd/paye-calc';
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ // ── Scales ───────────────────────────────────────
2
+ export { AFC_BANDS, AFC_BAND_IDS, AFC_HOURS_PER_YEAR, AFC_TAX_YEARS, NLW_HOURLY, WALES_LW_FLOOR, annualiseHourly, applyWalesFloor, } from './scales.js';
3
+ // ── Pension ──────────────────────────────────────
4
+ export { getEmployerPensionRate, getPensionTiers, lookupPensionTier, pensionTierRate, } from './pension.js';
5
+ // ── Pension Projection ─────────────────────────────
6
+ export { ACCRUAL_RATE, COMMUTATION_FACTOR, commute, lookupErf1, lookupLrf1, maxLumpSum, npaDate, periodInYearsMonths, projectPension, retirementFactor, revalue, yearlyAccrual, } from './pension-projection.js';
7
+ // ── HCAS ─────────────────────────────────────────
8
+ export { HCAS_ZONE_IDS, calculateHcasSupplement, grossSalary, isHcasZoneId, } from './hcas.js';
9
+ // ── HCAS PCTs ────────────────────────────────────
10
+ export { getHcasPcts, getHcasZone, } from './hcas-pcts.js';
11
+ // ── Regions ──────────────────────────────────────
12
+ export { AFC_REGIONS, ZONE_LABELS, ZONE_TO_REGION, afcRegionToHcasZone, afcRegionToNation, isAfcRegionId, isNation, resolveRegion, } from './regions.js';
13
+ // ── Bands ────────────────────────────────────────
14
+ export { AFC_BAND_INFO, AFC_CURRENT_YEAR, AFC_PREVIOUS_YEAR, getAfcScales, } from './bands.js';
15
+ // ── Take-home ────────────────────────────────────
16
+ export { nhsTakeHome } from './take-home.js';
17
+ // ── Format ───────────────────────────────────────
18
+ export { fmtMoney, fmtPct, fmtSalary, formatGBP, formatGBPPrecise, formatPct, yearLabel, } from './format.js';
19
+ // ── Re-exports from paye-calc ────────────────────
20
+ // Types that appear in our public API so consumers
21
+ // don't need a direct paye-calc import for NHS work.
22
+ export { TAX_REGIONS, TAX_YEARS, NATIONS, NATION_KEYS, TakeHomePay, GrossAnnual, PensionBasis, PensionPercent, StudentLoanPlan, nationToTaxRegion, getTaxYearConfig, hoursPerYear, } from '@casomoltd/paye-calc';
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EACL,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,cAAc,EACd,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAC;AAQrB,oDAAoD;AACpD,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,cAAc,CAAC;AAMtB,sDAAsD;AACtD,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,OAAO,EACP,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,aAAa,GACd,MAAM,yBAAyB,CAAC;AAUjC,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,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,cAAc,CAAC;AAMtB,oDAAoD;AACpD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC;AAOpB,oDAAoD;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,oDAAoD;AACpD,OAAO,EACL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,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,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * NHS 2015 CARE Pension Projection
3
+ *
4
+ * Models the 2015 scheme lifecycle:
5
+ * accrual → revaluation → crystallisation → commutation.
6
+ *
7
+ * Sources:
8
+ *
9
+ * GAD "NHSPS 2015 E&W — Early and late retirement in normal
10
+ * health — Factors and guidance", 7 August 2019
11
+ * → ERF1 table (Appendix B, p.25)
12
+ * → LRF1 table (Appendix C, p.26)
13
+ * → Rounding rules (§2.3 ERF, §3.4 LRF)
14
+ * → Order of operations (§1.18)
15
+ *
16
+ * NHSBSA 2015 Members' Guide (V13), May 2024
17
+ * → Accrual rate: 1/54 (p.6)
18
+ * → NPA = SPA, minimum 65
19
+ *
20
+ * NHS 2015 Scheme design document (gov.uk)
21
+ * → In-service revaluation: CPI + 1.5%
22
+ * → Deferred revaluation: CPI only
23
+ * → In-payment revaluation: CPI (Pensions Increase Order)
24
+ *
25
+ * NHSBSA Key Notes — 2015 Scheme Estimates (V2), March 2025
26
+ * → Commutation rate: £12 lump sum per £1 pension
27
+ * → HMRC 25% cap on lump sum
28
+ */
29
+ /** A point on the projection curve */
30
+ export interface ProjectionPoint {
31
+ /** Age in years (can be fractional) */
32
+ age: number;
33
+ /** Annual pension in nominal £ */
34
+ nominal: number;
35
+ /** Annual pension in today's £ (CPI-deflated) */
36
+ real: number;
37
+ /** Whether this is accrued (known) or projected */
38
+ accrued: boolean;
39
+ }
40
+ /** Input for statement path */
41
+ export interface PensionStatementInput {
42
+ kind: 'statement';
43
+ /** Accrued pension from Annual Benefit Statement (£/yr) */
44
+ accruedPension: number;
45
+ /** Current pensionable pay */
46
+ currentSalary: number;
47
+ dateOfBirth: Date;
48
+ /** Date member stops accruing (leaves NHS) */
49
+ exitDate: Date;
50
+ /** Date member starts drawing pension */
51
+ retirementDate: Date;
52
+ /** Normal Pension Age (67 for most) */
53
+ npa: number;
54
+ /** Assumed CPI rate as decimal, e.g. 0.02 */
55
+ assumedCpi: number;
56
+ }
57
+ /** Input for estimation path (no ABS available) */
58
+ export interface PensionEstimationInput {
59
+ kind: 'estimation';
60
+ /** Date joined 2015 scheme */
61
+ joinDate: Date;
62
+ /** Current pensionable pay */
63
+ currentSalary: number;
64
+ dateOfBirth: Date;
65
+ /** Date member stops accruing */
66
+ exitDate: Date;
67
+ /** Date member starts drawing pension */
68
+ retirementDate: Date;
69
+ /** Normal Pension Age */
70
+ npa: number;
71
+ /** Assumed CPI rate as decimal */
72
+ assumedCpi: number;
73
+ }
74
+ export type PensionProjectionInput = PensionStatementInput | PensionEstimationInput;
75
+ /** Commutation options (separate from projection) */
76
+ export interface CommutationResult {
77
+ pensionGivenUp: number;
78
+ residualPension: number;
79
+ lumpSum: number;
80
+ maxLumpSum: number;
81
+ }
82
+ /** Full projection result */
83
+ export interface PensionProjectionResult {
84
+ /** Accrued pension at exit date (nominal) */
85
+ accruedAtExit: number;
86
+ /** After revaluation, before ERF/LRF (nominal) */
87
+ revaluedAtRetirement: number;
88
+ /** After ERF/LRF (nominal) */
89
+ annualPension: number;
90
+ /** ERF or LRF factor applied */
91
+ factor: number;
92
+ factorType: 'erf' | 'lrf' | 'none';
93
+ /** Gap between revalued and drawn pension */
94
+ adjustmentAmount: number;
95
+ /** Curve data for chart (both views) */
96
+ curve: ProjectionPoint[];
97
+ /** Whether estimation path was used */
98
+ isEstimation: boolean;
99
+ }
100
+ /** 1/54 accrual rate — NHS 2015 CARE scheme */
101
+ export declare const ACCRUAL_RATE: number;
102
+ /** Commutation: £12 lump sum per £1 pension */
103
+ export declare const COMMUTATION_FACTOR = 12;
104
+ /** Look up ERF1 factor for given years and months early */
105
+ export declare function lookupErf1(years: number, months: number): number;
106
+ /** Look up LRF1 factor for given years and months late */
107
+ export declare function lookupLrf1(years: number, months: number): number;
108
+ /**
109
+ * Calculate the period between two dates in years,
110
+ * months, and remaining days.
111
+ */
112
+ export declare function periodInYearsMonths(from: Date, to: Date): {
113
+ years: number;
114
+ months: number;
115
+ days: number;
116
+ };
117
+ /** Calculate NPA date from date of birth and NPA age */
118
+ export declare function npaDate(dateOfBirth: Date, npa: number): Date;
119
+ /**
120
+ * Determine whether ERF or LRF applies and return the
121
+ * factor. ERF rounds UP to next month (§2.3), LRF
122
+ * rounds DOWN to complete months (§3.4).
123
+ */
124
+ export declare function retirementFactor(retirementDate: Date, npDate: Date): {
125
+ factor: number;
126
+ type: 'erf' | 'lrf' | 'none';
127
+ };
128
+ /** Annual pension accrual for one year of service */
129
+ export declare function yearlyAccrual(pensionablePay: number): number;
130
+ /**
131
+ * Compound revaluation over a number of years.
132
+ * Caller passes CPI + 1.5% for active, CPI for deferred.
133
+ */
134
+ export declare function revalue(pension: number, annualRate: number, years: number): number;
135
+ /**
136
+ * Maximum tax-free lump sum under HMRC 25% rule.
137
+ * Formula: (20 × pension) / (3 + 20/commutationFactor)
138
+ */
139
+ export declare function maxLumpSum(adjustedPension: number): number;
140
+ /**
141
+ * Calculate commutation at a given fraction of max.
142
+ * ERF/LRF is applied BEFORE commutation (§1.18).
143
+ */
144
+ export declare function commute(adjustedPension: number, fraction: number): CommutationResult;
145
+ /**
146
+ * Generate a full pension projection including curve
147
+ * data for both nominal and real (CPI-deflated) views.
148
+ */
149
+ export declare function projectPension(input: PensionProjectionInput): PensionProjectionResult;