Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -177,12 +177,28 @@ with tab1:
|
|
177 |
total_income = applicant_income + coapplicant_income
|
178 |
|
179 |
col1, col2, col3 = st.columns(3)
|
180 |
-
col1.metric("Total Income", f"${total_income:,}")
|
181 |
-
col2.metric("
|
182 |
col3.metric("Loan Term", f"{loan_term//12} years")
|
183 |
|
184 |
-
# Calculate
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
dti_percent = dti * 100
|
187 |
|
188 |
# Show DTI with visual gauge instead of raw number
|
|
|
177 |
total_income = applicant_income + coapplicant_income
|
178 |
|
179 |
col1, col2, col3 = st.columns(3)
|
180 |
+
col1.metric("Total Monthly Income", f"${total_income:,}")
|
181 |
+
col2.metric("Estimated Monthly Payment", f"${monthly_payment:.2f}")
|
182 |
col3.metric("Loan Term", f"{loan_term//12} years")
|
183 |
|
184 |
+
# Calculate monthly payment (simplified calculation)
|
185 |
+
# Convert loan term to years for calculation
|
186 |
+
loan_term_years = loan_term / 12
|
187 |
+
|
188 |
+
# Simple monthly payment calculation (approximation)
|
189 |
+
interest_rate = 0.05 # Assuming 5% annual interest rate
|
190 |
+
monthly_interest = interest_rate / 12
|
191 |
+
num_payments = loan_term
|
192 |
+
|
193 |
+
# Monthly payment using the loan amortization formula
|
194 |
+
if monthly_interest == 0:
|
195 |
+
monthly_payment = loan_amount / num_payments
|
196 |
+
else:
|
197 |
+
monthly_payment = loan_amount * (monthly_interest * (1 + monthly_interest) ** num_payments) / \
|
198 |
+
((1 + monthly_interest) ** num_payments - 1)
|
199 |
+
|
200 |
+
# Calculate proper Debt-to-Income ratio (monthly payment / monthly income)
|
201 |
+
dti = (monthly_payment / total_income) if total_income > 0 else 0
|
202 |
dti_percent = dti * 100
|
203 |
|
204 |
# Show DTI with visual gauge instead of raw number
|