Example #1
0
def new_transaction():
    merchants = merchant_repository.select_all()
    users = user_repository.select_all()
    tags = tag_repository.select_all()
    return render_template("/transactions/new.html",
                           merchants=merchants,
                           users=users,
                           tags=tags)
Example #2
0
def edit_transaction(id):
    transaction = transaction_repository.select(id)
    merchants = merchant_repository.select_all()
    tags = tag_repository.select_all()
    return render_template("transactions/edit.html",
                           transaction=transaction,
                           merchants=merchants,
                           tags=tags)
def new_transaction():
    users = user_repository.select_all()
    tags = tag_repository.select_all()
    merchants = merchant_repository.select_all()
    return render_template("transactions/new.html",
                           users=users,
                           tags=tags,
                           merchants=merchants,
                           title="New Transaction")
Example #4
0
def create_transaction():
    amount = request.form["amount"]
    user = user_repository.select(request.form["user"])
    merchant = merchant_repository.select(request.form["merchant"])
    tag = tag_repository.select(request.form["tag"])
    new_transaction = Transaction(amount, user, merchant, tag)
    transaction_repository.save(new_transaction)
    tags = tag_repository.select_all()
    transactions = user_repository.select_transactions(user)
    total = 0
    for transaction in transactions:
        total += transaction.amount
    return render_template("/users/dashboard.html", user = user, transactions = transactions, total = total, tags = tags)
def transactions():
    transactions = transaction_repository.select_all()
    users = user_repository.select_all()
    tags = tag_repository.select_all()
    total_amount = 0.00
    for transaction in transactions:
        total_amount += float(transaction.amount)
    return render_template("transactions/index.html",
                           transactions=transactions,
                           users=users,
                           total_amount=total_amount,
                           tags=tags,
                           title="Transactions")
Example #6
0
def welcome():
    id = request.form["user.id"]
    user = user_repository.select(id)
    transactions = user_repository.select_transactions(user)
    total = 0
    tags = tag_repository.select_all()
    for transaction in transactions:
        total += transaction.amount
    return render_template("/users/dashboard.html",
                           user=user,
                           transactions=transactions,
                           tags=tags,
                           total=total)
Example #7
0
def update_transaction(id):
    transaction = transaction_repository.select(id)
    user = user_repository.select(transaction.user.id)
    amount = request.form['amount']
    merchant = merchant_repository.select(request.form['merchant'])
    tag = tag_repository.select(request.form['tag'])
    updated_transaction = Transaction(amount, user, merchant, tag, transaction.id)
    transaction_repository.update(updated_transaction)
    transactions = user_repository.select_transactions(user)
    tags = tag_repository.select_all()
    total = 0
    for transaction in transactions:
        total += transaction.amount
    return render_template("/users/dashboard.html", user = user, transactions = transactions, total = total, tags = tags)
def tags():
    tags = tag_repository.select_all()
    return render_template("/categories/index.html", tags=tags)
Example #9
0
def new_tag():
    all_tags = tag_repository.select_all()
    return render_template("tags/new.html", all_tags=all_tags)
Example #10
0
merchant_1 = Merchant("Asda")
merchant_repository.save(merchant_1)
merchant_2 = Merchant("Vodafone")
merchant_repository.save(merchant_2)
merchant_3 = Merchant("Adidas")
merchant_repository.save(merchant_3)

tag_1 = Tag("Finances")
tag_repository.save(tag_1)
tag_2 = Tag("Groceries")
tag_repository.save(tag_2)
tag_3 = Tag("Shopping")
tag_repository.save(tag_3)

transaction_1 = Transaction(50, merchant_1, tag_2)
transaction_repository.save(transaction_1)
transaction_2 = Transaction(65, merchant_3, tag_3)
transaction_repository.save(transaction_2)
transaction_3 = Transaction(20, merchant_2, tag_1)
transaction_repository.save(transaction_3)

merchant_repository.select_all()
tag_repository.select_all()
transaction_repository.select_all()

merchant_1.name = "Tesco"
merchant_repository.update(merchant_1)

tag_1.category = "Bills"
tag_repository.update(tag_1)
Example #11
0
def add_transaction():
    companies = company_repository.select_all()
    tags = tag_repository.select_all()
    return render_template("add-transaction.html", companies=companies, tags=tags)
Example #12
0
def inject_users():
    users = user_repository.select_all()
    merchants = merchant_repository.select_all()
    tags = tag_repository.select_all()
    return dict(users=users, merchants=merchants, tags=tags)