Spaces:
Running
Running
Commit ·
c06a407
1
Parent(s): e3bb96a
Model idle (off-season) months in the Strategy break-even math
Browse filesA cycle shorter than 12 months (e.g. Parkdressen's 8-month active
season) now sits idle for the rest of the calendar year before the
next cycle's logistics cost is paid and it returns to active service.
Revenue and repair wear only accrue during active months; the
cumulative revenue line now visibly flatlines during idle months on
the Break Even Timeline chart, and the lead text/caption explain it.
Cycle lengths of 12+ months are unaffected (idle = 0).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -486,7 +486,13 @@ else:
|
|
| 486 |
# HELPER: Break-even calculation
|
| 487 |
# ============================================================
|
| 488 |
def calculate_breakeven_months(portfolio, monthly_lease, mfg_cost_nok, lease_term_mo=12, logistics_nok=150, repair_nok=200, max_months=120):
|
| 489 |
-
"""Return (breakeven_month, cumulative_list) for given parameters.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
monthly_revenue = portfolio * monthly_lease
|
| 491 |
monthly_repair = portfolio * (repair_nok / lease_term_mo)
|
| 492 |
initial = -portfolio * mfg_cost_nok
|
|
@@ -494,9 +500,11 @@ def calculate_breakeven_months(portfolio, monthly_lease, mfg_cost_nok, lease_ter
|
|
| 494 |
cumulative_list = [cumulative]
|
| 495 |
breakeven = None
|
| 496 |
for month in range(1, max_months + 1):
|
| 497 |
-
|
|
|
|
| 498 |
cumulative -= portfolio * logistics_nok
|
| 499 |
-
|
|
|
|
| 500 |
cumulative_list.append(cumulative)
|
| 501 |
if cumulative >= 0 and breakeven is None:
|
| 502 |
breakeven = month
|
|
@@ -526,6 +534,12 @@ if selected_view == "Strategy":
|
|
| 526 |
logistics_per_cycle = st.session_state.logistics_cost_per_cycle # NOK - pickup + delivery per cycle
|
| 527 |
repair_per_cycle = 200 # NOK - average repair/refurb per cycle
|
| 528 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
# Per-product economics
|
| 530 |
revenue_per_product = monthly_lease * lease_term_months * reuse_cycles
|
| 531 |
total_cost_per_product = s_mfg_cost + (logistics_per_cycle + repair_per_cycle) * reuse_cycles
|
|
@@ -578,7 +592,10 @@ if selected_view == "Strategy":
|
|
| 578 |
with r2_right:
|
| 579 |
st.markdown(metric_card("Portfolio Blended Cost", sfmt(blended_cost_portfolio), "NOK", COLORS["secondary"]), unsafe_allow_html=True)
|
| 580 |
|
| 581 |
-
|
|
|
|
|
|
|
|
|
|
| 582 |
|
| 583 |
st.markdown("---")
|
| 584 |
|
|
@@ -590,25 +607,32 @@ if selected_view == "Strategy":
|
|
| 590 |
if monthly_lease == 0:
|
| 591 |
st.warning("Set a lease price above 0 NOK to see the break-even timeline.")
|
| 592 |
else:
|
| 593 |
-
# Scale chart length with reuse cycles (each cycle =
|
| 594 |
-
chart_months = min(reuse_cycles *
|
| 595 |
be_months = list(range(chart_months + 1))
|
| 596 |
|
| 597 |
-
# Revenue builds steadily
|
| 598 |
-
#
|
| 599 |
-
#
|
|
|
|
|
|
|
| 600 |
monthly_revenue_val = portfolio_size * monthly_lease
|
| 601 |
monthly_repair_val = portfolio_size * (repair_per_cycle / lease_term_months)
|
| 602 |
initial_investment = portfolio_size * s_mfg_cost
|
| 603 |
|
| 604 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 605 |
cost_cum = [
|
| 606 |
-
initial_investment + monthly_repair_val * m
|
| 607 |
-
+ portfolio_size * logistics_per_cycle * (m //
|
| 608 |
for m in be_months
|
| 609 |
]
|
| 610 |
|
| 611 |
-
be_lead = f'Cost starts at <b>{sfmt(initial_investment)} NOK</b> — the upfront manufacturing spend — and climbs in steps as logistics and repairs are paid. Revenue builds
|
|
|
|
| 612 |
if breakeven_month and breakeven_month <= chart_months:
|
| 613 |
lead_gap = revenue_cum[-1] - cost_cum[-1]
|
| 614 |
be_lead += f' Revenue overtakes cost in <b>month {breakeven_month}</b>, and the portfolio is <b>{sfmt(lead_gap)} NOK</b> ahead by month {chart_months}.'
|
|
@@ -676,7 +700,9 @@ if selected_view == "Strategy":
|
|
| 676 |
margin=dict(t=30),
|
| 677 |
)
|
| 678 |
st.plotly_chart(fig_be, use_container_width=True)
|
| 679 |
-
|
|
|
|
|
|
|
| 680 |
|
| 681 |
st.markdown("---")
|
| 682 |
|
|
|
|
| 486 |
# HELPER: Break-even calculation
|
| 487 |
# ============================================================
|
| 488 |
def calculate_breakeven_months(portfolio, monthly_lease, mfg_cost_nok, lease_term_mo=12, logistics_nok=150, repair_nok=200, max_months=120):
|
| 489 |
+
"""Return (breakeven_month, cumulative_list) for given parameters.
|
| 490 |
+
|
| 491 |
+
A lease cycle shorter than 12 months (e.g. a seasonal product) is assumed to
|
| 492 |
+
sit idle — no revenue, no wear — for the rest of the calendar year before the
|
| 493 |
+
next cycle's logistics cost is paid and it goes back into active service.
|
| 494 |
+
"""
|
| 495 |
+
real_cycle_mo = max(lease_term_mo, 12)
|
| 496 |
monthly_revenue = portfolio * monthly_lease
|
| 497 |
monthly_repair = portfolio * (repair_nok / lease_term_mo)
|
| 498 |
initial = -portfolio * mfg_cost_nok
|
|
|
|
| 500 |
cumulative_list = [cumulative]
|
| 501 |
breakeven = None
|
| 502 |
for month in range(1, max_months + 1):
|
| 503 |
+
active = (month - 1) % real_cycle_mo < lease_term_mo
|
| 504 |
+
if month % real_cycle_mo == 0:
|
| 505 |
cumulative -= portfolio * logistics_nok
|
| 506 |
+
if active:
|
| 507 |
+
cumulative += monthly_revenue - monthly_repair
|
| 508 |
cumulative_list.append(cumulative)
|
| 509 |
if cumulative >= 0 and breakeven is None:
|
| 510 |
breakeven = month
|
|
|
|
| 534 |
logistics_per_cycle = st.session_state.logistics_cost_per_cycle # NOK - pickup + delivery per cycle
|
| 535 |
repair_per_cycle = 200 # NOK - average repair/refurb per cycle
|
| 536 |
|
| 537 |
+
# A cycle shorter than a year (e.g. a seasonal product) sits idle — no
|
| 538 |
+
# revenue, no wear — for the rest of the calendar year before the next
|
| 539 |
+
# cycle's logistics cost is paid and it goes back into active service.
|
| 540 |
+
idle_months = max(0, 12 - lease_term_months)
|
| 541 |
+
real_cycle_months = lease_term_months + idle_months
|
| 542 |
+
|
| 543 |
# Per-product economics
|
| 544 |
revenue_per_product = monthly_lease * lease_term_months * reuse_cycles
|
| 545 |
total_cost_per_product = s_mfg_cost + (logistics_per_cycle + repair_per_cycle) * reuse_cycles
|
|
|
|
| 592 |
with r2_right:
|
| 593 |
st.markdown(metric_card("Portfolio Blended Cost", sfmt(blended_cost_portfolio), "NOK", COLORS["secondary"]), unsafe_allow_html=True)
|
| 594 |
|
| 595 |
+
cycle_length_note = f"Assuming {lease_term_months}-month cycle length."
|
| 596 |
+
if idle_months > 0:
|
| 597 |
+
cycle_length_note = f"Assuming {lease_term_months} active months + {idle_months} idle (off-season) months per {real_cycle_months}-month cycle."
|
| 598 |
+
st.markdown(f'<p style="text-align: center; color: {COLORS["text_muted"]}; font-size: 0.95rem; margin-top: 1rem;">{cycle_length_note}</p>', unsafe_allow_html=True)
|
| 599 |
|
| 600 |
st.markdown("---")
|
| 601 |
|
|
|
|
| 607 |
if monthly_lease == 0:
|
| 608 |
st.warning("Set a lease price above 0 NOK to see the break-even timeline.")
|
| 609 |
else:
|
| 610 |
+
# Scale chart length with reuse cycles (each real cycle = active + idle months)
|
| 611 |
+
chart_months = min(reuse_cycles * real_cycle_months, len(breakeven_cumulative) - 1)
|
| 612 |
be_months = list(range(chart_months + 1))
|
| 613 |
|
| 614 |
+
# Revenue builds steadily during each cycle's active months, then flatlines
|
| 615 |
+
# for its idle months (e.g. a seasonal product with no one renting it).
|
| 616 |
+
# Cost starts at the upfront manufacturing spend, creeps up from repairs
|
| 617 |
+
# during active months, and steps up when logistics are paid at the start
|
| 618 |
+
# of the next cycle.
|
| 619 |
monthly_revenue_val = portfolio_size * monthly_lease
|
| 620 |
monthly_repair_val = portfolio_size * (repair_per_cycle / lease_term_months)
|
| 621 |
initial_investment = portfolio_size * s_mfg_cost
|
| 622 |
|
| 623 |
+
def _active_months_through(m):
|
| 624 |
+
full_cycles, remainder = divmod(m, real_cycle_months)
|
| 625 |
+
return full_cycles * lease_term_months + min(remainder, lease_term_months)
|
| 626 |
+
|
| 627 |
+
revenue_cum = [monthly_revenue_val * _active_months_through(m) for m in be_months]
|
| 628 |
cost_cum = [
|
| 629 |
+
initial_investment + monthly_repair_val * _active_months_through(m)
|
| 630 |
+
+ portfolio_size * logistics_per_cycle * (m // real_cycle_months)
|
| 631 |
for m in be_months
|
| 632 |
]
|
| 633 |
|
| 634 |
+
be_lead = f'Cost starts at <b>{sfmt(initial_investment)} NOK</b> — the upfront manufacturing spend — and climbs in steps as logistics and repairs are paid. Revenue builds during each cycle\'s active months'
|
| 635 |
+
be_lead += f' and flatlines for its {idle_months} idle months.' if idle_months > 0 else '.'
|
| 636 |
if breakeven_month and breakeven_month <= chart_months:
|
| 637 |
lead_gap = revenue_cum[-1] - cost_cum[-1]
|
| 638 |
be_lead += f' Revenue overtakes cost in <b>month {breakeven_month}</b>, and the portfolio is <b>{sfmt(lead_gap)} NOK</b> ahead by month {chart_months}.'
|
|
|
|
| 700 |
margin=dict(t=30),
|
| 701 |
)
|
| 702 |
st.plotly_chart(fig_be, use_container_width=True)
|
| 703 |
+
caption = f"Cost steps up when logistics are paid at the start of each {real_cycle_months}-month cycle, and creeps up during the {lease_term_months} active months (repairs); revenue accrues from the lease price during those same active months"
|
| 704 |
+
caption += f" and pauses for the {idle_months} idle months." if idle_months > 0 else "."
|
| 705 |
+
st.caption(caption)
|
| 706 |
|
| 707 |
st.markdown("---")
|
| 708 |
|