aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Model')
-rw-r--r--src/server/Model/Json/Payer.hs22
-rw-r--r--src/server/Model/Payer/Payment.hs40
-rw-r--r--src/server/Model/Payment.hs8
3 files changed, 0 insertions, 70 deletions
diff --git a/src/server/Model/Json/Payer.hs b/src/server/Model/Json/Payer.hs
deleted file mode 100644
index 2101e40..0000000
--- a/src/server/Model/Json/Payer.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-# LANGUAGE DeriveGeneric #-}
-
-module Model.Json.Payer
- ( Payer(..)
- ) where
-
-import GHC.Generics
-
-import Data.Aeson
-
-import Model.Database (UserId)
-import Model.Json.Income
-
-data Payer = Payer
- { userId :: UserId
- , preIncomePaymentSum :: Int
- , postIncomePaymentSum :: Int
- , incomes :: [Income]
- } deriving (Show, Generic)
-
-instance FromJSON Payer
-instance ToJSON Payer
diff --git a/src/server/Model/Payer/Payment.hs b/src/server/Model/Payer/Payment.hs
deleted file mode 100644
index 6efc38d..0000000
--- a/src/server/Model/Payer/Payment.hs
+++ /dev/null
@@ -1,40 +0,0 @@
-module Model.Payer.Payment
- ( getTotalPaymentsBefore
- , getTotalPaymentsAfter
- ) where
-
-import Data.Time.Clock (UTCTime)
-import Data.Maybe (catMaybes)
-
-import Database.Persist
-import Database.Esqueleto
-import qualified Database.Esqueleto as E
-
-import Model.Database
-import Model.Frequency
-
-getTotalPaymentsBefore :: UTCTime -> Persist [(UserId, Int)]
-getTotalPaymentsBefore time =
- getTotalPayments (\p -> p ^. PaymentCreation E.<. val time)
-
-getTotalPaymentsAfter :: UTCTime -> Persist [(UserId, Int)]
-getTotalPaymentsAfter time =
- getTotalPayments (\p -> p ^. PaymentCreation E.>=. val time)
-
-getTotalPayments :: (SqlExpr (Entity Payment) -> SqlExpr (Value Bool)) -> Persist [(UserId, Int)]
-getTotalPayments paymentWhere = do
- values <- select $
- from $ \payment -> do
- where_ (isNothing (payment ^. PaymentDeletedAt))
- where_ (payment ^. PaymentFrequency E.==. val Punctual)
- where_ (paymentWhere payment)
- groupBy (payment ^. PaymentUserId)
- return (payment ^. PaymentUserId, sum_ (payment ^. PaymentCost))
- return $ catMaybes . map (unMaybe . unValueTuple) $ values
-
-unValueTuple :: (Value a, Value b) -> (a, b)
-unValueTuple (Value a, Value b) = (a, b)
-
-unMaybe :: (a, Maybe b) -> Maybe (a, b)
-unMaybe (a, Just b) = Just (a, b)
-unMaybe _ = Nothing
diff --git a/src/server/Model/Payment.hs b/src/server/Model/Payment.hs
index 9b32fea..5c7d940 100644
--- a/src/server/Model/Payment.hs
+++ b/src/server/Model/Payment.hs
@@ -6,7 +6,6 @@ module Model.Payment
, getMonthlyPayments
, createPayment
, deleteOwnPayment
- , getPaymentsCount
) where
import Data.Text (Text)
@@ -91,10 +90,3 @@ deleteOwnPayment user paymentId = do
return False
Nothing ->
return False
-
-getPaymentsCount :: Persist Int
-getPaymentsCount =
- count
- [ PaymentDeletedAt P.==. Nothing
- , PaymentFrequency P.==. Punctual
- ]