services are checked
This commit is contained in:
@@ -3,11 +3,12 @@ from sqlalchemy import (
|
||||
ForeignKey,
|
||||
Index,
|
||||
Numeric,
|
||||
Identity,
|
||||
)
|
||||
from sqlalchemy.orm import mapped_column
|
||||
from sqlalchemy.orm import mapped_column, Mapped
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
|
||||
from validations import InsertCompanyEmployees
|
||||
from api_validations.validations_request import InsertCompanyEmployees
|
||||
|
||||
|
||||
class Staff(CrudCollection):
|
||||
@@ -15,14 +16,20 @@ class Staff(CrudCollection):
|
||||
__tablename__ = "staff"
|
||||
__exclude__fields__ = []
|
||||
|
||||
staff_description = mapped_column(
|
||||
staff_description: Mapped[str] = mapped_column(
|
||||
String, server_default="", comment="Staff Description"
|
||||
)
|
||||
staff_name = mapped_column(String, nullable=False, comment="Staff Name")
|
||||
staff_code = mapped_column(String, nullable=False, comment="Staff Code")
|
||||
staff_name: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Staff Name"
|
||||
)
|
||||
staff_code: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Staff Code"
|
||||
)
|
||||
|
||||
duties_id = mapped_column(ForeignKey("duties.id"), nullable=False)
|
||||
duties_uu_id = mapped_column(String, nullable=False, comment="Duty UUID")
|
||||
duties_id: Mapped[Identity] = mapped_column(ForeignKey("duties.id"), nullable=False)
|
||||
duties_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Duty UUID"
|
||||
)
|
||||
|
||||
# people: Mapped["People"] = relationship(
|
||||
# "People", back_populates="employees", foreign_keys=[people_id], uselist=True
|
||||
@@ -33,7 +40,7 @@ class Staff(CrudCollection):
|
||||
|
||||
@classmethod
|
||||
def create_action(cls, data: InsertCompanyEmployees):
|
||||
from database_sql_models import Duties
|
||||
from databases import Duties
|
||||
|
||||
data_dict = data.model_dump()
|
||||
if duty := Duties.find_one(uu_id=data.duty_uu_id):
|
||||
@@ -56,10 +63,14 @@ class Employees(CrudCollection):
|
||||
__tablename__ = "employees"
|
||||
__exclude__fields__ = []
|
||||
|
||||
staff_id = mapped_column(ForeignKey("staff.id"))
|
||||
staff_uu_id = mapped_column(String, nullable=False, comment="Staff UUID")
|
||||
people_id = mapped_column(ForeignKey("people.id"), nullable=True)
|
||||
people_uu_id = mapped_column(String, nullable=True, comment="People UUID")
|
||||
staff_id: Mapped[Identity] = mapped_column(ForeignKey("staff.id"))
|
||||
staff_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Staff UUID"
|
||||
)
|
||||
people_id: Mapped[Identity] = mapped_column(ForeignKey("people.id"), nullable=True)
|
||||
people_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="People UUID"
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
Index("employees_ndx_00", people_id, staff_id, unique=True),
|
||||
@@ -72,12 +83,18 @@ class EmployeeHistory(CrudCollection):
|
||||
__tablename__ = "employee_history"
|
||||
__exclude__fields__ = []
|
||||
|
||||
staff_id = mapped_column(ForeignKey("staff.id"), nullable=False, comment="Staff ID")
|
||||
staff_uu_id = mapped_column(String, nullable=False, comment="Staff UUID")
|
||||
people_id = mapped_column(
|
||||
staff_id: Mapped[Identity] = mapped_column(
|
||||
ForeignKey("staff.id"), nullable=False, comment="Staff ID"
|
||||
)
|
||||
staff_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Staff UUID"
|
||||
)
|
||||
people_id: Mapped[Identity] = mapped_column(
|
||||
ForeignKey("people.id"), nullable=False, comment="People ID"
|
||||
)
|
||||
people_uu_id = mapped_column(String, nullable=False, comment="People UUID")
|
||||
people_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="People UUID"
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
Index("_employee_history_ndx_00", people_id, staff_id),
|
||||
@@ -90,11 +107,17 @@ class EmployeesSalaries(CrudCollection):
|
||||
__tablename__ = "employee_salaries"
|
||||
__exclude__fields__ = []
|
||||
|
||||
gross_salary = mapped_column(Numeric(20, 6), nullable=False, comment="Gross Salary")
|
||||
net_salary = mapped_column(Numeric(20, 6), nullable=False, comment="Net Salary")
|
||||
gross_salary: Mapped[float] = mapped_column(
|
||||
Numeric(20, 6), nullable=False, comment="Gross Salary"
|
||||
)
|
||||
net_salary: Mapped[float] = mapped_column(
|
||||
Numeric(20, 6), nullable=False, comment="Net Salary"
|
||||
)
|
||||
|
||||
people_id = mapped_column(ForeignKey("people.id"), nullable=False)
|
||||
people_uu_id = mapped_column(String, nullable=False, comment="People UUID")
|
||||
people_id: Mapped[Identity] = mapped_column(ForeignKey("people.id"), nullable=False)
|
||||
people_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="People UUID"
|
||||
)
|
||||
|
||||
# people: Mapped["People"] = relationship(
|
||||
# "People", back_populates="employee_salaries", foreign_keys=[people_id]
|
||||
|
||||
Reference in New Issue
Block a user