66 lines
1.5 KiB
Haskell
66 lines
1.5 KiB
Haskell
{-# LANGUAGE DeriveGeneric #-}
|
|
-- {-# LANGUAGE OverloadedStrings #-}
|
|
module Types.Journal where
|
|
|
|
import GHC.Generics
|
|
|
|
import Data.Aeson
|
|
|
|
import Data.Time (UTCTime)
|
|
import Data.OpenApi (ToSchema)
|
|
|
|
data JournalEntry = JournalEntry
|
|
{ journalEntryId :: Int
|
|
, journalEntryTimestamp :: UTCTime
|
|
, journalEntryUser :: Maybe Int
|
|
, journalEntryAction :: JournalAction
|
|
, journalEntryAmount :: Int
|
|
, journalEntryTotalAmount :: Int
|
|
-- , journalEntryIsCheck :: Bool
|
|
}
|
|
deriving (Generic, Show)
|
|
|
|
instance ToJSON JournalEntry where
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
instance FromJSON JournalEntry
|
|
instance ToSchema JournalEntry
|
|
|
|
data JournalSubmit = JournalSubmit
|
|
{ journalSubmitUser :: Maybe Int
|
|
, journalSubmitAction :: JournalAction
|
|
, journalSubmitAmount :: Int
|
|
}
|
|
deriving (Generic, Show)
|
|
|
|
instance ToJSON JournalSubmit where
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
instance FromJSON JournalSubmit
|
|
instance ToSchema JournalSubmit
|
|
|
|
data JournalCashCheck = JournalCashCheck
|
|
{ journalCashCheckUser :: Int
|
|
, journalCashCheckTotalAmount :: Int
|
|
}
|
|
deriving (Generic, Show)
|
|
|
|
instance ToJSON JournalCashCheck where
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
instance FromJSON JournalCashCheck
|
|
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
|
|
instance ToSchema JournalAction
|