Safe Haskell | Safe-Infered |
---|
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.
- data Posting
- data Transaction
- data PostFam
- transaction :: Family TopLine Posting -> Exceptional Error Transaction
- data Error
- data Inferred
- = Inferred
- | NotInferred
- pPayee :: Posting -> Maybe Payee
- pNumber :: Posting -> Maybe Number
- pFlag :: Posting -> Maybe Flag
- pAccount :: Posting -> Account
- pTags :: Posting -> Tags
- pEntry :: Posting -> Entry
- pMemo :: Posting -> Memo
- pInferred :: Posting -> Inferred
- pMeta :: Posting -> PostingMeta
- changePostingMeta :: (PostingMeta -> PostingMeta) -> Transaction -> Transaction
- data TopLine
- tDateTime :: TopLine -> DateTime
- tFlag :: TopLine -> Maybe Flag
- tNumber :: TopLine -> Maybe Number
- tPayee :: TopLine -> Maybe Payee
- tMemo :: TopLine -> Memo
- tMeta :: TopLine -> TopLineMeta
- unTransaction :: Transaction -> Family TopLine Posting
- postFam :: Transaction -> [PostFam]
- changeTransactionMeta :: (TopLineMeta -> TopLineMeta) -> Transaction -> Transaction
- addSerialsToList :: (Serial -> TopLineMeta -> TopLineMeta) -> (Serial -> PostingMeta -> PostingMeta) -> [Transaction] -> [Transaction]
- addSerialsToEithers :: (Serial -> TopLineMeta -> TopLineMeta) -> (Serial -> PostingMeta -> PostingMeta) -> [Either a Transaction] -> [Either a Transaction]
- data Box m = Box {
- boxMeta :: m
- boxPostFam :: PostFam
Postings and transactions
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.
Making transactions
transaction :: Family TopLine Posting -> Exceptional Error TransactionSource
Makes transactions.
Errors that can arise when making a Transaction.
Querying postings
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.
pMeta :: Posting -> PostingMetaSource
changePostingMeta :: (PostingMeta -> PostingMeta) -> Transaction -> TransactionSource
Change the metadata on a posting.
Querying transactions
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.)
tMeta :: TopLine -> TopLineMetaSource
postFam :: Transaction -> [PostFam]Source
Get the Postings from a Transaction, with information on the sibling Postings.
:: (TopLineMeta -> TopLineMeta) | Function that, when applied to the old top line meta, returns the new meta. |
-> Transaction | The old transaction with metadata |
-> Transaction | Transaction with new metadata |
Change the metadata on a transaction.
Adding serials
addSerialsToList :: (Serial -> TopLineMeta -> TopLineMeta) -> (Serial -> PostingMeta -> PostingMeta) -> [Transaction] -> [Transaction]Source
addSerialsToEithers :: (Serial -> TopLineMeta -> TopLineMeta) -> (Serial -> PostingMeta -> PostingMeta) -> [Either a Transaction] -> [Either a Transaction]Source
Box
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.
Box | |
|