ps: auto-derive years of service from join year + retirement age
This commit is contained in:
1 parent
a0fbb390b5
commit
97cecb91a7
17 files changed
+667
-18
No files matched your search
@@ -87,6 +87,25 @@
|
||||
return y <= GROUP1_CUTOFF_YEAR ? 1 : 2;
|
||||
}
|
||||
|
||||
/* Auto-derive years of pensionable service (PS-AUTO-SERVICE):
|
||||
* yearsWorkedSoFar = currentYear − joinYear
|
||||
* ageAtJoin = age − yearsWorkedSoFar
|
||||
* serviceYears = retireAge − ageAtJoin, clamped to [0, 60] (whole years;
|
||||
* the pension formula applies its own 35-yr MAX_SERVICE cap).
|
||||
* currentYear defaults to the calendar year. Returns null when age, joinYear or
|
||||
* retireAge is missing/invalid — the UI then falls back to manual entry. */
|
||||
function autoServiceYears(age, joinYear, retireAge, currentYear) {
|
||||
var y = +currentYear;
|
||||
if (!(y > 0)) y = new Date().getFullYear();
|
||||
var a = +age, j = +joinYear, r = +retireAge;
|
||||
if (!(a > 0) || !(r > 0) || !(y > 0)) return null;
|
||||
if (!(j >= 1900 && j <= 2999)) return null;
|
||||
if (!isFinite(a) || !isFinite(j) || !isFinite(r) || !isFinite(y)) return null;
|
||||
var joinAge = a - (y - j);
|
||||
var s = r - joinAge;
|
||||
return Math.round(Math.max(0, Math.min(60, s)));
|
||||
}
|
||||
|
||||
function itLevel(id) {
|
||||
for (var i = 0; i < IT_LEVELS.length; i++) if (IT_LEVELS[i].id === id) return IT_LEVELS[i];
|
||||
return null;
|
||||
@@ -194,7 +213,7 @@
|
||||
SOURCES: SOURCES,
|
||||
psGroup: psGroup, psLifetimePension: psLifetimePension,
|
||||
psBridgeBenefit: psBridgeBenefit, psEarlyReduction: psEarlyReduction,
|
||||
computePSPension: computePSPension,
|
||||
computePSPension: computePSPension, autoServiceYears: autoServiceYears,
|
||||
itLevel: itLevel, itRange: itRange
|
||||
};
|
||||
});
|
||||
Reference in new issue
Block a user