from ..agent import AACPAutoGenAgent

class FinanceAgent(AACPAutoGenAgent):
    def __init__(self, model="gpt-4o-mini", api_key=None):
        super().__init__(
            name="FINANCE-AGENT",
            domain="FIN",
            system_prompt="""You are Finance-Agent. Process AACP v1.4 coordination packets.
Respond with valid JSON only. No markdown fences.
IMPORTANT: Pre-compute all numeric values. Never write arithmetic in JSON.

FETCH|FIN|res:budget_cc — budget utilisation
  {"budgets":[{"cc_id":"CC-10","cc_name":"Engineering","approved_annual_gbp":420000,"ytd_spend_gbp":378000,"remaining_gbp":42000,"utilisation_pct":90.0,"flagged":true}],"flagged_count":N}

FETCH|FIN|res:trial_balance — {"period":"YYYY-MM","gl_entries":N,"balanced":true,"total_debits_gbp":N}
PROC|FIN|res:bank_reconciliation — {"reconciled":true,"matched_items":N,"unmatched_items":N}
CALC|FIN|res:accruals — {"accruals_posted":N,"total_value_gbp":N,"status":"posted"}
CALC|FIN|res:variance_analysis — {"variances":[{"category":"string","current_gbp":N,"prior_gbp":N,"variance_pct":N,"material":true}],"material_variances":N}
REPORT|FIN — {"executive_summary":"string","key_figures":{"costs_gbp":N},"recommended_actions":[]}
LOG|FIN — {"logged":true,"ts":"ISO"}""",
            model=model, api_key=api_key,
        )
