Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides data definitions and functions for ledgers and postings.
Synopsis
- newtype GeneralLedger (precision :: Nat) account event = GeneralLedger {
- generalLedgerLedgers :: [Ledger precision account event]
- data Ledger (precision :: Nat) account event = Ledger {
- ledgerAccount :: !(Account account)
- ledgerOpening :: !(Balance precision)
- ledgerRunning :: ![LedgerEntry precision event]
- ledgerClosing :: KnownNat precision => Ledger precision account event -> Balance precision
- data LedgerEntry (precision :: Nat) event = LedgerEntry {
- ledgerEntryDate :: !Day
- ledgerEntryAmount :: !(Amount precision)
- ledgerEntryDescription :: !Text
- ledgerEntryEvent :: !event
- ledgerEntryPostingId :: !Text
- ledgerEntryBalance :: !(Balance precision)
- initLedger :: KnownNat precision => Account account -> Ledger precision account event
- initLedgerWithOpeningBalance :: KnownNat precision => Account account -> Balance precision -> Ledger precision account event
- initLedgerWithOpeningValue :: KnownNat precision => Account account -> (Maybe (Quantity 12), Quantity precision) -> Ledger precision account event
- initLedgerWithOpeningQuantity :: KnownNat precision => Account account -> (Maybe (Quantity 12), Quantity precision) -> Ledger precision account event
- postEntries :: KnownNat precision => Eq account => Ord account => GeneralLedger precision account event -> [JournalEntry precision account event] -> GeneralLedger precision account event
- postEntry :: KnownNat precision => Eq account => Ord account => GeneralLedger precision account event -> JournalEntry precision account event -> GeneralLedger precision account event
- postEntryItem :: KnownNat precision => Eq account => Ord account => GeneralLedger precision account event -> JournalEntry precision account event -> JournalEntryItem precision account event -> GeneralLedger precision account event
- postItem :: KnownNat precision => Ledger precision account event -> Day -> Amount precision -> Text -> event -> Text -> Maybe (JournalEntryItemInventoryEvent account event) -> (Maybe (JournalEntry precision account event), Ledger precision account event)
- histItemToJournalEntryItem :: KnownNat precision => event -> Account account -> Account account -> InventoryHistoryItem 8 12 precision -> [JournalEntryItem precision account event]
Documentation
newtype GeneralLedger (precision :: Nat) account event Source #
Data definition for a general ledger.
GeneralLedger | |
|
Instances
(KnownNat precision, FromJSON account, FromJSON event) => FromJSON (GeneralLedger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger parseJSON :: Value -> Parser (GeneralLedger precision account event) # parseJSONList :: Value -> Parser [GeneralLedger precision account event] # omittedField :: Maybe (GeneralLedger precision account event) # | |
(KnownNat precision, ToJSON account, ToJSON event) => ToJSON (GeneralLedger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger toJSON :: GeneralLedger precision account event -> Value # toEncoding :: GeneralLedger precision account event -> Encoding # toJSONList :: [GeneralLedger precision account event] -> Value # toEncodingList :: [GeneralLedger precision account event] -> Encoding # omitField :: GeneralLedger precision account event -> Bool # | |
Generic (GeneralLedger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger type Rep (GeneralLedger precision account event) :: Type -> Type # from :: GeneralLedger precision account event -> Rep (GeneralLedger precision account event) x # to :: Rep (GeneralLedger precision account event) x -> GeneralLedger precision account event # | |
(KnownNat precision, Show account, Show event) => Show (GeneralLedger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger showsPrec :: Int -> GeneralLedger precision account event -> ShowS # show :: GeneralLedger precision account event -> String # showList :: [GeneralLedger precision account event] -> ShowS # | |
(Eq account, Eq event) => Eq (GeneralLedger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger (==) :: GeneralLedger precision account event -> GeneralLedger precision account event -> Bool # (/=) :: GeneralLedger precision account event -> GeneralLedger precision account event -> Bool # | |
type Rep (GeneralLedger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger type Rep (GeneralLedger precision account event) = D1 ('MetaData "GeneralLedger" "Haspara.Accounting.Ledger" "haspara-0.0.0.10-LGg0czPpaCuGVkbC64W22n" 'True) (C1 ('MetaCons "GeneralLedger" 'PrefixI 'True) (S1 ('MetaSel ('Just "generalLedgerLedgers") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Ledger precision account event]))) |
data Ledger (precision :: Nat) account event Source #
Data definition for a ledger.
Ledger | |
|
Instances
(KnownNat precision, FromJSON account, FromJSON event) => FromJSON (Ledger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger | |
(KnownNat precision, ToJSON account, ToJSON event) => ToJSON (Ledger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger | |
Generic (Ledger precision account event) Source # | |
(KnownNat precision, Show account, Show event) => Show (Ledger precision account event) Source # | |
(Eq account, Eq event) => Eq (Ledger precision account event) Source # | |
type Rep (Ledger precision account event) Source # | |
Defined in Haspara.Accounting.Ledger type Rep (Ledger precision account event) = D1 ('MetaData "Ledger" "Haspara.Accounting.Ledger" "haspara-0.0.0.10-LGg0czPpaCuGVkbC64W22n" 'False) (C1 ('MetaCons "Ledger" 'PrefixI 'True) (S1 ('MetaSel ('Just "ledgerAccount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Account account)) :*: (S1 ('MetaSel ('Just "ledgerOpening") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Balance precision)) :*: S1 ('MetaSel ('Just "ledgerRunning") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [LedgerEntry precision event])))) |
ledgerClosing :: KnownNat precision => Ledger precision account event -> Balance precision Source #
Returns the closing balance of a ledger.
data LedgerEntry (precision :: Nat) event Source #
Type encoding of a ledger item.
LedgerEntry | |
|
Instances
initLedger :: KnownNat precision => Account account -> Ledger precision account event Source #
Initializes an empty ledger for a given account.
initLedgerWithOpeningBalance :: KnownNat precision => Account account -> Balance precision -> Ledger precision account event Source #
Initializes a ledger with the given opening balance.
initLedgerWithOpeningValue :: KnownNat precision => Account account -> (Maybe (Quantity 12), Quantity precision) -> Ledger precision account event Source #
Initializes a ledger with the given opening value.
See amountFromValue
for the meaning of the concept of value.
initLedgerWithOpeningQuantity :: KnownNat precision => Account account -> (Maybe (Quantity 12), Quantity precision) -> Ledger precision account event Source #
Initializes a ledger with the given opening quantity.
See amountFromQuantity
for the meaning of the concept of quantity.
postEntries :: KnownNat precision => Eq account => Ord account => GeneralLedger precision account event -> [JournalEntry precision account event] -> GeneralLedger precision account event Source #
Posts a given list of journal entries to the given general ledger and returns the new general ledger.
postEntry :: KnownNat precision => Eq account => Ord account => GeneralLedger precision account event -> JournalEntry precision account event -> GeneralLedger precision account event Source #
Posts a given journal entry to the given general ledger and returns the new general ledger.
postEntryItem :: KnownNat precision => Eq account => Ord account => GeneralLedger precision account event -> JournalEntry precision account event -> JournalEntryItem precision account event -> GeneralLedger precision account event Source #
Posts a given journal entry item of a given journal entry to the given general ledger and returns the new general ledger.
postItem :: KnownNat precision => Ledger precision account event -> Day -> Amount precision -> Text -> event -> Text -> Maybe (JournalEntryItemInventoryEvent account event) -> (Maybe (JournalEntry precision account event), Ledger precision account event) Source #
Performs a posting to the given ledger.
histItemToJournalEntryItem :: KnownNat precision => event -> Account account -> Account account -> InventoryHistoryItem 8 12 precision -> [JournalEntryItem precision account event] Source #
Creates 2 journal entry items for the captured non-zero PnL.