File size: 5,152 Bytes
f003859
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"""
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 scenario (realistic)
        base = self._calculate_scenario(monthly_incidents, avg_impact, team_size, 
                                       savings_rate=0.82, efficiency_gain=0.85)
        
        # Best case (aggressive adoption)
        best = self._calculate_scenario(monthly_incidents, avg_impact, team_size,
                                       savings_rate=0.92, efficiency_gain=0.92)
        
        # Worst case (conservative)
        worst = self._calculate_scenario(monthly_incidents, avg_impact, team_size,
                                        savings_rate=0.72, efficiency_gain=0.78)
        
        # Generate recommendation
        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  # Conservative $125k/engineer
        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"