mateamt/src/Types/Journal.hs

67 lines
1.5 KiB
Haskell
Raw Normal View History

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)
2022-07-17 19:28:22 +00:00
import Data.OpenApi (ToSchema)
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
, journalEntryUser :: Maybe Int
, journalEntryAction :: JournalAction
2019-08-09 17:21:38 +00:00
, journalEntryAmount :: Int
, journalEntryTotalAmount :: Int
-- , journalEntryIsCheck :: Bool
2019-08-09 17:21:38 +00:00
}
deriving (Generic, Show)
instance ToJSON JournalEntry where
toEncoding = genericToEncoding defaultOptions
instance FromJSON JournalEntry
2022-07-17 19:28:22 +00:00
instance ToSchema JournalEntry
2019-08-09 17:21:38 +00:00
data JournalSubmit = JournalSubmit
{ 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
2022-07-17 19:28:22 +00:00
instance ToSchema JournalSubmit
2019-08-09 17:21:38 +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
2022-07-17 19:28:22 +00:00
instance ToSchema JournalCashCheck
data JournalAction
= CashCheck
| Recharge
| BuyCash
| PayBill
| PayOut
deriving (Generic, Show, Enum, Eq)
instance ToJSON JournalAction where
toEncoding = genericToEncoding defaultOptions
instance FromJSON JournalAction
2022-07-17 19:28:22 +00:00
instance ToSchema JournalAction