import uuid from datetime import date as DateType, datetime from decimal import Decimal from typing import Literal from pydantic import BaseModel, Field BudgetPeriod = Literal["weekly", "monthly", "quarterly", "yearly"] class BudgetCreate(BaseModel): category_id: uuid.UUID name: str = Field(..., min_length=1, max_length=200) amount: Decimal = Field(..., gt=0) currency: str = Field(default="GBP", min_length=3, max_length=10) period: BudgetPeriod = "monthly" start_date: DateType end_date: DateType | None = None rollover: bool = False alert_threshold: Decimal = Field(default=Decimal("80"), ge=0, le=100) class BudgetUpdate(BaseModel): name: str | None = Field(default=None, min_length=1, max_length=200) amount: Decimal | None = Field(default=None, gt=0) period: BudgetPeriod | None = None end_date: DateType | None = None rollover: bool | None = None alert_threshold: Decimal | None = Field(default=None, ge=0, le=100) is_active: bool | None = None class BudgetResponse(BaseModel): id: uuid.UUID category_id: uuid.UUID name: str amount: Decimal currency: str period: str start_date: DateType end_date: DateType | None rollover: bool alert_threshold: Decimal is_active: bool created_at: datetime updated_at: datetime model_config = {"from_attributes": True} class BudgetSummaryItem(BaseModel): budget_id: uuid.UUID budget_name: str category_id: uuid.UUID category_name: str period: str budget_amount: Decimal spent_amount: Decimal remaining_amount: Decimal percent_used: Decimal is_over_budget: bool alert_triggered: bool currency: str period_start: DateType period_end: DateType