Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -185,20 +185,55 @@ with tab1:
|
|
185 |
dti = (loan_amount / total_income) if total_income > 0 else 0
|
186 |
dti_percent = dti * 100
|
187 |
|
188 |
-
# Show
|
189 |
-
st.markdown("<
|
190 |
|
191 |
-
#
|
192 |
-
|
|
|
|
|
193 |
if dti_percent <= 36:
|
194 |
-
dti_status = "
|
|
|
|
|
195 |
elif dti_percent <= 43:
|
196 |
-
dti_status = "
|
|
|
|
|
197 |
else:
|
198 |
-
dti_status = "
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
st.markdown('</div>', unsafe_allow_html=True)
|
204 |
|
|
|
185 |
dti = (loan_amount / total_income) if total_income > 0 else 0
|
186 |
dti_percent = dti * 100
|
187 |
|
188 |
+
# Show DTI with visual gauge instead of raw number
|
189 |
+
st.markdown("<h4>Debt-to-Income Assessment</h4>", unsafe_allow_html=True)
|
190 |
|
191 |
+
# Cap the displayed percentage at 100% for the visual
|
192 |
+
display_percent = min(dti_percent, 100)
|
193 |
+
|
194 |
+
# Determine the status and color
|
195 |
if dti_percent <= 36:
|
196 |
+
dti_status = "Good"
|
197 |
+
dti_color = "#4CAF50" # Green
|
198 |
+
emoji = "✅"
|
199 |
elif dti_percent <= 43:
|
200 |
+
dti_status = "Moderate"
|
201 |
+
dti_color = "#FF9800" # Orange
|
202 |
+
emoji = "⚠️"
|
203 |
else:
|
204 |
+
dti_status = "High"
|
205 |
+
dti_color = "#F44336" # Red
|
206 |
+
emoji = "❗"
|
207 |
+
|
208 |
+
# Create a visual progress bar
|
209 |
+
st.markdown(f"""
|
210 |
+
<div style="margin-bottom: 10px;">
|
211 |
+
<div style="background-color: #e0e0e0; border-radius: 10px; height: 20px; width: 100%;">
|
212 |
+
<div style="background-color: {dti_color}; width: {display_percent}%; height: 20px; border-radius: 10px;"></div>
|
213 |
+
</div>
|
214 |
+
<div style="display: flex; justify-content: space-between; font-size: 0.8rem;">
|
215 |
+
<span>0%</span>
|
216 |
+
<span>50%</span>
|
217 |
+
<span>100%+</span>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
""", unsafe_allow_html=True)
|
221 |
+
|
222 |
+
# Show a simple, friendly interpretation
|
223 |
+
if dti_percent > 100:
|
224 |
+
st.markdown(f"""
|
225 |
+
<div style="padding: 10px; background-color: #FFEBEE; border-radius: 5px; margin-bottom: 15px;">
|
226 |
+
{emoji} <strong>Your monthly loan payment would be {dti_percent/100:.1f}× your monthly income</strong>
|
227 |
+
<p style="margin: 5px 0 0 0; font-size: 0.9rem;">Most lenders look for a ratio below 43% (0.43× your income)</p>
|
228 |
+
</div>
|
229 |
+
""", unsafe_allow_html=True)
|
230 |
+
else:
|
231 |
+
st.markdown(f"""
|
232 |
+
<div style="padding: 10px; background-color: #F5F5F5; border-radius: 5px; margin-bottom: 15px;">
|
233 |
+
{emoji} <strong>Your monthly loan payment would be {dti_percent:.1f}% of your monthly income</strong>
|
234 |
+
<p style="margin: 5px 0 0 0; font-size: 0.9rem;">Most lenders look for this to be below 43%</p>
|
235 |
+
</div>
|
236 |
+
""", unsafe_allow_html=True)
|
237 |
|
238 |
st.markdown('</div>', unsafe_allow_html=True)
|
239 |
|