diff options
Diffstat (limited to 'front')
-rw-r--r-- | front/elm.json | 3 | ||||
-rw-r--r-- | front/src/Main.elm | 11 |
2 files changed, 8 insertions, 6 deletions
diff --git a/front/elm.json b/front/elm.json index 785c5be..a758c49 100644 --- a/front/elm.json +++ b/front/elm.json @@ -10,7 +10,8 @@ "elm/core": "1.0.5", "elm/html": "1.0.0", "elm/http": "2.0.0", - "elm/json": "1.1.3" + "elm/json": "1.1.3", + "myrho/elm-round": "1.0.5" }, "indirect": { "elm/bytes": "1.0.8", diff --git a/front/src/Main.elm b/front/src/Main.elm index 47edd9d..4d39cb3 100644 --- a/front/src/Main.elm +++ b/front/src/Main.elm @@ -1,5 +1,6 @@ module Main exposing (..) +import Round import Browser import Html exposing (Html, button, div, input, text) import Html.Attributes exposing (max, min, step, type_, value) @@ -36,7 +37,7 @@ capitalDecoder = capitalStr : Capital -> String capitalStr { principal, interest } = - String.concat [ "{principal=", String.fromFloat principal, ", interest=", String.fromFloat interest, "}" ] + String.concat [ "{principal=", Round.round 2 principal, ", interest=", Round.round 2 interest, "}" ] type alias Quota = @@ -121,7 +122,7 @@ init : () -> ( Model, Cmd Msg ) init () = let simSpecs = - { principal = 300000.0, i1 = 2.1, years = 30 } + { principal = 200000.0, i1 = 1.621, years = 30 } req = runSimulation simSpecs @@ -238,14 +239,14 @@ specsView { principal, i1, years } = , onInput (UpdateSimSpecs Principal) ] [] - , text (String.fromFloat principal) + , text (Round.round 2 principal) ] , div [] [ text "Interest rate: " , input [ Html.Attributes.min "0" , Html.Attributes.max "100" - , value (String.fromFloat i1) + , value (Round.round 2 i1) , onInput (UpdateSimSpecs I1) ] [] @@ -269,7 +270,7 @@ specsView { principal, i1, years } = quotaView : Quota -> Html Msg quotaView { period, payed, pending_principal } = - div [] [ text (String.join "\t" [ String.fromInt period, capitalStr payed, String.fromFloat pending_principal ]) ] + div [] [ text (String.join "\t" [ String.fromInt period, capitalStr payed, Round.round 2 pending_principal ]) ] historyView : List Quota -> Html Msg |