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

Haspara.Accounting.Ledger

Description

This module provides data definitions and functions for ledgers and postings.

Synopsis

Documentation

newtype GeneralLedger (precision :: Nat) account event Source #

Data definition for a general ledger.

Constructors

GeneralLedger 

Fields

Instances

Instances details
(Eq account, Eq event) => Eq (GeneralLedger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

(==) :: GeneralLedger precision account event -> GeneralLedger precision account event -> Bool #

(/=) :: GeneralLedger precision account event -> GeneralLedger precision account event -> Bool #

(KnownNat precision, Show account, Show event) => Show (GeneralLedger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

showsPrec :: Int -> GeneralLedger precision account event -> ShowS #

show :: GeneralLedger precision account event -> String #

showList :: [GeneralLedger precision account event] -> ShowS #

Generic (GeneralLedger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Associated Types

type Rep (GeneralLedger precision account event) :: Type -> Type #

Methods

from :: GeneralLedger precision account event -> Rep (GeneralLedger precision account event) x #

to :: Rep (GeneralLedger precision account event) x -> GeneralLedger precision account event #

(KnownNat precision, ToJSON account, ToJSON event) => ToJSON (GeneralLedger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

toJSON :: GeneralLedger precision account event -> Value #

toEncoding :: GeneralLedger precision account event -> Encoding #

toJSONList :: [GeneralLedger precision account event] -> Value #

toEncodingList :: [GeneralLedger precision account event] -> Encoding #

(KnownNat precision, FromJSON account, FromJSON event) => FromJSON (GeneralLedger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

parseJSON :: Value -> Parser (GeneralLedger precision account event) #

parseJSONList :: Value -> Parser [GeneralLedger precision account event] #

type Rep (GeneralLedger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

type Rep (GeneralLedger precision account event) = D1 ('MetaData "GeneralLedger" "Haspara.Accounting.Ledger" "haspara-0.0.0.4-91kyQ1gsJrx6JOOKY5ajCi" '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.

Constructors

Ledger 

Fields

Instances

Instances details
(Eq account, Eq event) => Eq (Ledger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

(==) :: Ledger precision account event -> Ledger precision account event -> Bool #

(/=) :: Ledger precision account event -> Ledger precision account event -> Bool #

(KnownNat precision, Show account, Show event) => Show (Ledger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

showsPrec :: Int -> Ledger precision account event -> ShowS #

show :: Ledger precision account event -> String #

showList :: [Ledger precision account event] -> ShowS #

Generic (Ledger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Associated Types

type Rep (Ledger precision account event) :: Type -> Type #

Methods

from :: Ledger precision account event -> Rep (Ledger precision account event) x #

to :: Rep (Ledger precision account event) x -> Ledger precision account event #

(KnownNat precision, ToJSON account, ToJSON event) => ToJSON (Ledger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

toJSON :: Ledger precision account event -> Value #

toEncoding :: Ledger precision account event -> Encoding #

toJSONList :: [Ledger precision account event] -> Value #

toEncodingList :: [Ledger precision account event] -> Encoding #

(KnownNat precision, FromJSON account, FromJSON event) => FromJSON (Ledger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

parseJSON :: Value -> Parser (Ledger precision account event) #

parseJSONList :: Value -> Parser [Ledger precision account event] #

type Rep (Ledger precision account event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

type Rep (Ledger precision account event) = D1 ('MetaData "Ledger" "Haspara.Accounting.Ledger" "haspara-0.0.0.4-91kyQ1gsJrx6JOOKY5ajCi" '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.

Instances

Instances details
Eq event => Eq (LedgerEntry precision event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

(==) :: LedgerEntry precision event -> LedgerEntry precision event -> Bool #

(/=) :: LedgerEntry precision event -> LedgerEntry precision event -> Bool #

(KnownNat precision, Show event) => Show (LedgerEntry precision event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

showsPrec :: Int -> LedgerEntry precision event -> ShowS #

show :: LedgerEntry precision event -> String #

showList :: [LedgerEntry precision event] -> ShowS #

Generic (LedgerEntry precision event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Associated Types

type Rep (LedgerEntry precision event) :: Type -> Type #

Methods

from :: LedgerEntry precision event -> Rep (LedgerEntry precision event) x #

to :: Rep (LedgerEntry precision event) x -> LedgerEntry precision event #

(KnownNat precision, ToJSON event) => ToJSON (LedgerEntry precision event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

toJSON :: LedgerEntry precision event -> Value #

toEncoding :: LedgerEntry precision event -> Encoding #

toJSONList :: [LedgerEntry precision event] -> Value #

toEncodingList :: [LedgerEntry precision event] -> Encoding #

(KnownNat precision, FromJSON event) => FromJSON (LedgerEntry precision event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

Methods

parseJSON :: Value -> Parser (LedgerEntry precision event) #

parseJSONList :: Value -> Parser [LedgerEntry precision event] #

type Rep (LedgerEntry precision event) Source # 
Instance details

Defined in Haspara.Accounting.Ledger

type Rep (LedgerEntry precision event) = D1 ('MetaData "LedgerEntry" "Haspara.Accounting.Ledger" "haspara-0.0.0.4-91kyQ1gsJrx6JOOKY5ajCi" 'False) (C1 ('MetaCons "LedgerEntry" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ledgerEntryDate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Day) :*: (S1 ('MetaSel ('Just "ledgerEntryAmount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Amount precision)) :*: S1 ('MetaSel ('Just "ledgerEntryDescription") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))) :*: (S1 ('MetaSel ('Just "ledgerEntryEvent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 event) :*: (S1 ('MetaSel ('Just "ledgerEntryPostingId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "ledgerEntryBalance") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Balance precision))))))

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 -> 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 -> 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 -> Ledger precision account event Source #

Performs a posting to the given ledger.