def test_max_results_six(self):
     self.assertEqual(
         utils.calc_max_financials(60000, "Yes", "Yes", 1.0, 0.05), {
             "checking": 3700,
             "savings": 11100,
             "match": 3000,
             "ira": 5500,
             "ret401k": 15000,
             "investment": 0
         })
 def test_max_results_four(self):
     self.assertEqual(
         utils.calc_max_financials(60000, "No", "No", 0, 0), {
             "checking": 3700,
             "savings": 11100,
             "match": 0,
             "ira": 5500,
             "ret401k": 0,
             "investment": 0
         })
 def test_max_results_three(self):
     self.assertEqual(
         utils.calc_max_financials(0, "Yes", "No", 0, 0), {
             "checking": 0,
             "savings": 0,
             "match": 0,
             "ira": 5500,
             "ret401k": 18000,
             "investment": 0
         })
def show_existing_results():
    """
    This route accesses saved data from the database and
    calculates the results.
    """
    if g.logged_in is True:
        if g.inputs is True:
            user_assets = m_session.query(model.UserBanking).filter_by(
                user_id=g.user.id).one()

            total_assets = user_assets.inputted_assets + \
                user_assets.checking_amt + user_assets.savings_amt + \
                user_assets.IRA_amt + user_assets.comp401k_amt + \
                user_assets.investment_amt
            income = g.user.income
            comp_401k = g.user.company_401k
            match_401k = g.user.company_match
            match_percent = g.user.match_percent
            match_salary = g.user.match_salary

            results = utils.calc_financial_results(
                total_assets, income, comp_401k, match_401k, match_percent,
                match_salary)
            max_results = utils.calc_max_financials(
                income, comp_401k, match_401k, match_percent, match_salary)

            return render_template(
                "results.html",
                checking=utils.format_currency(results["checking"]),
                savings=utils.format_currency(results["savings"]),
                match=utils.format_currency(results["match"]),
                ira=utils.format_currency(results["ira"]),
                ret401k=utils.format_currency(results["ret401k"]),
                investment=utils.format_currency(results["investment"]),
                results=json.dumps(results),
                max_results=json.dumps(max_results))
        else:
            flash("Our financial data on you is incomplete. \
                    Please input now.")
            return redirect("/input/banking")
    else:
        return redirect("/login")
 def test_max_results_one(self):
     self.assertEqual(utils.calc_max_financials(
         0, "No", "No", 0, 0), {
         "checking": 0, "savings": 0, "match": 0,
         "ira": 5500, "ret401k": 0, "investment": 0})
 def test_max_results_six(self):
     self.assertEqual(utils.calc_max_financials(
         60000, "Yes", "Yes", 1.0, 0.05), {
         "checking": 3700, "savings": 11100, "match": 3000,
         "ira": 5500, "ret401k": 15000, "investment": 0})