{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Haspara.Accounting.Account where
import qualified Data.Aeson as Aeson
import Data.Hashable (Hashable)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Haspara.Internal.Aeson (aesonOptionsForSingleTag, commonAesonOptions)
data AccountKind
= AccountKindAsset
| AccountKindLiability
| AccountKindEquity
| AccountKindRevenue
| AccountKindExpense
deriving (AccountKind
forall a. a -> a -> Bounded a
maxBound :: AccountKind
$cmaxBound :: AccountKind
minBound :: AccountKind
$cminBound :: AccountKind
Bounded, Int -> AccountKind
AccountKind -> Int
AccountKind -> [AccountKind]
AccountKind -> AccountKind
AccountKind -> AccountKind -> [AccountKind]
AccountKind -> AccountKind -> AccountKind -> [AccountKind]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: AccountKind -> AccountKind -> AccountKind -> [AccountKind]
$cenumFromThenTo :: AccountKind -> AccountKind -> AccountKind -> [AccountKind]
enumFromTo :: AccountKind -> AccountKind -> [AccountKind]
$cenumFromTo :: AccountKind -> AccountKind -> [AccountKind]
enumFromThen :: AccountKind -> AccountKind -> [AccountKind]
$cenumFromThen :: AccountKind -> AccountKind -> [AccountKind]
enumFrom :: AccountKind -> [AccountKind]
$cenumFrom :: AccountKind -> [AccountKind]
fromEnum :: AccountKind -> Int
$cfromEnum :: AccountKind -> Int
toEnum :: Int -> AccountKind
$ctoEnum :: Int -> AccountKind
pred :: AccountKind -> AccountKind
$cpred :: AccountKind -> AccountKind
succ :: AccountKind -> AccountKind
$csucc :: AccountKind -> AccountKind
Enum, AccountKind -> AccountKind -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountKind -> AccountKind -> Bool
$c/= :: AccountKind -> AccountKind -> Bool
== :: AccountKind -> AccountKind -> Bool
$c== :: AccountKind -> AccountKind -> Bool
Eq, forall x. Rep AccountKind x -> AccountKind
forall x. AccountKind -> Rep AccountKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountKind x -> AccountKind
$cfrom :: forall x. AccountKind -> Rep AccountKind x
Generic, Eq AccountKind
AccountKind -> AccountKind -> Bool
AccountKind -> AccountKind -> Ordering
AccountKind -> AccountKind -> AccountKind
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AccountKind -> AccountKind -> AccountKind
$cmin :: AccountKind -> AccountKind -> AccountKind
max :: AccountKind -> AccountKind -> AccountKind
$cmax :: AccountKind -> AccountKind -> AccountKind
>= :: AccountKind -> AccountKind -> Bool
$c>= :: AccountKind -> AccountKind -> Bool
> :: AccountKind -> AccountKind -> Bool
$c> :: AccountKind -> AccountKind -> Bool
<= :: AccountKind -> AccountKind -> Bool
$c<= :: AccountKind -> AccountKind -> Bool
< :: AccountKind -> AccountKind -> Bool
$c< :: AccountKind -> AccountKind -> Bool
compare :: AccountKind -> AccountKind -> Ordering
$ccompare :: AccountKind -> AccountKind -> Ordering
Ord, Int -> AccountKind -> ShowS
[AccountKind] -> ShowS
AccountKind -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [AccountKind] -> ShowS
$cshowList :: [AccountKind] -> ShowS
show :: AccountKind -> [Char]
$cshow :: AccountKind -> [Char]
showsPrec :: Int -> AccountKind -> ShowS
$cshowsPrec :: Int -> AccountKind -> ShowS
Show)
instance Hashable AccountKind
instance Aeson.FromJSON AccountKind where
parseJSON :: Value -> Parser AccountKind
parseJSON = forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
Aeson.genericParseJSON forall a b. (a -> b) -> a -> b
$ [Char] -> Options
aesonOptionsForSingleTag [Char]
"AccountKind"
instance Aeson.ToJSON AccountKind where
toJSON :: AccountKind -> Value
toJSON = forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
Aeson.genericToJSON forall a b. (a -> b) -> a -> b
$ [Char] -> Options
aesonOptionsForSingleTag [Char]
"AccountKind"
toEncoding :: AccountKind -> Encoding
toEncoding = forall a.
(Generic a, GToJSON' Encoding Zero (Rep a)) =>
Options -> a -> Encoding
Aeson.genericToEncoding forall a b. (a -> b) -> a -> b
$ [Char] -> Options
aesonOptionsForSingleTag [Char]
"AccountKind"
accountKindText :: AccountKind -> T.Text
accountKindText :: AccountKind -> Text
accountKindText AccountKind
AccountKindAsset = Text
"Asset"
accountKindText AccountKind
AccountKindLiability = Text
"Liability"
accountKindText AccountKind
AccountKindEquity = Text
"Equity"
accountKindText AccountKind
AccountKindRevenue = Text
"Revenue"
accountKindText AccountKind
AccountKindExpense = Text
"Expense"
data Account o = Account
{ forall o. Account o -> AccountKind
accountKind :: !AccountKind
, forall o. Account o -> o
accountObject :: !o
}
deriving (Account o -> Account o -> Bool
forall o. Eq o => Account o -> Account o -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Account o -> Account o -> Bool
$c/= :: forall o. Eq o => Account o -> Account o -> Bool
== :: Account o -> Account o -> Bool
$c== :: forall o. Eq o => Account o -> Account o -> Bool
Eq, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall o x. Rep (Account o) x -> Account o
forall o x. Account o -> Rep (Account o) x
$cto :: forall o x. Rep (Account o) x -> Account o
$cfrom :: forall o x. Account o -> Rep (Account o) x
Generic, Account o -> Account o -> Bool
Account o -> Account o -> Ordering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {o}. Ord o => Eq (Account o)
forall o. Ord o => Account o -> Account o -> Bool
forall o. Ord o => Account o -> Account o -> Ordering
forall o. Ord o => Account o -> Account o -> Account o
min :: Account o -> Account o -> Account o
$cmin :: forall o. Ord o => Account o -> Account o -> Account o
max :: Account o -> Account o -> Account o
$cmax :: forall o. Ord o => Account o -> Account o -> Account o
>= :: Account o -> Account o -> Bool
$c>= :: forall o. Ord o => Account o -> Account o -> Bool
> :: Account o -> Account o -> Bool
$c> :: forall o. Ord o => Account o -> Account o -> Bool
<= :: Account o -> Account o -> Bool
$c<= :: forall o. Ord o => Account o -> Account o -> Bool
< :: Account o -> Account o -> Bool
$c< :: forall o. Ord o => Account o -> Account o -> Bool
compare :: Account o -> Account o -> Ordering
$ccompare :: forall o. Ord o => Account o -> Account o -> Ordering
Ord, Int -> Account o -> ShowS
forall o. Show o => Int -> Account o -> ShowS
forall o. Show o => [Account o] -> ShowS
forall o. Show o => Account o -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Account o] -> ShowS
$cshowList :: forall o. Show o => [Account o] -> ShowS
show :: Account o -> [Char]
$cshow :: forall o. Show o => Account o -> [Char]
showsPrec :: Int -> Account o -> ShowS
$cshowsPrec :: forall o. Show o => Int -> Account o -> ShowS
Show)
instance Hashable o => Hashable (Account o)
instance Aeson.FromJSON o => Aeson.FromJSON (Account o) where
parseJSON :: Value -> Parser (Account o)
parseJSON = forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
Aeson.genericParseJSON forall a b. (a -> b) -> a -> b
$ [Char] -> Options
commonAesonOptions [Char]
"account"
instance Aeson.ToJSON o => Aeson.ToJSON (Account o) where
toJSON :: Account o -> Value
toJSON = forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
Aeson.genericToJSON forall a b. (a -> b) -> a -> b
$ [Char] -> Options
commonAesonOptions [Char]
"account"
toEncoding :: Account o -> Encoding
toEncoding = forall a.
(Generic a, GToJSON' Encoding Zero (Rep a)) =>
Options -> a -> Encoding
Aeson.genericToEncoding forall a b. (a -> b) -> a -> b
$ [Char] -> Options
commonAesonOptions [Char]
"account"