from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
from uuid import UUID
from decimal import Decimal
from .base_responses import BaseResponse, CrudCollection


class DecisionBookBudgetBooksResponse(BaseResponse):
    """Response model for decision book budget books"""

    country: str
    branch_type: int = 0
    company_id: int
    company_uu_id: str
    branch_id: Optional[int]
    branch_uu_id: Optional[str]
    build_decision_book_id: int
    build_decision_book_uu_id: Optional[str]


class DecisionBookBudgetBooksCollection(
    CrudCollection[DecisionBookBudgetBooksResponse]
):
    """Collection of decision book budget books"""

    pass


class DecisionBookBudgetCodesResponse(BaseResponse):
    """Response model for decision book budget codes"""

    budget_code: str
    comment_line: str
    budget_type: str
    budget_code_seperator: str = "."
    system_id: int = 0
    locked: bool = False
    company_id: Optional[int]
    company_uu_id: str
    customer_id: Optional[int]
    customer_uu_id: str


class DecisionBookBudgetCodesCollection(
    CrudCollection[DecisionBookBudgetCodesResponse]
):
    """Collection of decision book budget codes"""

    pass


class DecisionBookBudgetMasterResponse(BaseResponse):
    """Response model for decision book budget master"""

    budget_type: str
    currency: str = "TRY"
    total_budget: Decimal
    tracking_period_id: Optional[int]
    tracking_period_uu_id: Optional[str]
    budget_books_id: int
    budget_books_uu_id: Optional[str]
    department_id: int
    department_uu_id: Optional[str]


class DecisionBookBudgetMasterCollection(
    CrudCollection[DecisionBookBudgetMasterResponse]
):
    """Collection of decision book budget masters"""

    pass


class DecisionBookBudgetsResponse(BaseResponse):
    """Response model for decision book budgets"""

    process_date: datetime
    budget_codes_id: int
    total_budget: Decimal
    used_budget: Decimal = Decimal("0")
    remaining_budget: Decimal = Decimal("0")
    decision_book_budget_master_id: int
    decision_book_budget_master_uu_id: Optional[str]


class DecisionBookBudgetsCollection(CrudCollection[DecisionBookBudgetsResponse]):
    """Collection of decision book budgets"""

    pass
