penny-lib-0.12.0.0: Extensible double-entry accounting system - library

Safe HaskellNone

Penny.Lincoln.Transaction

Contents

Description

Transactions, the heart of Penny. The Transaction data type is abstract, so that only this module can create Transactions. This provides assurance that if a Transaction exists, it is a valid, balanced Transaction. In addition, the Posting data type is abstract as well, so you know that if you have a Posting, it was created as part of a balanced Transaction.

Functions prefixed with a p query a particular posting for its properties. Functions prefixed with a t query transactions. Every transaction has a single DateTime, and all the postings have this same DateTime, so there is no function to query a posting's DateTime. Just query the parent transaction. For other things such as Number and Flag, the transaction might have data and the posting might have data as well, so functions are provided to query both.

Often you will want to query a single posting and have a function that gives you, for example, the posting's flag if it has one, or the transaction's flag if it has one, or Nothing if neither the posting nor the transaction has a flag. The functions in Penny.Lincoln.Queries do that.

Synopsis

Postings and transactions

data Posting Source

Each Transaction consists of at least two Postings.

Instances

data Transaction Source

All the Postings in a Transaction must produce a Total whose debits and credits are equal. That is, the Transaction must be balanced. No Transactions are created that are not balanced.

data PostFam Source

Instances

Making and deconstructing transactions

data RTransaction Source

Constructors

RTransaction 

Fields

rtCommodity :: Commodity

All postings will have this same commodity

rtSide :: Maybe Side

All commodities will be on this side of the amount

rtSpaceBetween :: Maybe SpaceBetween

All amounts will have this SpaceBetween

rtDrCr :: DrCr

All postings except the inferred one will have this DrCr

rtTopLine :: TopLine
 
rtPosting :: RPosting

You must have at least one posting whose quantity you specify

rtMorePostings :: [RPosting]

Optionally you can have additional restricted postings.

rtIPosting :: IPosting

And at least one posting whose quantity and DrCr will be inferred

Instances

rTransaction :: RTransaction -> TransactionSource

Creates a restricted transaction; that is, one in which all the entries will have the same commodity, and in which all but one of the postings will all be debits or credits. The last posting will have no quantity specified at all and will be inferred. Creating these transactions never fails, in contrast to the transactions created by transaction, which can fail at runtime.

data Error Source

Errors that can arise when making a Transaction.

Instances

toUnverified :: Transaction -> Family TopLine PostingSource

Deconstruct a Transaction to a family of unverified data.

Querying postings

data Inferred Source

Indicates whether the entry for this posting was inferred. That is, if the user did not supply an entry for this posting, then it was inferred.

Constructors

Inferred 
NotInferred 

Instances

Querying transactions

data TopLine Source

The TopLine holds information that applies to all the postings in a transaction (so named because in a ledger file, this information appears on the top line.)

Instances

postFam :: Transaction -> [PostFam]Source

Get the Postings from a Transaction, with information on the sibling Postings.

Box

data Box m Source

A box stores a family of transaction data along with metadata. The transaction is stored in child form, indicating a particular posting of interest. The metadata is in addition to the metadata associated with the TopLine and with each posting.

Constructors

Box 

Fields

boxMeta :: m
 
boxPostFam :: PostFam
 

Instances

Functor Box 
Show m => Show (Box m) 

Changers

Functions allowing you to change aspects of an existing transaction, without having to destroy and completely rebuild the transaction. You cannot change the Entry or any of its components, as changing any of these would unbalance the Transaction.

changeTransaction :: Family TopLineChangeData PostingChangeData -> Transaction -> TransactionSource

Allows you to change the parts of a transaction that can be chanaged without unbalancing the transaction. You cannot change the DrCr, Qty, or Commodity, as changing these might unbalance the transaction. If there are elements you do not want to change at all, use an emptyTopLineChangeData or an emptyPostingChangeData in the appropriate part of the Family that you pass in. If the Family of change data has more children than the transaction, these extra children are ignored. If the Family in the Transaction has more children than the Family of change data, the extra postings are unchanged. That is, changeTransaction will never delete postings.