biweeklybudget.models.transaction module

class biweeklybudget.models.transaction.Transaction(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, biweeklybudget.models.base.ModelAsDict

Class that describes Transactions that have actually occurred, against one account and one or more budgets.

Note that in addition to the usual class attributes, the constructor of this class also accepts a budget_amounts keyword argument, which passes its value on to set_budget_amounts().

_dict_properties = ['actual_amount']

Class properties to include in as_dict result.

_sa_class_manager = {'account': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'account_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'budget_transactions': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'budgeted_amount': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'date': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'description': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'notes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'planned_budget': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'planned_budget_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'reconcile': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'scheduled_trans': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'scheduled_trans_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'transfer': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'transfer_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
account

Relationship - Account this transaction is against

account_id

ID of the account this transaction is against

actual_amount

Actual amount of the transaction.

Returns:actual total amount of the transaction
Return type:decimal.Decimal
budget_transactions
budgeted_amount

Budgeted amount of the transaction, if it was budgeted ahead of time via a ScheduledTransaction. This attribute is only set by submit() and submit(). And, for some incorrect reason, by biweeklybudget.models.utils.do_budget_transfer().

date

date of the transaction

description

description

id

Primary Key

notes

free-form notes

planned_budget

Relationship - the Budget this transaction was planned to be funded by, if it was planned ahead via a ScheduledTransaction.

planned_budget_id

ID of the Budget this transaction was planned to be funded by, if it was planned ahead via a ScheduledTransaction

reconcile
scheduled_trans

Relationship - the ScheduledTransaction this Transaction was created from; set when a scheduled transaction is converted to a real one

scheduled_trans_id

ID of the ScheduledTransaction this Transaction was created from; set when a scheduled transaction is converted to a real one

set_budget_amounts(budget_amounts)[source]

Manage child BudgetTransaction objects corresponding to budget allocations of the amount of this transaction. Given a dictionary (budget_amounts) of budgets (either int ID or Budget instances) to Decimal amounts, ensure that the BudgetTransactions for this Transaction match those amounts.

This method does NOT commit changes; it will modify database state and add the modifications to this object’s session, but the calling code must commit changes.

Parameters:budget_amounts (dict) – Mapping of one or more Budgets to the amount of this Transaction allocated to that Budget. Keys may be either an int id or a Budget instance, values must be a Decimal.
transfer

Relationship - the Transaction that makes up the other half/side of a transfer, if this transaction was for a transfer.

transfer_id

If the transaction is one half of a transfer, the Transaction ID of the other half/side of the transfer.

static unreconciled(db)[source]

Return a query to match all unreconciled Transactions.

Parameters:db (sqlalchemy.orm.session.Session) – active database session to use for queries
Returns:query to match all unreconciled Transactions
Return type:sqlalchemy.orm.query.Query