From 8c24464a4bd0a486cd0ddf846d3b5a323a7aaa9a Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 4 Oct 2015 20:48:32 +0200 Subject: Using incomes to compute a fair computation to designate the payer --- src/server/Controller/Payer.hs | 20 ++++++++++++++++++++ src/server/Controller/Payment.hs | 8 +------- 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 src/server/Controller/Payer.hs (limited to 'src/server/Controller') diff --git a/src/server/Controller/Payer.hs b/src/server/Controller/Payer.hs new file mode 100644 index 0000000..70760ae --- /dev/null +++ b/src/server/Controller/Payer.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Controller.Payer + ( getPayers + ) where + +import Web.Scotty + +import Control.Monad.IO.Class (liftIO) + +import Model.Database +import qualified Model.Payer as P + +import Secure (loggedAction) + +getPayers :: ActionM () +getPayers = + Secure.loggedAction (\_ -> + (liftIO $ runDb P.getPayers) >>= json + ) diff --git a/src/server/Controller/Payment.hs b/src/server/Controller/Payment.hs index 02c8a8e..ffb575c 100644 --- a/src/server/Controller/Payment.hs +++ b/src/server/Controller/Payment.hs @@ -5,7 +5,6 @@ module Controller.Payment , getMonthlyPayments , createPayment , deletePayment - , getTotalPayments , getPaymentsCount ) where @@ -26,6 +25,7 @@ import Json (jsonObject) import Model.Database import qualified Model.Payment as P +import qualified Model.Payer as Payer import Model.Frequency import Model.Json.Number import qualified Model.Json.PaymentId as JP @@ -63,12 +63,6 @@ deletePayment paymentId = jsonObject [("error", Json.String $ getMessage PaymentNotDeleted)] ) -getTotalPayments :: ActionM () -getTotalPayments = - Secure.loggedAction (\_ -> do - (liftIO . runDb $ P.getTotalPayments) >>= json - ) - getPaymentsCount :: ActionM () getPaymentsCount = Secure.loggedAction (\_ -> do -- cgit v1.2.3