2019-08-08 16:59:23 +00:00
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
2019-08-09 17:21:38 +00:00
|
|
|
-- {-# LANGUAGE OverloadedStrings #-}
|
2019-08-08 16:59:23 +00:00
|
|
|
module Types.Journal where
|
|
|
|
|
2019-08-09 17:21:38 +00:00
|
|
|
import GHC.Generics
|
|
|
|
|
|
|
|
import Data.Aeson
|
|
|
|
|
2019-08-09 18:54:06 +00:00
|
|
|
import Data.Time (UTCTime)
|
2019-08-09 17:21:38 +00:00
|
|
|
|
|
|
|
data JournalEntry = JournalEntry
|
2019-08-09 18:54:06 +00:00
|
|
|
{ journalEntryId :: Int
|
2019-08-09 17:21:38 +00:00
|
|
|
, journalEntryTimestamp :: UTCTime
|
2020-05-10 09:29:07 +00:00
|
|
|
, journalEntryUser :: Maybe Int
|
|
|
|
, journalEntryAction :: JournalAction
|
2019-08-09 17:21:38 +00:00
|
|
|
, journalEntryAmount :: Int
|
|
|
|
, journalEntryTotalAmount :: Int
|
2020-05-10 09:29:07 +00:00
|
|
|
-- , journalEntryIsCheck :: Bool
|
2019-08-09 17:21:38 +00:00
|
|
|
}
|
|
|
|
deriving (Generic, Show)
|
|
|
|
|
|
|
|
instance ToJSON JournalEntry where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON JournalEntry
|
|
|
|
|
|
|
|
|
|
|
|
data JournalSubmit = JournalSubmit
|
2020-05-10 09:29:07 +00:00
|
|
|
{ journalSubmitUser :: Maybe Int
|
|
|
|
, journalSubmitAction :: JournalAction
|
|
|
|
, journalSubmitAmount :: Int
|
2019-08-09 17:21:38 +00:00
|
|
|
}
|
|
|
|
deriving (Generic, Show)
|
|
|
|
|
|
|
|
instance ToJSON JournalSubmit where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON JournalSubmit
|
|
|
|
|
|
|
|
|
2020-05-10 09:29:07 +00:00
|
|
|
data JournalCashCheck = JournalCashCheck
|
|
|
|
{ journalCashCheckUser :: Int
|
|
|
|
, journalCashCheckTotalAmount :: Int
|
2019-08-09 17:21:38 +00:00
|
|
|
}
|
|
|
|
deriving (Generic, Show)
|
|
|
|
|
|
|
|
instance ToJSON JournalCashCheck where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON JournalCashCheck
|
2020-05-10 09:29:07 +00:00
|
|
|
|
|
|
|
data JournalAction
|
|
|
|
= CashCheck
|
|
|
|
| Recharge
|
|
|
|
| BuyCash
|
|
|
|
| PayBill
|
|
|
|
| PayOut
|
|
|
|
deriving (Generic, Show, Enum, Eq)
|
|
|
|
|
|
|
|
instance ToJSON JournalAction where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON JournalAction
|