def create_transaction(): tag = tag_repository.select(request.form["tag_id"]) merchant = merchant_repository.select(request.form["merchant_id"]) amount = request.form["amount"] new_transaction = Transaction(tag, merchant, amount) transaction_repository.save(new_transaction) return redirect("/transactions")
def create_transaction(): amount = request.form["amount"] company_id = request.form["company_id"] tag_id = request.form["tag_id"] company = company_repository.select(company_id) tag = tag_repository.select(tag_id) new_transaction = Transaction(amount, company, tag) transaction_repository.save(new_transaction) return redirect("/")
def create_transaction(): amount = request.form["amount"] merchant_id = request.form["merchant_id"] tag_id = request.form["tag_id"] merchant = merchant_repository.select(merchant_id) tag = tag_repository.select(tag_id) new_transaction = Transaction(amount, merchant, tag) transaction_repository.save(new_transaction) return redirect("/transactions")
def create_transactions(): amount = request.form['amount'] category = category_repository.select(request.form['category_id']) date = request.form['date'] merchant = merchant_repository.select(request.form['merchant_id']) user = user_repository.select(request.form['user_id']) transaction = Transaction(amount, category, date, merchant, user) transaction_repository.save(transaction) return redirect("/transactions")
def create_transaction(): merchant_id = request.form['merchant_id'] tag_id = request.form['tag_id'] amount = request.form['amount'] merchant = merchant_repository.select(merchant_id) tag = tag_repository.select(tag_id) transaction = Transaction(merchant, tag, amount) transaction_repository.save(transaction) return redirect('/transactions')
def create_transaction(): merchant_id = request.form["merchant_id"] merchant = merchant_repository.select(merchant_id) date = request.form["date"] amount = float(request.form["amount"]) tag_id = request.form["tag_id"] tag = tag_repository.select(tag_id) new_transaction = Transaction(merchant, date, amount, tag) transaction_repository.save(new_transaction) return redirect("/transactions")
def log_new_transaction(): merchant_id = request.form['merchant-name'] tag_id = request.form['tag-category'] amount = request.form['amount'] merchant = merchant_repository.select(merchant_id) tag = tag_repository.select(tag_id) transaction = Transaction(merchant, tag, amount) transaction_repository.save(transaction) return redirect("/transactions")
def add_transaction(): tag_id = request.form['tag_id'] merchant_id = request.form['merchant_id'] user_id = request.form['user_id'] amount = request.form['amount'] date = request.form['date'] tag = tag_repository.select(tag_id) merchant = merchant_repository.select(merchant_id) user = user_repository.select(user_id) new_transaction = Transaction(tag, merchant, user, amount, date) transaction_repository.save(new_transaction) return redirect("/transactions")
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 create_transaction(): user_id = request.form["user_id"] date = request.form["date"] time = request.form["time"] merchant_id = request.form["merchant_id"] amount = float(request.form["amount"]) tag_id = request.form["tag_id"] user = user_repository.select(user_id) merchant = merchant_repository.select(merchant_id) tag = tag_repository.select(tag_id) if user.can_afford(amount) == True: transaction = Transaction(user, date, time, merchant, amount, tag) transaction_repository.save(transaction) return redirect("/transactions") else: error = "I'm sorry, this transaction will put you over your budget." return render_template("/transactions/error.html", error=error, title="Error")
tag_repository.delete_all() merchant_repository.delete_all() user_repository.delete_all() user_1 = User('Mary Berry', 0) user_repository.save(user_1) user_2 = User('Paul Hollywood', 0) user_repository.save(user_2) merchant_1 = Merchant('Tesco') merchant_repository.save(merchant_1) merchant_2 = Merchant('ASDA') merchant_repository.save(merchant_2) tag_1 = Tag('Groceries') tag_repository.save(tag_1) tag_2 = Tag('Transport') tag_repository.save(tag_2) transaction_1 = Transaction(15, user_1, merchant_1, tag_1) transaction_repository.save(transaction_1) transaction_2 = Transaction(10, user_2, merchant_2, tag_2) transaction_3 = Transaction(25, user_2, merchant_1, tag_1) transaction_repository.save(transaction_2) transaction_repository.save(transaction_3) pdb.set_trace()
merchant1 = Merchant("Overlook Hotel") merchant_repository.save(merchant1) merchant2 = Merchant("Stars Hollow Library") merchant_repository.save(merchant2) merchant3 = Merchant("Luke's Diner") merchant_repository.save(merchant3) tag1 = Tag("Holidays") tag_repository.save(tag1) tag2 = Tag("Self-development") tag_repository.save(tag2) tag3 = Tag("Eating out") tag_repository.save(tag3) transaction1 = Transaction(tag1, merchant1, 1313) transaction_repository.save(transaction1) transaction2 = Transaction(tag2, merchant2, 30) transaction_repository.save(transaction2) transaction3 = Transaction(tag3, merchant3, 65) transaction_repository.save(transaction3) pdb.set_trace
tag_repository.save(tag_3) tag_4 = Tag("utilities") tag_repository.save(tag_4) tag_5 = Tag("entertainment") tag_repository.save(tag_5) tag_6 = Tag("floristry") tag_repository.save(tag_6) tag_7 = Tag("personal") tag_repository.save(tag_7) transaction_1 = Transaction(150.00, company_1, tag_1) transaction_repository.save(transaction_1) transaction_2 = Transaction(32.00, company_2, tag_2) transaction_repository.save(transaction_2) transaction_3 = Transaction(750.00, company_3, tag_3) transaction_repository.save(transaction_3) transaction_4 = Transaction(70.34, company_4, tag_4) transaction_repository.save(transaction_4) transaction_5 = Transaction(8.50, company_5, tag_5) transaction_repository.save(transaction_5) transaction_6 = Transaction(28.99, company_6, tag_6) transaction_repository.save(transaction_6)