hax-0.0.2: Haskell cash-flow and tax simulation

Safe HaskellNone
LanguageHaskell2010

HAX.Bookkeeping

Contents

Description

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.

Synopsis

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

fromTo :: Amount -> Transfer s Source #

Apply a simple transaction

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

curDate :: Monoid w => Acc s l w ADate Source #

Get the current date

onceAt :: Monoid w => ADate -> Acc s l w () -> Acc s l w () Source #

Restrict an accounting action to a certain date

onceEvery Source #

Arguments

:: Monoid w 
=> ASpan

Period

-> ADate

Offset

-> Acc s l w a 
-> Acc s l w () 

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

logMsg Source #

Arguments

:: 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

singleLog Source #

Arguments

:: 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

singleResult Source #

Arguments

:: (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