diff --git a/src/compensations/Compensations.tsx b/src/compensations/Compensations.tsx
index 710664121..13c0da409 100644
--- a/src/compensations/Compensations.tsx
+++ b/src/compensations/Compensations.tsx
@@ -86,9 +86,12 @@ const Compensations = ({ compensations, locations }: CompensationsProps) => {
{salary !== null ? (
Du vil få en årlig lønn på {salary}
-
- Du vil få en årlig pensjon på omtrent {calculatePension(salary)}
-
+ {compensations.pensionPercent && (
+
+ Du vil få en årlig pensjon på omtrent{" "}
+ {calculatePension(salary, compensations.pensionPercent)}
+
+ )}
) : null}
>
diff --git a/src/compensations/utils/calculateSalary.ts b/src/compensations/utils/calculateSalary.ts
index 6e1e1ec6b..54ef5087d 100644
--- a/src/compensations/utils/calculateSalary.ts
+++ b/src/compensations/utils/calculateSalary.ts
@@ -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 {
diff --git a/studio/lib/payloads/compensations.ts b/studio/lib/payloads/compensations.ts
index 63abc1a1a..36d0e9682 100644
--- a/studio/lib/payloads/compensations.ts
+++ b/studio/lib/payloads/compensations.ts
@@ -30,6 +30,7 @@ export interface CompensationsPage {
basicTitle: string;
page: string;
slug: Slug;
+ pensionPercent?: number;
benefitsByLocation: BenefitsByLocation[];
showSalaryCalculator: boolean;
}
diff --git a/studio/schemas/objects/compensations/pension.ts b/studio/schemas/objects/compensations/pension.ts
index d7345b407..bdaeefa30 100644
--- a/studio/schemas/objects/compensations/pension.ts
+++ b/studio/schemas/objects/compensations/pension.ts
@@ -1,7 +1,7 @@
import { defineField } from "sanity";
export const pension = defineField({
- name: "pensionData",
+ name: "pensionPercent",
title: "Pension Percentage",
type: "number",
initialValue: 7,