Beispiel #1
0
def edit_transaction(transaction_id):
    db_session = create_session()
    category_dao = CategoryDAO(db_session)
    categories = category_dao.find_by_user_id(session["id"])
    account_dao = AccountDAO(db_session)
    accounts = account_dao.find_by_user_id(session["id"])
    transaction_dao = TransactionDAO(db_session)
    transaction = transaction_dao.find_by_id_and_user_id(
        transaction_id=transaction_id,
        user_id=session["id"]
    )
    destination_accnt_id = None
    linked_transaction_id = None
    if transaction.link_id is not None:
        linked_transaction = transaction_dao.find_linked_transaction(
            link_id=transaction.link_id,
            user_id=session["id"],
            transaction_id=transaction.id
        )
        destination_accnt_id = linked_transaction.source_accnt_id
        linked_transaction_id = linked_transaction.id
    db_session.close()
    return render_template(
        "transactions/edit.html",
        categories=categories,
        accounts=accounts,
        category_id=transaction.category_id,
        date=transaction.date,
        description=transaction.description,
        destination_accnt_id=destination_accnt_id,
        id=transaction.id,
        source_accnt_id=transaction.source_accnt_id,
        value=transaction.value,
        link_id=linked_transaction_id
    )
Beispiel #2
0
def list_accounts():
    db_session = create_session()
    accounts_dao = AccountDAO(db_session)

    accounts = accounts_dao.find_by_user_id(session["id"])
    db_session.close()
    return render_template("accounts/index.html", accounts=accounts)
Beispiel #3
0
def list_transactions():
    db_session = create_session()
    transaction_dao = TransactionDAO(db_session)
    all_transactions = transaction_dao.find_by_user_id(user_id=session["id"])
    category_dao = CategoryDAO(db_session)
    categories = category_dao.find_by_user_id(session["id"])
    account_dao = AccountDAO(db_session)
    accounts = account_dao.find_by_user_id(session["id"])
    db_session.close()
    return render_template("transactions/index.html",
                           transactions=all_transactions,
                           categories=categories,
                           accounts=accounts)
Beispiel #4
0
def new_transaction():
    db_session = create_session()
    category_dao = CategoryDAO(db_session)
    categories = category_dao.find_by_user_id(session["id"])
    account_dao = AccountDAO(db_session)
    accounts = account_dao.find_by_user_id(session["id"])
    db_session.close()
    return render_template(
        "transactions/edit.html",
        categories=categories,
        date=datetime.now(),
        destination_accnt_id=None,
        accounts=accounts
    )