beansoup package

Submodules

beansoup.transactions module

Utilities to work with beancount.core.data.Transaction objects.

class beansoup.transactions.TransactionCompleter(existing_entries, account, min_score=0.5, max_age=None, interpolated=False)[source]

Bases: object

A class capable of completing partial transactions.

Importers typically generate incomplete transactions with a single posting to the main account related to the imported data. This class attempts to complete those transaction by adding a second posting to an account chosen based on the existing transaction history for the main account.

It looks for existing transactions that have exactly two postings and where one of the two postings is to the main account. It scores each of these transactions based on the similarity of its payee and narration fields to the narration field of the incomplete transaction and selects the one with the highest score as a model to fill in the missing posting of the incomplete transaction. Equal scores are broken by selecting the most recent transaction.

__call__(entries)[source]

Same as complete_entries method.

complete_entries(entries)[source]

Complete the given entries.

Only transactions with a single posting to the account bound to the completer may be modified.

Parameters:entries – The entries to be completed.
Returns:A list of completed entries
complete_entry(entry)[source]

Complete the given entry.

This method attempts to complete the entry only if it is a transaction with a single posting to the account bound to the completer. The entry will be completed only if a suitable model transaction can be found. If multiple model transactions are found that balance the transaction against different account, the missing posting will be flagged for review.

Parameters:entry – The entry to be completed.

Returns: True is the entry was completed; False, otherwise.

find_best_model(txn)[source]

Return the best model for the given incomplete transaction.

Parameters:txn – A beancount.core.data.Transaction object; an incomplete transaction with a single posting.
Returns:A pair of a beancount.core.data.Transaction object and a set of account strings; the first part is the model transaction or None, if no suitable model could be found; the second part is a set of the different accounts used by top-scoring transaction to balance the posting to the target account.
score_model(model_txn, txn)[source]

Score an existing transaction for its ability to provide a model for an incomplete transaction.

Parameters:
  • model_txn – The transaction to be scored.
  • txn – The incomplete transaction.
Returns:

A float number representing the score, normalized in [0,1].

beansoup.version module

Project version.

Module contents