prod-wag-backend-automate-s.../api_services/schemas/company/department.py

83 lines
2.5 KiB
Python

from schemas.base_imports import (
CrudCollection,
String,
Integer,
Boolean,
ForeignKey,
Index,
TIMESTAMP,
Numeric,
SmallInteger,
mapped_column,
Mapped,
)
class Departments(CrudCollection):
__tablename__ = "departments"
__exclude__fields__ = []
parent_department_id = mapped_column(Integer, server_default="0")
department_code = mapped_column(
String(16), nullable=False, index=True, comment="Department Code"
)
department_name: Mapped[str] = mapped_column(
String(128), nullable=False, comment="Department Name"
)
department_description: Mapped[str] = mapped_column(String, server_default="")
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=False)
company_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Company UUID"
)
__table_args__ = {"comment": "Departments Information"}
class Duty(CrudCollection):
__tablename__ = "duty"
__exclude__fields__ = []
duty_name: Mapped[str] = mapped_column(
String, unique=True, nullable=False, comment="Duty Name"
)
duty_code: Mapped[str] = mapped_column(String, nullable=False, comment="Duty Code")
duty_description: Mapped[str] = mapped_column(String, comment="Duty Description")
__table_args__ = ({"comment": "Duty Information"},)
class Duties(CrudCollection):
__tablename__ = "duties"
__exclude__fields__ = []
users_default_duty = mapped_column(
ForeignKey("duty.id"), nullable=True, comment="Default Duty for Users"
)
company_id: Mapped[int] = mapped_column(Integer)
company_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Company UUID"
)
duties_id: Mapped[int] = mapped_column(ForeignKey("duty.id"), nullable=False)
duties_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Duty UUID"
)
department_id = mapped_column(
ForeignKey("departments.id"), nullable=False, comment="Department ID"
)
department_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Department UUID"
)
# priority_id: Mapped[int] = mapped_column(ForeignKey("priority.id"), nullable=True)
management_duty = mapped_column(
Boolean, server_default="0"
) # is this a prime Company Duty ???
__table_args__ = (
Index("duty_ndx_00", company_id, duties_id, department_id, unique=True),
{"comment": "Duty & Company & Department Information"},
)