save and confirmed added
This commit is contained in:
@@ -179,7 +179,9 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
site_id: Mapped[int] = mapped_column(ForeignKey("build_sites.id"), nullable=True)
|
||||
site_uu_id: Mapped[str] = mapped_column(String, comment="Site UUID", nullable=True)
|
||||
address_id: Mapped[int] = mapped_column(ForeignKey("addresses.id"), nullable=False)
|
||||
address_uu_id: Mapped[str] = mapped_column(String, comment="Address UUID", nullable=False)
|
||||
address_uu_id: Mapped[str] = mapped_column(
|
||||
String, comment="Address UUID", nullable=False
|
||||
)
|
||||
build_types_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_types.id"), nullable=False, comment="Building Type"
|
||||
)
|
||||
@@ -226,8 +228,8 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
|
||||
@property
|
||||
def management_room(self):
|
||||
if management_room := BuildParts.find_one(
|
||||
id=self.management_room_id, build_id=self.id, active=True, is_confirmed=True
|
||||
if management_room := BuildParts.filter_by_one(
|
||||
system=True, id=self.management_room_id, build_id=self.id
|
||||
):
|
||||
return management_room
|
||||
return None
|
||||
@@ -240,7 +242,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
data_dict["address_id"] = None
|
||||
if data.address_uu_id:
|
||||
official_address = Addresses.filter_one(
|
||||
Addresses.uu_id==data.address_uu_id,
|
||||
Addresses.uu_id == data.address_uu_id,
|
||||
).data
|
||||
data_dict["address_id"] = official_address.id
|
||||
data_dict["build_no"] = str(official_address.build_number)
|
||||
@@ -249,7 +251,9 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Address is not found in database. Re-enter address record then try again.",
|
||||
)
|
||||
build_type = BuildTypes.filter_by_one(system=True, uu_id=str(data.build_types_uu_id)).data
|
||||
build_type = BuildTypes.filter_by_one(
|
||||
system=True, uu_id=str(data.build_types_uu_id)
|
||||
).data
|
||||
data_dict["build_types_id"] = build_type.id
|
||||
build_created = cls.find_or_create(**data_dict)
|
||||
created_build_relation = cls.__many__table__.find_or_create(
|
||||
@@ -304,7 +308,8 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
@property
|
||||
def livable_part_count(self):
|
||||
livable_parts = BuildParts.filter_all(
|
||||
BuildParts.build_id == self.id, BuildParts.human_livable == True,
|
||||
BuildParts.build_id == self.id,
|
||||
BuildParts.human_livable == True,
|
||||
)
|
||||
if not livable_parts.data:
|
||||
raise HTTPException(
|
||||
@@ -318,7 +323,9 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
building_types = None
|
||||
for part in self.parts:
|
||||
building_types = {}
|
||||
build_type = BuildTypes.filter_by_one(system=True, id=part.build_part_type_id).data
|
||||
build_type = BuildTypes.filter_by_one(
|
||||
system=True, id=part.build_part_type_id
|
||||
).data
|
||||
if build_type.type_code in building_types:
|
||||
building_types[build_type.type_code]["list"].append(part.part_no)
|
||||
else:
|
||||
@@ -363,7 +370,9 @@ class BuildParts(CrudCollection):
|
||||
part_gross_size: Mapped[int] = mapped_column(
|
||||
Integer, server_default="0", comment="Part Gross Size"
|
||||
)
|
||||
part_net_size: Mapped[int] = mapped_column(Integer, server_default="0", comment="Part Net Size")
|
||||
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"
|
||||
)
|
||||
@@ -469,7 +478,9 @@ class BuildParts(CrudCollection):
|
||||
|
||||
@property
|
||||
def part_name(self):
|
||||
if build_type := BuildTypes.filter_by_one(system=True, id=self.build_part_type_id).data:
|
||||
if build_type := BuildTypes.filter_by_one(
|
||||
system=True, id=self.build_part_type_id
|
||||
).data:
|
||||
return f"{str(build_type.type_name).upper()} : {str(self.part_no).upper()}"
|
||||
return f"Undefined:{str(build_type.type_name).upper()}"
|
||||
|
||||
@@ -552,23 +563,21 @@ class BuildLivingSpace(CrudCollection):
|
||||
from api_events.events.events.events_bind_services import (
|
||||
ServiceBindOccupantEventMethods,
|
||||
)
|
||||
if data.get('expiry_starts'):
|
||||
data['expiry_starts'] = str(system_arrow.get(data['expiry_starts']))
|
||||
if data.get('expiry_ends'):
|
||||
data['expiry_ends'] = str(system_arrow.get(data['expiry_ends']))
|
||||
|
||||
if data.get("expiry_starts"):
|
||||
data["expiry_starts"] = str(system_arrow.get(data["expiry_starts"]))
|
||||
if data.get("expiry_ends"):
|
||||
data["expiry_ends"] = str(system_arrow.get(data["expiry_ends"]))
|
||||
created_living_space = BuildLivingSpace.find_or_create(**data)
|
||||
occupant_type = OccupantTypes.filter_by_one(
|
||||
system=True,
|
||||
uu_id=created_living_space.occupant_type_uu_id
|
||||
system=True, uu_id=created_living_space.occupant_type_uu_id
|
||||
).data
|
||||
related_service = Services.filter_by_one(
|
||||
related_responsibility=occupant_type.occupant_code,
|
||||
**Services.valid_record_dict
|
||||
**Services.valid_record_dict,
|
||||
).data
|
||||
|
||||
created_living_space.save()
|
||||
created_living_space.is_confirmed = True
|
||||
created_living_space.save()
|
||||
created_living_space.save_and_confirm()
|
||||
|
||||
if not related_service:
|
||||
raise HTTPException(
|
||||
@@ -586,6 +595,7 @@ class BuildLivingSpace(CrudCollection):
|
||||
cls, customer_id, process_date, add_days: int = 32
|
||||
):
|
||||
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_(
|
||||
@@ -642,7 +652,7 @@ class BuildSites(CrudCollection):
|
||||
__exclude__fields__ = []
|
||||
__include__fields__ = []
|
||||
|
||||
site_name : Mapped[str]= mapped_column(String(24), 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"))
|
||||
@@ -671,14 +681,22 @@ class BuildCompaniesProviding(CrudCollection):
|
||||
build_id = mapped_column(
|
||||
ForeignKey("build.id"), nullable=False, comment="Building ID"
|
||||
)
|
||||
build_uu_id: Mapped[str] = 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[str] = 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[str] = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
contract_id: Mapped[int] = 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(
|
||||
@@ -702,14 +720,22 @@ class BuildPersonProviding(CrudCollection):
|
||||
build_id = mapped_column(
|
||||
ForeignKey("build.id"), nullable=False, comment="Building ID"
|
||||
)
|
||||
build_uu_id: Mapped[str] = 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[str] = 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[str] = mapped_column(String, nullable=True, comment="Providing UUID")
|
||||
contract_id: Mapped[int] = 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(
|
||||
|
||||
@@ -45,7 +45,9 @@ class BuildDecisionBook(CrudCollection):
|
||||
__tablename__ = "build_decision_book"
|
||||
__exclude__fields__ = []
|
||||
|
||||
decision_book_pdf_path: Mapped[str] = mapped_column(String)
|
||||
decision_book_pdf_path: Mapped[str] = mapped_column(
|
||||
String, server_default="", nullable=True
|
||||
)
|
||||
resp_company_fix_wage: Mapped[float] = mapped_column(
|
||||
Numeric(10, 2), server_default="0"
|
||||
) #
|
||||
@@ -135,9 +137,7 @@ class BuildDecisionBook(CrudCollection):
|
||||
related_companies_ids = list(
|
||||
related_.id for related_ in related_companies.all()
|
||||
)
|
||||
related_building = Build.filter_all(
|
||||
Build.company_id.in_(related_companies_ids)
|
||||
)
|
||||
related_building = Build.filter_all(Build.company_id.in_(related_companies_ids))
|
||||
related_building_ids = list(related_.id for related_ in related_building.data)
|
||||
return cls.filter_all(cls.build_id.in_(related_building_ids)).query
|
||||
|
||||
@@ -223,13 +223,13 @@ class BuildDecisionBook(CrudCollection):
|
||||
):
|
||||
bank_date = datetime.strptime(str(bank_date), "%Y-%m-%d %H:%M:%S")
|
||||
build_iban = BuildIbans.find_one(iban=iban)
|
||||
decision_book: cls = cls.filter(
|
||||
decision_book: cls = cls.filter_one(
|
||||
cls.build_id == build_iban.build_id,
|
||||
cls.expiry_starts < bank_date,
|
||||
cls.expiry_ends > bank_date,
|
||||
cls.active == True,
|
||||
cls.deleted == False,
|
||||
)
|
||||
).data
|
||||
decision_book.check_book_is_valid(bank_date.__str__())
|
||||
return decision_book
|
||||
return
|
||||
@@ -263,11 +263,13 @@ class BuildDecisionBookInvitations(CrudCollection):
|
||||
Numeric(10, 2), server_default="0.51"
|
||||
)
|
||||
|
||||
message = mapped_column(Text, nullable=True, comment="Invitation Message")
|
||||
planned_date = mapped_column(
|
||||
message: Mapped[str] = mapped_column(
|
||||
Text, nullable=True, comment="Invitation Message"
|
||||
)
|
||||
planned_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Planned Meeting Date"
|
||||
)
|
||||
planned_date_expires = mapped_column(
|
||||
planned_date_expires: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Planned Meeting Date Expires"
|
||||
)
|
||||
|
||||
@@ -284,13 +286,12 @@ class BuildDecisionBookInvitations(CrudCollection):
|
||||
|
||||
@classmethod
|
||||
def check_invites_are_ready_for_meeting(cls, selected_decision_book, token_dict):
|
||||
first_book_invitation = BuildDecisionBookInvitations.find_one(
|
||||
build_id=token_dict.selected_occupant.build_id,
|
||||
decision_book_id=selected_decision_book.id,
|
||||
invitation_attempt=1,
|
||||
active=True,
|
||||
is_confirmed=True,
|
||||
)
|
||||
first_book_invitation = BuildDecisionBookInvitations.filter_one(
|
||||
BuildDecisionBookInvitations.build_id
|
||||
== token_dict.selected_occupant.build_id,
|
||||
BuildDecisionBookInvitations.decision_book_id == selected_decision_book.id,
|
||||
BuildDecisionBookInvitations.invitation_attempt == 1,
|
||||
).data
|
||||
if not first_book_invitation:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
@@ -305,19 +306,19 @@ class BuildDecisionBookInvitations(CrudCollection):
|
||||
BuildDecisionBookPerson.build_decision_book_id
|
||||
== selected_decision_book.id,
|
||||
BuildDecisionBookPerson.is_attending == True,
|
||||
filter_records=False,
|
||||
system=True,
|
||||
)
|
||||
.query.distinct(BuildDecisionBookPerson.person_id)
|
||||
.count()
|
||||
)
|
||||
|
||||
second_book_invitation = BuildDecisionBookInvitations.find_one(
|
||||
build_id=token_dict.selected_occupant.build_id,
|
||||
decision_book_id=selected_decision_book.id,
|
||||
invitation_attempt=2,
|
||||
active=True,
|
||||
is_confirmed=True,
|
||||
)
|
||||
second_book_invitation = BuildDecisionBookInvitations.filter_one(
|
||||
BuildDecisionBookInvitations.build_id
|
||||
== token_dict.selected_occupant.build_id,
|
||||
BuildDecisionBookInvitations.decision_book_id == selected_decision_book.id,
|
||||
BuildDecisionBookInvitations.invitation_attempt == 2,
|
||||
system=True,
|
||||
).data
|
||||
if not valid_invite_count >= need_attend_count and not second_book_invitation:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@@ -341,46 +342,48 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||
__exclude__fields__ = []
|
||||
__enum_list__ = [("management_typecode", "BuildManagementType", "bm")]
|
||||
|
||||
dues_percent_discount = mapped_column(SmallInteger, server_default="0")
|
||||
dues_percent_discount: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
dues_fix_discount: Mapped[float] = mapped_column(Numeric(10, 2), server_default="0")
|
||||
dues_discount_approval_date = mapped_column(
|
||||
dues_discount_approval_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, server_default="1900-01-01 00:00:00"
|
||||
)
|
||||
send_date = mapped_column(TIMESTAMP, nullable=False, comment="Confirmation Date")
|
||||
is_attending = mapped_column(
|
||||
send_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Confirmation Date"
|
||||
)
|
||||
is_attending: Mapped[bool] = mapped_column(
|
||||
Boolean, server_default="0", comment="Occupant is Attending to invitation"
|
||||
)
|
||||
confirmed_date = mapped_column(
|
||||
confirmed_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=True, comment="Confirmation Date"
|
||||
)
|
||||
token: Mapped[str] = mapped_column(
|
||||
String, server_default="", comment="Invitation Token"
|
||||
)
|
||||
|
||||
vicarious_person_id = mapped_column(
|
||||
vicarious_person_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("people.id"), nullable=True, comment="Vicarious Person ID"
|
||||
)
|
||||
vicarious_person_uu_id = mapped_column(
|
||||
vicarious_person_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Vicarious Person UUID"
|
||||
)
|
||||
|
||||
invite_id = mapped_column(
|
||||
invite_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_invitations.id"), nullable=False
|
||||
)
|
||||
invite_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Invite UUID"
|
||||
)
|
||||
|
||||
build_decision_book_id = mapped_column(
|
||||
build_decision_book_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book.id"), nullable=False
|
||||
)
|
||||
build_decision_book_uu_id = mapped_column(
|
||||
build_decision_book_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Decision Book UUID"
|
||||
)
|
||||
build_living_space_id = mapped_column(
|
||||
build_living_space_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_living_space.id"), nullable=False
|
||||
)
|
||||
build_living_space_uu_id = mapped_column(
|
||||
build_living_space_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Living Space UUID"
|
||||
)
|
||||
person_id: Mapped[int] = mapped_column(ForeignKey("people.id"), nullable=False)
|
||||
@@ -403,7 +406,7 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||
system=True,
|
||||
)
|
||||
BuildDecisionBookPersonOccupants.pre_query = all_decision_book_people.query
|
||||
return BuildDecisionBookPersonOccupants.filter_all(system=True)
|
||||
return BuildDecisionBookPersonOccupants.filter_all(system=True).data
|
||||
|
||||
def add_occupant_type(self, occupant_type, build_living_space_id: int = None):
|
||||
from databases import (
|
||||
@@ -422,15 +425,14 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||
invite_uu_id=str(self.invite_uu_id),
|
||||
occupant_type_id=occupant_type.id,
|
||||
occupant_type_uu_id=str(occupant_type.uu_id),
|
||||
is_confirmed=True,
|
||||
)
|
||||
if person_occupants := BuildDecisionBookPersonOccupants.find_or_create(
|
||||
**book_dict
|
||||
):
|
||||
person_occupants.save_and_confirm()
|
||||
|
||||
decision_book = BuildDecisionBook.filter_one(
|
||||
BuildDecisionBook.id == self.build_decision_book_id,
|
||||
BuildDecisionBook.active == True,
|
||||
BuildDecisionBook.is_confirmed == True,
|
||||
).data
|
||||
person_occupants.update(
|
||||
expiry_starts=decision_book.expiry_starts,
|
||||
@@ -449,8 +451,6 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||
|
||||
decision_build = Build.filter_one(
|
||||
Build.id == decision_book.build_id,
|
||||
Build.active == True,
|
||||
Build.is_confirmed == True,
|
||||
).data
|
||||
management_room = decision_build.management_room
|
||||
if not management_room:
|
||||
@@ -461,8 +461,6 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||
|
||||
living_space = BuildLivingSpace.filter_one(
|
||||
BuildLivingSpace.id == build_living_space_id,
|
||||
BuildLivingSpace.active == True,
|
||||
BuildLivingSpace.is_confirmed == True,
|
||||
).data
|
||||
expiry_ends = str(
|
||||
system_arrow.get(decision_book.meeting_date).shift(hours=23)
|
||||
@@ -477,15 +475,11 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||
person_uu_id=str(living_space.person_uu_id),
|
||||
expiry_starts=expiry_starts,
|
||||
expiry_ends=expiry_ends,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
)
|
||||
expires_at = str(
|
||||
system_arrow.get(decision_book.meeting_date).shift(days=15)
|
||||
)
|
||||
related_living_space.save()
|
||||
related_living_space.is_confirmed = True
|
||||
related_living_space.save()
|
||||
related_living_space.save_and_confirm()
|
||||
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
||||
build_living_space_id=related_living_space.id,
|
||||
service_id=related_service.id,
|
||||
@@ -524,13 +518,13 @@ class BuildDecisionBookPersonOccupants(CrudCollection):
|
||||
__tablename__ = "build_decision_book_person_occupants"
|
||||
__exclude__fields__ = []
|
||||
|
||||
build_decision_book_person_id = mapped_column(
|
||||
build_decision_book_person_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_person.id"), nullable=False
|
||||
)
|
||||
build_decision_book_person_uu_id = mapped_column(
|
||||
build_decision_book_person_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Person UUID"
|
||||
)
|
||||
invite_id = mapped_column(
|
||||
invite_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_invitations.id"), nullable=True
|
||||
)
|
||||
invite_uu_id: Mapped[str] = mapped_column(
|
||||
@@ -566,15 +560,17 @@ class BuildDecisionBookItems(CrudCollection):
|
||||
__tablename__ = "build_decision_book_items"
|
||||
__exclude__fields__ = []
|
||||
|
||||
item_order = mapped_column(
|
||||
item_order: Mapped[int] = mapped_column(
|
||||
SmallInteger, nullable=False, comment="Order Number of Item"
|
||||
)
|
||||
item_comment = mapped_column(Text, nullable=False, comment="Comment Content")
|
||||
item_objection = mapped_column(Text)
|
||||
info_is_completed = mapped_column(
|
||||
item_comment: Mapped[str] = mapped_column(
|
||||
Text, nullable=False, comment="Comment Content"
|
||||
)
|
||||
item_objection: Mapped[str] = mapped_column(Text)
|
||||
info_is_completed: Mapped[bool] = mapped_column(
|
||||
Boolean, server_default="0", comment="Info process is Completed"
|
||||
)
|
||||
is_payment_created = mapped_column(
|
||||
is_payment_created: Mapped[bool] = mapped_column(
|
||||
Boolean, server_default="0", comment="Are payment Records Created"
|
||||
)
|
||||
|
||||
@@ -585,10 +581,10 @@ class BuildDecisionBookItems(CrudCollection):
|
||||
String, nullable=True, comment="Info Type UUID"
|
||||
)
|
||||
|
||||
build_decision_book_id = mapped_column(
|
||||
build_decision_book_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book.id"), nullable=False
|
||||
)
|
||||
build_decision_book_uu_id = mapped_column(
|
||||
build_decision_book_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book UUID"
|
||||
)
|
||||
|
||||
@@ -610,7 +606,7 @@ class BuildDecisionBookItems(CrudCollection):
|
||||
Companies,
|
||||
)
|
||||
|
||||
related_companies = Companies.select_action(duty_id=duty_id)
|
||||
related_companies = Companies.select_action(duty_id_list=[duty_id])
|
||||
related_companies_ids = list(
|
||||
related_.id for related_ in related_companies.all()
|
||||
)
|
||||
@@ -635,9 +631,9 @@ class BuildDecisionBookItems(CrudCollection):
|
||||
duty_id=token.duty_list["duty_id"]
|
||||
)
|
||||
cls.pre_query = cls.select_action(duty_id=token.duty_list["duty_id"])
|
||||
if decision_book := BuildDecisionBook.find_one(
|
||||
uu_id=data.build_decision_book_uu_id
|
||||
):
|
||||
if decision_book := BuildDecisionBook.filter_one(
|
||||
BuildDecisionBook.uu_id == data.build_decision_book_uu_id
|
||||
).data:
|
||||
found_dict = dict(
|
||||
item_order=data.item_order, build_decision_book_id=decision_book.id
|
||||
)
|
||||
@@ -666,9 +662,11 @@ class BuildDecisionBookItems(CrudCollection):
|
||||
occupant_type_list = OccupantTypes.filter_all(
|
||||
OccupantTypes.occupant_code.in_(occupant_type_required_list),
|
||||
system=True,
|
||||
)
|
||||
).data
|
||||
# active_invite = invitations[1] if invitations[1] else invitations[0]
|
||||
invitation = BuildDecisionBookInvitations.find_one(id=active_invite.id)
|
||||
invitation = BuildDecisionBookInvitations.filter_one(
|
||||
BuildDecisionBookInvitations.id == active_invite.id
|
||||
).data
|
||||
people_book_attend_count = None
|
||||
if invitation.invitation_attempt == 1:
|
||||
people_book_attend_is_attending = BuildDecisionBookPerson.filter_all(
|
||||
@@ -702,26 +700,25 @@ class BuildDecisionBookItems(CrudCollection):
|
||||
active=True,
|
||||
is_payment_created=True,
|
||||
)
|
||||
occupant_type_pre = OccupantTypes.find_one(
|
||||
occupant_code="MT-PRS", occupant_category_type="MT"
|
||||
)
|
||||
occupant_type_wrt = OccupantTypes.find_one(
|
||||
occupant_code="MT-WRT", occupant_category_type="MT"
|
||||
)
|
||||
occupant_type_mng = OccupantTypes.find_one(
|
||||
occupant_code="BU-MNG", occupant_category_type="BU"
|
||||
)
|
||||
occupant_type_pre = OccupantTypes.filter_by_one(
|
||||
system=True, occupant_code="MT-PRS", occupant_category_type="MT"
|
||||
).data
|
||||
occupant_type_wrt = OccupantTypes.filter_by_one(
|
||||
system=True, occupant_code="MT-WRT", occupant_category_type="MT"
|
||||
).data
|
||||
occupant_type_mng = OccupantTypes.filter_by_one(
|
||||
system=True, occupant_code="BU-MNG", occupant_category_type="BU"
|
||||
).data
|
||||
|
||||
person_occupants_pre = BuildDecisionBookPersonOccupants.find_one(
|
||||
invite_id=invitation.id,
|
||||
occupant_type_id=occupant_type_pre.id,
|
||||
)
|
||||
person_invite_pret = BuildDecisionBookPerson.find_one(
|
||||
id=person_occupants_pre.build_decision_book_person_id
|
||||
)
|
||||
person = People.find_one(
|
||||
id=person_invite_pret.person_id, active=True, is_confirmed=True
|
||||
)
|
||||
person_occupants_pre = BuildDecisionBookPersonOccupants.filter_one(
|
||||
BuildDecisionBookPersonOccupants.invite_id == invitation.id,
|
||||
BuildDecisionBookPersonOccupants.occupant_type_id == occupant_type_pre.id,
|
||||
).data
|
||||
person_invite_pret = BuildDecisionBookPerson.filter_one(
|
||||
BuildDecisionBookPerson.id
|
||||
== person_occupants_pre.build_decision_book_person_id
|
||||
).data
|
||||
person = People.filter_one(People.id == person_invite_pret.person_id).data
|
||||
BuildDecisionBookItems.find_or_create(
|
||||
**book_items_dict,
|
||||
item_order=1,
|
||||
@@ -732,16 +729,15 @@ class BuildDecisionBookItems(CrudCollection):
|
||||
),
|
||||
)
|
||||
|
||||
person_occupants_wrt = BuildDecisionBookPersonOccupants.find_one(
|
||||
invite_id=invitation.id,
|
||||
occupant_type_id=occupant_type_wrt.id,
|
||||
)
|
||||
person_invite_wrt = BuildDecisionBookPerson.find_one(
|
||||
id=person_occupants_wrt.build_decision_book_person_id
|
||||
)
|
||||
person = People.find_one(
|
||||
id=person_invite_pret.person_id, active=True, is_confirmed=True
|
||||
)
|
||||
person_occupants_wrt = BuildDecisionBookPersonOccupants.filter_one(
|
||||
BuildDecisionBookPersonOccupants.invite_id == invitation.id,
|
||||
BuildDecisionBookPersonOccupants.occupant_type_id == occupant_type_wrt.id,
|
||||
).data
|
||||
person_invite_wrt = BuildDecisionBookPerson.filter_one(
|
||||
BuildDecisionBookPerson.id
|
||||
== person_occupants_wrt.build_decision_book_person_id
|
||||
).data
|
||||
person = People.filter_one(People.id == person_invite_pret.person_id).data
|
||||
BuildDecisionBookItems.find_or_create(
|
||||
**book_items_dict,
|
||||
item_order=2,
|
||||
@@ -752,16 +748,15 @@ class BuildDecisionBookItems(CrudCollection):
|
||||
),
|
||||
)
|
||||
|
||||
person_occupants_mng = BuildDecisionBookPersonOccupants.find_one(
|
||||
invite_id=invitation.id,
|
||||
occupant_type_id=occupant_type_mng.id,
|
||||
)
|
||||
person_invite_mng = BuildDecisionBookPerson.find_one(
|
||||
id=person_occupants_mng.build_decision_book_person_id
|
||||
)
|
||||
person = People.find_one(
|
||||
id=person_invite_pret.person_id, active=True, is_confirmed=True
|
||||
)
|
||||
person_occupants_mng = BuildDecisionBookPersonOccupants.filter_one(
|
||||
BuildDecisionBookPersonOccupants.invite_id == invitation.id,
|
||||
BuildDecisionBookPersonOccupants.occupant_type_id == occupant_type_mng.id,
|
||||
).data
|
||||
person_invite_mng = BuildDecisionBookPerson.filter_one(
|
||||
BuildDecisionBookPerson.id
|
||||
== person_occupants_mng.build_decision_book_person_id
|
||||
).data
|
||||
person = People.filter_one(People.id == person_invite_pret.person_id).data
|
||||
BuildDecisionBookItems.find_or_create(
|
||||
**book_items_dict,
|
||||
item_order=3,
|
||||
@@ -795,23 +790,27 @@ class BuildDecisionBookItemsUnapproved(CrudCollection):
|
||||
__tablename__ = "build_decision_book_items_unapproved"
|
||||
__exclude__fields__ = []
|
||||
|
||||
item_objection = mapped_column(Text, nullable=False, comment="Objection Content")
|
||||
item_order = mapped_column(SmallInteger, nullable=False, comment="Order Number")
|
||||
item_objection: Mapped[str] = mapped_column(
|
||||
Text, nullable=False, comment="Objection Content"
|
||||
)
|
||||
item_order: Mapped[int] = mapped_column(
|
||||
SmallInteger, nullable=False, comment="Order Number"
|
||||
)
|
||||
|
||||
decision_book_item_id = mapped_column(
|
||||
decision_book_item_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_items.id"), nullable=False
|
||||
)
|
||||
decision_book_item_uu_id = mapped_column(
|
||||
decision_book_item_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Item"
|
||||
)
|
||||
person_id: Mapped[int] = mapped_column(ForeignKey("people.id"), nullable=False)
|
||||
person_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Person UUID"
|
||||
)
|
||||
build_decision_book_item = mapped_column(
|
||||
build_decision_book_item: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_items.id"), nullable=False
|
||||
)
|
||||
build_decision_book_item_uu_id = mapped_column(
|
||||
build_decision_book_item_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Item UUID"
|
||||
)
|
||||
|
||||
@@ -833,11 +832,13 @@ class BuildDecisionBookPayments(CrudCollection):
|
||||
__exclude__fields__ = []
|
||||
__enum_list__ = [("receive_debit", "DebitTypes", "D")]
|
||||
|
||||
payment_plan_time_periods = mapped_column(
|
||||
payment_plan_time_periods: Mapped[str] = mapped_column(
|
||||
String(10), nullable=False, comment="Payment Plan Time Periods"
|
||||
)
|
||||
process_date = mapped_column(TIMESTAMP, nullable=False, comment="Payment Due Date")
|
||||
payment_amount = mapped_column(
|
||||
process_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Payment Due Date"
|
||||
)
|
||||
payment_amount: Mapped[float] = mapped_column(
|
||||
Numeric(16, 2), nullable=False, comment="Payment Amount"
|
||||
)
|
||||
currency: Mapped[str] = mapped_column(String(8), server_default="TRY")
|
||||
@@ -853,20 +854,20 @@ class BuildDecisionBookPayments(CrudCollection):
|
||||
process_date_y: Mapped[int] = mapped_column(SmallInteger)
|
||||
process_date_m: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
build_decision_book_item_id = mapped_column(
|
||||
build_decision_book_item_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_items.id"),
|
||||
nullable=False,
|
||||
comment="Build Decision Book Item ID",
|
||||
)
|
||||
build_decision_book_item_uu_id = mapped_column(
|
||||
build_decision_book_item_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Item UUID"
|
||||
)
|
||||
decision_book_project_id = mapped_column(
|
||||
decision_book_project_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_projects.id"),
|
||||
nullable=True,
|
||||
comment="Decision Book Project ID",
|
||||
)
|
||||
decision_book_project_uu_id = mapped_column(
|
||||
decision_book_project_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Project UUID"
|
||||
)
|
||||
|
||||
@@ -932,29 +933,37 @@ class BuildDecisionBookLegal(CrudCollection):
|
||||
__tablename__ = "build_decision_book_legal"
|
||||
__exclude__fields__ = []
|
||||
|
||||
period_start_date = mapped_column(
|
||||
period_start_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Start Date of Legal Period"
|
||||
)
|
||||
lawsuits_decision_number = mapped_column(
|
||||
lawsuits_decision_number: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Lawsuits Decision Number"
|
||||
)
|
||||
lawsuits_decision_date = mapped_column(
|
||||
lawsuits_decision_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Lawsuits Decision Date"
|
||||
)
|
||||
|
||||
period_stop_date = mapped_column(TIMESTAMP, server_default="2099-12-31 23:59:59")
|
||||
decision_book_pdf_path: Mapped[str] = mapped_column(String(128))
|
||||
resp_company_total_wage: Mapped[float] = mapped_column(
|
||||
Numeric(10, 2), server_default="0"
|
||||
period_stop_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, server_default="2099-12-31 23:59:59"
|
||||
)
|
||||
contact_agreement_path = mapped_column(String(128))
|
||||
contact_agreement_date = mapped_column(
|
||||
decision_book_pdf_path: Mapped[str] = mapped_column(
|
||||
String, server_default="", nullable=True
|
||||
)
|
||||
resp_company_total_wage: Mapped[float] = mapped_column(
|
||||
Numeric(10, 2), server_default="0", nullable=True
|
||||
)
|
||||
contact_agreement_path: Mapped[str] = mapped_column(
|
||||
String, server_default="", nullable=True
|
||||
)
|
||||
contact_agreement_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, server_default="1900-01-01 00:00:00", nullable=True
|
||||
)
|
||||
meeting_date: Mapped[str] = mapped_column(
|
||||
TIMESTAMP, server_default="1900-01-01 00:00:00"
|
||||
)
|
||||
meeting_date = mapped_column(TIMESTAMP, server_default="1900-01-01 00:00:00")
|
||||
lawsuits_type = mapped_column(String(1), server_default="C")
|
||||
lawsuits_name = mapped_column(String(128))
|
||||
lawsuits_note = mapped_column(String(512))
|
||||
lawsuits_type: Mapped[str] = mapped_column(String(1), server_default="C")
|
||||
lawsuits_name: Mapped[str] = mapped_column(String(128))
|
||||
lawsuits_note: Mapped[str] = mapped_column(String(512))
|
||||
lawyer_cost: Mapped[float] = mapped_column(Numeric(20, 2))
|
||||
mediator_lawyer_cost: Mapped[float] = mapped_column(Numeric(20, 2))
|
||||
other_cost: Mapped[float] = mapped_column(Numeric(20, 2))
|
||||
@@ -962,22 +971,24 @@ class BuildDecisionBookLegal(CrudCollection):
|
||||
approved_cost: Mapped[float] = mapped_column(Numeric(20, 2))
|
||||
total_price: Mapped[float] = mapped_column(Numeric(20, 2))
|
||||
|
||||
build_db_item_id = mapped_column(
|
||||
build_db_item_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_items.id"), nullable=False
|
||||
)
|
||||
build_db_item_uu_id = mapped_column(
|
||||
build_db_item_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Item UUID"
|
||||
)
|
||||
resp_attorney_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("people.id"), nullable=False
|
||||
)
|
||||
resp_attorney_uu_id = mapped_column(String, nullable=True, comment="Attorney UUID")
|
||||
resp_attorney_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Attorney UUID"
|
||||
)
|
||||
resp_attorney_company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
resp_attorney_company_uu_id = mapped_column(
|
||||
resp_attorney_company_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Company UUID"
|
||||
)
|
||||
mediator_lawyer_person_id: Mapped[int] = mapped_column(ForeignKey("people.id"))
|
||||
mediator_lawyer_person_uu_id = mapped_column(
|
||||
mediator_lawyer_person_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Mediator Lawyer UUID"
|
||||
)
|
||||
|
||||
@@ -998,60 +1009,70 @@ class BuildDecisionBookProjects(CrudCollection):
|
||||
__tablename__ = "build_decision_book_projects"
|
||||
__exclude__fields__ = []
|
||||
|
||||
project_no = mapped_column(
|
||||
project_no: Mapped[str] = mapped_column(
|
||||
String(12), nullable=True, comment="Project Number of Decision Book"
|
||||
)
|
||||
project_name = mapped_column(String, nullable=False, comment="Project Name")
|
||||
project_start_date = mapped_column(
|
||||
project_name: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Project Name"
|
||||
)
|
||||
project_start_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Project Start Date"
|
||||
)
|
||||
|
||||
project_stop_date = mapped_column(TIMESTAMP, server_default="2099-12-31 23:59:59")
|
||||
project_type = mapped_column(String, server_default="C")
|
||||
project_note = mapped_column(Text)
|
||||
project_stop_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, server_default="2099-12-31 23:59:59"
|
||||
)
|
||||
project_type: Mapped[str] = mapped_column(String, server_default="C")
|
||||
project_note: Mapped[str] = mapped_column(Text)
|
||||
|
||||
decision_book_pdf_path = mapped_column(String)
|
||||
decision_book_pdf_path: Mapped[str] = mapped_column(
|
||||
String, server_default="", nullable=True
|
||||
)
|
||||
|
||||
resp_company_fix_wage: Mapped[float] = mapped_column(
|
||||
Numeric(10, 2), server_default="0"
|
||||
)
|
||||
is_out_sourced: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
contact_id = mapped_column(
|
||||
contact_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("contracts.id"), nullable=True, comment="Contract id"
|
||||
)
|
||||
contact_uu_id = mapped_column(String, nullable=True, comment="Contract UUID")
|
||||
meeting_date = mapped_column(
|
||||
contact_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Contract UUID"
|
||||
)
|
||||
meeting_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, server_default="1900-01-01 00:00:00", index=True
|
||||
)
|
||||
currency = mapped_column(String(8), server_default="TRY")
|
||||
currency: Mapped[float] = mapped_column(String(8), server_default="TRY")
|
||||
bid_price: Mapped[float] = mapped_column(Numeric(16, 4), server_default="0")
|
||||
approved_price: Mapped[float] = mapped_column(Numeric(16, 4), server_default="0")
|
||||
final_price: Mapped[float] = mapped_column(Numeric(16, 4), server_default="0")
|
||||
|
||||
build_decision_book_id = mapped_column(
|
||||
build_decision_book_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book.id"), nullable=False
|
||||
)
|
||||
build_decision_book_uu_id = mapped_column(
|
||||
build_decision_book_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book UUID"
|
||||
)
|
||||
build_decision_book_item_id = mapped_column(
|
||||
ForeignKey("build_decision_book_items.id"), nullable=False
|
||||
)
|
||||
build_decision_book_item_uu_id = mapped_column(
|
||||
build_decision_book_item_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Item UUID"
|
||||
)
|
||||
project_response_living_space_id = mapped_column(
|
||||
project_response_living_space_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_living_space.id"),
|
||||
nullable=True,
|
||||
comment="Project Response Person ID",
|
||||
)
|
||||
project_response_living_space_uu_id = mapped_column(
|
||||
project_response_living_space_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Project Response Person UUID"
|
||||
)
|
||||
resp_company_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("companies.id"), nullable=True
|
||||
)
|
||||
resp_company_uu_id = mapped_column(String, nullable=True, comment="Company UUID")
|
||||
resp_company_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Company UUID"
|
||||
)
|
||||
|
||||
build_decision_book_item: Mapped["BuildDecisionBookItems"] = relationship(
|
||||
"BuildDecisionBookItems",
|
||||
@@ -1070,9 +1091,7 @@ class BuildDecisionBookProjects(CrudCollection):
|
||||
related_companies_ids = list(
|
||||
related_.id for related_ in related_companies.all()
|
||||
)
|
||||
related_building = Build.filter_all(
|
||||
Build.company_id.in_(related_companies_ids)
|
||||
)
|
||||
related_building = Build.filter_all(Build.company_id.in_(related_companies_ids))
|
||||
related_building_ids = list(related_.id for related_ in related_building.data)
|
||||
related_decision_books = BuildDecisionBook.filter_all(
|
||||
BuildDecisionBook.build_id.in_(related_building_ids),
|
||||
@@ -1153,30 +1172,30 @@ class BuildDecisionBookProjectPerson(CrudCollection):
|
||||
|
||||
__tablename__ = "build_decision_book_project_person"
|
||||
__exclude__fields__ = []
|
||||
__enum_list__ = [("management_typecode", "ProjectTeamTypes", "PTT-EMP")]
|
||||
# __enum_list__ = [("management_typecode", "ProjectTeamTypes", "PTT-EMP")]
|
||||
|
||||
dues_percent_discount = mapped_column(SmallInteger, server_default="0")
|
||||
dues_percent_discount: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
job_fix_wage: Mapped[float] = mapped_column(Numeric(10, 2), server_default="0")
|
||||
bid_price: Mapped[float] = mapped_column(Numeric(10, 2), server_default="0")
|
||||
decision_price: Mapped[float] = mapped_column(Numeric(10, 2), server_default="0")
|
||||
|
||||
build_decision_book_project_id = mapped_column(
|
||||
build_decision_book_project_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book_projects.id"), nullable=False
|
||||
)
|
||||
build_decision_book_project_uu_id = mapped_column(
|
||||
build_decision_book_project_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Project UUID"
|
||||
)
|
||||
living_space_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_living_space.id"), nullable=False
|
||||
)
|
||||
living_space_uu_id = mapped_column(
|
||||
living_space_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Living Space UUID"
|
||||
)
|
||||
|
||||
project_team_type_id = mapped_column(
|
||||
project_team_type_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("api_enum_dropdown.id"), nullable=True
|
||||
)
|
||||
project_team_type_uu_id = mapped_column(
|
||||
project_team_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Management Type UUID"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user