Account
Standard Accounts
- class account.Account(guid: str | None = None, slots: list[Slot] | None = None, name: str = '', account_type: str | None = None, description: str | None = None, children: list[Account] | None = None, code: str | None = None, commodity: Commodity | None = None, commodity_scu: str | None = None, non_std_scu: int | None = None)[source]
Bases:
GuidObject
,SlottableObject
Represents an account in GnuCash.
- as_dict(account_hierarchy: dict[str, Account] | None = None, path_to_self: str = '/') dict[str, Account] [source]
Retrieves the current account hierarchy as a dictionary.
- property dict_entry_name: str
Retrieves the dictionary entry based on account name.
Only alpha-numeric and underscore characters allowed. Spaces and slashes (/) are converted to underscores.
- Returns:
String with the dictionary entry name.
- Return type:
- get_account_guids(account_guids: list[str] | None = None) list[str] [source]
Gets a flat list of account GUIDs under the current account.
- get_parent_commodity() Commodity | None [source]
Retrieves the commodity for the account.
If none is provided, it will look at it’s parent (and ancestors recursively) to find it.
- Returns:
Commodity object, or None if no commodity was found in the ancestry chain.
- Return type:
NoneType|Commodity
- get_subaccount_by_id(subaccount_id: str) Account | None [source]
Finds a subaccount by its guid field.
Hidden flag for the account.
- Returns:
True if account is marked hidden, otherwise False.
- Return type:
Shortcut Accounts
- class account.AssetAccount(name: str = '', description: str | None = None, children: list[Account] | None = None, code: str | None = None, commodity: Commodity | None = None, commodity_scu: str | None = None, non_std_scu: int | None = None)[source]
Bases:
Account
Shortcut class to create an account with the type set to AccountType.ASSET.
- class account.BankAccount(name: str = '', description: str | None = None, children: list[Account] | None = None, code: str | None = None, commodity: Commodity | None = None, commodity_scu: str | None = None, non_std_scu: int | None = None)[source]
Bases:
Account
Shortcut class to create an account with the type set to AccountType.BANK.
- class account.CreditAccount(name: str = '', description: str | None = None, children: list[Account] | None = None, code: str | None = None, commodity: Commodity | None = None, commodity_scu: str | None = None, non_std_scu: int | None = None)[source]
Bases:
Account
Shortcut class to create an account with the type set to AccountType.CREDIT.
- class account.EquityAccount(name: str = '', description: str | None = None, children: list[Account] | None = None, code: str | None = None, commodity: Commodity | None = None, commodity_scu: str | None = None, non_std_scu: int | None = None)[source]
Bases:
Account
Shortcut class to create an account with the type set to AccountType.EQUITY.
- class account.ExpenseAccount(name: str = '', description: str | None = None, children: list[Account] | None = None, code: str | None = None, commodity: Commodity | None = None, commodity_scu: str | None = None, non_std_scu: int | None = None)[source]
Bases:
Account
Shortcut class to create an account with the type set to AccountType.EXPENSE.
- class account.IncomeAccount(name: str = '', description: str | None = None, children: list[Account] | None = None, code: str | None = None, commodity: Commodity | None = None, commodity_scu: str | None = None, non_std_scu: int | None = None)[source]
Bases:
Account
Shortcut class to create an account with the type set to AccountType.INCOME.
- class account.LiabilityAccount(name: str = '', description: str | None = None, children: list[Account] | None = None, code: str | None = None, commodity: Commodity | None = None, commodity_scu: str | None = None, non_std_scu: int | None = None)[source]
Bases:
Account
Shortcut class to create an account with the type set to AccountType.LIABILITY.
Special Accounts
- class account.InterestAccountBase[source]
Abstract class defining the API for Interest accounts.
- abstract get_all_payments(skip_additional_payments: bool = False) list[tuple[datetime, Decimal, Decimal]] [source]
Abstract method for retrieving all payments for the loan plan.
- Parameters:
skip_additional_payments (bool) – Skips additional payments if True.
- abstract get_info_at_date(date: datetime) LoanStatus [source]
Abstract method for retrieving the loan info at a specified date for the account.
- Parameters:
date (datetime.datetime) – datetime object indicating the date you want the loan status of
- abstract property interest_percentage: Decimal
Abstract method for retrieving the interest percentage for the account.
- abstract property payment_amount: Decimal
Abstract method for retrieving the payment amount for the account.
- class account.InterestAccount(starting_balance: Decimal, starting_date: datetime, interest_percentage: Decimal, payment_amount: Decimal, additional_payments: list[LoanExtraPayment] | None = None, skip_payment_dates: list[datetime] | None = None, interest_start_date: datetime | None = None)[source]
Class used to calculate interest balances.
- __init__(starting_balance: Decimal, starting_date: datetime, interest_percentage: Decimal, payment_amount: Decimal, additional_payments: list[LoanExtraPayment] | None = None, skip_payment_dates: list[datetime] | None = None, interest_start_date: datetime | None = None)[source]
Class initializer.
- Parameters:
starting_balance (decimal.Decimal|NoneType) – Starting balance for the interest account.
starting_date (datetime.datetime|NoneType) – datetime object indicating the date of the starting balance.
interest_percentage (decimal.Decimal|NoneType) – Percentage to interest on the loan.
payment_amount (decimal.Decimal|NoneType) – Payment amount on the loan.
additional_payments (list[LoanExtraPayment]|NoneType) – List of LoanExtraPayment objects indicating extra payments to the loan.
skip_payment_dates (list[datetime.datetime]|NoneType) – List of datetime objects that the loan payment should be skipped
interest_start_date (datetime.datetime|NoneType) – datetime object that interest starts on
- get_all_payments(skip_additional_payments: bool = False) list[tuple[datetime, Decimal, Decimal]] [source]
Retrieves a list of tuples that show all payments for the loan plan.
- get_info_at_date(date: datetime) LoanStatus [source]
Retrieves the loan info at a specified date for the current account.
- Parameters:
date (datetime.datetime) – datetime object indicating the date you want the loan status of
- Returns:
LoanStatus object
- Return type:
- property interest_percentage: Decimal
Retrieves the interest percentage for the account.
- Returns:
Current InterestAccount object’s percentage.
- Return type:
- property payment_amount: Decimal
Retrieves the payment amount for the account.
- Returns:
Current InterestAccount object’s payment amount.
- Return type:
- property starting_balance: Decimal
Retrieves the starting balance for the account.
- Returns:
Current InterestAccount object’s starting balance.
- Return type:
- class account.InterestAccountWithSubaccounts(subaccounts: list[InterestAccount], additional_payments: list[dict[str, Decimal | datetime]] | None = None, skip_payment_dates: list[datetime] | None = None)[source]
Class used to calculate interest balances based off of balances of subaccounts.
- __init__(subaccounts: list[InterestAccount], additional_payments: list[dict[str, Decimal | datetime]] | None = None, skip_payment_dates: list[datetime] | None = None)[source]
Class initializer.
- Parameters:
subaccounts (list[InterestAccount]) – List of InterestAccount objects that are subaccounts of this InterestAccount
additional_payments (list[dict]|NoneType) – List of dictionaries containing an “amount” key for additional amount paid, and “payment_date” for the date the additional amount was paid.
skip_payment_dates (list[datetime.datetime]|NoneType) – List of datetime objects that the loan payment should be skipped
- get_all_payments(skip_additional_payments: bool = False) list[tuple[datetime, Decimal, Decimal]] [source]
Retrieves a list of tuples that show all payments for the loan plan.
- get_info_at_date(date: datetime) LoanStatus [source]
Retrieves the loan info at a specified date for all subaccounts.
- Parameters:
date (datetime.datetime) – datetime object indicating the date you want the loan status of
- Returns:
LoanStatus object
- Return type:
- property interest_percentage: Decimal
Retrieves the sum of the subaccounts’ interest percentage.
- Returns:
Sum of interest percentages.
- Return type:
- property payment_amount: Decimal
Retrieves the sum of the subaccounts’ payment amount.
- Returns:
Sum of the payment amounts.
- Return type:
- property starting_balance: Decimal
Retrieves the sum of the subaccounts’ starting balance.
- Returns:
Sum of the starting balances.
- Return type: