-
Notifications
You must be signed in to change notification settings - Fork 0
/
inputs_page.py
71 lines (62 loc) · 2.54 KB
/
inputs_page.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import streamlit as st
from inputs.income import show_income_inputs
from inputs.assets import show_assets_inputs
def show_net_worth_breakdown(prefix):
return show_assets_inputs(prefix)
def show_input_page():
st.title("UK Financial Planning Tool")
# Sidebar for inputs
st.sidebar.header("Personal Information")
inflation_rate = st.sidebar.number_input(
"Inflation Rate (%)", value=st.session_state.user_inputs["inflation_rate"] * 100
) or 0
st.session_state.user_inputs["inflation_rate"] = inflation_rate / 100
has_partner = st.sidebar.checkbox(
"Do you have a partner?",
value=st.session_state.user_inputs.get("has_partner", False),
key="has_partner_checkbox",
)
st.session_state.user_inputs["has_partner"] = has_partner
st.session_state.age_inputs["current_age"] = st.sidebar.number_input(
"Current Age",
min_value=18,
max_value=100,
value=st.session_state.age_inputs["current_age"],
)
st.session_state.age_inputs["retirement_age"] = st.sidebar.number_input(
"Retirement Age",
min_value=st.session_state.age_inputs["current_age"] + 1,
max_value=100,
value=st.session_state.age_inputs["retirement_age"],
)
st.session_state.age_inputs["life_expectancy"] = st.sidebar.number_input(
"Life Expectancy",
min_value=st.session_state.age_inputs["retirement_age"],
max_value=120,
value=st.session_state.age_inputs["life_expectancy"],
)
if has_partner:
st.session_state.age_inputs["partner_current_age"] = st.sidebar.number_input(
"Partner's Current Age",
min_value=18,
max_value=100,
value=st.session_state.age_inputs["partner_current_age"],
)
st.session_state.age_inputs["partner_retirement_age"] = st.sidebar.number_input(
"Partner's Retirement Age",
min_value=st.session_state.age_inputs["partner_current_age"] + 1,
max_value=100,
value=st.session_state.age_inputs["partner_retirement_age"],
)
st.session_state.age_inputs["partner_life_expectancy"] = (
st.sidebar.number_input(
"Partner's Life Expectancy",
min_value=st.session_state.age_inputs["partner_retirement_age"],
max_value=120,
value=st.session_state.age_inputs["partner_life_expectancy"],
)
)
show_income_inputs()
show_assets_inputs("user")
if has_partner:
show_assets_inputs("partner")