from datetime import date, datetime from sqlalchemy import Date, DateTime, Integer, String, Text from sqlalchemy.orm import Mapped, mapped_column from app.core.database import Base from app.modules.business.constants import ( SourceSystem, StatusValue, ) from app.modules.business.models.common import TimestampMixin class AttendanceRecord(Base, TimestampMixin): __tablename__ = "attendance_records" id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) code: Mapped[str] = mapped_column(String(64), unique=True, index=True) employee_name: Mapped[str] = mapped_column(String(128), index=True) employee_id: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True) department: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True) project_code: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True) work_date: Mapped[date] = mapped_column(Date, index=True) check_in_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True) check_out_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True) status: Mapped[str] = mapped_column(String(64), default=StatusValue.NORMAL_CN, index=True) location: Mapped[str | None] = mapped_column(String(255), nullable=True) source_system: Mapped[str] = mapped_column(String(64), default=SourceSystem.INTERNAL) external_id: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True) note: Mapped[str | None] = mapped_column(Text, nullable=True)