aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model/Payment.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Model/Payment.elm')
-rw-r--r--src/client/elm/Model/Payment.elm12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm
index 4f0f85a..d9a5d68 100644
--- a/src/client/elm/Model/Payment.elm
+++ b/src/client/elm/Model/Payment.elm
@@ -11,10 +11,12 @@ module Model.Payment exposing
, punctual
, monthly
, groupAndSortByMonth
+ , sortedFiltredPunctual
)
import Date exposing (..)
import Json.Decode as Json exposing ((:=))
+import String
import Model.User exposing (UserId, userIdDecoder)
import Model.Date exposing (dateDecoder)
@@ -93,3 +95,13 @@ groupAndSortByMonth payments =
|> List.sortBy fst
|> List.map (\((year, month), payments) -> ((Date.numToMonth month, year), payments))
|> List.reverse
+
+sortedFiltredPunctual : String -> Payments -> Payments
+sortedFiltredPunctual search payments =
+ punctual payments
+ |> List.sortBy (Date.toTime << .creation)
+ |> List.filter (searchSuccess search)
+ |> List.reverse
+
+searchSuccess : String -> Payment -> Bool
+searchSuccess text { name } = (String.toLower text) `String.contains` (String.toLower name)