Exemplo n.º 1
0
def dashboard():
  dashboard = 'dashboard.html'
  dashboard_admin = 'dashboard_admin.html'
  jumbomessage = None
  accounts = None
  networth = 0.00
  inexAllGraph = exAllGraph = inexYearlyAllGraph = None
  unread = None
  if not request.method == "POST":
    if 'logged_in' in session:
      if session['username'] == 'admin':
        return render_template(dashboard_admin)
      jumbomessage = dashboardMessage(session['username'])
      if checkTotalAccounts(session['username']) != 0:
        accounts = getAccounts(session['username'])
        networth = getNetworth(session['username'])
        inexAllGraph = inexTrendAll(session['username'])
        exAllGraph = exTrendAll(session['username'])
        inexYearlyAllGraph = inexTrendYearlyAll(session['username'])
      unreadCount = getInboxCount(session['username'], "unread")
      if unreadCount > 0:
        unread = unreadCount
      return render_template(dashboard, jumbomessage=jumbomessage, accounts=accounts, networth=networth, inexAllGraph=inexAllGraph, inexYearlyAllGraph=inexYearlyAllGraph, exAllGraph=exAllGraph, unread=unread)
    return render_template('index.html', message="You need to login first", mtype="warning")
  username = request.form['username']
  password = request.form['password']
  if checkLogin(username, password):
    session['logged_in'] = True
    session['username'] = username
    session['user'] = getNameofUser(username)
    if username == "admin":
      return render_template(dashboard_admin)
    else:
      # Check if user has investment accounts
      if not checkTotalInvestmentAccounts(session['username']) == 0:
        # Fetch MF NAV data to temp file
        mfNAV2File() 
      jumbomessage = dashboardMessage(username)
      if checkTotalAccounts(username) != 0:
        accounts = getAccounts(username)
        networth = getNetworth(username)
        inexAllGraph = inexTrendAll(session['username'])
        inexYearlyAllGraph = inexTrendYearlyAll(session['username'])
        exAllGraph = exTrendAll(session['username'])
      unreadCount = getInboxCount(session['username'], "unread")
      if unreadCount > 0:
        unread = unreadCount
      return render_template(dashboard, jumbomessage=jumbomessage, accounts=accounts, networth=networth, inexAllGraph=inexAllGraph, inexYearlyAllGraph=inexYearlyAllGraph, exAllGraph=exAllGraph, unread=unread)
  else:
    return render_template('index.html', message="Invalid credentials. Please try again", mtype="danger")
Exemplo n.º 2
0
def account_transactions(username, accountname, period):
  transactions = year = month = None
  curyear = datetime.now().year
  if username and accountname and period:
    if request.method == "POST":
      year = request.form['year']
      month = request.form['month']
    transactions = getTransactions(username, accountname, period, year, month)
    accinfo = getAccounts(username, accountname)
  return render_template('account-transactions.html', username=username, accinfo=accinfo, transactions=transactions, curyear=curyear)
Exemplo n.º 3
0
def transferfunds():
  if checkTotalAccounts(session['username']) == 0:
    flash("Please add some accounts first before trying to transfer funds!!")
    jumbomessage = dashboardMessage(session['username'])
    return render_template('dashboard.html', jumbomessage=jumbomessage)
  accounts = getAccounts(session['username'])
  if request.method == "POST":
    fromacc = request.form['fromaccount']
    toacc = request.form['toaccount']
    amount = request.form['amount']
    date = request.form['date']
    notes = request.form['notes']
    addTransactionsDB(date, notes, amount, "TRANSFER OUT", fromacc, session['username'])
    addTransactionsDB(date, notes, amount, "TRANSFER IN", toacc, session['username'])
    flash("Funds transferred from %s to %s successfully" % (fromacc, toacc))
  return render_template('transferfunds.html', accounts=accounts)
Exemplo n.º 4
0
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)