haspara-0.0.0.1: A library providing definitions to work with monetary values.
Safe HaskellNone
LanguageHaskell2010

Haspara.Accounting.Entry

Synopsis

Documentation

data Entry o (s :: Nat) Source #

Encoding of a posting entry.

>>> :set -XDataKinds
>>> import Refined
>>> let date = read "2021-01-01"
>>> let oid = 1 :: Int
>>> let qty = $$(refineTH 42) :: UnsignedQuantity 2
>>> let entry = EntryDebit date oid qty
>>> let json = Aeson.encode entry
>>> json
"{\"qty\":42.0,\"obj\":1,\"date\":\"2021-01-01\",\"type\":\"DEBIT\"}"
>>> Aeson.decode json :: Maybe (Entry Int 2)
Just (EntryDebit 2021-01-01 1 (Refined 42.00))
>>> Aeson.decode json == Just entry
True

Instances

Instances details
Eq o => Eq (Entry o s) Source # 
Instance details

Defined in Haspara.Accounting.Entry

Methods

(==) :: Entry o s -> Entry o s -> Bool #

(/=) :: Entry o s -> Entry o s -> Bool #

Ord o => Ord (Entry o s) Source # 
Instance details

Defined in Haspara.Accounting.Entry

Methods

compare :: Entry o s -> Entry o s -> Ordering #

(<) :: Entry o s -> Entry o s -> Bool #

(<=) :: Entry o s -> Entry o s -> Bool #

(>) :: Entry o s -> Entry o s -> Bool #

(>=) :: Entry o s -> Entry o s -> Bool #

max :: Entry o s -> Entry o s -> Entry o s #

min :: Entry o s -> Entry o s -> Entry o s #

(Show o, KnownNat s) => Show (Entry o s) Source # 
Instance details

Defined in Haspara.Accounting.Entry

Methods

showsPrec :: Int -> Entry o s -> ShowS #

show :: Entry o s -> String #

showList :: [Entry o s] -> ShowS #

(ToJSON o, KnownNat s) => ToJSON (Entry o s) Source # 
Instance details

Defined in Haspara.Accounting.Entry

Methods

toJSON :: Entry o s -> Value #

toEncoding :: Entry o s -> Encoding #

toJSONList :: [Entry o s] -> Value #

toEncodingList :: [Entry o s] -> Encoding #

(FromJSON o, KnownNat s) => FromJSON (Entry o s) Source # 
Instance details

Defined in Haspara.Accounting.Entry

Methods

parseJSON :: Value -> Parser (Entry o s) #

parseJSONList :: Value -> Parser [Entry o s] #

entryObject :: KnownNat s => Entry o s -> o Source #

buildEntry :: KnownNat s => Event o s -> AccountKind -> Entry o s Source #

Kind of accountDebitCredit
AssetIncreaseDecrease
LiabilityDecreaseIncrease
Equity/CapitalDecreaseIncrease
Income/RevenueDecreaseIncrease
ExpenseCostDividendIncreaseDecrease