Skip to content

Instantly share code, notes, and snippets.

@Manokii
Created February 24, 2022 19:20
Show Gist options
  • Select an option

  • Save Manokii/55e516c9c7f46a49094fcf662e860618 to your computer and use it in GitHub Desktop.

Select an option

Save Manokii/55e516c9c7f46a49094fcf662e860618 to your computer and use it in GitHub Desktop.
SSS Contribution formula
interface Contribution {
/**
* employee
*/
ee: number;
/**
* employer
*/
er: number;
total: number;
range: {
min: number;
max: number;
};
}
export const getSSS = (salary: number): Contribution => {
const lowest = 3249.999;
const initial = 3250;
const highest = 24750;
const erInitial = 265;
const eeInitial = 135;
const erStep = 42.5;
const eeStep = 22.5;
const erShifter = (amount: number, multiplyer: number) =>
multiplyer >= 25 ? amount + 20 : amount;
if (salary < initial)
return {
er: erInitial,
ee: eeInitial,
total: erInitial + eeInitial,
range: { min: 0, max: initial },
};
if (salary >= highest)
return {
er: 2155,
ee: 1125,
total: 2155 + 1125,
range: { min: highest, max: 999999999 },
};
const index = Math.floor((salary - lowest) / 500);
const range = { min: index * 500 + initial, max: (index + 1) * 500 + lowest };
const multiplier = index + 2;
const er = erInitial + erShifter(erStep * multiplier, multiplier);
const ee = eeInitial + eeStep * multiplier;
const total = er + ee;
return { er, ee, total, range };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment