def categorystats(): if checkTotalAccounts(session['username']) == 0: flash( "No reports as you don't have any accounts setup. Please start adding your accounts" ) jumbomessage = dashboardMessage(session['username']) return render_template('dashboard.html', jumbomessage=jumbomessage) categoryStatsGraph = categoryStatsGraphYearly = None categoryStatsData = categoryStatsDataYearly = None categoryAllGraph = None if request.method == "POST": statcategory = request.form['statcategory'] categoryStatsGraph, categoryStatsData = categoryStats( session['username'], statcategory, "YEAR_MONTH") categoryStatsGraphYearly, categoryStatsDataYearly = categoryStats( session['username'], statcategory, "YEAR") categoryAllGraph = categoryAllGraphDot(session['username'], statcategory) categoriesRaw = getCategories() categories = ([x for x in categoriesRaw[0] if x != "TRANSFER IN"], [x for x in categoriesRaw[1] if x != "TRANSFER OUT"]) return render_template('categorystats.html', categories=categories, categoryStatsGraph=categoryStatsGraph, categoryStatsData=categoryStatsData, categoryStatsGraphYearly=categoryStatsGraphYearly, categoryStatsDataYearly=categoryStatsDataYearly, categoryAllGraph=categoryAllGraph)
def search(): searchresults = listresults = None curyear = datetime.now().year if request.method == "POST": if request.form['searchForm'] == "search": keyword = request.form['keyword'] searchresults = searchTransactions(session['username'], keyword) else: category = request.form['listcategory'] period = request.form['period'] year = request.form['year'] month = request.form['month'] if category == "Select": flash("Please choose a category") else: if "Select" in period and "Select" in year and "Select" in month: listresults = getTransactionsForCategory(session['username'], category, None, None, None) elif not "Select" in period: listresults = getTransactionsForCategory(session['username'], category, period, None, None) elif not "Select" in year and not "Select" in month: listresults = getTransactionsForCategory(session['username'], category, None, year, month) else: flash("Please choose period carefully. If you didn't select one of the predefined period, you have to select both year and month") if listresults is None: flash("No transacations to list") categories = getCategories() return render_template('searchtransactions.html', searchresults=searchresults, listresults=listresults, categories=categories, curyear=curyear)
def managecategories(): if request.method == "POST": if 'incategory' in request.form: data = addCategory(request.form['incategory'], 'IN') else: data = addCategory(request.form['excategory'], 'EX') flash(data) inc_categories, exp_categories = getCategories() return render_template('managecategories.html', inc_categories=inc_categories, exp_categories=exp_categories)
def addtransaction(): if checkTotalAccounts(session['username']) == 0: flash("Please add an account first before trying to add a transaction!!") jumbomessage = dashboardMessage(session['username']) return render_template('dashboard.html', jumbomessage=jumbomessage) inc_categories, exp_categories = getCategories() categories = exp_categories + inc_categories accounts = getAccounts(session['username']) if request.method == "POST": account = request.form['account'] category = request.form['category'] amount = request.form['amount'] date = request.form['date'] notes = request.form['notes'] flash(addTransactionsDB(date, notes, amount, category, account, session['username'])) return render_template('addtransaction.html', categories=categories, accounts=accounts)