Transaction

class transaction.Transaction[source]

Represents a transaction in GnuCash.

associated_uri

URI associated with the transaction.

Returns:URI associated with the transaction
Return type:str
cleared

Checks if all splits in the transaction are cleared.

Returns:Boolean indicating if all splits in the transaction are cleared.
Return type:bool
mark_transaction_cleared() → None[source]

Marks all splits in the transaction as cleared (reconciled_state = ‘c’).

notes

Notes on the transaction.

Returns:Notes tied to the transaction
Return type:str
reversed_by

GUID of the transaction that reverses this transaction.

Returns:Transaction GUID
Return type:str
void_reason

Reason that the transaction was voided.

Returns:Reason that the transaction was voided
Return type:str
void_time

Time that the transaction was voided.

Returns:Time that the transaction was voided
Return type:str
voided

Void status.

Returns:Void status
Return type:str
class transaction.Split(account: Optional[gnewcash.account.Account], amount: Optional[decimal.Decimal], reconciled_state: str = 'n')[source]

Represents a split in GnuCash.

class transaction.TransactionManager[source]

Class used to add/remove transactions, maintaining a chronological order based on transaction posted date.

add(new_transaction: transaction.Transaction) → None[source]

Adds a transaction to the transaction manager.

Parameters:new_transaction (Transaction) – Transaction to add
delete(transaction: transaction.Transaction) → None[source]

Removes a transaction from the transaction manager.

Parameters:transaction (Transaction) – Transaction to remove
get_account_ending_balance(account: gnewcash.account.Account) → decimal.Decimal[source]

Retrieves the ending balance for the provided account given the list of transactions in the manager.

Parameters:account (Account) – Account to get the ending balance for
Returns:Account starting balance
Return type:decimal.Decimal
get_account_starting_balance(account: gnewcash.account.Account) → decimal.Decimal[source]

Retrieves the starting balance for the current account, given the list of transactions.

Parameters:account (Account) – Account to get starting balance of.
Returns:First transaction amount if the account has transactions, otherwise 0.
Return type:decimal.Decimal
get_balance_at_date(account: gnewcash.account.Account, date: Optional[datetime.datetime] = None) → decimal.Decimal[source]

Retrieves the account balance for the current account at a certain date, given the list of transactions.

If the provided date is None, it will retrieve the ending balance.

Parameters:
  • account (Account) – Account to get the balance of
  • date (datetime.datetime) – Last date to consider when determining the account balance.
Returns:

Account balance at specified date (or ending balance) or 0, if no applicable transactions were found.

Return type:

decimal.Decimal

get_transactions(account: Optional[gnewcash.account.Account] = None) → Iterator[transaction.Transaction][source]

Generator function that gets transactions based on a from account and/or to account for the transaction.

Parameters:account (Account) – Account to retrieve transactions for (default None, all transactions)
Returns:Generator that produces transactions based on the given from account and/or to account
Return type:Iterator[Transaction]
minimum_balance_past_date(account: gnewcash.account.Account, date: datetime.datetime) → Tuple[Optional[decimal.Decimal], Optional[datetime.datetime]][source]

Gets the minimum balance for the account after a certain date, given the list of transactions.

Parameters:
  • account (Account) – Account to get the minimum balance information of
  • date (datetime.datetime) – datetime object representing the date you want to find the minimum balance for.
Returns:

Tuple containing the minimum balance (element 0) and the date it’s at that balance (element 1)

Return type:

tuple

class transaction.ScheduledTransaction[source]

Class that represents a scheduled transaction in Gnucash.

class transaction.SimpleTransaction[source]

Class used to simplify creating and manipulating Transactions that only have 2 splits.

amount

Dollar amount for funds transferred.

Returns:Dollar amount for funds transferred.
Return type:decimal.Decimal
from_account

Account which the transaction transfers funds from.

Returns:Account which the transaction transfers funds from.
Return type:Account
classmethod from_transaction(other: transaction.Transaction) → transaction.SimpleTransaction[source]

Creates a SimpleTransaction from a regular Transaction.

to_account

Account which the transaction transfers funds to.

Returns:Account which the transaction transfers funds to.
Return type:Account