Safe Haskell | None |
---|
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
- unPostFam :: PostFam -> Child TopLine Posting
- transaction :: Family TopLine Posting -> Exceptional Error Transaction
- data RTransaction = RTransaction {}
- rTransaction :: RTransaction -> Transaction
- data Error
- toUnverified :: Transaction -> Family TopLine Posting
- 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 -> Maybe Memo
- pInferred :: Posting -> Inferred
- pPostingLine :: Posting -> Maybe PostingLine
- pGlobalPosting :: Posting -> Maybe GlobalPosting
- pFilePosting :: Posting -> Maybe FilePosting
- data TopLine
- tDateTime :: TopLine -> DateTime
- tFlag :: TopLine -> Maybe Flag
- tNumber :: TopLine -> Maybe Number
- tPayee :: TopLine -> Maybe Payee
- tMemo :: TopLine -> Maybe Memo
- tTopLineLine :: TopLine -> Maybe TopLineLine
- tTopMemoLine :: TopLine -> Maybe TopMemoLine
- tFilename :: TopLine -> Maybe Filename
- tGlobalTransaction :: TopLine -> Maybe GlobalTransaction
- tFileTransaction :: TopLine -> Maybe FileTransaction
- unTransaction :: Transaction -> Family TopLine Posting
- postFam :: Transaction -> [PostFam]
- data Box m = Box {
- boxMeta :: m
- boxPostFam :: PostFam
- data TopLineChangeData = TopLineChangeData {
- tcDateTime :: Maybe DateTime
- tcFlag :: Maybe (Maybe Flag)
- tcNumber :: Maybe (Maybe Number)
- tcPayee :: Maybe (Maybe Payee)
- tcMemo :: Maybe (Maybe Memo)
- tcTopLineLine :: Maybe (Maybe TopLineLine)
- tcTopMemoLine :: Maybe (Maybe TopMemoLine)
- tcFilename :: Maybe (Maybe Filename)
- tcGlobalTransaction :: Maybe (Maybe GlobalTransaction)
- tcFileTransaction :: Maybe (Maybe FileTransaction)
- emptyTopLineChangeData :: TopLineChangeData
- data PostingChangeData = PostingChangeData {
- pcPayee :: Maybe (Maybe Payee)
- pcNumber :: Maybe (Maybe Number)
- pcFlag :: Maybe (Maybe Flag)
- pcAccount :: Maybe Account
- pcTags :: Maybe Tags
- pcMemo :: Maybe (Maybe Memo)
- pcSide :: Maybe (Maybe Side)
- pcSpaceBetween :: Maybe (Maybe SpaceBetween)
- pcPostingLine :: Maybe (Maybe PostingLine)
- pcGlobalPosting :: Maybe (Maybe GlobalPosting)
- pcFilePosting :: Maybe (Maybe FilePosting)
- emptyPostingChangeData :: PostingChangeData
- changeTransaction :: Family TopLineChangeData PostingChangeData -> Transaction -> Transaction
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 and deconstructing transactions
transaction :: Family TopLine Posting -> Exceptional Error TransactionSource
Makes transactions.
data RTransaction Source
RTransaction | |
|
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.
Errors that can arise when making a Transaction.
toUnverified :: Transaction -> Family TopLine PostingSource
Deconstruct a Transaction to a family of unverified data.
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.
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.)
postFam :: Transaction -> [PostFam]Source
Get the Postings from a Transaction, with information on the sibling Postings.
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 | |
|
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.
data TopLineChangeData Source
Each field in the record is a Maybe. If Nothing, make no change to this part of the TopLine.
TopLineChangeData | |
|
data PostingChangeData Source
PostingChangeData | |
|
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.