def edit_category(category, account): data = AccountingAPI.GetCategories() form = AccountingForms.Accounts(request.form) cats = AccountingAPI.GetCategory(session['username'], session['password'], account) AllAccounts = AccountingAPI.GetAccounts(category, account) form.Currency.choices = AccountingAPI.GetCurrencies() if request.method == 'POST': if request.form['submit'] == 'Submit': try: account = request.form['CategoryName'] AccountingAPI.EditCategory(session['username'], session['password'], cats[0], request.form['CategoryName'], request.form['CategoryDescription']) return redirect(url_for('accounting.add_account', category = category, account = account)) except Exception as e: flash(str(e), category = 'fail') return redirect(url_for('accounting.add_account', category = category, account = account)) return render_template('accounting/add-account.html', username = session['username'], role = session['role'], data = data, category = category, cats = cats, form = form, accounts = AllAccounts, account = account)
def edit_account(type, category, account): data = AccountingAPI.GetCategories() cats = AccountingAPI.GetCategory(session['username'], session['password'], category) currencies = AccountingAPI.GetCurrencies() AllAccounts = AccountingAPI.GetAccounts(type, category) AccountData = AccountingAPI.GetAccountData(session['username'], session['password'], type, category, account) if request.method == 'POST': if request.form['submit'] == 'Submit': try: AccountingAPI.UpdateAccount(session['username'], session['password'], request.form['AccountID'], type, category, request.form['AccountCode'], request.form['AccountName'], request.form['Currency'], request.form['OpenBalance'], request.form['CurrentBalance'], request.form['Comments']) flash('Account successfully updated...', category = 'success') return redirect(url_for('accounting.add_account', category = type, account = category)) except Exception as e: flash(str(e), category = 'fail') return render_template('accounting/edit-account.html', username = session['username'], role = session['role'], data = data, category = type, cats = cats, accounts = AllAccounts, account = category, acdata = AccountData, curs = currencies)
def add_account(category, account): data = AccountingAPI.GetCategories() form = AccountingForms.Accounts(request.form) cats = AccountingAPI.GetCategory(session['username'], session['password'], account) AllAccounts = AccountingAPI.GetAccounts(category, account) form.Currency.choices = AccountingAPI.GetCurrencies() if request.method == 'POST': if request.form['submit'] == 'Submit': try: AccountingAPI.AddNewAccount(session['username'], session['password'], category, account, request.form['AccountCode'], request.form['AccountName'], request.form['Currency'], request.form['OpeningBalance'], request.form['CurrentBalance'], request.form['Comments']) flash('Account Created', category = 'success') return redirect(url_for('accounting.add_account', category = category, account = account)) except Exception as e: flash(str(e), category = 'fail') return redirect(url_for('accounting.add_account', category = category, account = account)) return render_template('accounting/add-account.html', username = session['username'], role = session['role'], data = data, category = category, cats = cats, form = form, accounts = AllAccounts, account = account)