Exemplo n.º 1
0
def investments():
    # Currency symbol hardcoded for INR. Revisit for dynamic feature
    currencySymbol = getCurrencySymbol('INR')
    totalAccounts = checkTotalInvestmentAccounts(session['username'])
    accountsAvailable = activeAccounts = holdingAccounts = closedAccounts = None
    investmentTrendGraph = None
    navdict = None
    if totalAccounts == 0:
        flash(
            "You don't have any investment accounts\nPlease add your investment details"
        )
    else:
        accountsAvailable = "yes"
        activeAccounts = getInvestmentAccounts(session['username'], 'Active')
        holdingAccounts = getInvestmentAccounts(session['username'], 'Holding')
        closedAccounts = getInvestmentAccounts(session['username'], 'Closed')
        investmentTrendGraph = investmentTrend(session['username'])
        navdict = getFundNAVDict(session['username'])
    return render_template('investments.html',
                           accountsAvailable=accountsAvailable,
                           activeAccounts=activeAccounts,
                           holdingAccounts=holdingAccounts,
                           closedAccounts=closedAccounts,
                           currencySymbol=currencySymbol,
                           investmentTrendGraph=investmentTrendGraph,
                           navdict=navdict)
Exemplo n.º 2
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.º 3
0
def addsip():
  activeAccounts = None
  if request.method == "POST":
    sipinfo = {}
    sipinfo['owner'] = session['username']
    sipinfo['accid'] = request.form['accid']
    sipinfo['amount'] = request.form['amount']
    sipinfo['units'] = request.form['units']
    sipinfo['sipdate'] = request.form['sipdate']
    flash(addSIPTransaction(sipinfo))
  totalAccounts = checkTotalInvestmentAccounts(session['username'])
  if totalAccounts == 0:
    flash("You don't have any investment accounts\nPlease add your investment details")
  else:
    activeAccounts = getInvestmentAccounts(session['username'], 'Active')
  return render_template('addsip.html', accounts=activeAccounts)