aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2015-09-09 21:35:29 +0200
committerJoris2015-09-09 21:35:29 +0200
commit984356c796963bcba44dcbe261e460bd37385c35 (patch)
tree093c6ede90a77ca6f497aa23c7c13e95f6f2040b /src
parent0e85e2815f5bb0ab8b5fb8156bd772b4a7743f13 (diff)
Authorizing refunds (negative payments) but stop authorizing null payments
Diffstat (limited to 'src')
-rw-r--r--src/client/Model/View/LoggedIn/Add.elm2
-rw-r--r--src/client/View/LoggedIn/Monthly.elm6
-rw-r--r--src/client/View/LoggedIn/Table.elm4
-rw-r--r--src/server/Design/Global.hs4
-rw-r--r--src/server/Main.hs3
-rw-r--r--src/server/Model/Message/Key.hs2
-rw-r--r--src/server/Model/Message/Translations.hs6
7 files changed, 16 insertions, 11 deletions
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
diff --git a/src/server/Design/Global.hs b/src/server/Design/Global.hs
index 53a73eb..ec75287 100644
--- a/src/server/Design/Global.hs
+++ b/src/server/Design/Global.hs
@@ -190,7 +190,9 @@ global = do
".cell" ? do
display tableCell
".category" & width (pct 40)
- ".cost" & width (pct 17)
+ ".cost" & do
+ width (pct 17)
+ ".refund" & color C.greenSuccess
".user" & width (pct 20)
".date" & do
width (pct 20)
diff --git a/src/server/Main.hs b/src/server/Main.hs
index 1c2bc08..1a151fc 100644
--- a/src/server/Main.hs
+++ b/src/server/Main.hs
@@ -22,15 +22,14 @@ import Config
main :: IO ()
main = do
+ runMigrations
_ <- forkIO monthlyPaymentJobListener
eitherConfig <- getConfig "config.txt"
case eitherConfig of
Left errorMessage ->
TIO.putStrLn errorMessage
Right config -> do
- runMigrations
scotty (port config) $ do
-
middleware $
staticPolicy (noDots >-> addBase "public")
diff --git a/src/server/Model/Message/Key.hs b/src/server/Model/Message/Key.hs
index 163a21f..3d915b9 100644
--- a/src/server/Model/Message/Key.hs
+++ b/src/server/Model/Message/Key.hs
@@ -45,7 +45,7 @@ data Key =
| CategoryRequired
| CostRequired
- | CostMustBeNumber
+ | CostMustBeNonNullNumber
-- Payments
diff --git a/src/server/Model/Message/Translations.hs b/src/server/Model/Message/Translations.hs
index a3603b8..79d177f 100644
--- a/src/server/Model/Message/Translations.hs
+++ b/src/server/Model/Message/Translations.hs
@@ -178,10 +178,10 @@ m l CostRequired =
English -> "Type a cost."
French -> "Entre un coût."
-m l CostMustBeNumber =
+m l CostMustBeNonNullNumber =
case l of
- English -> "The cost must be a positive natural number."
- French -> "Le coût doit être un entier positif."
+ English -> "The cost must be a non-null integer."
+ French -> "Le coût doit être un entier non nul."
-- Payments