Skip to content

Commit

Permalink
Round the commitment bonus to two decimal points so that it is
Browse files Browse the repository at this point in the history
easier to verify that the salary is being calculated correctly.

Refs teamniteo/handbook#343 (comment)
  • Loading branch information
zupo committed Feb 6, 2024
1 parent 192c626 commit d287dce
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ++ "%"

0 comments on commit d287dce

Please sign in to comment.