#!/usr/bin/env python3 """Monthly five-level Vimshottari snapshots for the KP monthly report.""" from __future__ import annotations from datetime import datetime try: # pragma: no cover - import path differs under CLI vs pytest from dasha_calculator_enhanced import calculate_five_level_dasha from domain_calculation_service import compute_vimshottari_timeline except ImportError: # pragma: no cover from scripts.dasha_calculator_enhanced import calculate_five_level_dasha from scripts.domain_calculation_service import compute_vimshottari_timeline def build_monthly_vimshottari_snapshot( *, birth_dt: datetime, moon_lon: float, anchor_dt: datetime ) -> dict: timeline = compute_vimshottari_timeline( birth_dt=birth_dt, moon_lon=moon_lon, current_date=anchor_dt, ) current = timeline.get("current_dasha") or {} start_text = current.get("start") if start_text: current_start = datetime.strptime(start_text, "%Y-%m-%d") elapsed_years = max((anchor_dt - current_start).days / 365.25, 0.0) else: elapsed_years = 0.0 md_lord = current.get("lord") or timeline.get("birth_balance", {}).get("lord") levels = calculate_five_level_dasha(md_lord, elapsed_years) return { "anchor_date": anchor_dt.strftime("%Y-%m-%d"), "timeline": { "current_dasha": current, "birth_balance": timeline.get("birth_balance"), }, "levels": { "mahadasha": levels.get("mahadasha"), "antardasha": levels.get("bhukti"), "pratyantardasha": levels.get("pratyantar"), "sookshma": levels.get("sookshma"), "prana": levels.get("prana"), }, "status": "parameter_sensitive", "must_not_claim": ["exact_event_timing", "specific_event_prediction"], }