Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides definitions for acccounts and types of accounts as they are used in accounting reporting.
Synopsis
- data AccountKind
- accountKindText :: AccountKind -> Text
- data Account o = Account {
- accountKind :: !AccountKind
- accountObject :: !o
Account Kind
data AccountKind Source #
Type encoding for ledger account type.
This type covers both balance sheet and income statement account types:
- For balance sheet accounts:
- Asset (
AccountKindAsset
) - Liability (
AccountKindLiability
) - Equity (
AccountKindEquity
) - For income statement accounts:
- Revenue (
AccountKindRevenue
) - Expense (
AccountKindExpense
)
FromJSON
and ToJSON
instances, too:
>>>
:set -XTypeApplications
>>>
Data.Aeson.decode @AccountKind "\"ASSET\""
Just AccountKindAsset>>>
Data.Aeson.decode @AccountKind "\"LIABILITY\""
Just AccountKindLiability>>>
Data.Aeson.decode @AccountKind "\"EQUITY\""
Just AccountKindEquity>>>
Data.Aeson.decode @AccountKind "\"REVENUE\""
Just AccountKindRevenue>>>
Data.Aeson.decode @AccountKind "\"EXPENSE\""
Just AccountKindExpense>>>
Data.Aeson.encode AccountKindAsset
"\"ASSET\"">>>
Data.Aeson.encode AccountKindLiability
"\"LIABILITY\"">>>
Data.Aeson.encode AccountKindEquity
"\"EQUITY\"">>>
Data.Aeson.encode AccountKindRevenue
"\"REVENUE\"">>>
Data.Aeson.encode AccountKindExpense
"\"EXPENSE\""
Instances
accountKindText :: AccountKind -> Text Source #
Provides textual representation of a given AccountKind
.
>>>
accountKindText AccountKindAsset
"Asset">>>
accountKindText AccountKindLiability
"Liability">>>
accountKindText AccountKindEquity
"Equity">>>
accountKindText AccountKindRevenue
"Revenue">>>
accountKindText AccountKindExpense
"Expense"
Account
Type encoding for account values.
This definition provides both the AccountKind
and an arbitrary object
identifying the account. This arbitrary nature provides flexibility to
use-site to use its own account identity and accompanying information when
required.
>>>
:set -XTypeApplications
>>>
let acc = Account AccountKindAsset (1 ::Int)
>>>
Data.Aeson.encode acc
"{\"kind\":\"ASSET\",\"object\":1}">>>
Data.Aeson.decode @(Account Int) (Data.Aeson.encode acc)
Just (Account {accountKind = AccountKindAsset, accountObject = 1})>>>
Data.Aeson.decode (Data.Aeson.encode acc) == Just acc
True
Account | |
|
Instances
FromJSON o => FromJSON (Account o) Source # | |
ToJSON o => ToJSON (Account o) Source # | |
Defined in Haspara.Accounting.Account | |
Generic (Account o) Source # | |
Show o => Show (Account o) Source # | |
Eq o => Eq (Account o) Source # | |
Ord o => Ord (Account o) Source # | |
Defined in Haspara.Accounting.Account | |
Hashable o => Hashable (Account o) Source # | |
Defined in Haspara.Accounting.Account | |
type Rep (Account o) Source # | |
Defined in Haspara.Accounting.Account type Rep (Account o) = D1 ('MetaData "Account" "Haspara.Accounting.Account" "haspara-0.0.0.8-83lIPqySeX32MZXT98KoZ2" 'False) (C1 ('MetaCons "Account" 'PrefixI 'True) (S1 ('MetaSel ('Just "accountKind") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 AccountKind) :*: S1 ('MetaSel ('Just "accountObject") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 o))) |