blob: 15f5cf5ee1aa1782294893ebe48dca16e5ad5a6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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)) ]
]
|