aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Server.elm
diff options
context:
space:
mode:
authorJoris2016-08-08 20:58:17 +0200
committerJoris2016-08-08 20:58:17 +0200
commit8816cf758119a6a2073e561c8df297a833630986 (patch)
tree20e63f3c0de15945b818a6d7a78359f9134b5e82 /src/client/elm/Server.elm
parentb54d8e45fc8784d8fa6eaa03f58536b7a19cf70b (diff)
downloadbudget-8816cf758119a6a2073e561c8df297a833630986.tar.gz
budget-8816cf758119a6a2073e561c8df297a833630986.tar.bz2
budget-8816cf758119a6a2073e561c8df297a833630986.zip
Show incomes in a table and update like payments are updated
Diffstat (limited to 'src/client/elm/Server.elm')
-rw-r--r--src/client/elm/Server.elm11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/client/elm/Server.elm b/src/client/elm/Server.elm
index fd32cec..c017548 100644
--- a/src/client/elm/Server.elm
+++ b/src/client/elm/Server.elm
@@ -4,6 +4,7 @@ module Server exposing
, editPayment
, deletePayment
, createIncome
+ , editIncome
, deleteIncome
, signOut
)
@@ -66,6 +67,16 @@ createIncome amount date =
|> HttpUtils.jsonRequest "POST" "/income"
|> flip Task.andThen (HttpUtils.decodeHttpValue <| "id" := incomeIdDecoder)
+editIncome : IncomeId -> Int -> Date -> Task Http.Error ()
+editIncome incomeId amount date =
+ Json.object
+ [ ("id", Json.int incomeId)
+ , ("amount", Json.int amount)
+ , ("date", Json.string (DateFormat.isoDateString date))
+ ]
+ |> HttpUtils.jsonRequest "PUT" "/income"
+ |> Task.map (always ())
+
deleteIncome : IncomeId -> Task Http.Error ()
deleteIncome incomeId =
HttpUtils.request "DELETE" ("/income?id=" ++ (toString incomeId))