Skip to content

Commit

Permalink
πŸ› Set max year to 2023 in salary calculator (#980)
Browse files Browse the repository at this point in the history
* πŸ› Masters shouldn't earn less than bachelors!

* πŸ› Fix salary calculation
  • Loading branch information
petterhh authored Dec 10, 2024
1 parent c963b86 commit a752406
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/compensations/utils/salary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export function calculateSalary(
degree: string,
salaries: Salaries,
): number | undefined {
const degreeValue = degree === "bachelor" ? 1 : 0;
const adjustedYear = examinationYear - degreeValue;
const adjustedYear =
degree == "master" ? examinationYear - 1 : examinationYear;
return salaries[adjustedYear];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function Calculator({
}

const { min, max } = getMinMaxYear(salaries.value);
const salary = calculateSalary(year, degree, salaries.value) ?? 0;
const salary = calculateSalary(year + 1, degree, salaries.value) ?? 0;

const degreeOptions: IOption[] = [
{ id: "bachelor", label: t("degreeOptions.bachelor") },
Expand Down Expand Up @@ -100,11 +100,13 @@ export default function Calculator({
function getMinMaxYear(salaries: SalaryData) {
const years = Object.keys(salaries).map((s) => parseInt(s));
const min = Math.min(...years);
const max = Math.max(...years);
// We subtract 1 because we don't have data for the current year
const max = Math.max(...years) - 1;
return { min, max };
}
function getMaybeMaxYear(salaries: Result<SalaryData, unknown>) {
if (!salaries.ok) return undefined;
const years = Object.keys(salaries.value).map((s) => parseInt(s));
return Math.max(...years);
// We subtract 1 because we don't have data for the current year
return Math.max(...years) - 1;
}

0 comments on commit a752406

Please sign in to comment.