fava.beans¶
Types, functions and wrappers to deal with Beancount types.
fava.beans.abc¶
Abstract base classes for Beancount types.
- class fava.beans.abc.Amount¶
An amount in some currency.
- class fava.beans.abc.Balance¶
A Beancount Balance directive.
- class fava.beans.abc.Close¶
A Beancount Close directive.
- class fava.beans.abc.Commodity¶
A Beancount Commodity directive.
- class fava.beans.abc.Cost¶
A cost (basically an amount with date and label).
- class fava.beans.abc.Custom¶
A Beancount Custom directive.
- class fava.beans.abc.Directive¶
A Beancount directive.
- class fava.beans.abc.Document¶
A Beancount Document directive.
- class fava.beans.abc.Event¶
A Beancount Event directive.
- class fava.beans.abc.Note¶
A Beancount Note directive.
- class fava.beans.abc.Open¶
A Beancount Open directive.
- class fava.beans.abc.Pad¶
A Beancount Pad directive.
- class fava.beans.abc.Position¶
A Beancount position - just cost and units.
- class fava.beans.abc.Posting¶
A Beancount posting.
- class fava.beans.abc.Price¶
A Beancount Price directive.
- class fava.beans.abc.Query¶
A Beancount Query directive.
- class fava.beans.abc.Transaction¶
A Beancount Transaction directive.
- class fava.beans.abc.TxnPosting¶
A transaction and a posting.
- abstract property txn: Transaction¶
Transaction.
fava.beans.account¶
Account name helpers.
- fava.beans.account.account_tester(account, *, with_children)¶
Get a function to check if an account is equal to the account.
- fava.beans.account.child_account_tester(account)¶
Get a function to check if an account is a descendant of the account.
- fava.beans.account.get_entry_accounts(entry)¶
Accounts for an entry.
- Parameters:
entry (
Directive
) – An entry.- Returns:
For transactions the posting accounts are listed in reverse order.
- Return type:
A list with the entry’s accounts ordered by priority
- fava.beans.account.parent(account)¶
Get the name of the parent of the given account.
fava.beans.create¶
Helpers to create entries.
- fava.beans.create.balance(meta, date, account, amount, tolerance=None, diff_amount=None)¶
Create a Beancount Balance.
- Return type:
- fava.beans.create.document(meta, date, account, filename, tags=None, links=None)¶
Create a Beancount Document.
- Return type:
- fava.beans.create.note(meta, date, account, comment, tags=None, links=None)¶
Create a Beancount Note.
- Return type:
- fava.beans.create.open(meta, date, account, currencies, booking=None)¶
Create a Beancount Open.
- Return type:
- fava.beans.create.posting(account, units, cost=None, price=None, flag=None, meta=None)¶
Create a Beancount Posting.
- Return type:
- fava.beans.create.transaction(meta, date, flag, payee, narration, tags=None, links=None, postings=None)¶
Create a Beancount Transaction.
- Return type:
fava.beans.flags¶
Beancount entry flags.
fava.beans.funcs¶
Various functions to deal with Beancount data.
- fava.beans.funcs.get_position(entry)¶
Get the filename and position from the entry metadata.
fava.beans.helpers¶
Helpers for Beancount entries.
fava.beans.ingest¶
Types for Beancount importers.
- class fava.beans.ingest.BeanImporterProtocol(*args, **kwargs)¶
Interface for Beancount importers.
typing.Protocol version of beancount.ingest.importer.ImporterProtocol
Importers can subclass from this one instead of the Beancount one to get type checking for the methods.
- extract(file, *, existing_entries=None)¶
Extract transactions from a file.
- file_date(file)¶
Attempt to obtain a date that corresponds to the given file.
- class fava.beans.ingest.FileMemo(*args, **kwargs)¶
The file with caching support that is passed to importers.
fava.beans.load¶
Load Beancount files and strings.
- fava.beans.load.load_string(value)¶
Load a Beancoun string.
- Return type:
tuple
[list
[Directive
],list
[BeancountError
],BeancountOptions
]
- fava.beans.load.load_uncached(beancount_file_path, *, is_encrypted)¶
Load a Beancount file.
- Return type:
tuple
[list
[Directive
],list
[BeancountError
],BeancountOptions
]
fava.beans.prices¶
Price helpers.
- class fava.beans.prices.DateKeyWrapper(inner)¶
A class wrapping a list of prices for bisect.
This is needed before Python 3.10, which adds the key argument.
- inner¶
- class fava.beans.prices.FavaPriceMap(price_entries)¶
A Fava alternative to Beancount’s PriceMap.
By having some more methods on this class, fewer helper functions need to be imported. Also, this is fully typed and allows to more easily reproduce issues with the whole price logic.
This behaves slightly differently than Beancount. Beancount creates a list for each currency pair and then merges the inverse rates. We just create both the lists in tandem and count the directions that prices occur in.
- commodity_pairs(operating_currencies)¶
List pairs of commodities.
- get_all_prices(base_quote)¶
Get all prices for the given currency pair.
- get_price(base_quote, date=None)¶
Get the price for the given currency pair.
fava.beans.protocols¶
Abstract base classes for Beancount types.
- class fava.beans.protocols.Amount(*args, **kwargs)¶
An amount in some currency.
- class fava.beans.protocols.Cost(*args, **kwargs)¶
A cost (basically an amount with date and label).
fava.beans.str¶
Convert Beancount types to string.
fava.beans.types¶
Typing helpers.
- class fava.beans.types.BeancountOptions¶
Beancount options.
- account_current_conversions: str¶
- account_current_earnings: str¶
- dcontext: DisplayContext¶
- documents: Sequence[str]¶
- filename: str¶
- include: Sequence[str]¶
- name_assets: str¶
- name_equity: str¶
- name_expenses: str¶
- name_income: str¶
- name_liabilities: str¶
- operating_currency: Sequence[str]¶
- render_commas: bool¶
- title: str¶