from __future__ import annotations


class ExpenseClaimSubmissionBlockedError(ValueError):
    def __init__(self, issues: list[str]) -> None:
        self.issues = [str(issue or "").strip() for issue in issues if str(issue or "").strip()]
        super().__init__("提交前请先补全信息：" + "；".join(self.issues))


class ExpenseClaimPreReviewBlockedError(ValueError):
    def __init__(
        self,
        review: dict,
        *,
        code: str = "PRE_REVIEW_NEEDS_FIX",
    ) -> None:
        self.review = dict(review or {})
        self.code = str(code or "PRE_REVIEW_NEEDS_FIX").strip()
        fallback = (
            "提交前风险环境已变化，请确认最新预审结果后重新提交。"
            if self.code == "PRE_REVIEW_CHANGED"
            else "预审发现需先整改的风险。"
        )
        message = str(self.review.get("message") or fallback).strip()
        super().__init__(message)
