From 0a340a78580cd5814c8721d7adbb0c047fa9f132 Mon Sep 17 00:00:00 2001 From: Neyts Zupan Date: Tue, 6 Feb 2024 15:56:42 +0000 Subject: [PATCH] Round the commitment bonus to two decimal points so that it is easier to verify that the salary is being calculated correctly. Refs https://github.com/teamniteo/handbook/pull/343#discussion_r1479412496 --- src/Main.elm | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Main.elm b/src/Main.elm index e616db6..1ce5de5 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -729,9 +729,24 @@ humanizeTenure years = -} humanizeCommitmentBonus : Float -> String humanizeCommitmentBonus bonus = - (bonus - |> (*) 100 - |> round - |> String.fromInt - ) - ++ "%" + let + scaledBonus = + bonus * 100 + + bonusText = + String.fromFloat scaledBonus + + dotIndex = + String.indexes "." bonusText + + endIndex = + case List.head dotIndex of + -- Keep two decimal places + Just index -> + index + 3 + + -- No decimal point found + Nothing -> + String.length bonusText + in + String.slice 0 endIndex bonusText ++ "%"