def select(id): sql = "SELECT * FROM transactions WHERE id=%s" values = [id] result = run_sql(sql, values)[0] company = company_repository.select(result["company_id"]) tag = tag_repository.select(result["tag_id"]) transaction = Transaction(result["amount"], company, tag, result["id"]) return transaction
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 select_all(): transactions = [] sql = "SELECT * FROM transactions" results = run_sql(sql) for result in results: company = company_repository.select(result["company_id"]) tag = tag_repository.select(result["tag_id"]) transaction = Transaction(result["amount"], company, tag, result["id"]) transactions.append(transaction) return transactions
def select_all(): investments = [] sql = 'SELECT * FROM investments' results = run_sql(sql) for row in results: investor = investor_repository.select(row['investor_id']) company = company_repository.select(row['company_id']) investment = Investment(investor, company, row['equity'], row['payment'], row['date_of_investment'], row['id']) investments.append(investment) return investments
def create_investment(): investor_id = request.form['investor_id'] company_id = request.form['company_id'] equity = request.form['equity'] payment = request.form['payment'] date_of_investment = request.form['date_of_investment'] investor = investor_repository.select(investor_id) company = company_repository.select(company_id) investment = Investment(investor, company, equity, payment, date_of_investment) investment_repository.save(investment) return redirect('/investments')
def edit_company(id): company = company_repository.select(id) category = category_repository.select_all() account = account_repository.select_all() return render_template('companys/edit.html', company=company, all_category=category, accounts=account)
def show(id): company = company_repository.select(id) investors = company_repository.investors(company) investments = company_repository.investments(id) return render_template("companies/show.html", company=company, investors=investors, investments=investments)
def edit_company(id): company = company_repository.select(id) return render_template("companies/edit.html", company=company)