-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
171 lines (151 loc) · 5.56 KB
/
app.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import streamlit as st
from ui_components import (
render_personal_info,
render_income_inputs,
render_itemized_deductions,
render_import_expenses,
)
from calculator import (
calculate_reforms,
format_detailed_metrics,
format_federal_credit_components,
format_state_credit_components,
format_benefits_components,
format_tax_components,
format_tariff_components,
)
from config import (
APP_TITLE,
NOTES,
BASELINE_DESCRIPTION,
ADDITIONAL_POLICIES,
REFORMS_DESCRIPTION,
)
from nationwide_impacts.main import render_nationwide_impacts
# Page setup
st.set_page_config(page_title=APP_TITLE, page_icon="👪", layout="wide")
st.title(APP_TITLE)
# Create tabs for Personal and Nationwide impacts
tab_personal, tab_nationwide = st.tabs(["Personal Calculator", "Nationwide Impacts"])
with tab_personal:
st.markdown(BASELINE_DESCRIPTION)
st.markdown("## Enter your household information")
st.markdown("*Please enter estimated annual amounts for 2025*")
# Render form sections
personal_col, income_col = st.columns(2)
with personal_col:
st.markdown("### Personal Information")
personal_info = render_personal_info()
(
is_married,
state,
child_ages,
head_age,
spouse_age,
in_nyc,
) = personal_info
with income_col:
st.markdown("### Income Information")
(
income,
tip_income,
overtime_income,
social_security,
capital_gains,
qualified_dividend_income,
non_qualified_dividend_income,
rental_income,
taxable_interest_income,
itemized_deductions, # Get itemized deductions from the income inputs
) = render_income_inputs(is_married)
china_imports, other_imports = render_import_expenses()
# Calculate button
if st.button("Calculate my household income"):
# Create two columns for results
left_col, right_col = st.columns([1, 1])
progress_text = st.empty()
# Prepare inputs and calculate results
inputs = {
"state": state,
"is_married": is_married,
"child_ages": child_ages,
"head_age": head_age,
"spouse_age": spouse_age,
"income": income,
"social_security": social_security,
"capital_gains": capital_gains,
"qualified_dividend_income": qualified_dividend_income,
"non_qualified_dividend_income": non_qualified_dividend_income,
"taxable_interest_income": taxable_interest_income,
"rental_income": rental_income,
"tip_income": tip_income,
"overtime_income": overtime_income,
"in_nyc": in_nyc,
**itemized_deductions,
"china_imports": china_imports,
"other_imports": other_imports,
}
# Left column - Graph with progressive updates
with left_col:
chart_placeholder = st.empty()
summary_results, results_df = calculate_reforms(
inputs, progress_text, chart_placeholder
)
# Right column - All tabs
with right_col:
tabs = st.tabs(
[
"Main Breakdown",
"Taxes",
"Tariffs",
"Benefits",
"Federal Credits",
"State Credits",
]
)
with tabs[0]:
formatted_df = format_detailed_metrics(results_df)
st.markdown(formatted_df.to_markdown())
with tabs[1]:
tax_df = format_tax_components(results_df)
if tax_df is not None:
st.markdown(tax_df.to_markdown())
else:
st.markdown("No applicable income tax")
with tabs[2]:
tariffs_df = format_tariff_components(results_df)
if tariffs_df is not None:
st.markdown(tariffs_df.to_markdown())
else:
st.markdown("No tariffs applicable")
with tabs[3]:
benefits_df = format_benefits_components(results_df)
if benefits_df is not None:
st.markdown(benefits_df.to_markdown())
else:
st.markdown("No Benefits available")
with tabs[4]:
federal_credit_df = format_federal_credit_components(results_df)
if federal_credit_df is not None:
st.markdown(federal_credit_df.to_markdown())
else:
st.markdown("No federal credits available")
with tabs[5]:
state_credit_df = format_state_credit_components(results_df, state)
if state_credit_df is not None:
st.markdown(state_credit_df.to_markdown())
else:
st.markdown("No state credits available")
# Add collapsible sections after the main content
st.markdown("---")
with st.expander("Policy Proposals modeled in this calculator"):
st.markdown(REFORMS_DESCRIPTION)
with st.expander(
"View Additional Tax & Benefit Proposals (Not Currently Modeled)"
):
st.markdown(ADDITIONAL_POLICIES)
with st.expander("Assumptions and Notes"):
st.markdown(NOTES)
progress_text.empty()
with tab_nationwide:
render_nationwide_impacts()