Beispiel #1
0
def result():
    if g.user:
        report = Report.get_by_user_id(g.user.id)
        if not report or report.is_deprecated:
            wxplan = session.get('wxplan')
            if not wxplan:
                return redirect(url_for('.info'))
            plan = PlanData.from_dict(wxplan)
            plan = plan.assign_to_user(g.user.id)
            formula = Formula(plan=plan)
            report = formula.gen_report()
        else:
            plan = PlanData.get_by_user_id(g.user.id)
            if not plan:
                return redirect(url_for('.info'))
        weekly_annual_rates = []
        latest_rate = 0
        if report.pocket_money > 0:
            dashboard = PublicDashboard.today()
            weekly_annual_rates = [(unicode(r.date),
                                    round_half_up(r.annual_rate, 2))
                                   for r in dashboard.weekly_annual_rates]
            latest_rate = round_half_up(
                dashboard.latest_annual_rate.annual_rate, 2)
        return render_template(
            'plan/detail_result.html',
            report=report,
            plan=plan,
            weekly_annual_rates=weekly_annual_rates,
            latest_rate=latest_rate,
            monthly_mortgages=report.get_monthly_mortgages(),
            rent_data=report.get_rent_data())

    return redirect(url_for('.brief'))
Beispiel #2
0
def brief():
    wxplan = session.get('wxplan')
    if not wxplan:
        return redirect(url_for('.info'))

    plan = PlanData.from_dict(wxplan)
    formula = Formula(plan=plan)
    raise_quota = round_half_up(formula.get_raise_quota() * 100, 2)
    norm_dist = [min(99, int(n * 100)) for n in formula.get_ten_norm_dist()]
    income_msg = formula.get_income_msg()
    province = ProvinceSalary.get_by_province_code(plan.province_code)

    return render_template('plan/brief_result.html',
                           province=province,
                           raise_quota=raise_quota,
                           norm_dist=norm_dist,
                           income_msg=income_msg)