mateamt/src/Types/Journal.hs

64 lines
1.4 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)
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
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
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
data JournalAction
= CashCheck
| Recharge
| BuyCash
| PayBill
| PayOut
deriving (Generic, Show, Enum, Eq)
instance ToJSON JournalAction where
toEncoding = genericToEncoding defaultOptions
instance FromJSON JournalAction