"""Detailed rationale analysis for divestiture decision."""
import asyncio
import sys
from pathlib import Path
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from fccs_agent.config import load_config
from fccs_agent.agent import initialize_agent, close_agent
from fccs_agent.tools.data import smart_retrieve
from fccs_agent.utils.cache import load_members_from_cache
async def analyze_divestiture_rationale():
"""Analyze and explain the rationale behind divestiture decision."""
print("=" * 80)
print("DIVESTITURE DECISION RATIONALE - CVNT")
print("=" * 80)
print()
try:
config = load_config()
await initialize_agent(config)
print("[OK] Connected to FCCS")
print()
# Get CVNT performance
cvnt_ytd = await smart_retrieve(
account="FCCS_Net Income",
entity="CVNT",
period="Dec",
years="FY25",
scenario="Actual"
)
# Get consolidated performance
consolidated = await smart_retrieve(
account="FCCS_Net Income",
entity="FCCS_Total Geography",
period="Dec",
years="FY25",
scenario="Actual"
)
cvnt_loss = None
consolidated_total = None
if cvnt_ytd.get("status") == "success":
data = cvnt_ytd.get("data", {})
rows = data.get("rows", [])
if rows and rows[0].get("data"):
cvnt_loss = float(rows[0]["data"][0])
if consolidated.get("status") == "success":
data = consolidated.get("data", {})
rows = data.get("rows", [])
if rows and rows[0].get("data"):
consolidated_total = float(rows[0]["data"][0])
print("=" * 80)
print("1. PROBLEM IDENTIFICATION")
print("=" * 80)
print()
print(f"Entity: CVNT")
print(f"Annual Loss (FY25): ${abs(cvnt_loss):,.2f}")
print(f"Consolidated Total (FY25): ${consolidated_total:,.2f}")
print()
if cvnt_loss and consolidated_total:
impact_pct = (abs(cvnt_loss) / abs(consolidated_total)) * 100 if consolidated_total != 0 else 0
print(f"CVNT represents {impact_pct:.1f}% of total consolidated loss")
print(f" - CVNT loss: ${abs(cvnt_loss):,.2f}")
print(f" - Total loss: ${abs(consolidated_total):,.2f}")
print()
print("=" * 80)
print("2. FINANCIAL IMPACT ANALYSIS")
print("=" * 80)
print()
print("Current Situation:")
print(f" - Consolidated Group: ${consolidated_total:,.2f} (LOSS)")
print(f" - CVNT Contribution: ${cvnt_loss:,.2f} (LOSS)")
print()
if cvnt_loss and consolidated_total:
# Scenario 1: Keep CVNT
keep_scenario = consolidated_total
print("Scenario A: KEEP CVNT")
print(f" - Projected FY25 Result: ${keep_scenario:,.2f}")
print(f" - Impact: Continues to drag down consolidated performance")
print(f" - Risk: Losses may continue or worsen in future periods")
print()
# Scenario 2: Divest in January
jan_loss = -3380228.11 # From previous analysis
sale_price = 13031117.94
divest_scenario = consolidated_total - jan_loss + sale_price
improvement = divest_scenario - keep_scenario
print("Scenario B: DIVEST CVNT (January)")
print(f" - Loss Removed: ${abs(jan_loss):,.2f} (Jan YTD)")
print(f" - Sale Proceeds: ${sale_price:,.2f}")
print(f" - Projected FY25 Result: ${divest_scenario:,.2f}")
print(f" - Improvement: ${improvement:,.2f}")
print(f" - Impact: Transforms loss into profit")
print()
print("=" * 80)
print("3. STRATEGIC RATIONALE")
print("=" * 80)
print()
print("A. FINANCIAL RATIONALE:")
print(" [+] Eliminates $26M annual loss")
print(" [+] Generates $13M in sale proceeds")
print(" [+] Improves consolidated profitability by $16.4M")
print(" [+] Transforms group from loss to profit position")
print()
print("B. TIMING RATIONALE (January Sale):")
print(" [+] Minimizes loss exposure (-$3.4M vs -$26M)")
print(" [+] Early divestiture prevents further losses")
print(" [+] Allows buyer to operate for full year")
print(" [+] Better sale price earlier in year")
print()
print("C. OPERATIONAL RATIONALE:")
print(" [+] Frees up management time and resources")
print(" [+] Eliminates ongoing operational costs")
print(" [+] Reduces risk exposure")
print(" [+] Allows focus on profitable entities")
print()
print("D. VALUATION RATIONALE:")
print(" [+] Sale Price: $13M (50% of annual loss)")
print(" [+] Based on asset value and liability assumption")
print(" [+] Buyer takes on operations and some liabilities")
print(" [+] Alternative: Pay $5.2M to divest (worse option)")
print()
print("=" * 80)
print("4. RISK ANALYSIS")
print("=" * 80)
print()
print("RISKS OF KEEPING CVNT:")
print(" [-] Continued losses: -$26M+ annually")
print(" [-] Dragging down entire group performance")
print(" [-] Opportunity cost: Resources tied to loss-making entity")
print(" [-] Future uncertainty: Losses may increase")
print()
print("RISKS OF DIVESTING:")
print(" [!] Sale price may be lower than estimated")
print(" [!] May need to pay buyer to take entity")
print(" [!] One-time transaction costs")
print(" [!] Potential disruption to other operations")
print()
print("MITIGATION:")
print(" [+] Early sale (January) minimizes exposure")
print(" [+] Conservative valuation estimate")
print(" [+] Multiple valuation scenarios considered")
print(" [+] Focus on asset-based valuation")
print()
print("=" * 80)
print("5. DECISION MATRIX")
print("=" * 80)
print()
print(f"{'Criteria':<30} {'Keep CVNT':<20} {'Divest CVNT':<20}")
print("-" * 70)
print(f"{'Financial Impact':<30} {'-$26M loss':<20} {'+$16.4M improvement':<20}")
print(f"{'Consolidated Result':<30} {'-$6.3M (loss)':<20} {'+$10.1M (profit)':<20}")
print(f"{'Cash Flow':<30} {'Negative':<20} {'+$13M proceeds':<20}")
print(f"{'Risk Level':<30} {'High (ongoing)':<20} {'Low (one-time)':<20}")
print(f"{'Resource Allocation':<30} {'Tied to loss':<20} {'Freed up':<20}")
print(f"{'Strategic Focus':<30} {'Distracted':<20} {'On winners':<20}")
print()
print("=" * 80)
print("6. RECOMMENDATION SUMMARY")
print("=" * 80)
print()
print("DECISION: DIVEST CVNT in JANUARY 2025")
print()
print("Key Reasons:")
print(" 1. Financial: Eliminates $26M annual loss, improves group by $16.4M")
print(" 2. Timing: January minimizes exposure to only $3.4M loss")
print(" 3. Valuation: $13M sale price provides cash infusion")
print(" 4. Strategic: Allows focus on profitable entities")
print(" 5. Risk: One-time transaction vs ongoing losses")
print()
print("Expected Outcome:")
print(f" - Current: ${consolidated_total:,.2f} (LOSS)")
print(f" - After Divestiture: ${divest_scenario:,.2f} (PROFIT)")
print(f" - Improvement: ${improvement:,.2f} ({improvement/abs(consolidated_total)*100:.1f}% improvement)")
print()
print("=" * 80)
print("CONCLUSION")
print("=" * 80)
print()
print("The divestiture of CVNT is financially and strategically sound:")
print(" • Transforms consolidated group from loss to profit")
print(" • Minimizes loss exposure through early sale")
print(" • Provides cash proceeds for reinvestment")
print(" • Allows management to focus on profitable operations")
print(" • Reduces ongoing risk and uncertainty")
print()
print("The decision is supported by clear financial metrics and")
print("strategic alignment with improving overall group performance.")
print()
await close_agent()
except Exception as e:
print(f"\n[ERROR] {e}")
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
asyncio.run(analyze_divestiture_rationale())