Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains the accounting combinators that can be used to build complex accounting actions.
All combinators are guaranteed to only allow balanced transactions that adhere to the double-entry bookkeeping standards.
The module Accounting contains the functions to run these actions and calculate the resulting ledger.
- tx :: BalancingTx -> AccountingRW s ()
- closingTx :: [AccountName] -> BalancingTx -> AccountingRW s ()
- type Transfer s = String -> AccountName -> AccountName -> AccountingRW s ()
- fromTo :: Amount -> Transfer s
- fromToLimit :: Amount -> Transfer s
- transferAll :: Transfer s
- currentBalance :: AccPair l w => AccountName -> Acc s l w Amount
- soll :: AccPair l w => AccountName -> Acc s l w Amount
- haben :: AccPair l w => AccountName -> Acc s l w Amount
- balanceAt :: AccPair l w => ADate -> AccountName -> Acc s l w Amount
- balancesSince :: AccPair l w => ADate -> AccountName -> Acc s l w [Amount]
- curDate :: Monoid w => Acc s l w ADate
- onceAt :: Monoid w => ADate -> Acc s l w () -> Acc s l w ()
- onceEvery :: Monoid w => ASpan -> ADate -> Acc s l w a -> Acc s l w ()
- atYearEnd :: Monoid w => Acc s l w a -> Acc s l w ()
- onlyAfter :: Monoid w => ADate -> Acc s l w a -> Acc s l w ()
- schedule :: Monoid w => ADate -> Acc s l w a -> Acc s l w a
- logMsg :: Bool -> String -> AccountingRW s ()
- logLedger :: String -> AccountingRW s ()
- singleLog :: PrintfArg t => String -> t -> AccountingReadOnly body ()
- singleResult :: (PrintfArg a, Num a, Eq a) => String -> AccountingReadOnly body a -> AccountingReadOnly body a
Transactions
tx :: BalancingTx -> AccountingRW s () Source #
Applies a balanced transaction to the ledger at the current date.
closingTx :: [AccountName] -> BalancingTx -> AccountingRW s () Source #
as tx
but taking a list of accounts that should be emptied completely
type Transfer s = String -> AccountName -> AccountName -> AccountingRW s () Source #
Type for simple transfers between two accounts
fromToLimit :: Amount -> Transfer s Source #
Apply a simple transaction, but ensure, that source does not change sign
transferAll :: Transfer s Source #
Transfer all funds from one account to the other
Balances
currentBalance :: AccPair l w => AccountName -> Acc s l w Amount Source #
Get the current balance of an account
soll :: AccPair l w => AccountName -> Acc s l w Amount Source #
Get the balance of a Soll account (uses the amounts directly as stored in the ledger)
haben :: AccPair l w => AccountName -> Acc s l w Amount Source #
Get the balance of a Haben Account account (negates the internally stored amounts)
balanceAt :: AccPair l w => ADate -> AccountName -> Acc s l w Amount Source #
Get the balance at a certain date
balancesSince :: AccPair l w => ADate -> AccountName -> Acc s l w [Amount] Source #
Get the balances since a certain date
Date combinators
onceAt :: Monoid w => ADate -> Acc s l w () -> Acc s l w () Source #
Restrict an accounting action to a certain date
Execute an action periodically
atYearEnd :: Monoid w => Acc s l w a -> Acc s l w () Source #
Execute an action at the end of every year
onlyAfter :: Monoid w => ADate -> Acc s l w a -> Acc s l w () Source #
Executes an action only after a certain date
schedule :: Monoid w => ADate -> Acc s l w a -> Acc s l w a Source #
Perform an accounting action now, but run it with a modified (future) date. E.g.
schedule (date 12 2016) $ tx1
All changes that tx1 performs will be written to the ledger right now, but only modify balances at 12/2016.
Logging
:: Bool | True = to stdout, False = to ledger |
-> String | |
-> AccountingRW s () |
Write a log entry to stdout or to the ledger
logLedger :: String -> AccountingRW s () Source #
Write a log entry to the ledger
:: PrintfArg t | |
=> String | formatting string |
-> t | value |
-> AccountingReadOnly body () |
within the ReadOnly Monad: register a single log entry consisting of a formating string and a value
:: (PrintfArg a, Num a, Eq a) | |
=> String | formatting string |
-> AccountingReadOnly body a | action |
-> AccountingReadOnly body a |
within the ReadOnly Monad: return the value of an action and register a single log entry describing the value, but only if it s not zero