from __future__ import annotations

from .decision import OpportunityDecision
from .types import ACTION_CONFIRM_PAYMENT, ACTION_SEND_INVOICE, ACTION_WAIT_PRODUCTION


def decision_coherence_flags(decision: OpportunityDecision) -> list[str]:
    """Small safety net used by future audits/tests."""
    flags: list[str] = []
    if decision.next_action.code == ACTION_CONFIRM_PAYMENT and decision.financial_state == "payment_confirmed":
        flags.append("payment_confirmed_but_action_is_confirm_payment")
    if decision.next_action.code == ACTION_SEND_INVOICE and decision.financial_state == "payment_confirmed" and decision.physical_state == "in_production":
        flags.append("invoice_send_action_while_production_should_be_wait")
    if decision.next_action.code == ACTION_WAIT_PRODUCTION and decision.physical_state != "in_production":
        flags.append("wait_production_without_production_state")
    return flags
