From 6fa47c0e1ee0ef241c8d2d98094cf586b1c39f81 Mon Sep 17 00:00:00 2001 From: nek0 Date: Fri, 9 Aug 2019 19:21:38 +0200 Subject: [PATCH] draft out types for journal --- src/Types/Journal.hs | 53 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/src/Types/Journal.hs b/src/Types/Journal.hs index a39492c..08d040e 100644 --- a/src/Types/Journal.hs +++ b/src/Types/Journal.hs @@ -1,11 +1,48 @@ {-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE OverloadedStrings #-} +-- {-# LANGUAGE OverloadedStrings #-} module Types.Journal where -data JournalEntry - = JournalEntry - { journalEntryDescription :: String - , journalEntryTimestamp :: UTCTime - , journalEntryAmount :: Int - , journalEntryIsCheck :: Bool - } +import GHC.Generics + +import qualified Data.Text as T (Text) + +import Data.Aeson + +import Data.Time.Clock (UTCTime) + +data JournalEntry = JournalEntry + { journalEntryDescription :: T.Text + , journalEntryTimestamp :: UTCTime + , journalEntryAmount :: Int + , journalEntryTotalAmount :: Int + , journalEntryIsCheck :: Bool + } + deriving (Generic, Show) + +instance ToJSON JournalEntry where + toEncoding = genericToEncoding defaultOptions + +instance FromJSON JournalEntry + + +data JournalSubmit = JournalSubmit + { journalSubmitDescription :: T.Text + , journalSubmitAmount :: Int + } + deriving (Generic, Show) + +instance ToJSON JournalSubmit where + toEncoding = genericToEncoding defaultOptions + +instance FromJSON JournalSubmit + + +data JournalCashCheck = JournalCashCheck + { journalCashCheckTotalAmount :: Int + } + deriving (Generic, Show) + +instance ToJSON JournalCashCheck where + toEncoding = genericToEncoding defaultOptions + +instance FromJSON JournalCashCheck