def currencies(): data = AccountingAPI.GetCategories() form = AccountingForms.Currencies(request.form) data1 = AccountingAPI.GetAllCurrencies() if request.method == 'POST': if request.form['submit'] == 'Submit': try: NewCur = AccountingAPI.AddCurrency( session['username'], session['password'], request.form['CurrencyName'], request.form['CurrencyCode'], request.form['ExchageRate'], request.form['Functional']) if NewCur == False: flash('Currency is successfully added', category='success') return redirect(url_for('users.currencies')) else: flash('You already have a functional currency', category='fail') return redirect(url_for('users.currencies')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('users.currencies')) return render_template('users/currencies.html', username=session['username'], role=session['role'], form=form, data=data, data1=data1)
def EditCurrency(code): data = AccountingAPI.GetCategories() data1 = AccountingAPI.GetCurrency(code) data2 = AccountingAPI.GetAllCurrencies() if request.method == 'POST': if request.form['submit'] == 'Submit': try: UpCur = AccountingAPI.UpdateCurrency( session['username'], session['password'], code, request.form['CurrencyName'], request.form['CurrencyCode'], request.form['ExchangeRate'], request.form['Functional']) if UpCur == False: flash('Currency updated successfully...', category='success') return redirect(url_for('users.currencies')) else: flash('You already have a functional currency', category='fail') return redirect(url_for('users.EditCurrency', code=code)) except Exception as e: flash(str(e), category='fail') return redirect(url_for('users.currencies')) return render_template('users/edit_currency.html', username=session['username'], role=session['role'], data=data, data1=data1, data2=data2)
def TrialSheet(): data = AccountingAPI.GetCategories() data1 = AccountingAPI.GetAllAccounts() cmp = EnterpriseAPI.GetCompanyProfile() if request.method == 'POST': if request.form['submit'] == 'Submit': if request.form['SheetFormat'] == 'pdf': trial1, trial2 = AccountingAPI.TrialBalancePDF(session['username'],session['password'], request.form['StartDate'], request.form['EndDate'], request.form.getlist('act_check')) rendered = render_template('accounting/trial_balance_sheet.html', data = trial1, sums = trial2, date1 = request.form['StartDate'], date2 = request.form['EndDate'], cmp = cmp) pdf = pdfkit.from_string(rendered, False) response = make_response(pdf) response.headers['Content-type'] = 'application/pdf' response.headers['Content-Disposition'] = 'attachement; filename = trial_balance_statement.pdf' return response elif request.form['SheetFormat'] == 'csv': file = AccountingAPI.TrialBalanceCSV(session['username'],session['password'], request.form['StartDate'], request.form['EndDate'], request.form.getlist('act_check')) response = make_response(file) response.headers['Content-type'] = 'text/csv' response.headers['Content-Disposition'] = 'attachement; filename = Trial_Balance_Statement.csv' return response return render_template('accounting/get_trial_sheet.html', username = session['username'], role = session['role'], data = data, data1 = data1)
def view_journal_entry(entrycode): data = AccountingAPI.GetCategories() jrns = AccountingAPI.GetJournals() data1, data2, data3 = AccountingAPI.GrabJournalEntry(entrycode) FCurr = AccountingAPI.GetFuntionalCurrency() if request.method == 'POST': return redirect(url_for('accounting.journal')) return render_template('accounting/view-journal-entry.html', username = session['username'], role = session['role'], data = data, jrns = jrns, data1 = data1, data2 = data2, data3 = data3, FC = FCurr)
def add_category(category): data = AccountingAPI.GetCategories() form = AccountingForms.CategoryForm(request.form) if request.method == 'POST': if request.form['submit'] == 'Submit': try: AccountingAPI.AddCategory(session['username'], session['password'], category, request.form['CategoryName'], request.form['CategoryDescription']) flash('category created successfully...', category = 'success') return redirect(url_for('accounting.add_category', category = category)) except Exception as e: flash(str(e), category = 'fail') return redirect(url_for('accounting.add_category', category = category)) return render_template('accounting/add-category.html', username = session['username'], role = session['role'], data = data, category = category, form = form)
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 BalanceSheet(): data = AccountingAPI.GetCategories() cmp = EnterpriseAPI.GetCompanyProfile() if request.method == 'POST': if request.form['submit'] == 'Submit': if request.form['SheetFormat'] == 'pdf': data1, data2 = AccountingAPI.GetBalanceSheetPDF(session['username'], session['password'], request.form['SheetDate']) rendered = render_template('accounting/balance_sheet.html', data1 = data1, data2 = data2, date = request.form['SheetDate'], cmp = cmp) pdf = pdfkit.from_string(rendered, False) response = make_response(pdf) response.headers['Content-type'] = 'application/pdf' response.headers['Content-Disposition'] = 'attachement; filename = balance-sheet.pdf' return response elif request.form['SheetFormat'] == 'csv': file = AccountingAPI.BalanceSheetCSV(session['username'], session['password'], request.form['SheetDate']) response = make_response(file) response.headers['Content-type'] = 'text/csv' response.headers['Content-Disposition'] = 'attachement; filename = Balance_Sheet.csv' return response return render_template('accounting/get_balancesheet.html', username = session['username'], role = session['role'], data = data)
def journal(): data = AccountingAPI.GetCategories() jrns = AccountingAPI.GetJournals() FCurr = AccountingAPI.GetFuntionalCurrency() if request.method == 'POST': if request.form['submit'] == 'Submit': try: AccountingAPI.AddJournalEntry(session['username'], session['password'], request.form.getlist('account-type'), request.form.getlist('account-category'), request.form.getlist('account-name'), request.form.getlist('currency'), request.form.getlist('debit'), request.form.getlist('credit'), request.form.getlist('comments')) flash('Journal successfully created...', category = 'success') return redirect(url_for('accounting.journal')) except Exception as e: flash(str(e), category = 'fail') return redirect(url_for('accounting.journal')) return render_template('accounting/journal.html', username = session['username'], role = session['role'], data = data, jrns = jrns, FC = FCurr)
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)
def accounting(): data = AccountingAPI.GetCategories() return render_template('accounting/accounting.html', username = session['username'], role = session['role'], data = data)