Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 - pension in web calculator #620

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/compensations/Compensations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ const Compensations = ({ compensations, locations }: CompensationsProps) => {
{salary !== null ? (
<div aria-live="polite">
<Text> Du vil få en årlig lønn på {salary}</Text>
<Text>
Du vil få en årlig pensjon på omtrent {calculatePension(salary)}
</Text>
{compensations.pensionPercent && (
<Text>
Du vil få en årlig pensjon på omtrent{" "}
{calculatePension(salary, compensations.pensionPercent)}
</Text>
)}
</div>
) : null}
</>
Expand Down
7 changes: 5 additions & 2 deletions src/compensations/utils/calculateSalary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ export function calculateSalary(
return salaryPayscale[currentYear][adjustedYear];
}

export function calculatePension(salary: number): number {
return Math.round(salary * 0.07);
export function calculatePension(
salary: number,
pensionPercent: number,
): number {
return Math.round(salary * (pensionPercent / 100));
}

export function maxExperience(thisYear: number): number {
Expand Down
1 change: 1 addition & 0 deletions studio/lib/payloads/compensations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface CompensationsPage {
basicTitle: string;
page: string;
slug: Slug;
pensionPercent?: number;
benefitsByLocation: BenefitsByLocation[];
showSalaryCalculator: boolean;
}
2 changes: 1 addition & 1 deletion studio/schemas/objects/compensations/pension.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineField } from "sanity";

export const pension = defineField({
name: "pensionData",
name: "pensionPercent",
title: "Pension Percentage",
type: "number",
initialValue: 7,
Expand Down