alchemy updated
This commit is contained in:
@@ -28,85 +28,6 @@ from api_validations.validations_request import (
|
||||
)
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
#
|
||||
# class AbstractBuild:
|
||||
# """
|
||||
# Abstract and explanation of Build class for end-user guide
|
||||
# """
|
||||
#
|
||||
# gov_address_code = Explanation(
|
||||
# explanation="Devletin resmi adres kodudur.",
|
||||
# usage="Devletin resmi adres kodu istendiğinde kullanılır.",
|
||||
# alias="Devlet Adres Kodu",
|
||||
# example=["1234567890"],
|
||||
# )
|
||||
# build_name = Explanation(
|
||||
# explanation="Bina adıdır.",
|
||||
# usage="Bina adı istendiğinde kullanılır.",
|
||||
# alias="Bina Adı",
|
||||
# example=["X Binası", "Y Binası"],
|
||||
# )
|
||||
# build_no = Explanation(
|
||||
# explanation="Bina numarasıdır.",
|
||||
# usage="Bina numarası istendiğinde kullanılır.",
|
||||
# alias="Bina No",
|
||||
# example=["1234567890"],
|
||||
# )
|
||||
# build_types = Explanation(
|
||||
# explanation="Bina türüdür.",
|
||||
# usage="Bina türü istendiğinde kullanılır.",
|
||||
# alias="Bina Türü",
|
||||
# example=["Ofis", "Konut", "Depo"],
|
||||
# )
|
||||
# max_floor = Explanation(
|
||||
# explanation="Bina kat sayısıdır.",
|
||||
# usage="Bina kat sayısı istendiğinde kullanılır.",
|
||||
# alias="Kat Sayısı",
|
||||
# example=["1", "2", "3"],
|
||||
# )
|
||||
# underground_floor = Explanation(
|
||||
# explanation="Bina bodrum kat sayısıdır.",
|
||||
# usage="Bina bodrum kat sayısı istendiğinde kullanılır.",
|
||||
# alias="Bodrum Kat Sayısı",
|
||||
# example=["1", "2", "3"],
|
||||
# )
|
||||
# build_date = Explanation(
|
||||
# explanation="Bina yapım tarihidir.",
|
||||
# usage="Bina yapım tarihi istendiğinde kullanılır.",
|
||||
# alias="Yapım Tarihi",
|
||||
# example=["2021-01-01"],
|
||||
# )
|
||||
# tax_no = Explanation(
|
||||
# explanation="Bina vergi numarasıdır.",
|
||||
# usage="Bina vergi numarası istendiğinde kullanılır.",
|
||||
# alias="Vergi No",
|
||||
# example=["1234567890"],
|
||||
# )
|
||||
# lift_count = Explanation(
|
||||
# explanation="Bina asansör sayısıdır.",
|
||||
# usage="Bina asansör sayısı istendiğinde kullanılır.",
|
||||
# alias="Asansör Sayısı",
|
||||
# example=["1", "2", "3"],
|
||||
# )
|
||||
# heating_system = Explanation(
|
||||
# explanation="Bina ısıtma sistemi var mı?",
|
||||
# usage="Bina ısıtma sistemi var mı istendiğinde kullanılır.",
|
||||
# alias="Isıtma Sistemi",
|
||||
# example=[True, False],
|
||||
# )
|
||||
# cooling_system = Explanation(
|
||||
# explanation="Bina soğutma sistemi var mı?",
|
||||
# usage="Bina soğutma sistemi var mı istendiğinde kullanılır.",
|
||||
# alias="Soğutma Sistemi",
|
||||
# example=[True, False],
|
||||
# )
|
||||
# hot_water_system = Explanation(
|
||||
# explanation="Bina sıcak su sistemi var mı?",
|
||||
# usage="Bina sıcak su sistemi var mı istendiğinde kullanılır.",
|
||||
# alias="Sıcak Su Sistemi",
|
||||
# example=[True, False],
|
||||
# )
|
||||
|
||||
|
||||
class BuildTypes(CrudCollection):
|
||||
"""
|
||||
@@ -257,7 +178,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
site_uu_id: Mapped[str] = mapped_column(String, comment="Site UUID")
|
||||
address_id: Mapped[int] = mapped_column(ForeignKey("addresses.id"))
|
||||
address_uu_id: Mapped[str] = mapped_column(String, comment="Address UUID")
|
||||
build_types_id = mapped_column(
|
||||
build_types_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_types.id"), nullable=False, comment="Building Type"
|
||||
)
|
||||
build_types_uu_id: Mapped[str] = mapped_column(String, comment="Building Type UUID")
|
||||
@@ -376,8 +297,9 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
|
||||
@property
|
||||
def livable_part_count(self):
|
||||
livable_parts = BuildParts.filter_active(
|
||||
BuildParts.build_id == self.id, BuildParts.human_livable == True
|
||||
livable_parts = BuildParts.filter_all(
|
||||
BuildParts.build_id == self.id, BuildParts.human_livable == True,
|
||||
*BuildParts.valid_record_args(BuildParts)
|
||||
)
|
||||
if not livable_parts.data:
|
||||
raise HTTPException(
|
||||
@@ -420,34 +342,34 @@ class BuildParts(CrudCollection):
|
||||
__enum_list__ = [("part_direction", "Directions", "NN")]
|
||||
|
||||
# https://adres.nvi.gov.tr/VatandasIslemleri/AdresSorgu
|
||||
address_gov_code = mapped_column(
|
||||
address_gov_code: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Goverment Door Code"
|
||||
)
|
||||
# part_name: Mapped[str] = mapped_column(String(24), server_default="", nullable=False, comment="Part Name")
|
||||
part_no = mapped_column(
|
||||
part_no: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", nullable=False, comment="Part Number"
|
||||
)
|
||||
part_level = mapped_column(
|
||||
part_level: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", comment="Building Part Level"
|
||||
)
|
||||
part_code = mapped_column(
|
||||
part_code: Mapped[str] = mapped_column(
|
||||
String, server_default="", nullable=False, comment="Part Code"
|
||||
)
|
||||
part_gross_size = mapped_column(
|
||||
part_gross_size: Mapped[int] = mapped_column(
|
||||
Integer, server_default="0", comment="Part Gross Size"
|
||||
)
|
||||
part_net_size = mapped_column(Integer, server_default="0", comment="Part Net Size")
|
||||
default_accessory = mapped_column(
|
||||
part_net_size: Mapped[int] = mapped_column(Integer, server_default="0", comment="Part Net Size")
|
||||
default_accessory: Mapped[str] = mapped_column(
|
||||
Text, server_default="0", comment="Default Accessory"
|
||||
)
|
||||
human_livable: Mapped[bool] = mapped_column(
|
||||
Boolean, server_default="1", comment="Human Livable"
|
||||
)
|
||||
due_part_key = mapped_column(
|
||||
due_part_key: Mapped[str] = mapped_column(
|
||||
String, server_default="", nullable=False, comment="Constant Payment Group"
|
||||
)
|
||||
|
||||
build_id = mapped_column(
|
||||
build_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build.id"), nullable=False, comment="Building ID"
|
||||
)
|
||||
build_uu_id: Mapped[str] = mapped_column(
|
||||
@@ -456,13 +378,13 @@ class BuildParts(CrudCollection):
|
||||
part_direction_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("api_enum_dropdown.id"), nullable=True
|
||||
)
|
||||
part_direction_uu_id = mapped_column(
|
||||
part_direction_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Part Direction UUID"
|
||||
)
|
||||
part_type_id = mapped_column(
|
||||
part_type_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_types.id"), nullable=False, comment="Building Part Type"
|
||||
)
|
||||
part_type_uu_id = mapped_column(
|
||||
part_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Building Part Type UUID"
|
||||
)
|
||||
|
||||
@@ -558,12 +480,12 @@ class BuildLivingSpace(CrudCollection):
|
||||
__exclude__fields__ = []
|
||||
__include__fields__ = []
|
||||
|
||||
fix_value = mapped_column(
|
||||
fix_value: Mapped[float] = mapped_column(
|
||||
Numeric(20, 6),
|
||||
server_default="0",
|
||||
comment="Fixed value is deducted from debit.",
|
||||
)
|
||||
fix_percent = mapped_column(
|
||||
fix_percent: Mapped[float] = mapped_column(
|
||||
Numeric(6, 2),
|
||||
server_default="0",
|
||||
comment="Fixed percent is deducted from debit.",
|
||||
@@ -573,19 +495,19 @@ class BuildLivingSpace(CrudCollection):
|
||||
String, server_default="", comment="Agreement No"
|
||||
)
|
||||
marketing_process: Mapped[bool] = mapped_column(Boolean, server_default="False")
|
||||
marketing_layer = mapped_column(SmallInteger, server_default="0")
|
||||
marketing_layer: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
discounted_percentage: Mapped[float] = mapped_column(
|
||||
Numeric(6, 2), server_default="0.00"
|
||||
) # %22
|
||||
discounted_price = mapped_column(
|
||||
discounted_price: Mapped[float] = mapped_column(
|
||||
Numeric(20, 2), server_default="0.00"
|
||||
) # Normal: 78.00 TL
|
||||
calculated_price = mapped_column(
|
||||
calculated_price: Mapped[float] = mapped_column(
|
||||
Numeric(20, 2), server_default="0.00"
|
||||
) # sana düz 75.00 TL yapar
|
||||
|
||||
build_parts_id = mapped_column(
|
||||
build_parts_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_parts.id"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
@@ -594,21 +516,21 @@ class BuildLivingSpace(CrudCollection):
|
||||
build_parts_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Build Part UUID"
|
||||
)
|
||||
person_id = mapped_column(
|
||||
person_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("people.id"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment="Responsible People ID",
|
||||
)
|
||||
person_uu_id = mapped_column(
|
||||
person_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Responsible People UUID"
|
||||
)
|
||||
occupant_type = mapped_column(
|
||||
occupant_type: Mapped[int] = mapped_column(
|
||||
ForeignKey("occupant_types.id"),
|
||||
nullable=False,
|
||||
comment="Occupant Type",
|
||||
)
|
||||
occupant_type_uu_id = mapped_column(
|
||||
occupant_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Occupant Type UUID"
|
||||
)
|
||||
__table_args__ = (
|
||||
@@ -649,11 +571,13 @@ class BuildLivingSpace(CrudCollection):
|
||||
def find_living_from_customer_id(
|
||||
cls, customer_id, process_date, add_days: int = 32
|
||||
):
|
||||
formatted_date = datetime.strptime(str(process_date), "%Y-%m-%d %H:%M:%S")
|
||||
living_spaces = cls.filter_active(
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
formatted_date = system_arrow.get(str(process_date))
|
||||
living_spaces = cls.filter_all(
|
||||
or_(
|
||||
cls.owner_person_id == customer_id,
|
||||
cls.life_person_id == customer_id,
|
||||
*cls.valid_record_args(cls)
|
||||
),
|
||||
cls.start_date < formatted_date - timedelta(days=add_days),
|
||||
cls.stop_date > formatted_date + timedelta(days=add_days),
|
||||
@@ -678,11 +602,11 @@ class BuildArea(CrudCollection):
|
||||
size = mapped_column(Integer, server_default="0")
|
||||
|
||||
build_id: Mapped[int] = mapped_column(ForeignKey("build.id"))
|
||||
build_uu_id = mapped_column(String, comment="Building UUID")
|
||||
part_type_id = mapped_column(
|
||||
build_uu_id: Mapped[str] = mapped_column(String, comment="Building UUID")
|
||||
part_type_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_types.id"), nullable=True, comment="Building Part Type"
|
||||
)
|
||||
part_type_uu_id = mapped_column(
|
||||
part_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Building Part Type UUID"
|
||||
)
|
||||
|
||||
@@ -704,11 +628,11 @@ class BuildSites(CrudCollection):
|
||||
__exclude__fields__ = []
|
||||
__include__fields__ = []
|
||||
|
||||
site_name = mapped_column(String(24), nullable=False)
|
||||
site_no = mapped_column(String(8), nullable=False)
|
||||
site_name : Mapped[str]= mapped_column(String(24), nullable=False)
|
||||
site_no: Mapped[str] = mapped_column(String(8), nullable=False)
|
||||
|
||||
address_id: Mapped[int] = mapped_column(ForeignKey("addresses.id"))
|
||||
address_uu_id = mapped_column(String, comment="Address UUID")
|
||||
address_uu_id: Mapped[str] = mapped_column(String, comment="Address UUID")
|
||||
|
||||
# addresses: Mapped["Address"] = relationship(
|
||||
# "Address", back_populates="site", foreign_keys=[address_id]
|
||||
@@ -733,14 +657,14 @@ class BuildCompaniesProviding(CrudCollection):
|
||||
build_id = mapped_column(
|
||||
ForeignKey("build.id"), nullable=False, comment="Building ID"
|
||||
)
|
||||
build_uu_id = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
build_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
company_uu_id = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
company_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
provide_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("api_enum_dropdown.id"), nullable=True
|
||||
)
|
||||
provide_uu_id = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
contract_id = mapped_column(Integer, ForeignKey("companies.id"), nullable=True)
|
||||
provide_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
contract_id: Mapped[int] = mapped_column(Integer, ForeignKey("companies.id"), nullable=True)
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
@@ -764,14 +688,14 @@ class BuildPersonProviding(CrudCollection):
|
||||
build_id = mapped_column(
|
||||
ForeignKey("build.id"), nullable=False, comment="Building ID"
|
||||
)
|
||||
build_uu_id = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
build_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
people_id: Mapped[int] = mapped_column(ForeignKey("people.id"))
|
||||
people_uu_id = mapped_column(String, nullable=True, comment="People UUID")
|
||||
people_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="People UUID")
|
||||
provide_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("api_enum_dropdown.id"), nullable=True
|
||||
)
|
||||
provide_uu_id = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
contract_id = mapped_column(Integer, ForeignKey("companies.id"), nullable=True)
|
||||
provide_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
contract_id: Mapped[int] = mapped_column(Integer, ForeignKey("companies.id"), nullable=True)
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
|
||||
Reference in New Issue
Block a user