From 984356c796963bcba44dcbe261e460bd37385c35 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 9 Sep 2015 21:35:29 +0200 Subject: Authorizing refunds (negative payments) but stop authorizing null payments --- src/client/Model/View/LoggedIn/Add.elm | 2 +- src/client/View/LoggedIn/Monthly.elm | 6 ++++-- src/client/View/LoggedIn/Table.elm | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/client') diff --git a/src/client/Model/View/LoggedIn/Add.elm b/src/client/Model/View/LoggedIn/Add.elm index abd8a4d..5598084 100644 --- a/src/client/Model/View/LoggedIn/Add.elm +++ b/src/client/Model/View/LoggedIn/Add.elm @@ -38,6 +38,6 @@ validateCost : String -> Translations -> Result String Int validateCost cost translations = cost |> validateNonEmpty (getMessage "CostRequired" translations) - |> flip Result.andThen (validateNumber (getMessage "CostMustBeNumber" translations) (\number -> number >= 0)) + |> flip Result.andThen (validateNumber (getMessage "CostMustBeNonNullNumber" translations) ((/=) 0)) type Frequency = Punctual | Monthly diff --git a/src/client/View/LoggedIn/Monthly.elm b/src/client/View/LoggedIn/Monthly.elm index 5d7260e..17c354a 100644 --- a/src/client/View/LoggedIn/Monthly.elm +++ b/src/client/View/LoggedIn/Monthly.elm @@ -68,8 +68,10 @@ paymentLine model loggedInView payment = [ class ("row" ++ (if loggedInView.paymentEdition == Just payment.id then " edition" else "")) , onClick actions.address (UpdateLoggedIn (ToggleEdit payment.id)) ] - [ div [ class "cell" ] [ text (payment.name) ] - , div [ class "cell" ] [ text (toString payment.cost ++ " " ++ getMessage "MoneySymbol" model.translations) ] + [ div [ class "cell category" ] [ text (payment.name) ] + , div + [ class ("cell cost" ++ if payment.cost < 0 then " refund" else "") ] + [ text (toString payment.cost ++ " " ++ getMessage "MoneySymbol" model.translations) ] , div [ class "cell delete" , onClick serverCommunications.address (SC.DeleteMonthlyPayment payment.id) diff --git a/src/client/View/LoggedIn/Table.elm b/src/client/View/LoggedIn/Table.elm index a8fef3e..0c65e50 100644 --- a/src/client/View/LoggedIn/Table.elm +++ b/src/client/View/LoggedIn/Table.elm @@ -57,7 +57,9 @@ paymentLine model loggedInView payment = , onClick actions.address (UpdateLoggedIn (ToggleEdit payment.id)) ] [ div [ class "cell category" ] [ text payment.name ] - , div [ class "cell cost" ] [ text ((toString payment.cost) ++ " " ++ (getMessage "MoneySymbol" model.translations)) ] + , div + [ class ("cell cost" ++ if payment.cost < 0 then " refund" else "") ] + [ text ((toString payment.cost) ++ " " ++ (getMessage "MoneySymbol" model.translations)) ] , div [ class "cell user" ] [ payment.userId -- cgit v1.2.3