From 9ec84e3a20c767f6525639f58cd22715e302b88d Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 26 Jun 2016 12:31:24 +0200 Subject: Add an editable date field for punctual payment creation --- src/client/elm/Model/Income.elm | 2 +- src/client/elm/Model/Payer.elm | 6 +++--- src/client/elm/Model/Payment.elm | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/client/elm/Model') diff --git a/src/client/elm/Model/Income.elm b/src/client/elm/Model/Income.elm index 7eaa77f..06ba772 100644 --- a/src/client/elm/Model/Income.elm +++ b/src/client/elm/Model/Income.elm @@ -45,7 +45,7 @@ incomeDecoder : Json.Decoder Income incomeDecoder = Json.object3 Income ("userId" := userIdDecoder) - ("day" := timeDecoder) + ("date" := timeDecoder) ("amount" := Json.int) incomeDefinedForAll : List UserId -> Incomes -> Maybe Time diff --git a/src/client/elm/Model/Payer.elm b/src/client/elm/Model/Payer.elm index fb9940a..e5a4b65 100644 --- a/src/client/elm/Model/Payer.elm +++ b/src/client/elm/Model/Payer.elm @@ -71,7 +71,7 @@ useIncomesFrom : Users -> Incomes -> Payments -> Maybe Time useIncomesFrom users incomes payments = let firstPaymentTime = payments - |> List.map (Date.toTime << .creation) + |> List.map (Date.toTime << .date) |> List.sort |> List.head mbIncomeTime = incomeDefinedForAll (Dict.keys users) incomes @@ -90,7 +90,7 @@ getPayers currentTime users incomes payments = ( userId , { preIncomePaymentSum = totalPayments - (\p -> (Date.toTime p.creation) < (Maybe.withDefault currentTime incomesDefined)) + (\p -> (Date.toTime p.date) < (Maybe.withDefault currentTime incomesDefined)) userId payments , postIncomePaymentSum = @@ -98,7 +98,7 @@ getPayers currentTime users incomes payments = (\p -> case incomesDefined of Nothing -> False - Just t -> (Date.toTime p.creation) >= t + Just t -> (Date.toTime p.date) >= t ) userId payments diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm index ab3cbb7..c89e709 100644 --- a/src/client/elm/Model/Payment.elm +++ b/src/client/elm/Model/Payment.elm @@ -33,9 +33,9 @@ type alias Payments = List Payment type alias Payment = { id : PaymentId - , creation : Date , name : String , cost : Int + , date : Date , userId : UserId , frequency : Frequency } @@ -51,9 +51,9 @@ paymentDecoder : Json.Decoder Payment paymentDecoder = Json.object6 Payment ("id" := paymentIdDecoder) - ("creation" := dateDecoder) ("name" := Json.string) ("cost" := Json.int) + ("date" := dateDecoder) ("userId" := userIdDecoder) ("frequency" := frequencyDecoder) @@ -92,7 +92,7 @@ monthly = List.filter ((==) Monthly << .frequency) groupAndSortByMonth : Payments -> List ((Month, Int), Payments) groupAndSortByMonth payments = payments - |> List.groupBy (\payment -> (Date.year payment.creation, monthToInt << Date.month <| payment.creation)) + |> List.groupBy (\payment -> (Date.year payment.date, monthToInt << Date.month <| payment.date)) |> List.sortBy fst |> List.map (\((year, month), payments) -> ((intToMonth month, year), payments)) |> List.reverse @@ -101,7 +101,7 @@ search : String -> Frequency -> Payments -> Payments search name frequency payments = payments |> List.filter ((==) frequency << .frequency) - |> List.sortBy (Date.toTime << .creation) + |> List.sortBy (Date.toTime << .date) |> List.filter (searchSuccess name) |> List.reverse -- cgit v1.2.3