| """ |
| Enhanced ROI calculators and business logic |
| """ |
|
|
| from typing import Dict |
| from core.data_models import IncidentScenario |
|
|
| class EnhancedROICalculator: |
| """Investor-grade ROI calculator with sensitivity analysis""" |
| |
| def calculate_comprehensive_roi(self, monthly_incidents: int, |
| avg_impact: float, team_size: int) -> Dict: |
| """Calculate multi-scenario ROI analysis""" |
| |
| base = self._calculate_scenario(monthly_incidents, avg_impact, team_size, |
| savings_rate=0.82, efficiency_gain=0.85) |
| |
| |
| best = self._calculate_scenario(monthly_incidents, avg_impact, team_size, |
| savings_rate=0.92, efficiency_gain=0.92) |
| |
| |
| worst = self._calculate_scenario(monthly_incidents, avg_impact, team_size, |
| savings_rate=0.72, efficiency_gain=0.78) |
| |
| |
| recommendation = self._get_recommendation(base['roi_multiplier']) |
| |
| return { |
| "summary": { |
| "your_annual_impact": f"${base['annual_impact']:,.0f}", |
| "potential_savings": f"${base['savings']:,.0f}", |
| "enterprise_cost": f"${base['enterprise_cost']:,.0f}", |
| "roi_multiplier": f"{base['roi_multiplier']:.1f}Γ", |
| "payback_months": f"{base['payback_months']:.1f}", |
| "annual_roi_percentage": f"{base['roi_percentage']:.0f}%" |
| }, |
| "scenarios": { |
| "base_case": { |
| "roi": f"{base['roi_multiplier']:.1f}Γ", |
| "payback": f"{base['payback_months']:.1f} months", |
| "confidence": "High" |
| }, |
| "best_case": { |
| "roi": f"{best['roi_multiplier']:.1f}Γ", |
| "payback": f"{best['payback_months']:.1f} months", |
| "confidence": "Medium" |
| }, |
| "worst_case": { |
| "roi": f"{worst['roi_multiplier']:.1f}Γ", |
| "payback": f"{worst['payback_months']:.1f} months", |
| "confidence": "Medium" |
| } |
| }, |
| "comparison": { |
| "industry_average": "5.2Γ ROI", |
| "top_performers": "8.7Γ ROI", |
| "your_position": f"Top {self._get_percentile(base['roi_multiplier'])}%" |
| }, |
| "recommendation": recommendation |
| } |
| |
| def _calculate_scenario(self, monthly_incidents: int, avg_impact: float, |
| team_size: int, savings_rate: float, |
| efficiency_gain: float) -> Dict: |
| """Calculate specific scenario""" |
| annual_impact = monthly_incidents * 12 * avg_impact |
| enterprise_cost = team_size * 125000 |
| savings = annual_impact * savings_rate * efficiency_gain |
| |
| roi_multiplier = savings / enterprise_cost if enterprise_cost > 0 else 0 |
| roi_percentage = (roi_multiplier - 1) * 100 |
| payback_months = (enterprise_cost / (savings / 12)) if savings > 0 else 0 |
| |
| return { |
| "annual_impact": annual_impact, |
| "enterprise_cost": enterprise_cost, |
| "savings": savings, |
| "roi_multiplier": roi_multiplier, |
| "roi_percentage": roi_percentage, |
| "payback_months": payback_months |
| } |
| |
| def _get_recommendation(self, roi_multiplier: float) -> Dict: |
| """Get recommendation based on ROI""" |
| if roi_multiplier >= 5.0: |
| return { |
| "action": "π Deploy ARF Enterprise", |
| "reason": "Exceptional ROI (>5Γ) with quick payback", |
| "timeline": "30-day implementation", |
| "expected_value": ">$1M annual savings", |
| "priority": "High" |
| } |
| elif roi_multiplier >= 2.0: |
| return { |
| "action": "β
Implement ARF Enterprise", |
| "reason": "Strong ROI (2-5Γ) with operational benefits", |
| "timeline": "60-day phased rollout", |
| "expected_value": ">$500K annual savings", |
| "priority": "Medium" |
| } |
| else: |
| return { |
| "action": "π Start with ARF OSS", |
| "reason": "Validate value before Enterprise investment", |
| "timeline": "14-day evaluation", |
| "expected_value": "Operational insights + clear upgrade path", |
| "priority": "Low" |
| } |
| |
| def _get_percentile(self, roi_multiplier: float) -> str: |
| """Calculate percentile vs industry""" |
| if roi_multiplier >= 8.0: |
| return "10" |
| elif roi_multiplier >= 5.0: |
| return "25" |
| elif roi_multiplier >= 3.0: |
| return "50" |
| elif roi_multiplier >= 2.0: |
| return "75" |
| else: |
| return "90" |