Spaces:
Running
Running
Commit ·
406a69d
1
Parent(s): bb80198
Add Executive Summary section with 5 key KPIs
Browse files- Calculate operating margin (lifecycle profit / revenue)
- Show color-coded status badge (Profitable/Healthy/Break-even/Loss)
- Display 5 KPI metrics: Monthly Lease, Operating Margin, Manufacturing Cost, Recovery Rate, Max Cycles
- Add contextual insight message based on model status
- Section visible in all stakeholder views
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -200,6 +200,22 @@ total_lease_cost = lease_price * lease_term
|
|
| 200 |
refurb_a = int(avg_refurb_cost * 0.4)
|
| 201 |
refurb_b = int(avg_refurb_cost * 1.8)
|
| 202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
# ============================================================
|
| 204 |
# SHARED PRODUCT HEADER (compact)
|
| 205 |
# ============================================================
|
|
@@ -215,6 +231,45 @@ with header_col2:
|
|
| 215 |
|
| 216 |
st.markdown("---")
|
| 217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
# ============================================================
|
| 219 |
# VIEW: STRATEGY (C-Level)
|
| 220 |
# ============================================================
|
|
|
|
| 200 |
refurb_a = int(avg_refurb_cost * 0.4)
|
| 201 |
refurb_b = int(avg_refurb_cost * 1.8)
|
| 202 |
|
| 203 |
+
# Executive Summary calculations
|
| 204 |
+
lifecycle_revenue = max_cycles * revenue_per_customer
|
| 205 |
+
lifecycle_cost = new_unit_cost + (max_cycles - 1) * refurb_unit_cost
|
| 206 |
+
lifecycle_profit = lifecycle_revenue - lifecycle_cost
|
| 207 |
+
operating_margin = (lifecycle_profit / lifecycle_revenue) * 100 if lifecycle_revenue > 0 else 0
|
| 208 |
+
|
| 209 |
+
# Model status thresholds
|
| 210 |
+
if operating_margin >= 30:
|
| 211 |
+
model_status, status_color = "Profitable", "#2ecc71"
|
| 212 |
+
elif operating_margin >= 15:
|
| 213 |
+
model_status, status_color = "Healthy", "#f1c40f"
|
| 214 |
+
elif operating_margin >= 0:
|
| 215 |
+
model_status, status_color = "Break-even", "#e67e22"
|
| 216 |
+
else:
|
| 217 |
+
model_status, status_color = "Loss", "#e74c3c"
|
| 218 |
+
|
| 219 |
# ============================================================
|
| 220 |
# SHARED PRODUCT HEADER (compact)
|
| 221 |
# ============================================================
|
|
|
|
| 231 |
|
| 232 |
st.markdown("---")
|
| 233 |
|
| 234 |
+
# ============================================================
|
| 235 |
+
# EXECUTIVE SUMMARY (visible in all views)
|
| 236 |
+
# ============================================================
|
| 237 |
+
st.markdown("**Executive Summary**")
|
| 238 |
+
|
| 239 |
+
# Model Status Badge
|
| 240 |
+
st.markdown(f'''
|
| 241 |
+
<span style="background-color: {status_color}; color: white; padding: 0.3rem 0.8rem;
|
| 242 |
+
border-radius: 20px; font-weight: 600; font-size: 0.85rem;">
|
| 243 |
+
Model: {model_status}</span>
|
| 244 |
+
<span style="color: #888; margin-left: 1rem; font-size: 0.85rem;">
|
| 245 |
+
{operating_margin:.1f}% margin across {max_cycles} cycles</span>
|
| 246 |
+
''', unsafe_allow_html=True)
|
| 247 |
+
|
| 248 |
+
# 5 KPI Metrics Row
|
| 249 |
+
kpi_cols = st.columns(5)
|
| 250 |
+
with kpi_cols[0]:
|
| 251 |
+
st.metric("A: Monthly Lease", f"€{lease_price}", help="Revenue driver")
|
| 252 |
+
with kpi_cols[1]:
|
| 253 |
+
st.metric("B: Operating Margin", f"{operating_margin:.1f}%",
|
| 254 |
+
delta="healthy" if operating_margin >= 25 else "tight",
|
| 255 |
+
help="Lifecycle profit / revenue")
|
| 256 |
+
with kpi_cols[2]:
|
| 257 |
+
st.metric("C: Manufacturing", f"€{mfg_cost}", help="First-cycle cost")
|
| 258 |
+
with kpi_cols[3]:
|
| 259 |
+
st.metric("D: Recovery Rate", f"{eolrr:.1%}", help="Enables reuse cycles")
|
| 260 |
+
with kpi_cols[4]:
|
| 261 |
+
st.metric("E: Max Cycles", f"{max_cycles}", help="Families per product")
|
| 262 |
+
|
| 263 |
+
# Contextual insight based on status
|
| 264 |
+
if model_status == "Loss":
|
| 265 |
+
st.error("Action needed: Raise lease price, reduce costs, or increase cycles.")
|
| 266 |
+
elif model_status == "Break-even":
|
| 267 |
+
st.warning(f"Margin thin at {operating_margin:.1f}%. Review pricing or costs.")
|
| 268 |
+
else:
|
| 269 |
+
st.success(f"Strong: {operating_margin:.1f}% margin, {eolrr:.0%} recovery, {max_cycles} cycles.")
|
| 270 |
+
|
| 271 |
+
st.markdown("---")
|
| 272 |
+
|
| 273 |
# ============================================================
|
| 274 |
# VIEW: STRATEGY (C-Level)
|
| 275 |
# ============================================================
|