Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Entry o (s :: Nat)
- = EntryDebit Date o (UnsignedQuantity s)
- | EntryCredit Date o (UnsignedQuantity s)
- entryDate :: KnownNat s => Entry o s -> Date
- entryQuantity :: KnownNat s => Entry o s -> Quantity s
- entryObject :: KnownNat s => Entry o s -> o
- entryDebit :: KnownNat s => Entry o s -> Maybe (UnsignedQuantity s)
- entryCredit :: KnownNat s => Entry o s -> Maybe (UnsignedQuantity s)
- buildEntry :: KnownNat s => Event o s -> AccountKind -> Entry o s
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
EntryDebit Date o (UnsignedQuantity s) | |
EntryCredit Date o (UnsignedQuantity s) |
Instances
entryObject :: KnownNat s => Entry o s -> o Source #
entryDebit :: KnownNat s => Entry o s -> Maybe (UnsignedQuantity s) Source #
entryCredit :: KnownNat s => Entry o s -> Maybe (UnsignedQuantity s) Source #
buildEntry :: KnownNat s => Event o s -> AccountKind -> Entry o s Source #
Kind of account | Debit | Credit |
Asset | Increase | Decrease |
Liability | Decrease | Increase |
Equity/Capital | Decrease | Increase |
Income/Revenue | Decrease | Increase |
ExpenseCostDividend | Increase | Decrease |