module LoggedIn.Home.View.ExceedingPayers exposing ( view ) import Html exposing (..) import Html.Attributes exposing (..) import Msg exposing (Msg) import LoggedData exposing (LoggedData) import LoggedIn.View.Format as Format import Model exposing (Model) import Model.User exposing (getUserName) import Model.Payment as Payment import Model.Payer exposing (..) import Model.Translations exposing (getMessage) view : LoggedData -> Html Msg view loggedData = let payments = Payment.punctual loggedData.payments exceedingPayers = getOrderedExceedingPayers loggedData.currentTime loggedData.users loggedData.incomes payments in div [ class "exceedingPayers" ] ( if List.isEmpty exceedingPayers then [ text <| getMessage "PaymentsAreBalanced" loggedData.translations ] else (List.map (exceedingPayer loggedData) exceedingPayers) ) exceedingPayer : LoggedData -> ExceedingPayer -> Html Msg exceedingPayer loggedData payer = span [ class "exceedingPayer" ] [ span [ class "userName" ] [ payer.userId |> getUserName loggedData.users |> Maybe.withDefault "−" |> text ] , span [ class "amount" ] [ text ("+ " ++ (Format.price loggedData.conf payer.amount)) ] ]