GnuCash File¶
-
class
gnucash_file.
GnuCashFile
(books: Optional[List[Book]] = None)[source]¶ Class representing a GnuCash file on disk.
-
build_file
(target_file: str, file_format: Any, prettify_xml: bool = False) → None[source]¶ Writes the contents of the GnuCashFile object out to a .gnucash file on disk.
Parameters:
-
-
class
gnucash_file.
Book
(root_account: Optional[gnewcash.account.Account] = None, transactions: Optional[gnewcash.transaction.TransactionManager] = None, commodities: Optional[List[gnewcash.commodity.Commodity]] = None, slots: Optional[List[gnewcash.slot.Slot]] = None, template_root_account: Optional[gnewcash.account.Account] = None, template_transactions: Optional[List[gnewcash.transaction.Transaction]] = None, scheduled_transactions: Optional[List[gnewcash.transaction.ScheduledTransaction]] = None, budgets: Optional[List[Budget]] = None)[source]¶ Represents a Book in GnuCash.
-
get_account
(*paths_to_account, **kwargs) → Optional[gnewcash.account.Account][source]¶ Retrieves an account based on a path of account names.
Parameters: - paths_to_account – Names of accounts that indicate the path
- kwargs (dict) – Keyword arguments.
Returns: Account object if found, otherwise None
Return type: NoneType|Account
Example:
get_account('Assets', 'Current Assets', 'Checking Account')
Keyword Arguments:
current_level
= Account to start searching from. If no account is provided, root account is assumed.
-
get_account_balance
(account: gnewcash.account.Account) → decimal.Decimal[source]¶ Retrieves the balance for a specified account based on the transactions in the Book.
Parameters: account (Account) – Account object to retrieve the balance of. Returns: Account balance if applicable transactions found, otherwise 0. Return type: decimal.Decimal or int
-