alchemy functions updated
This commit is contained in:
parent
a28d4c22d1
commit
aeda315119
|
|
@ -1,4 +1,4 @@
|
||||||
from date_time_actions.date_functions import client_arrow, system_arrow
|
from api_library.date_time_actions.date_functions import client_arrow, system_arrow
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["client_arrow", "system_arrow"]
|
__all__ = ["client_arrow", "system_arrow"]
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ class AccountBooks(CrudCollection):
|
||||||
branch_type: Mapped[str] = mapped_column(SmallInteger, server_default="0")
|
branch_type: Mapped[str] = mapped_column(SmallInteger, server_default="0")
|
||||||
|
|
||||||
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=False)
|
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=False)
|
||||||
company_uu_id: Mapped[UUID] = mapped_column(String, nullable=False)
|
company_uu_id: Mapped[str] = mapped_column(String, nullable=False)
|
||||||
branch_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
branch_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||||
branch_uu_id: Mapped[UUID] = mapped_column(String, comment="Branch UU ID")
|
branch_uu_id: Mapped[str] = mapped_column(String, comment="Branch UU ID")
|
||||||
|
|
||||||
# company: Mapped["Companies"] = relationship(
|
# company: Mapped["Companies"] = relationship(
|
||||||
# "Company", back_populates="company_account_books", foreign_keys=[company_id]
|
# "Company", back_populates="company_account_books", foreign_keys=[company_id]
|
||||||
|
|
@ -46,7 +46,7 @@ class AccountBooks(CrudCollection):
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
Index(
|
Index(
|
||||||
"account_companies_book_ndx_00", company_id, CrudCollection.expiry_starts
|
"account_companies_book_ndx_00", company_id, "expiry_starts"
|
||||||
),
|
),
|
||||||
{"comment": "Account Book Information"},
|
{"comment": "Account Book Information"},
|
||||||
)
|
)
|
||||||
|
|
@ -74,15 +74,15 @@ class AccountCodes(CrudCollection):
|
||||||
locked: Mapped[bool] = mapped_column(SmallInteger, server_default="0")
|
locked: Mapped[bool] = mapped_column(SmallInteger, server_default="0")
|
||||||
|
|
||||||
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||||
company_uu_id: Mapped[UUID] = mapped_column(
|
company_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Company UU ID"
|
String, nullable=False, comment="Company UU ID"
|
||||||
)
|
)
|
||||||
customer_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
customer_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||||
customer_uu_id: Mapped[UUID] = mapped_column(
|
customer_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Customer UU ID"
|
String, nullable=False, comment="Customer UU ID"
|
||||||
)
|
)
|
||||||
person_id: Mapped[int] = mapped_column(ForeignKey("people.id"))
|
person_id: Mapped[int] = mapped_column(ForeignKey("people.id"))
|
||||||
person_uu_id: Mapped[UUID] = mapped_column(
|
person_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Person UU ID"
|
String, nullable=False, comment="Person UU ID"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -123,7 +123,7 @@ class AccountCodeParser(CrudCollection):
|
||||||
account_code_id: Mapped[int] = mapped_column(
|
account_code_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("account_codes.id"), nullable=False
|
ForeignKey("account_codes.id"), nullable=False
|
||||||
)
|
)
|
||||||
account_code_uu_id: Mapped[UUID] = mapped_column(
|
account_code_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Account Code UU ID"
|
String, nullable=False, comment="Account Code UU ID"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -201,17 +201,17 @@ class AccountMaster(CrudCollection):
|
||||||
account_header_id: Mapped[int] = mapped_column(
|
account_header_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("account_books.id"), nullable=False
|
ForeignKey("account_books.id"), nullable=False
|
||||||
)
|
)
|
||||||
account_header_uu_id: Mapped[UUID] = mapped_column(
|
account_header_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Account Header UU ID"
|
String, nullable=False, comment="Account Header UU ID"
|
||||||
)
|
)
|
||||||
project_item_id: Mapped[int] = mapped_column(
|
project_item_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("build_decision_book_projects.id")
|
ForeignKey("build_decision_book_projects.id")
|
||||||
)
|
)
|
||||||
project_item_uu_id: Mapped[UUID] = mapped_column(
|
project_item_uu_id: Mapped[str] = mapped_column(
|
||||||
String, comment="Project Item UU ID"
|
String, comment="Project Item UU ID"
|
||||||
)
|
)
|
||||||
department_id: Mapped[int] = mapped_column(ForeignKey("departments.id"))
|
department_id: Mapped[int] = mapped_column(ForeignKey("departments.id"))
|
||||||
department_uu_id: Mapped[UUID] = mapped_column(String, comment="Department UU ID")
|
department_uu_id: Mapped[str] = mapped_column(String, comment="Department UU ID")
|
||||||
|
|
||||||
# account_header: Mapped["AccountBooks"] = relationship(
|
# account_header: Mapped["AccountBooks"] = relationship(
|
||||||
# "AccountBooks",
|
# "AccountBooks",
|
||||||
|
|
@ -296,25 +296,25 @@ class AccountDetail(CrudCollection):
|
||||||
account_header_id: Mapped[int] = mapped_column(
|
account_header_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("account_books.id"), nullable=False
|
ForeignKey("account_books.id"), nullable=False
|
||||||
)
|
)
|
||||||
account_header_uu_id: Mapped[UUID] = mapped_column(
|
account_header_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Account Header UU ID"
|
String, nullable=False, comment="Account Header UU ID"
|
||||||
)
|
)
|
||||||
account_code_id: Mapped[int] = mapped_column(
|
account_code_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("account_codes.id"), nullable=False
|
ForeignKey("account_codes.id"), nullable=False
|
||||||
)
|
)
|
||||||
account_code_uu_id: Mapped[UUID] = mapped_column(
|
account_code_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Account Code UU ID"
|
String, nullable=False, comment="Account Code UU ID"
|
||||||
)
|
)
|
||||||
account_master_id: Mapped[int] = mapped_column(
|
account_master_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("account_master.id"), nullable=False
|
ForeignKey("account_master.id"), nullable=False
|
||||||
)
|
)
|
||||||
account_master_uu_id: Mapped[UUID] = mapped_column(
|
account_master_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Account Master UU ID"
|
String, nullable=False, comment="Account Master UU ID"
|
||||||
)
|
)
|
||||||
project_id: Mapped[int] = mapped_column(
|
project_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("build_decision_book_projects.id")
|
ForeignKey("build_decision_book_projects.id")
|
||||||
)
|
)
|
||||||
project_uu_id: Mapped[UUID] = mapped_column(String, comment="Project UU ID")
|
project_uu_id: Mapped[str] = mapped_column(String, comment="Project UU ID")
|
||||||
|
|
||||||
# account_header: Mapped["AccountBooks"] = relationship(
|
# account_header: Mapped["AccountBooks"] = relationship(
|
||||||
# "AccountBooks",
|
# "AccountBooks",
|
||||||
|
|
@ -469,13 +469,13 @@ class AccountRecords(CrudCollection):
|
||||||
)
|
)
|
||||||
# build_id: Mapped[int] = mapped_column(ForeignKey("build.id"), nullable=True)
|
# build_id: Mapped[int] = mapped_column(ForeignKey("build.id"), nullable=True)
|
||||||
build_parts_id: Mapped[int] = mapped_column(ForeignKey("build_parts.id"))
|
build_parts_id: Mapped[int] = mapped_column(ForeignKey("build_parts.id"))
|
||||||
build_parts_uu_id: Mapped[UUID] = mapped_column(
|
build_parts_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=True, comment="Build Parts UU ID"
|
String, nullable=True, comment="Build Parts UU ID"
|
||||||
)
|
)
|
||||||
build_decision_book_id: Mapped[int] = mapped_column(
|
build_decision_book_id: Mapped[int] = mapped_column(
|
||||||
ForeignKey("build_decision_book.id")
|
ForeignKey("build_decision_book.id")
|
||||||
)
|
)
|
||||||
build_decision_book_uu_id: Mapped[UUID] = mapped_column(
|
build_decision_book_uu_id: Mapped[str] = mapped_column(
|
||||||
String, nullable=True, comment="Build Decision Book UU ID"
|
String, nullable=True, comment="Build Decision Book UU ID"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,8 @@ from sqlalchemy import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from databases.sql_models.core_mixin import CrudCollection
|
from databases.sql_models.core_mixin import CrudCollection
|
||||||
from databases import ApiEnumDropdown
|
|
||||||
|
|
||||||
from databases.extensions.selector_classes import SelectActionWithEmployee, Explanation
|
from databases.extensions.selector_classes import SelectActionWithEmployee
|
||||||
from api_validations.validations_request import (
|
from api_validations.validations_request import (
|
||||||
InsertBuildParts,
|
InsertBuildParts,
|
||||||
InsertBuild,
|
InsertBuild,
|
||||||
|
|
@ -29,84 +28,84 @@ from api_validations.validations_request import (
|
||||||
)
|
)
|
||||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||||
|
|
||||||
|
#
|
||||||
class AbstractBuild:
|
# class AbstractBuild:
|
||||||
"""
|
# """
|
||||||
Abstract and explanation of Build class for end-user guide
|
# Abstract and explanation of Build class for end-user guide
|
||||||
"""
|
# """
|
||||||
|
#
|
||||||
gov_address_code = Explanation(
|
# gov_address_code = Explanation(
|
||||||
explanation="Devletin resmi adres kodudur.",
|
# explanation="Devletin resmi adres kodudur.",
|
||||||
usage="Devletin resmi adres kodu istendiğinde kullanılır.",
|
# usage="Devletin resmi adres kodu istendiğinde kullanılır.",
|
||||||
alias="Devlet Adres Kodu",
|
# alias="Devlet Adres Kodu",
|
||||||
example=["1234567890"],
|
# example=["1234567890"],
|
||||||
)
|
# )
|
||||||
build_name = Explanation(
|
# build_name = Explanation(
|
||||||
explanation="Bina adıdır.",
|
# explanation="Bina adıdır.",
|
||||||
usage="Bina adı istendiğinde kullanılır.",
|
# usage="Bina adı istendiğinde kullanılır.",
|
||||||
alias="Bina Adı",
|
# alias="Bina Adı",
|
||||||
example=["X Binası", "Y Binası"],
|
# example=["X Binası", "Y Binası"],
|
||||||
)
|
# )
|
||||||
build_no = Explanation(
|
# build_no = Explanation(
|
||||||
explanation="Bina numarasıdır.",
|
# explanation="Bina numarasıdır.",
|
||||||
usage="Bina numarası istendiğinde kullanılır.",
|
# usage="Bina numarası istendiğinde kullanılır.",
|
||||||
alias="Bina No",
|
# alias="Bina No",
|
||||||
example=["1234567890"],
|
# example=["1234567890"],
|
||||||
)
|
# )
|
||||||
build_types = Explanation(
|
# build_types = Explanation(
|
||||||
explanation="Bina türüdür.",
|
# explanation="Bina türüdür.",
|
||||||
usage="Bina türü istendiğinde kullanılır.",
|
# usage="Bina türü istendiğinde kullanılır.",
|
||||||
alias="Bina Türü",
|
# alias="Bina Türü",
|
||||||
example=["Ofis", "Konut", "Depo"],
|
# example=["Ofis", "Konut", "Depo"],
|
||||||
)
|
# )
|
||||||
max_floor = Explanation(
|
# max_floor = Explanation(
|
||||||
explanation="Bina kat sayısıdır.",
|
# explanation="Bina kat sayısıdır.",
|
||||||
usage="Bina kat sayısı istendiğinde kullanılır.",
|
# usage="Bina kat sayısı istendiğinde kullanılır.",
|
||||||
alias="Kat Sayısı",
|
# alias="Kat Sayısı",
|
||||||
example=["1", "2", "3"],
|
# example=["1", "2", "3"],
|
||||||
)
|
# )
|
||||||
underground_floor = Explanation(
|
# underground_floor = Explanation(
|
||||||
explanation="Bina bodrum kat sayısıdır.",
|
# explanation="Bina bodrum kat sayısıdır.",
|
||||||
usage="Bina bodrum kat sayısı istendiğinde kullanılır.",
|
# usage="Bina bodrum kat sayısı istendiğinde kullanılır.",
|
||||||
alias="Bodrum Kat Sayısı",
|
# alias="Bodrum Kat Sayısı",
|
||||||
example=["1", "2", "3"],
|
# example=["1", "2", "3"],
|
||||||
)
|
# )
|
||||||
build_date = Explanation(
|
# build_date = Explanation(
|
||||||
explanation="Bina yapım tarihidir.",
|
# explanation="Bina yapım tarihidir.",
|
||||||
usage="Bina yapım tarihi istendiğinde kullanılır.",
|
# usage="Bina yapım tarihi istendiğinde kullanılır.",
|
||||||
alias="Yapım Tarihi",
|
# alias="Yapım Tarihi",
|
||||||
example=["2021-01-01"],
|
# example=["2021-01-01"],
|
||||||
)
|
# )
|
||||||
tax_no = Explanation(
|
# tax_no = Explanation(
|
||||||
explanation="Bina vergi numarasıdır.",
|
# explanation="Bina vergi numarasıdır.",
|
||||||
usage="Bina vergi numarası istendiğinde kullanılır.",
|
# usage="Bina vergi numarası istendiğinde kullanılır.",
|
||||||
alias="Vergi No",
|
# alias="Vergi No",
|
||||||
example=["1234567890"],
|
# example=["1234567890"],
|
||||||
)
|
# )
|
||||||
lift_count = Explanation(
|
# lift_count = Explanation(
|
||||||
explanation="Bina asansör sayısıdır.",
|
# explanation="Bina asansör sayısıdır.",
|
||||||
usage="Bina asansör sayısı istendiğinde kullanılır.",
|
# usage="Bina asansör sayısı istendiğinde kullanılır.",
|
||||||
alias="Asansör Sayısı",
|
# alias="Asansör Sayısı",
|
||||||
example=["1", "2", "3"],
|
# example=["1", "2", "3"],
|
||||||
)
|
# )
|
||||||
heating_system = Explanation(
|
# heating_system = Explanation(
|
||||||
explanation="Bina ısıtma sistemi var mı?",
|
# explanation="Bina ısıtma sistemi var mı?",
|
||||||
usage="Bina ısıtma sistemi var mı istendiğinde kullanılır.",
|
# usage="Bina ısıtma sistemi var mı istendiğinde kullanılır.",
|
||||||
alias="Isıtma Sistemi",
|
# alias="Isıtma Sistemi",
|
||||||
example=[True, False],
|
# example=[True, False],
|
||||||
)
|
# )
|
||||||
cooling_system = Explanation(
|
# cooling_system = Explanation(
|
||||||
explanation="Bina soğutma sistemi var mı?",
|
# explanation="Bina soğutma sistemi var mı?",
|
||||||
usage="Bina soğutma sistemi var mı istendiğinde kullanılır.",
|
# usage="Bina soğutma sistemi var mı istendiğinde kullanılır.",
|
||||||
alias="Soğutma Sistemi",
|
# alias="Soğutma Sistemi",
|
||||||
example=[True, False],
|
# example=[True, False],
|
||||||
)
|
# )
|
||||||
hot_water_system = Explanation(
|
# hot_water_system = Explanation(
|
||||||
explanation="Bina sıcak su sistemi var mı?",
|
# explanation="Bina sıcak su sistemi var mı?",
|
||||||
usage="Bina sıcak su sistemi var mı istendiğinde kullanılır.",
|
# usage="Bina sıcak su sistemi var mı istendiğinde kullanılır.",
|
||||||
alias="Sıcak Su Sistemi",
|
# alias="Sıcak Su Sistemi",
|
||||||
example=[True, False],
|
# example=[True, False],
|
||||||
)
|
# )
|
||||||
|
|
||||||
|
|
||||||
class BuildTypes(CrudCollection):
|
class BuildTypes(CrudCollection):
|
||||||
|
|
@ -210,7 +209,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||||
__include__fields__ = []
|
__include__fields__ = []
|
||||||
__access_by__ = []
|
__access_by__ = []
|
||||||
__many__table__ = RelationshipEmployee2Build
|
__many__table__ = RelationshipEmployee2Build
|
||||||
__explain__ = AbstractBuild()
|
# __explain__ = AbstractBuild()
|
||||||
|
|
||||||
gov_address_code: Mapped[str] = mapped_column(
|
gov_address_code: Mapped[str] = mapped_column(
|
||||||
String, server_default="", unique=True
|
String, server_default="", unique=True
|
||||||
|
|
@ -478,6 +477,7 @@ class BuildParts(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_action(cls, data: InsertBuildParts, token):
|
def create_action(cls, data: InsertBuildParts, token):
|
||||||
|
from databases import ApiEnumDropdown
|
||||||
data_dict = data.dump()
|
data_dict = data.dump()
|
||||||
build_from_duty = Build.select_action(
|
build_from_duty = Build.select_action(
|
||||||
employee_id=token.selected_company.employee_id,
|
employee_id=token.selected_company.employee_id,
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,6 @@ from decimal import Decimal
|
||||||
from typing import List
|
from typing import List
|
||||||
from fastapi import HTTPException, status
|
from fastapi import HTTPException, status
|
||||||
|
|
||||||
from databases.sql_models.core_mixin import CrudCollection
|
|
||||||
from databases import (
|
|
||||||
Build,
|
|
||||||
BuildLivingSpace,
|
|
||||||
BuildIbans,
|
|
||||||
People,
|
|
||||||
Companies,
|
|
||||||
OccupantTypes,
|
|
||||||
Services,
|
|
||||||
)
|
|
||||||
from api_library.date_time_actions.date_functions import system_arrow, client_arrow
|
from api_library.date_time_actions.date_functions import system_arrow, client_arrow
|
||||||
|
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
|
|
@ -35,6 +25,8 @@ from api_validations.validations_request import (
|
||||||
InsertBuildDecisionBookItemDebits,
|
InsertBuildDecisionBookItemDebits,
|
||||||
InsertBuildDecisionBookProjects,
|
InsertBuildDecisionBookProjects,
|
||||||
)
|
)
|
||||||
|
from databases.sql_models.core_mixin import CrudCollection
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BuildDecisionBook(CrudCollection):
|
class BuildDecisionBook(CrudCollection):
|
||||||
|
|
@ -104,6 +96,9 @@ class BuildDecisionBook(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def retrieve_active_rbm(cls):
|
def retrieve_active_rbm(cls):
|
||||||
|
from databases import (
|
||||||
|
Build,
|
||||||
|
)
|
||||||
related_build = Build.find_one(id=cls.build_id)
|
related_build = Build.find_one(id=cls.build_id)
|
||||||
related_date = system_arrow.get(related_build.build_date)
|
related_date = system_arrow.get(related_build.build_date)
|
||||||
date_processed = related_date.replace(
|
date_processed = related_date.replace(
|
||||||
|
|
@ -131,7 +126,10 @@ class BuildDecisionBook(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def select_action(cls, duty_id, token=None):
|
def select_action(cls, duty_id, token=None):
|
||||||
|
from databases import (
|
||||||
|
Build,
|
||||||
|
Companies,
|
||||||
|
)
|
||||||
related_companies = Companies.select_action(duty_id_list=[int(duty_id)])
|
related_companies = Companies.select_action(duty_id_list=[int(duty_id)])
|
||||||
related_companies_ids = list(
|
related_companies_ids = list(
|
||||||
related_.id for related_ in related_companies.all()
|
related_.id for related_ in related_companies.all()
|
||||||
|
|
@ -145,7 +143,10 @@ class BuildDecisionBook(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_action(cls, data: InsertDecisionBook, token=None):
|
def create_action(cls, data: InsertDecisionBook, token=None):
|
||||||
|
from databases import (
|
||||||
|
Build,
|
||||||
|
Companies,
|
||||||
|
)
|
||||||
data_dict = data.model_dump()
|
data_dict = data.model_dump()
|
||||||
if building := Build.find_one(uu_id=data.build_uu_id):
|
if building := Build.find_one(uu_id=data.build_uu_id):
|
||||||
data_dict["build_id"] = building.id
|
data_dict["build_id"] = building.id
|
||||||
|
|
@ -213,6 +214,9 @@ class BuildDecisionBook(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def retrieve_valid_book(cls, bank_date, iban):
|
def retrieve_valid_book(cls, bank_date, iban):
|
||||||
|
from databases import (
|
||||||
|
BuildIbans,
|
||||||
|
)
|
||||||
if all(
|
if all(
|
||||||
[True if letter in str(bank_date) else False for letter in ["-", " ", ":"]]
|
[True if letter in str(bank_date) else False for letter in ["-", " ", ":"]]
|
||||||
):
|
):
|
||||||
|
|
@ -401,6 +405,11 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||||
return BuildDecisionBookPersonOccupants.filter_active(filter_records=False)
|
return BuildDecisionBookPersonOccupants.filter_active(filter_records=False)
|
||||||
|
|
||||||
def add_occupant_type(self, occupant_type, build_living_space_id: int = None):
|
def add_occupant_type(self, occupant_type, build_living_space_id: int = None):
|
||||||
|
from databases import (
|
||||||
|
Build,
|
||||||
|
BuildLivingSpace,
|
||||||
|
Services,
|
||||||
|
)
|
||||||
from api_events.events.events.events_bind_services import (
|
from api_events.events.events.events_bind_services import (
|
||||||
ServiceBindOccupantEventMethods,
|
ServiceBindOccupantEventMethods,
|
||||||
)
|
)
|
||||||
|
|
@ -593,7 +602,10 @@ class BuildDecisionBookItems(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def select_action(cls, duty_id, token=None):
|
def select_action(cls, duty_id, token=None):
|
||||||
|
from databases import (
|
||||||
|
Build,
|
||||||
|
Companies,
|
||||||
|
)
|
||||||
related_companies = Companies.select_action(duty_id=duty_id)
|
related_companies = Companies.select_action(duty_id=duty_id)
|
||||||
related_companies_ids = list(
|
related_companies_ids = list(
|
||||||
related_.id for related_ in related_companies.all()
|
related_.id for related_ in related_companies.all()
|
||||||
|
|
@ -635,7 +647,10 @@ class BuildDecisionBookItems(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_meeting_is_valid_to_start_add_attendance(cls, decision_book, token_dict):
|
def check_meeting_is_valid_to_start_add_attendance(cls, decision_book, token_dict):
|
||||||
|
from databases import (
|
||||||
|
People,
|
||||||
|
OccupantTypes,
|
||||||
|
)
|
||||||
active_invite = (
|
active_invite = (
|
||||||
BuildDecisionBookInvitations.check_invites_are_ready_for_meeting(
|
BuildDecisionBookInvitations.check_invites_are_ready_for_meeting(
|
||||||
selected_decision_book=decision_book,
|
selected_decision_book=decision_book,
|
||||||
|
|
@ -1040,7 +1055,10 @@ class BuildDecisionBookProjects(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def select_action(cls, duty_id, token=None):
|
def select_action(cls, duty_id, token=None):
|
||||||
|
from databases import (
|
||||||
|
Build,
|
||||||
|
Companies,
|
||||||
|
)
|
||||||
related_companies = Companies.select_action(duty_id_list=[duty_id])
|
related_companies = Companies.select_action(duty_id_list=[duty_id])
|
||||||
related_companies_ids = list(
|
related_companies_ids = list(
|
||||||
related_.id for related_ in related_companies.all()
|
related_.id for related_ in related_companies.all()
|
||||||
|
|
@ -1073,11 +1091,15 @@ class BuildDecisionBookProjects(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_action(cls, data: InsertBuildDecisionBookProjects, token=None):
|
def create_action(cls, data: InsertBuildDecisionBookProjects, token=None):
|
||||||
|
from databases import (
|
||||||
|
People,
|
||||||
|
Companies,
|
||||||
|
)
|
||||||
data_dict = data.dump()
|
data_dict = data.dump()
|
||||||
BuildDecisionBookItems.pre_query = BuildDecisionBookItems.select_action(
|
BuildDecisionBookItems.pre_query = BuildDecisionBookItems.select_action(
|
||||||
duty_id=token.duty_list["duty_id"]
|
duty_id=token.duty_list["duty_id"]
|
||||||
)
|
)
|
||||||
People.pre_query = People.select_action(duty_id=token.duty_list["duty_id"])
|
People.pre_query = People.select_action(duty_id_list=[token.duty_list["duty_id"]])
|
||||||
decision_book_project_item = BuildDecisionBookItems.find_one_or_abort(
|
decision_book_project_item = BuildDecisionBookItems.find_one_or_abort(
|
||||||
uu_id=data_dict.get("build_decision_book_item_uu_id")
|
uu_id=data_dict.get("build_decision_book_item_uu_id")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
from fastapi.exceptions import HTTPException
|
from fastapi.exceptions import HTTPException
|
||||||
|
|
||||||
from databases import (
|
|
||||||
Addresses,
|
|
||||||
Duties,
|
|
||||||
)
|
|
||||||
from databases.sql_models.core_mixin import CrudCollection
|
from databases.sql_models.core_mixin import CrudCollection
|
||||||
|
|
||||||
from sqlalchemy import String, Integer, Boolean, ForeignKey, Index, Identity
|
from sqlalchemy import String, Integer, Boolean, ForeignKey, Index, Identity
|
||||||
from sqlalchemy.orm import mapped_column, Mapped
|
from sqlalchemy.orm import mapped_column, Mapped
|
||||||
|
|
||||||
from api_configs import RelationAccess
|
from api_configs import RelationAccess
|
||||||
from databases.extensions import SelectAction, Explanation
|
from databases.extensions import SelectAction
|
||||||
from api_validations.validations_request import (
|
from api_validations.validations_request import (
|
||||||
InsertCompany,
|
InsertCompany,
|
||||||
UpdateCompany,
|
UpdateCompany,
|
||||||
|
|
@ -64,7 +60,9 @@ class RelationshipDutyCompany(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def match_company_to_company_commercial(cls, data: MatchCompany2Company, token):
|
def match_company_to_company_commercial(cls, data: MatchCompany2Company, token):
|
||||||
|
from databases import (
|
||||||
|
Duties,
|
||||||
|
)
|
||||||
token_duties_id, token_company_id = token.get("duty_id"), token.get(
|
token_duties_id, token_company_id = token.get("duty_id"), token.get(
|
||||||
"company_id"
|
"company_id"
|
||||||
)
|
)
|
||||||
|
|
@ -103,7 +101,9 @@ class RelationshipDutyCompany(CrudCollection):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def match_company_to_company_organization(cls, data: MatchCompany2Company, token):
|
def match_company_to_company_organization(cls, data: MatchCompany2Company, token):
|
||||||
|
from databases import (
|
||||||
|
Duties,
|
||||||
|
)
|
||||||
token_duties_id, token_company_id = token.get("duty_id"), token.get(
|
token_duties_id, token_company_id = token.get("duty_id"), token.get(
|
||||||
"company_id"
|
"company_id"
|
||||||
)
|
)
|
||||||
|
|
@ -157,152 +157,6 @@ class RelationshipDutyCompany(CrudCollection):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AbstractCompany:
|
|
||||||
"""
|
|
||||||
Abstract and explanation of Company class for end-user guide
|
|
||||||
"""
|
|
||||||
|
|
||||||
formal_name = Explanation(
|
|
||||||
explanation="Devletin resmi kayıtlarında bulunan şirket ünvanıdır.",
|
|
||||||
usage="Devletin resmi kayıtlarında bulunan şirket adı istendiğinde kullanılır.",
|
|
||||||
alias="Resmi Ünvan",
|
|
||||||
example=["X Şirketi LTD", "Y Şirketi A.Ş."],
|
|
||||||
)
|
|
||||||
company_type = Explanation(
|
|
||||||
explanation="Şirketin türüdür.",
|
|
||||||
usage="Şirketin türü istendiğinde kullanılır.",
|
|
||||||
alias="Şirket Türü",
|
|
||||||
example=[
|
|
||||||
"Şahıs",
|
|
||||||
"Limited",
|
|
||||||
"Anonim",
|
|
||||||
"Kolektif",
|
|
||||||
"Komandit",
|
|
||||||
"Kooperatif",
|
|
||||||
"Serbest Meslek",
|
|
||||||
"Adi Ortaklık",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
commercial_type = Explanation(
|
|
||||||
explanation="Şirketin ticari türüdür.",
|
|
||||||
usage="Şirketin ticari türü istendiğinde kullanılır.",
|
|
||||||
alias="Ticari Tür",
|
|
||||||
example=["Tüzel", "Birey"],
|
|
||||||
)
|
|
||||||
tax_no = Explanation(
|
|
||||||
explanation="Şirketin vergi numarasıdır.",
|
|
||||||
usage="Şirketin vergi numarası istendiğinde kullanılır.",
|
|
||||||
alias="Vergi No",
|
|
||||||
example=["1234567890"],
|
|
||||||
)
|
|
||||||
public_name = Explanation(
|
|
||||||
explanation="Şirketin kamuoyunda bilinen adıdır.",
|
|
||||||
usage="Şirketin kamuoyunda bilinen adı istendiğinde kullanılır.",
|
|
||||||
alias="Piyasada Bilinen Adı",
|
|
||||||
example=["X Şirketi", "Y Şirketi"],
|
|
||||||
)
|
|
||||||
company_tag = Explanation(
|
|
||||||
explanation="Şirketin takma adı veya etiketidir.",
|
|
||||||
usage="Şirketin yöneticisin karar verdiği takma adı veya etiketi istendiğinde kullanılır.",
|
|
||||||
alias="Şirket Etiketi veya Takma Adı",
|
|
||||||
example=["X", "Y"],
|
|
||||||
)
|
|
||||||
default_lang_type = Explanation(
|
|
||||||
explanation="Şirketin varsayılan dil türüdür.",
|
|
||||||
usage="Şirketin varsayılan dil türü istendiğinde kullanılır.",
|
|
||||||
alias="Şirketin Dil Türü",
|
|
||||||
example=["TR", "EN"],
|
|
||||||
)
|
|
||||||
default_money_type = Explanation(
|
|
||||||
explanation="Şirketin varsayılan para birimi türüdür.",
|
|
||||||
usage="Şirketin varsayılan para birimi türü istendiğinde kullanılır.",
|
|
||||||
alias="Şirketin Para Birimi Türü",
|
|
||||||
example=["TL", "USD", "EUR"],
|
|
||||||
)
|
|
||||||
is_commercial = Explanation(
|
|
||||||
explanation="Şirketin ticari olup olmadığını belirtir.",
|
|
||||||
usage="Şirketin ticari olup olmadığını applikasyonun anlaması için kullanılır.",
|
|
||||||
condition=lambda commercial_type: True if commercial_type == "Şahıs" else False,
|
|
||||||
alias="Şirket Ticari mi?",
|
|
||||||
)
|
|
||||||
is_blacklist = Explanation(
|
|
||||||
explanation="Şirketin kara listeye alınıp alınmadığını belirtir.",
|
|
||||||
usage="Şirketin kara listeye alınıp alınmadığını applikasyonun anlaması için kullanılır.",
|
|
||||||
alias="Kara Listeye alınsın mı?",
|
|
||||||
example=[True, False],
|
|
||||||
)
|
|
||||||
parent_id = Explanation(
|
|
||||||
explanation="Şirketin sorumlu olduğu şirketin ID'sidir.",
|
|
||||||
usage="Şirketin sorumlu olduğu şirketin ID'si istendiğinde kullanılır.",
|
|
||||||
alias="Sorumlu Şirket",
|
|
||||||
example=[
|
|
||||||
"Bir şirketin sorumlu şirketi hangisi olduğunu bulmak için kullanılır.",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
workplace_no = Explanation(
|
|
||||||
explanation="Şirketin iş yeri numarasıdır.",
|
|
||||||
usage="Şirketin iş yeri numarası istendiğinde kullanılır.",
|
|
||||||
alias="İş Yeri No",
|
|
||||||
example=["1234567890"],
|
|
||||||
)
|
|
||||||
official_address_id = Explanation(
|
|
||||||
explanation="Şirketin resmi adresidi.",
|
|
||||||
usage="Şirketin resmi adresinin ne olduğunu bulmak için kullanılır.",
|
|
||||||
alias="Resmi Adres",
|
|
||||||
example=[
|
|
||||||
"Bu şirketin adresi nedir sorusuna cevap vermek için kullanılır.",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
top_responsible_company_id = Explanation(
|
|
||||||
explanation="Şirketin en üst sorumlu şirketin ID'sidir.",
|
|
||||||
usage="Şirketin en üst sorumlu şirketin hangisi olduğunu bulmak için kullanılır.",
|
|
||||||
alias="Ana Yetkili Şirket",
|
|
||||||
example=[
|
|
||||||
"Bölge veya ülke genelinde en üst sorumlu şirketin hangisi olduğunu belirtmek için kullanılır.",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
buildings = Explanation(
|
|
||||||
explanation="Şirketin sahip olduğu binaların listesidir.",
|
|
||||||
usage="Şirketin sahip olduğu binaların listesini bulmak için kullanılır.",
|
|
||||||
alias="Sorumlu olduğu binalar Binalar",
|
|
||||||
example=[
|
|
||||||
"Şirketin sahip olduğu binaların listesini bulmak için kullanılır.",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
def wag_create_company(self):
|
|
||||||
"""
|
|
||||||
Er kişiye wag_create_company fonksiyonu = fieldları manipule edebilir?
|
|
||||||
78 ile oluşturulan bir user için wag_create_company fonksiyonu = fieldları manipule edebilir?
|
|
||||||
"""
|
|
||||||
return {
|
|
||||||
"commercial_type": self.commercial_type,
|
|
||||||
"formal_name": self.formal_name,
|
|
||||||
"public_name": self.public_name,
|
|
||||||
"company_type": self.company_type,
|
|
||||||
"tax_no": self.tax_no,
|
|
||||||
"workplace_no": self.workplace_no,
|
|
||||||
"company_tag": self.company_tag,
|
|
||||||
"default_lang_type": self.default_lang_type,
|
|
||||||
"default_money_type": self.default_money_type,
|
|
||||||
"official_address_id": self.official_address_id,
|
|
||||||
}
|
|
||||||
|
|
||||||
def wag_update_company(self):
|
|
||||||
return {
|
|
||||||
"commercial_type": self.commercial_type,
|
|
||||||
"formal_name": self.formal_name,
|
|
||||||
"public_name": self.public_name,
|
|
||||||
"company_type": self.company_type,
|
|
||||||
"tax_no": self.tax_no,
|
|
||||||
"workplace_no": self.workplace_no,
|
|
||||||
"company_tag": self.company_tag,
|
|
||||||
"default_lang_type": self.default_lang_type,
|
|
||||||
"default_money_type": self.default_money_type,
|
|
||||||
"official_address_id": self.official_address_id,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Companies(CrudCollection, SelectAction):
|
class Companies(CrudCollection, SelectAction):
|
||||||
"""
|
"""
|
||||||
Company class based on declarative_base and CrudCollection via session
|
Company class based on declarative_base and CrudCollection via session
|
||||||
|
|
@ -316,7 +170,7 @@ class Companies(CrudCollection, SelectAction):
|
||||||
__exclude__fields__ = ["is_blacklist", "is_commercial"]
|
__exclude__fields__ = ["is_blacklist", "is_commercial"]
|
||||||
__access_by__ = []
|
__access_by__ = []
|
||||||
__many__table__ = RelationshipDutyCompany
|
__many__table__ = RelationshipDutyCompany
|
||||||
__explain__ = AbstractCompany()
|
# __explain__ = AbstractCompany()
|
||||||
|
|
||||||
formal_name: Mapped[str] = mapped_column(
|
formal_name: Mapped[str] = mapped_column(
|
||||||
String, nullable=False, comment="Formal Name"
|
String, nullable=False, comment="Formal Name"
|
||||||
|
|
@ -423,6 +277,9 @@ class Companies(CrudCollection, SelectAction):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_action(cls, data: UpdateCompany, token):
|
def update_action(cls, data: UpdateCompany, token):
|
||||||
|
from databases import (
|
||||||
|
Addresses,
|
||||||
|
)
|
||||||
data_dict = data.excluded_dump()
|
data_dict = data.excluded_dump()
|
||||||
duty_id = token.get("duty_id")
|
duty_id = token.get("duty_id")
|
||||||
company_id = token.get("company_id")
|
company_id = token.get("company_id")
|
||||||
|
|
@ -554,3 +411,151 @@ class Companies(CrudCollection, SelectAction):
|
||||||
# back_populates="related_company",
|
# back_populates="related_company",
|
||||||
# foreign_keys="CompanyRelationship.related_company_id",
|
# foreign_keys="CompanyRelationship.related_company_id",
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# class AbstractCompany:
|
||||||
|
# """
|
||||||
|
# Abstract and explanation of Company class for end-user guide
|
||||||
|
# """
|
||||||
|
#
|
||||||
|
# formal_name = Explanation(
|
||||||
|
# explanation="Devletin resmi kayıtlarında bulunan şirket ünvanıdır.",
|
||||||
|
# usage="Devletin resmi kayıtlarında bulunan şirket adı istendiğinde kullanılır.",
|
||||||
|
# alias="Resmi Ünvan",
|
||||||
|
# example=["X Şirketi LTD", "Y Şirketi A.Ş."],
|
||||||
|
# )
|
||||||
|
# company_type = Explanation(
|
||||||
|
# explanation="Şirketin türüdür.",
|
||||||
|
# usage="Şirketin türü istendiğinde kullanılır.",
|
||||||
|
# alias="Şirket Türü",
|
||||||
|
# example=[
|
||||||
|
# "Şahıs",
|
||||||
|
# "Limited",
|
||||||
|
# "Anonim",
|
||||||
|
# "Kolektif",
|
||||||
|
# "Komandit",
|
||||||
|
# "Kooperatif",
|
||||||
|
# "Serbest Meslek",
|
||||||
|
# "Adi Ortaklık",
|
||||||
|
# ],
|
||||||
|
# )
|
||||||
|
# commercial_type = Explanation(
|
||||||
|
# explanation="Şirketin ticari türüdür.",
|
||||||
|
# usage="Şirketin ticari türü istendiğinde kullanılır.",
|
||||||
|
# alias="Ticari Tür",
|
||||||
|
# example=["Tüzel", "Birey"],
|
||||||
|
# )
|
||||||
|
# tax_no = Explanation(
|
||||||
|
# explanation="Şirketin vergi numarasıdır.",
|
||||||
|
# usage="Şirketin vergi numarası istendiğinde kullanılır.",
|
||||||
|
# alias="Vergi No",
|
||||||
|
# example=["1234567890"],
|
||||||
|
# )
|
||||||
|
# public_name = Explanation(
|
||||||
|
# explanation="Şirketin kamuoyunda bilinen adıdır.",
|
||||||
|
# usage="Şirketin kamuoyunda bilinen adı istendiğinde kullanılır.",
|
||||||
|
# alias="Piyasada Bilinen Adı",
|
||||||
|
# example=["X Şirketi", "Y Şirketi"],
|
||||||
|
# )
|
||||||
|
# company_tag = Explanation(
|
||||||
|
# explanation="Şirketin takma adı veya etiketidir.",
|
||||||
|
# usage="Şirketin yöneticisin karar verdiği takma adı veya etiketi istendiğinde kullanılır.",
|
||||||
|
# alias="Şirket Etiketi veya Takma Adı",
|
||||||
|
# example=["X", "Y"],
|
||||||
|
# )
|
||||||
|
# default_lang_type = Explanation(
|
||||||
|
# explanation="Şirketin varsayılan dil türüdür.",
|
||||||
|
# usage="Şirketin varsayılan dil türü istendiğinde kullanılır.",
|
||||||
|
# alias="Şirketin Dil Türü",
|
||||||
|
# example=["TR", "EN"],
|
||||||
|
# )
|
||||||
|
# default_money_type = Explanation(
|
||||||
|
# explanation="Şirketin varsayılan para birimi türüdür.",
|
||||||
|
# usage="Şirketin varsayılan para birimi türü istendiğinde kullanılır.",
|
||||||
|
# alias="Şirketin Para Birimi Türü",
|
||||||
|
# example=["TL", "USD", "EUR"],
|
||||||
|
# )
|
||||||
|
# is_commercial = Explanation(
|
||||||
|
# explanation="Şirketin ticari olup olmadığını belirtir.",
|
||||||
|
# usage="Şirketin ticari olup olmadığını applikasyonun anlaması için kullanılır.",
|
||||||
|
# condition=lambda commercial_type: True if commercial_type == "Şahıs" else False,
|
||||||
|
# alias="Şirket Ticari mi?",
|
||||||
|
# )
|
||||||
|
# is_blacklist = Explanation(
|
||||||
|
# explanation="Şirketin kara listeye alınıp alınmadığını belirtir.",
|
||||||
|
# usage="Şirketin kara listeye alınıp alınmadığını applikasyonun anlaması için kullanılır.",
|
||||||
|
# alias="Kara Listeye alınsın mı?",
|
||||||
|
# example=[True, False],
|
||||||
|
# )
|
||||||
|
# parent_id = Explanation(
|
||||||
|
# explanation="Şirketin sorumlu olduğu şirketin ID'sidir.",
|
||||||
|
# usage="Şirketin sorumlu olduğu şirketin ID'si istendiğinde kullanılır.",
|
||||||
|
# alias="Sorumlu Şirket",
|
||||||
|
# example=[
|
||||||
|
# "Bir şirketin sorumlu şirketi hangisi olduğunu bulmak için kullanılır.",
|
||||||
|
# ],
|
||||||
|
# )
|
||||||
|
# workplace_no = Explanation(
|
||||||
|
# explanation="Şirketin iş yeri numarasıdır.",
|
||||||
|
# usage="Şirketin iş yeri numarası istendiğinde kullanılır.",
|
||||||
|
# alias="İş Yeri No",
|
||||||
|
# example=["1234567890"],
|
||||||
|
# )
|
||||||
|
# official_address_id = Explanation(
|
||||||
|
# explanation="Şirketin resmi adresidi.",
|
||||||
|
# usage="Şirketin resmi adresinin ne olduğunu bulmak için kullanılır.",
|
||||||
|
# alias="Resmi Adres",
|
||||||
|
# example=[
|
||||||
|
# "Bu şirketin adresi nedir sorusuna cevap vermek için kullanılır.",
|
||||||
|
# ],
|
||||||
|
# )
|
||||||
|
# top_responsible_company_id = Explanation(
|
||||||
|
# explanation="Şirketin en üst sorumlu şirketin ID'sidir.",
|
||||||
|
# usage="Şirketin en üst sorumlu şirketin hangisi olduğunu bulmak için kullanılır.",
|
||||||
|
# alias="Ana Yetkili Şirket",
|
||||||
|
# example=[
|
||||||
|
# "Bölge veya ülke genelinde en üst sorumlu şirketin hangisi olduğunu belirtmek için kullanılır.",
|
||||||
|
# ],
|
||||||
|
# )
|
||||||
|
# buildings = Explanation(
|
||||||
|
# explanation="Şirketin sahip olduğu binaların listesidir.",
|
||||||
|
# usage="Şirketin sahip olduğu binaların listesini bulmak için kullanılır.",
|
||||||
|
# alias="Sorumlu olduğu binalar Binalar",
|
||||||
|
# example=[
|
||||||
|
# "Şirketin sahip olduğu binaların listesini bulmak için kullanılır.",
|
||||||
|
# ],
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# def wag_create_company(self):
|
||||||
|
# """
|
||||||
|
# Er kişiye wag_create_company fonksiyonu = fieldları manipule edebilir?
|
||||||
|
# 78 ile oluşturulan bir user için wag_create_company fonksiyonu = fieldları manipule edebilir?
|
||||||
|
# """
|
||||||
|
# return {
|
||||||
|
# "commercial_type": self.commercial_type,
|
||||||
|
# "formal_name": self.formal_name,
|
||||||
|
# "public_name": self.public_name,
|
||||||
|
# "company_type": self.company_type,
|
||||||
|
# "tax_no": self.tax_no,
|
||||||
|
# "workplace_no": self.workplace_no,
|
||||||
|
# "company_tag": self.company_tag,
|
||||||
|
# "default_lang_type": self.default_lang_type,
|
||||||
|
# "default_money_type": self.default_money_type,
|
||||||
|
# "official_address_id": self.official_address_id,
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# def wag_update_company(self):
|
||||||
|
# return {
|
||||||
|
# "commercial_type": self.commercial_type,
|
||||||
|
# "formal_name": self.formal_name,
|
||||||
|
# "public_name": self.public_name,
|
||||||
|
# "company_type": self.company_type,
|
||||||
|
# "tax_no": self.tax_no,
|
||||||
|
# "workplace_no": self.workplace_no,
|
||||||
|
# "company_tag": self.company_tag,
|
||||||
|
# "default_lang_type": self.default_lang_type,
|
||||||
|
# "default_money_type": self.default_money_type,
|
||||||
|
# "official_address_id": self.official_address_id,
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ class EmployeesSalaries(CrudCollection):
|
||||||
# )
|
# )
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
Index("_employee_salaries_ndx_00", people_id, CrudCollection.expiry_starts),
|
Index("_employee_salaries_ndx_00", people_id, "expiry_starts"),
|
||||||
{"comment": "Employee Salaries Information"},
|
{"comment": "Employee Salaries Information"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -321,11 +321,11 @@ class CrudCollection(BaseMixin, SmartQueryMixin):
|
||||||
__repr__ = ReprMixin.__repr__
|
__repr__ = ReprMixin.__repr__
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
uu_id: Mapped[UUID] = mapped_column(
|
uu_id: Mapped[str] = mapped_column(
|
||||||
UUID, server_default=text("gen_random_uuid()"), index=True, unique=True
|
UUID, server_default=text("gen_random_uuid()"), index=True, unique=True
|
||||||
)
|
)
|
||||||
|
|
||||||
ref_id: Mapped[UUID] = mapped_column(String(100), nullable=True, index=True)
|
ref_id: Mapped[str] = mapped_column(String(100), nullable=True, index=True)
|
||||||
created_at: Mapped[TIMESTAMP] = mapped_column(
|
created_at: Mapped[TIMESTAMP] = mapped_column(
|
||||||
"created_at",
|
"created_at",
|
||||||
TIMESTAMP(timezone=True),
|
TIMESTAMP(timezone=True),
|
||||||
|
|
@ -342,7 +342,7 @@ class CrudCollection(BaseMixin, SmartQueryMixin):
|
||||||
nullable=False,
|
nullable=False,
|
||||||
index=True,
|
index=True,
|
||||||
)
|
)
|
||||||
cryp_uu_id: Mapped[UUID] = mapped_column(String, nullable=True, index=True)
|
cryp_uu_id: Mapped[str] = mapped_column(String, nullable=True, index=True)
|
||||||
|
|
||||||
created_by: Mapped[str] = mapped_column(String, nullable=True)
|
created_by: Mapped[str] = mapped_column(String, nullable=True)
|
||||||
created_by_id: Mapped[int] = mapped_column(Integer, nullable=True)
|
created_by_id: Mapped[int] = mapped_column(Integer, nullable=True)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ from fastapi import HTTPException
|
||||||
|
|
||||||
from databases.sql_models.core_mixin import CrudCollection
|
from databases.sql_models.core_mixin import CrudCollection
|
||||||
from databases.extensions import SelectAction, SelectActionWithEmployee
|
from databases.extensions import SelectAction, SelectActionWithEmployee
|
||||||
from databases import Employees, Duties
|
from databases.extensions.auth import UserLoginModule
|
||||||
|
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
String,
|
String,
|
||||||
|
|
@ -24,7 +24,6 @@ from sqlalchemy import (
|
||||||
from sqlalchemy.orm import mapped_column, relationship, Mapped
|
from sqlalchemy.orm import mapped_column, relationship, Mapped
|
||||||
|
|
||||||
from api_validations.validations_request import InsertUsers, InsertPerson
|
from api_validations.validations_request import InsertUsers, InsertPerson
|
||||||
from databases.extensions.auth import UserLoginModule
|
|
||||||
|
|
||||||
|
|
||||||
class UsersTokens(CrudCollection):
|
class UsersTokens(CrudCollection):
|
||||||
|
|
@ -219,7 +218,7 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
|
||||||
# }
|
# }
|
||||||
|
|
||||||
def get_employee_and_duty_details(self):
|
def get_employee_and_duty_details(self):
|
||||||
|
from databases import Employees, Duties
|
||||||
found_person = People.find_one(id=self.person_id)
|
found_person = People.find_one(id=self.person_id)
|
||||||
found_employees = Employees.filter_by_active(
|
found_employees = Employees.filter_by_active(
|
||||||
people_id=found_person.id, is_confirmed=True
|
people_id=found_person.id, is_confirmed=True
|
||||||
|
|
@ -381,6 +380,7 @@ class People(CrudCollection, SelectAction):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_action(cls, data: InsertPerson, token):
|
def create_action(cls, data: InsertPerson, token):
|
||||||
|
from databases import Employees, Duties
|
||||||
token_duties_id, token_company_id = (
|
token_duties_id, token_company_id = (
|
||||||
token.selected_company.duty_id,
|
token.selected_company.duty_id,
|
||||||
token.selected_company.company_id,
|
token.selected_company.company_id,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class ApiEnumDropdown(BaseCollection):
|
||||||
__exclude__fields__ = ["enum_class"]
|
__exclude__fields__ = ["enum_class"]
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
uu_id: Mapped[UUID] = mapped_column(
|
uu_id: Mapped[str] = mapped_column(
|
||||||
UUID, server_default=text("gen_random_uuid()"), index=True, unique=True
|
UUID, server_default=text("gen_random_uuid()"), index=True, unique=True
|
||||||
)
|
)
|
||||||
enum_class: Mapped[str] = mapped_column(
|
enum_class: Mapped[str] = mapped_column(
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ COPY ../api_objects ./service_app/api_objects
|
||||||
COPY ../api_configs ./service_app/api_configs
|
COPY ../api_configs ./service_app/api_configs
|
||||||
COPY ../api_events ./service_app/api_events
|
COPY ../api_events ./service_app/api_events
|
||||||
COPY ../api_library ./service_app/api_library
|
COPY ../api_library ./service_app/api_library
|
||||||
COPY ../api_validations ./service_app_init/api_validations
|
COPY ../api_validations ./service_app/api_validations
|
||||||
|
|
||||||
WORKDIR /service_app
|
WORKDIR /service_app
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,14 @@ from fastapi.exceptions import HTTPException
|
||||||
|
|
||||||
from middlewares.token_middleware import AuthHeaderMiddleware
|
from middlewares.token_middleware import AuthHeaderMiddleware
|
||||||
from application.create_file import create_app
|
from application.create_file import create_app
|
||||||
|
from application.app_runner_init import create_endpoints_from_api_functions
|
||||||
from handlers_exception import (
|
from handlers_exception import (
|
||||||
exception_handler_http,
|
exception_handler_http,
|
||||||
exception_handler_exception,
|
exception_handler_exception,
|
||||||
)
|
)
|
||||||
from prometheus_fastapi_instrumentator import Instrumentator
|
from prometheus_fastapi_instrumentator import Instrumentator
|
||||||
|
|
||||||
# from prometheus_client import Counter, Histogram
|
# from prometheus_client import Counter, Histogram
|
||||||
|
|
||||||
from .app_runner_init import create_endpoints_from_api_functions
|
|
||||||
|
|
||||||
app = create_app()
|
app = create_app()
|
||||||
Instrumentator().instrument(app=app).expose(app=app)
|
Instrumentator().instrument(app=app).expose(app=app)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue