from __future__ import annotations

from datetime import date, datetime

from pydantic import BaseModel


class RealtimeAttendanceSyncRequest(BaseModel):
    """实时考勤同步请求。"""

    attendance_date: date
    include_salary_preview: bool = True


class TodayAttendanceItem(BaseModel):
    """实时考勤看板中的员工行。"""

    employee_id: int | None
    employee_no: str
    employee_name: str
    department: str
    position: str
    first_punch: str
    last_punch: str
    attendance_status: str
    late_minutes: int
    missing_card_count: int
    leave_hours: float
    today_overtime_hours: float
    month_remaining_overtime_hours: float
    estimated_net_salary: float | None
    note: str


class RealtimeAttendanceSummary(BaseModel):
    """实时考勤看板摘要。"""

    attendance_date: date
    employee_total: int
    checked_in_count: int
    unchecked_count: int
    late_count: int
    leave_count: int
    missing_card_count: int
    estimated_overtime_count: int
    estimated_net_total: float


class RealtimeAttendanceResponse(BaseModel):
    """实时考勤看板响应。"""

    sync_job_id: str | None
    synced_at: datetime | None
    summary: RealtimeAttendanceSummary
    items: list[TodayAttendanceItem]
