"""
賞与計算のスキーマ定義 (Bonus Schemas)
"""
from pydantic import BaseModel
from datetime import date, datetime
from typing import Optional
from decimal import Decimal


class BonusPaymentBase(BaseModel):
    """賞与計算基本情報"""
    employee_id: int
    bonus_year: int
    bonus_month: int
    bonus_type: str  # 夏季賞与/冬季賞与/決算賞与/その他
    payment_date: date
    base_bonus: Decimal = Decimal("0")
    performance_bonus: Decimal = Decimal("0")
    other_bonus: Decimal = Decimal("0")


class BonusPaymentCreate(BonusPaymentBase):
    """賞与計算の作成"""
    pass


class BonusCalculationRequest(BaseModel):
    """賞与計算リクエスト"""
    employee_id: int
    bonus_year: int
    bonus_month: int
    bonus_type: str
    payment_date: date
    base_bonus: Decimal
    performance_bonus: Decimal = Decimal("0")
    other_bonus: Decimal = Decimal("0")
    other_deduction: Decimal = Decimal("0")
    calculated_by: str = "system"


class BonusPayment(BonusPaymentBase):
    """賞与計算結果"""
    bonus_id: int
    status: str
    total_bonus: Decimal
    health_insurance: Decimal
    care_insurance: Decimal
    pension_insurance: Decimal
    employment_insurance: Decimal
    income_tax: Decimal
    other_deduction: Decimal
    total_deduction: Decimal
    net_bonus: Decimal
    notes: Optional[str] = None
    calculated_at: Optional[datetime] = None
    calculated_by: Optional[str] = None
    approved_at: Optional[datetime] = None
    approved_by: Optional[str] = None
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
