save and confirmed added

This commit is contained in:
berkay 2024-11-17 16:30:50 +03:00
parent 7e1b26f3c4
commit 295dbe2cd8
48 changed files with 922 additions and 697 deletions

View File

@ -107,11 +107,15 @@ class AccountRecordsCreateEventMethods(MethodToEvent):
data_dict["bank_date_y"] = bank_date.year
if int(data.currency_value) < 0:
debit_type = ApiEnumDropdown.filter_by_one(system=True, enum_class="DebitTypes", key="DT-D").data
debit_type = ApiEnumDropdown.filter_by_one(
system=True, enum_class="DebitTypes", key="DT-D"
).data
data_dict["receive_debit"] = debit_type.id
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
else:
debit_type = ApiEnumDropdown.filter_by_one(system=True, enum_class="DebitTypes", key="DT-R").data
debit_type = ApiEnumDropdown.filter_by_one(
system=True, enum_class="DebitTypes", key="DT-R"
).data
data_dict["receive_debit"] = debit_type.id
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)

View File

@ -66,8 +66,7 @@ class AddressListEventMethods(MethodToEvent):
Addresses.street_id.in_(get_street_ids),
).query
Addresses.filter_attr = list_options
records = Addresses.filter_all(
).data
records = Addresses.filter_all().data
return AlchemyJsonResponse(
completed=True,
message="List Address records",

View File

@ -202,12 +202,9 @@ class AuthenticationSelectEventMethods(MethodToEvent):
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Build Part is not found",
)
build = Build.filter_one(
Build.id == build_part.build_id
).data
build = Build.filter_one(Build.id == build_part.build_id).data
related_company = RelationshipEmployee2Build.filter_one(
RelationshipEmployee2Build.member_id == build.id,
).data
company_related = Companies.filter_one(
Companies.id == related_company.company_id,
@ -340,9 +337,7 @@ class AuthenticationChangePasswordEventMethods(MethodToEvent):
):
token_user = get_object_via_access_key(request=request)
if token_user.user_type == 1:
if found_user := Users.filter_one(
Users.uu_id == token_user.uu_id
).data:
if found_user := Users.filter_one(Users.uu_id == token_user.uu_id).data:
if found_user.check_password(data.old_password):
found_user.set_password(data.new_password)
return JSONResponse(
@ -427,9 +422,7 @@ class AuthenticationDisconnectUserEventMethods(MethodToEvent):
):
if token_user := get_object_via_access_key(request=request):
found_user = Users.filter_one(
Users.uu_id == token_user.get("uu_id")
).data
found_user = Users.filter_one(Users.uu_id == token_user.get("uu_id")).data
if not found_user:
return JSONResponse(
content={

View File

@ -102,7 +102,7 @@ class AuthenticationSelectEventMethods(MethodToEvent):
cls,
request: Request,
data: Union[EmployeeSelection, OccupantSelection],
token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
):
from api_objects import OccupantToken, CompanyToken
@ -152,9 +152,7 @@ class AuthenticationSelectEventMethods(MethodToEvent):
department = Departments.filter_one(
Departments.id == duties.department_id,
).data
bulk_id = Duty.filter_by_one(
system=True, duty_code="BULK"
).data
bulk_id = Duty.filter_by_one(system=True, duty_code="BULK").data
bulk_duty_id = Duties.filter_by_one(
company_id=selected_company.id,
duties_id=bulk_id.id,

View File

@ -214,7 +214,7 @@ class BuildPatchEventMethods(MethodToEvent):
@classmethod
def build_patch(cls, build_uu_id: str, data: PatchRecord, token_dict):
find_one_build = Build.filter_one(
Build.uu_id==build_uu_id,
Build.uu_id == build_uu_id,
)
access_authorized_build = Build.select_action(
employee_id=token_dict.selected_company.employee_id,

View File

@ -75,7 +75,9 @@ class BuildAreaCreateEventMethods(MethodToEvent):
"build_uu_id": data.build_uu_id,
},
)
selected_build = Build.filter_by_one(system=True, uu_id=data.build_uu_id).data
selected_build = Build.filter_by_one(
system=True, uu_id=data.build_uu_id
).data
elif isinstance(token_dict, EmployeeTokenObject):
build_ids = Build.select_action(
employee_id=token_dict.selected_company.employee_id
@ -89,7 +91,9 @@ class BuildAreaCreateEventMethods(MethodToEvent):
"build_uu_id": data.build_uu_id,
},
)
selected_build = Build.filter_by_one(system=True, uu_id=data.build_uu_id).data
selected_build = Build.filter_by_one(
system=True, uu_id=data.build_uu_id
).data
data_dict["build_id"] = selected_build.id
data_dict["build_uu_id"] = str(selected_build.uu_id)

View File

@ -18,11 +18,12 @@ class BuildTypesListEventMethods(MethodToEvent):
@classmethod
def build_types_list(
cls,
list_options: ListOptions,
token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
cls,
list_options: ListOptions,
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
):
from fastapi.exceptions import HTTPException
if isinstance(token_dict, EmployeeTokenObject):
BuildTypes.filter_attr = list_options
results = BuildTypes.filter_all()
@ -33,15 +34,14 @@ class BuildTypesListEventMethods(MethodToEvent):
)
elif isinstance(token_dict, OccupantTokenObject):
raise HTTPException(
status_code=403,
detail="You are not authorized to access this endpoint"
status_code=403, detail="You are not authorized to access this endpoint"
)
else:
raise HTTPException(
status_code=403,
detail="You are not authorized to access this endpoint"
status_code=403, detail="You are not authorized to access this endpoint"
)
BuildTypesListEventMethod = BuildTypesListEventMethods(
action=ActionsSchema(endpoint="/building/types/list")
)
)

View File

@ -180,9 +180,11 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
dt = system_arrow.get(last_living_space.expiry_ends)
if dt > system_arrow.now():
minute_df = int(dt.time().minute) - 10
last_living_space.expiry_ends = str(dt.replace(
minute=60 - abs(minute_df) if minute_df < 0 else minute_df
))
last_living_space.expiry_ends = str(
dt.replace(
minute=60 - abs(minute_df) if minute_df < 0 else minute_df
)
)
last_living_space.save()
user_module = Modules.filter_one(

View File

@ -129,7 +129,7 @@ class CompanyPatchEventMethods(MethodToEvent):
cls, company_uu_id: str, data: PatchRecord, token_dict: EmployeeTokenObject
):
find_one_company = Companies.filter_one(
Companies.uu_id==company_uu_id,
Companies.uu_id == company_uu_id,
).data
access_authorized_company = Companies.select_action(
duty_id_list=[

View File

@ -39,6 +39,7 @@ class DutiesListEventMethods(MethodToEvent):
message="List of Duties records",
)
class DutiesGetByUUIDEventMethods(MethodToEvent):
event_type = "GET"

View File

@ -195,9 +195,7 @@ class Employee2PeopleEmployEventMethods(MethodToEvent):
selected_staff = Staff.filter_one(
Staff.uu_id == data.staff_uu_id,
).data
selected_people = People.filter_one(
People.uu_id == data.people_uu_id
).data
selected_people = People.filter_one(People.uu_id == data.people_uu_id).data
if not selected_staff:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,

View File

@ -76,9 +76,7 @@ class StaffGetByUUIDEventMethods(MethodToEvent):
duties_id = Duties.filter_one(
Duties.uu_id == data.duties_uu_id,
).data
selected_staffs = Staff.filter_all(
Staff.duties_id == duties_id.id
)
selected_staffs = Staff.filter_all(Staff.duties_id == duties_id.id)
return JSONResponse(
content={
"completed": True,

View File

@ -36,7 +36,6 @@ class DecisionBookListEventMethods(MethodToEvent):
):
records = []
if isinstance(token_dict, EmployeeTokenObject):
build_id_list_query = Build.select_action(
employee_id=token_dict.selected_company.employee_id
)
@ -49,12 +48,12 @@ class DecisionBookListEventMethods(MethodToEvent):
BuildDecisionBook.filter_attr = list_options
records = BuildDecisionBook.filter_all(
BuildDecisionBook.build_id.in_([build.id for build in build_id_list]),
).data
)
elif isinstance(token_dict, OccupantTokenObject):
BuildDecisionBook.filter_attr = list_options
records = BuildDecisionBook.filter_all(
BuildDecisionBook.build_id == token_dict.selected_occupant.build_id,
).data
)
return AlchemyJsonResponse(
completed=True,
message="DecisionBook are listed successfully",
@ -154,7 +153,9 @@ class DecisionBookCreateEventMethods(MethodToEvent):
int(decision_period_date.date().month),
int(decision_period_date.date().day),
)
data_dict["expiry_ends"] = str(data_dict["expiry_starts"].shift(years=1, days=-1))
data_dict["expiry_ends"] = str(
data_dict["expiry_starts"].shift(years=1, days=-1)
)
data_dict["expiry_starts"] = str(data_dict["expiry_starts"])
build_decision_book = BuildDecisionBook.find_or_create(**data_dict)
build_decision_book.save()

View File

@ -25,6 +25,7 @@ from api_library.date_time_actions.date_functions import system_arrow, client_ar
from api_validations.validations_request import (
InsertBuildDecisionBookItems,
ListOptions,
ListDecisionBook,
)
@ -39,7 +40,7 @@ class DecisionBookDecisionBookItemsListEventMethods(MethodToEvent):
@classmethod
def building_decision_book_items_list(
cls,
data: ListDecisionBook,
data: ListOptions,
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
):
decision_book = BuildDecisionBook.filter_one(
@ -141,7 +142,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
payment_amount = -1 * (
abs(payment_amount) + (50 - float(abs(payment_amount)) % 50)
)
BuildDecisionBookPayments.create(
created_book_payment = BuildDecisionBookPayments.find_or_create(
build_parts_id=build_part_single.id,
build_parts_uu_id=str(build_part_single.uu_id),
payment_amount=payment_amount,
@ -153,6 +154,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
period_time=f"{local_date.year}-{str(local_date.month).zfill(2)}",
**book_payment_dict,
)
created_book_payment.save_and_confirm()
local_date = local_date.shift(days=2)
part_key = str(build_part_single.due_part_key).upper()
if part_key not in payment_return_dict:
@ -181,7 +183,6 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
payment_plan_time_periods=str(data_info_type.key),
build_decision_book_item_id=decision_book_item.id,
build_decision_book_item_uu_id=str(decision_book_item.uu_id),
is_confirmed=True,
currency=currency,
)
payment_types = ApiEnumDropdown.get_debit_search(search_debit="DT-D")
@ -235,7 +236,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
BuildParts.part_no == 0,
).data
occupant_man = OccupantTypes.filter_by_one(
occupant_code="MT-VPR", occupant_category_type="MT"
system=True, occupant_code="MT-VPR", occupant_category_type="MT"
).data
manager_living_space = BuildLivingSpace.filter_one(
BuildLivingSpace.build_parts_id == management_room.id,
@ -270,7 +271,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
f"is assigned to {occupant_man.occupant_description}"
)
project_lead = ApiEnumDropdown.filter_by_one(
key="PTT-LDR", enum_class="ProjectTeamTypes"
system=True, key="PTT-LDR", enum_class="ProjectTeamTypes"
).data
project_person = BuildDecisionBookProjectPerson.find_or_create(
build_decision_book_project_id=book_project_created.id,
@ -281,12 +282,12 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
project_team_type_uu_id=str(project_lead.uu_id),
)
BuildDecisionBookProjects.save()
return
return book_project_created
elif data_info_type.key == "BDT-SF":
elif data_info_type.key == "BDT-S":
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="BDT-SF is not implemented yet. Check info type and try again",
detail="BDT-S is not implemented yet. Check info type and try again",
)
else:
raise HTTPException(
@ -309,7 +310,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
elif isinstance(token_dict, OccupantTokenObject):
data_dict = data.dump()
occupant_wrt = OccupantTypes.filter_by_one(
occupant_code="MT-WRT", occupant_category_type="MT"
system=True, occupant_code="MT-WRT", occupant_category_type="MT"
).data
if token_dict.selected_occupant.occupant_type_id != occupant_wrt.id:
@ -337,30 +338,29 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
data_dict["build_decision_book_uu_id"] = str(decision_book.uu_id)
data_dict["is_confirmed"] = True
data_info_types, data_info_type = ApiEnumDropdown.due_type_search(), None
data_info_type = ApiEnumDropdown.filter_by_one(
system=True, enum_class="BuildDuesTypes", key="BDT-I",
).data
data_info_types = ApiEnumDropdown.due_type_search()
for info_type in data_info_types:
if str(info_type.uu_id) == data_dict["info_type_uu_id"]:
data_info_type = info_type
break
if not data_info_type:
row_is_debit = str(data_info_type.key).upper() in ["BDT-A", "BDT-D"]
row_is_project = str(data_info_type.key).upper() in ["BDT-R", "BDT-L", "BDT-S"]
debit_dates_required = not data_dict["debit_start_date"] or not data_dict["debit_end_date"]
if any([row_is_debit, row_is_project]) and debit_dates_required:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Info Type is not valid. Check info type and try again",
detail="Debit Start Date and Debit End Date is required for this payment type. "
"Check debit start date and debit end date and try again",
)
if str(data_info_type.key).upper() in ["BDT-A", "BDT-R", "BDT-L", "BDT-SF"]:
if not data_dict["debit_start_date"] or not data_dict["debit_end_date"]:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Debit Start Date and Debit End Date is required for this payment type. "
"Check debit start date and debit end date and try again",
)
data_dict["info_type_id"] = data_info_type.id
data_dict["info_type_uu_id"] = str(data_info_type.uu_id)
unit_price, unit_type = float(data_dict["unit_price"]), str(
data_dict["unit_type"]
)
unit_price, unit_type = float(data_dict["unit_price"]), str(data_dict["unit_type"])
debit_start_date, debit_end_date = (
data_dict["debit_start_date"],
data_dict["debit_end_date"],
@ -376,58 +376,49 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
data_dict["currency"],
)
if new_decision_book_item := BuildDecisionBookItems.find_or_create(
new_decision_book_item = BuildDecisionBookItems.find_or_create(
**data_dict
)
if created_payment_records_dict := cls.create_payment_records_for_each_build_part(
data_info_type=data_info_type,
build_id=decision_book.build_id,
unit_price=unit_price,
unit_type=unit_type.upper(),
decision_book=decision_book,
decision_book_item=new_decision_book_item,
unit_price_is_fixed=data.unit_price_is_fixed,
debit_start_date=debit_start_date,
debit_end_date=debit_end_date,
currency=currency,
):
if new_decision_book_item.is_found:
return JSONResponse(
status_code=status.HTTP_200_OK,
content=dict(
message=f"Decision Book Item is already exist for given Decision Book UUID {decision_book.uu_id}",
completed=True,
data=new_decision_book_item.get_dict(),
),
)
if created_payment_records_dict := cls.create_payment_records_for_each_build_part(
data_info_type=data_info_type,
build_id=decision_book.build_id,
unit_price=unit_price,
unit_type=unit_type.upper(),
decision_book=decision_book,
decision_book_item=new_decision_book_item,
unit_price_is_fixed=data.unit_price_is_fixed,
debit_start_date=debit_start_date,
debit_end_date=debit_end_date,
currency=currency,
):
if data_info_type.key == "BDT-A" or data_info_type.key == "BDT-D":
if data_info_type.key == "BDT-D":
item_comment = "Regular Payment Plan : "
else:
item_comment = "Additional Payment Plan : "
for key, value in dict(
sorted(
created_payment_records_dict.items(),
key=lambda x: x[1],
reverse=True,
)
).items():
item_comment += f" {key} | {abs(float(value))} {currency}, "
item_comment = item_comment[:-2]
new_decision_book_item.update(item_comment=item_comment)
new_decision_book_item.update(is_payment_created=True)
return JSONResponse(
status_code=status.HTTP_200_OK,
content=dict(
message=f"Decision Book Item has created for given Decision Book UUID {decision_book.uu_id}",
completed=True,
data=new_decision_book_item.get_dict(),
),
)
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Decision Book Item is not created. Check info type and info no and try again. Unique constraint index is implemented for info type and info no",
)
if row_is_debit:
if data_info_type.key == "BDT-D":
item_comment = "Regular Payment Plan : "
else:
item_comment = "Additional Payment Plan : "
for key, value in dict(
sorted(
created_payment_records_dict.items(),
key=lambda x: x[1],
reverse=True,
)
).items():
item_comment += f" {key} | {abs(float(value))} {currency}, "
item_comment = item_comment[:-2]
new_decision_book_item.update(item_comment=item_comment)
new_decision_book_item.update(is_payment_created=True)
return JSONResponse(
status_code=status.HTTP_200_OK,
content=dict(
message=f"Decision Book Item has created for given Decision Book UUID {decision_book.uu_id}",
completed=True,
data=new_decision_book_item.get_dict(),
),
)
# raise HTTPException(
# status_code=status.HTTP_400_BAD_REQUEST,
# detail="Decision Book Item is not created. Check info type and info no and try again. Unique constraint index is implemented for info type and info no",
# )
class DecisionBookDecisionBookItemsUpdateEventMethods(MethodToEvent):

View File

@ -70,8 +70,10 @@ class DecisionBookPersonAddEventMethods(MethodToEvent):
detail=f"No Decision Book is match with given UUID {data.build_decision_book_uu_id}",
)
manager_occupant_type = OccupantTypes.filter_by_one(
occupant_code="BU-MNG", occupant_category_type="BU"
).get(1)
system=True,
occupant_code="BU-MNG",
occupant_category_type="BU"
).data
if (
not manager_occupant_type.uu_id
== token_dict.selected_occupant.occupant_type_uu_id
@ -82,9 +84,10 @@ class DecisionBookPersonAddEventMethods(MethodToEvent):
)
assign_occupant_type = OccupantTypes.filter_by_one(
system=True,
uu_id=data.occupant_type_uu_id,
occupant_category_type="MT",
).get(1)
).data
if not assign_occupant_type:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -95,9 +98,7 @@ class DecisionBookPersonAddEventMethods(MethodToEvent):
BuildDecisionBookPerson.token == data.token,
BuildDecisionBookPerson.build_decision_book_uu_id
== data.build_decision_book_uu_id,
BuildDecisionBookPerson.is_confirmed == True,
BuildDecisionBookPerson.active == True,
).get(1)
).data
if not manger_book_person:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -107,7 +108,7 @@ class DecisionBookPersonAddEventMethods(MethodToEvent):
BuildDecisionBookInvitations.id == manger_book_person.invite_id,
BuildDecisionBookInvitations.build_id
== token_dict.selected_occupant.build_id,
).get(1)
).data
if not book_invite:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -116,9 +117,7 @@ class DecisionBookPersonAddEventMethods(MethodToEvent):
selected_book_person = BuildDecisionBookPerson.filter_one(
BuildDecisionBookPerson.invite_id == book_invite.id,
BuildDecisionBookPerson.person_uu_id == data.person_uu_id,
BuildDecisionBookPerson.is_confirmed == True,
BuildDecisionBookPerson.active == True,
).get(1)
).data
if not selected_book_person:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -173,12 +172,10 @@ class DecisionBookPersonAttendEventMethods(MethodToEvent):
detail="Employee cannot create decision book invitations",
)
token_user = Users.filter_one(Users.id == token_dict.user_id).get(1)
token_user = Users.filter_one(Users.id == token_dict.user_id).data
invitation_person = BuildDecisionBookPerson.filter_one(
BuildDecisionBookPerson.token == data.token,
BuildDecisionBookPerson.active == True,
BuildDecisionBookPerson.is_confirmed == True,
).get(1)
).data
if not invitation_person:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -197,8 +194,7 @@ class DecisionBookPersonAttendEventMethods(MethodToEvent):
BuildDecisionBookInvitations.id == invitation_person.invite_id,
BuildDecisionBookInvitations.build_id
== token_dict.selected_occupant.build_id,
BuildDecisionBookInvitations.active == True,
).get(1)
).data
if not invitation:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -246,12 +242,10 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
BuildDecisionBookPerson.token == data.token,
BuildDecisionBookPerson.build_living_space_id
== token_dict.selected_occupant.living_space_id,
BuildDecisionBookPerson.active == True,
BuildDecisionBookPerson.is_confirmed == True,
).get(1)
).data
manager_occupant_type = OccupantTypes.filter_by_one(
occupant_code="BU-MNG", occupant_category_type="BU"
).get(1)
system=True, occupant_code="BU-MNG", occupant_category_type="BU"
).data
book_person_manager.check_occupant_type(manager_occupant_type)
# supervisor_occupant_type = OccupantTypes.find_or_abort(occupant_code="BU-SPV", occupant_category_type="BU")
@ -261,8 +255,7 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
BuildDecisionBookInvitations.id == book_person_manager.invite_id,
BuildDecisionBookInvitations.build_id
== token_dict.selected_occupant.build_id,
BuildDecisionBookInvitations.active == True,
).get(1)
).data
if not invitation:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -270,8 +263,8 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
)
assign_occupant_type = OccupantTypes.filter_by_one(
uu_id=data.occupant_type_uu_id
).get(1)
system=True, uu_id=data.occupant_type_uu_id,
).data
if not assign_occupant_type:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -286,7 +279,7 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
BuildLivingSpace.build_parts_id.in_(
[build.id for build in build_parts_of_token]
),
).get(1)
).data
if not selected_living_space:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -298,35 +291,31 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
BuildDecisionBookPerson.build_living_space_id
== selected_living_space.id,
BuildDecisionBookPerson.invite_id == invitation.id,
BuildDecisionBookPerson.active == True,
).get(1)
).data
)
if not book_person_to_assign:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"Person not found in the invitation list. Please check person uuid: {data.person_uu_id}",
detail=f"Person not found in the invitation list. Please check person uuid: {data.build_living_space_uu_id}",
)
if not book_person_to_assign.is_attending:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=f"Person is declined the invitation. This person is not attending the meeting. "
f"Please check person uuid: {data.person_uu_id}. Invite UUID: {invitation.uu_id}",
f"Please check person uuid: {data.build_living_space_uu_id}. Invite UUID: {invitation.uu_id}",
)
if assign_occupant_type.occupant_code in ("MT-PRS", "MT-WRT"):
occupant_type_unique = OccupantTypes.filter_by_one(
system=True,
occupant_code=assign_occupant_type.occupant_code,
occupant_category_type="MT",
).get(1)
).data
if assigned_book_person_occupant := BuildDecisionBookPersonOccupants.filter_one(
BuildDecisionBookPersonOccupants.invite_id == invitation.id,
BuildDecisionBookPersonOccupants.occupant_type_id
== occupant_type_unique.id,
BuildDecisionBookPersonOccupants.active == True,
BuildDecisionBookPersonOccupants.is_confirmed == True,
).get(
1
):
).data:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=f"Only one person can be assigned to {assign_occupant_type.occupant_code} type"
@ -338,8 +327,6 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
BuildDecisionBookPersonOccupants.invite_id == invitation.id,
BuildDecisionBookPersonOccupants.occupant_type_id
== manager_occupant_type.id,
BuildDecisionBookPersonOccupants.active == True,
BuildDecisionBookPersonOccupants.is_confirmed == True,
)
person_occupant_manager.query.delete()

View File

@ -63,8 +63,8 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
)
# Check token posses the occupant type of Build Manager
occupant_manager = OccupantTypes.filter_by_one(
occupant_category_type="BU", occupant_code="BU-MNG"
).get(1)
system=True, occupant_category_type="BU", occupant_code="BU-MNG"
).data
if not token_dict.selected_occupant.occupant_type_id == occupant_manager.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
@ -75,8 +75,7 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
decision_book = BuildDecisionBook.filter_one(
BuildDecisionBook.uu_id == data.build_decision_book_uu_id,
BuildDecisionBook.build_id == token_dict.selected_occupant.build_id,
BuildDecisionBook.active == True,
).get(1)
).data
if not decision_book:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@ -84,22 +83,12 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
)
occupant_building = Build.filter_one(
Build.id == token_dict.selected_occupant.build_id
).get(1)
# Check meeting type is valid
meeting_type = ApiEnumDropdown.filter_by_one(
enum_class="MeetingTypes",
).get(1)
if not meeting_type:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Meeting type not found",
)
).data
# Check planned decision book date is valid
if (
not system_arrow.get(data.planned_date).date()
>= system_arrow.shift(days=1).date()
>= system_arrow.now().shift(days=1).date()
):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
@ -107,32 +96,21 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
)
# Create an invitation for specific invitation type to start invite sending process
planned_date_expires = (
str(system_arrow.get(data.planned_date).shift(days=15).date()),
)
planned_date_expires = str(system_arrow.get(data.planned_date).shift(days=15).date())
book_invitation = BuildDecisionBookInvitations.find_or_create(
build_id=token_dict.selected_occupant.build_id,
build_uu_id=token_dict.selected_occupant.build_uuid,
decision_book_id=decision_book.id,
decision_book_uu_id=str(decision_book.uu_id),
invitation_type=meeting_type.key,
invitation_type=str(decision_book.decision_type),
living_part_count=occupant_building.livable_part_count,
living_part_percentage=0.51,
message=data.message,
planned_date=data.planned_date,
planned_date=str(system_arrow.get(data.planned_date)),
planned_date_expires=planned_date_expires,
expiry_ends=str(system_arrow.get(data.planned_date).shift(days=15).date()),
is_confirmed=True,
)
if book_invitation.is_found:
detail_message = (
f"Invitation with: {str(book_invitation.planned_date)} already exists"
f" for {book_invitation.invitation_type}"
)
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=detail_message,
)
book_invitation.save_and_confirm()
# Get all the parts of the building that is occupant in token
build_parts = BuildParts.filter_all(
@ -164,12 +142,12 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
)
# Send invitation to all the users as attend and update the manager as build manager
attendance_occupant_type = OccupantTypes.find_or_abort(
occupant_code="MT-ATT", occupant_category_type="MT"
)
manager_occupant_type = OccupantTypes.find_or_abort(
occupant_code="BU-MNG", occupant_category_type="BU"
)
attendance_occupant_type = OccupantTypes.filter_by_one(
system=True, occupant_code="MT-ATT", occupant_category_type="MT"
).data
manager_occupant_type = OccupantTypes.filter_by_one(
system=True, occupant_code="BU-MNG", occupant_category_type="BU"
).data
build_decision_book_person_dict = dict(
build_decision_book_id=decision_book.id,
@ -179,7 +157,6 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
send_date=str(system_arrow.now().date()),
expiry_starts=decision_book.expiry_starts,
expiry_ends=decision_book.expiry_ends,
is_confirmed=True,
)
# Check if the invitation is already created at database
for build_living_spaces_user in build_living_spaces_people:
@ -201,12 +178,12 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
person_id=build_living_spaces_user.person_id,
token=Users.generate_token(40),
)
invitations_person.save_and_confirm()
invitations_person.add_occupant_type(occupant_type=attendance_occupant_type)
if invitations_person and not invitations_person.is_found:
if invitations_person:
print(f'"{invitations_person.token}",')
spaces_user = Users.filter_one(
Users.active == True,
Users.is_confirmed == True,
Users.person_id == build_living_spaces_user.person_id,
).data
# print(
@ -222,18 +199,22 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
BuildDecisionBookPerson.invite_id == book_invitation.id,
BuildDecisionBookPerson.build_living_space_id.in_(
[
manager_living_space.id
for manager_living_space in manager_living_spaces.data
manager_living_space.id for manager_living_space in manager_living_spaces.data
]
),
system=True,
)
manager_people_occupants = BuildDecisionBookPersonOccupants.filter_all(
BuildDecisionBookPersonOccupants.build_decision_book_person_id
== manager_people.get(1).id,
system=True,
)
manager_people_occupants.query.delete()
manager_people.query.delete()
if manager_people_occupants.count:
manager_people_occupants.query.delete()
BuildDecisionBookPersonOccupants.save()
if manager_people.count:
manager_people.query.delete()
BuildDecisionBookPerson.save()
if book_person_manager := BuildDecisionBookPerson.find_or_create(
**build_decision_book_person_dict,
@ -244,6 +225,7 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
person_id=token_dict.person_id,
token=Users.generate_token(40),
):
book_person_manager.save_and_confirm()
book_person_manager.add_occupant_type(occupant_type=manager_occupant_type)
print(f"Manager Token : {book_person_manager.token}")
BuildDecisionBookPerson.save()

View File

@ -32,9 +32,7 @@ class ModulesBindOccupantEventMethods(MethodToEvent):
living_space = BuildLivingSpace.filter_one(
BuildLivingSpace.id == build_living_space_id,
).data
modules = Modules.filter_one(
Modules.id == modules_id
).data
modules = Modules.filter_one(Modules.id == modules_id).data
if not living_space or not modules:
print(f"Giving living Space or Modules: {modules.module_name} not found")
@ -43,7 +41,9 @@ class ModulesBindOccupantEventMethods(MethodToEvent):
if expires_at:
service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
else:
service_build_dict["expires_at"] = str(system_arrow.get(living_space.expiry_ends))
service_build_dict["expires_at"] = str(
system_arrow.get(living_space.expiry_ends)
)
for service in modules.retrieve_services():
ServiceBindOccupantEventMethods.bind_services_occupant_system(

View File

@ -35,6 +35,7 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
cls, build_living_space_id: int, service_id: int, expires_at: str = None
):
from sqlalchemy.dialects.postgresql import insert
living_space = BuildLivingSpace.filter_one(
BuildLivingSpace.id == build_living_space_id,
).data
@ -218,10 +219,8 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
)
count_row = session_execute.rowcount
print(f"{count_row} events are added to employee {employee.uu_id}")
Services.save()
for service_event in service_events:
service_event.is_confirmed = True
Service2Events.save()
service_event.save_and_confirm()
@classmethod
def bind_services_employee_super_user(

View File

@ -45,9 +45,7 @@ class UserListEventMethods(MethodToEvent):
people_ids = list_options.query.pop("user_uu_id_list")
people_id_list = (
user.person_id
for user in Users.filter_all(
Users.uu_id.in_(people_ids)
).data
for user in Users.filter_all(Users.uu_id.in_(people_ids)).data
)
Users.filter_attr = list_options
records = Users.filter_all(
@ -80,12 +78,11 @@ class UserCreateEventMethods(MethodToEvent):
data: InsertUsers,
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
):
created_user = Users.create_action(create_user=data)
created_user.related_company = token_dict.selected_company.company_uu_id
created_user = Users.create_action(create_user=data, token_dict=token_dict)
domain_via_user = DomainViaUser(
**{"user_uu_id": str(created_user.uu_id), "main_domain": "evyos.com.tr"}
)
created_user.save()
created_user.save_and_confirm()
mongo_query_identity = MongoQueryIdentity(
company_uuid=created_user.related_company,
)

View File

@ -136,12 +136,8 @@ def save_access_token_to_redis(
companies_uu_id_list, companies_id_list = [], []
duty_uu_id_list, duty_id_list = [], []
for employee in list_employee:
staff = Staff.filter_one(
Staff.id == employee.staff_id
).data
if duties := Duties.filter_one(
Duties.id == staff.duties_id
).data:
staff = Staff.filter_one(Staff.id == employee.staff_id).data
if duties := Duties.filter_one(Duties.id == staff.duties_id).data:
if duty_found := Duty.filter_by_one(id=duties.duties_id).data:
duty_uu_id_list.append(str(duty_found.uu_id))
duty_id_list.append(duty_found.id)

View File

@ -39,7 +39,7 @@ class AlchemyJsonResponse:
),
)
first_item = getattr(cls.result, 'data', None)
first_item = getattr(cls.result, "data", None)
if not first_item:
return JSONResponse(
status_code=cls.status_code,

View File

@ -10,7 +10,7 @@ from .address import (
UpdateAddress,
UpdatePostCode,
InsertPostCode,
SearchAddress
SearchAddress,
)
from .application import (
SingleEnumUUID,

View File

@ -77,13 +77,14 @@ class UpdateDecisionBook(PydanticBaseModel):
class InsertBuildDecisionBookItems(BaseModelRegular):
token: str
info_type_uu_id: str
unit_price: float
item_comment: str
currency: Optional[str] = "TL"
unit_type: Optional[str] = "M2"
debit_start_date: Optional[str] = None
debit_end_date: Optional[str] = None
unit_price_is_fixed: Optional[bool] = False
item_comment: Optional[str] = None
unit_price: Optional[float] = 0.00
# build_decision_book_uu_id: str
# item_objection: Optional[str] = None

View File

@ -209,6 +209,7 @@ class UserLoginModule(AuthModule):
People,
MongoQueryIdentity,
)
found_user = Users.check_user_exits(
access_key=data.access_key, domain=data.domain
)
@ -260,9 +261,7 @@ class UserLoginModule(AuthModule):
no_address_validates = mongo_db.mongo_engine.get_all()[0] == 0
record_id = uuid.uuid4().__str__()
notice_link = ApiStatic.blacklist_login(record_id=record_id)
found_people = People.filter_one(
People.id == found_user.person_id
).data
found_people = People.filter_one(People.id == found_user.person_id).data
access_via_user = query_engine.update_access_history_via_user(
AccessHistoryViaUser(
**{

View File

@ -437,10 +437,16 @@ class AccountRecords(CrudCollection):
status_id: Mapped[int] = mapped_column(SmallInteger, server_default="0")
approved_record: Mapped[bool] = mapped_column(Boolean, server_default="0")
import_file_name: Mapped[str] = mapped_column(String, nullable=True, comment="XLS Key")
import_file_name: Mapped[str] = mapped_column(
String, nullable=True, comment="XLS Key"
)
receive_debit: Mapped[int] = mapped_column(ForeignKey("api_enum_dropdown.id"), nullable=True)
receive_debit_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Debit UU ID")
receive_debit: Mapped[int] = mapped_column(
ForeignKey("api_enum_dropdown.id"), nullable=True
)
receive_debit_uu_id: Mapped[str] = mapped_column(
String, nullable=True, comment="Debit UU ID"
)
budget_type: Mapped[int] = mapped_column(
ForeignKey("api_enum_dropdown.id"), nullable=True
)
@ -449,20 +455,32 @@ class AccountRecords(CrudCollection):
)
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=True)
company_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Company UU ID")
send_company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=True)
send_company_uu_id = mapped_column(String, nullable=True, comment="Send Company UU ID" )
company_uu_id: Mapped[str] = mapped_column(
String, nullable=True, comment="Company UU ID"
)
send_company_id: Mapped[int] = mapped_column(
ForeignKey("companies.id"), nullable=True
)
send_company_uu_id = mapped_column(
String, nullable=True, comment="Send Company UU ID"
)
customer_id: Mapped[int] = mapped_column(ForeignKey("people.id"), nullable=True)
customer_uu_id = mapped_column(String, nullable=True, comment="Customer UU ID")
send_person_id: Mapped[int] = mapped_column(ForeignKey("people.id"), nullable=True)
send_person_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Send Person UU ID")
approving_accounting_person: Mapped[int] = mapped_column(ForeignKey("people.id"), nullable=True)
send_person_uu_id: Mapped[str] = mapped_column(
String, nullable=True, comment="Send Person UU ID"
)
approving_accounting_person: Mapped[int] = mapped_column(
ForeignKey("people.id"), nullable=True
)
approving_accounting_person_uu_id: Mapped[str] = mapped_column(
String, nullable=True, comment="Approving Accounting Person UU ID"
)
# build_id: Mapped[int] = mapped_column(ForeignKey("build.id"), nullable=True)
build_parts_id: Mapped[int] = mapped_column(ForeignKey("build_parts.id"), nullable=True)
build_parts_id: Mapped[int] = mapped_column(
ForeignKey("build_parts.id"), nullable=True
)
build_parts_uu_id: Mapped[str] = mapped_column(
String, nullable=True, comment="Build Parts UU ID"
)

View File

@ -24,9 +24,9 @@ class CrypterEngine(CrudCollection):
@classmethod
def get_valid_keys(cls, row=None):
cls.encrypt_list, cls.decrypt_list = [], []
if not cls.filter_all(
cls.created_at > datetime.now() - timedelta(days=29)
).get(1):
if not cls.filter_all(cls.created_at > datetime.now() - timedelta(days=29)).get(
1
):
cls.create_encrypt_keys(count=100)
if decrypt_identifier := getattr(row, "cryp_uu_id", None):
if decrypt_row := cls.find_one(uu_id=str(decrypt_identifier)):

View File

@ -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(

View File

@ -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"
)

View File

@ -120,7 +120,7 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
key_ = cls.__annotations__.get(key, None)
is_primary, value_type = key in cls.primary_keys, type(val)
row_attr = bool(getattr(getattr(cls, key), "foreign_keys", None))
if is_primary or row_attr and key_ == Mapped[int]:
if is_primary or row_attr:
return False, None
elif val is None:
return True, None
@ -136,12 +136,16 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
elif key_ == Mapped[int]:
return True, int(val)
elif key_ == Mapped[TIMESTAMP]:
return True, str(client_arrow.get(str(val)).format("DD-MM-YYYY HH:mm:ss"))
return True, str(
client_arrow.get(str(val)).format("DD-MM-YYYY HH:mm:ss")
)
elif key_ == Mapped[str]:
return True, str(val)
else:
if isinstance(val, datetime.datetime):
return True, str(client_arrow.get(str(val)).format("DD-MM-YYYY HH:mm:ss"))
return True, str(
client_arrow.get(str(val)).format("DD-MM-YYYY HH:mm:ss")
)
elif isinstance(value_type, bool):
return True, bool(val)
elif isinstance(value_type, float) or isinstance(value_type, Decimal):
@ -241,12 +245,12 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
exclude_list = [
element
for element in self.__system_default_model__
if str(element)[-2:] == "id" and str(element)[-5:].lower() == 'uu_id'
if str(element)[-2:] == "id" and str(element)[-5:].lower() == "uu_id"
]
columns_include_list = list(set(include).difference(set(exclude_list)))
# columns_include_list.extend([column for column in self.columns if str(column)[-5:].lower() == 'uu_id'])
columns_include_list.extend(['uu_id'])
columns_include_list.extend(["uu_id"])
for key in list(columns_include_list):
val = getattr(self, key)
correct, value_of_database = self.iterate_over_variables(val, key)
@ -265,7 +269,7 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
)
columns_excluded_list = list(set(self.columns).difference(set(exclude)))
# columns_excluded_list.extend([column for column in self.columns if str(column)[-5:].lower() == 'uu_id'])
columns_excluded_list.extend(['uu_id', 'active'])
columns_excluded_list.extend(["uu_id", "active"])
for key in list(columns_excluded_list):
val = getattr(self, key)
@ -280,7 +284,13 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
columns_list = [
columns for columns in columns_list if str(columns)[-2:] != "id"
]
columns_list.extend([column for column in self.columns if str(column)[-5:].lower() == 'uu_id'])
columns_list.extend(
[
column
for column in self.columns
if str(column)[-5:].lower() == "uu_id"
]
)
for remove_field in self.__system_default_model__:
if remove_field in columns_list:
columns_list.remove(remove_field)

View File

@ -68,9 +68,7 @@ class Modules(CrudCollection):
is_default_module = mapped_column(Boolean, server_default="0")
def retrieve_services(self):
services = Services.filter_all(
Services.module_id == self.id
).data
services = Services.filter_all(Services.module_id == self.id).data
if not services:
self.raise_http_exception(
status_code="HTTP_404_NOT_FOUND",
@ -145,13 +143,9 @@ class Event2Employee(CrudCollection):
@classmethod
def get_event_id_by_employee_id(cls, employee_id) -> (list, list):
active_events = cls.filter_all(
cls.employee_id == employee_id
)
active_events = cls.filter_all(cls.employee_id == employee_id)
active_events_id = [event.event_id for event in active_events.data]
active_events = Events.filter_all(
Events.id.in_(active_events_id)
)
active_events = Events.filter_all(Events.id.in_(active_events_id))
active_events_uu_id = [str(event.uu_id) for event in active_events.data]
return active_events_id, active_events_uu_id
@ -191,9 +185,7 @@ class Event2Occupant(CrudCollection):
cls.build_living_space_id == build_living_space_id,
).data
active_events_id = [event.event_id for event in active_events]
active_events = Events.filter_all(
Events.id.in_(active_events_id)
).data
active_events = Events.filter_all(Events.id.in_(active_events_id)).data
active_events_uu_id = [str(event.uu_id) for event in active_events]
return active_events_id, active_events_uu_id

View File

@ -136,10 +136,11 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
return getattr(self.priority, "priority_code", 0) == 0
@classmethod
def create_action(cls, create_user: InsertUsers):
def create_action(cls, create_user: InsertUsers, token_dict):
found_person = People.filter_one(
People.uu_id == create_user.people_uu_id,
).data
if not found_person:
raise HTTPException(status_code=400, detail="Person not found.")
if (
@ -156,8 +157,9 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
del create_dict["people_uu_id"]
create_dict["person_id"] = found_person.id
create_dict["person_uu_id"] = str(found_person.uu_id)
create_dict["related_company"] = token_dict.selected_company.company_uu_id
created_user = cls.find_or_create(**create_dict)
created_user.reset_password_token()
created_user.reset_password_token(found_user=created_user)
return created_user
@classmethod
@ -182,7 +184,7 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
from databases import Employees, Duties
found_person = People.filter_one(
People.id==self.person_id,
People.id == self.person_id,
)
found_employees = Employees.filter_by_active(
people_id=found_person.id, is_confirmed=True
@ -416,8 +418,12 @@ class AddressPostcode(CrudCollection, SelectActionWithEmployee):
__many__table__ = RelationshipEmployee2PostCode
street_id: Mapped[int] = mapped_column(ForeignKey("address_street.id"))
street_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="Street UUID")
postcode: Mapped[str] = mapped_column(String(32), nullable=False, comment="Postcode")
street_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="Street UUID"
)
postcode: Mapped[str] = mapped_column(
String(32), nullable=False, comment="Postcode"
)
__table_args__ = ({"comment": "Postcode Information"},)
@ -456,10 +462,12 @@ class Addresses(CrudCollection):
street_id: Mapped[int] = mapped_column(
ForeignKey("address_street.id"), nullable=False
)
street_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="Street UUID")
street_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="Street UUID"
)
@classmethod
def list_via_employee(cls, token_dict, filter_expr = None):
def list_via_employee(cls, token_dict, filter_expr=None):
post_code_list = RelationshipEmployee2PostCode.filter_all(
RelationshipEmployee2PostCode.employee_id
== token_dict.selected_company.employee_id,
@ -470,9 +478,7 @@ class Addresses(CrudCollection):
status_code=404,
detail="User has no post code registered. User can not list addresses.",
)
cls.pre_query = cls.filter_all(
cls.post_code_id.in_(post_code_id_list)
).query
cls.pre_query = cls.filter_all(cls.post_code_id.in_(post_code_id_list)).query
filter_cls = cls.filter_all(*filter_expr or [])
cls.pre_query = None
return filter_cls.data
@ -527,9 +533,15 @@ class AddressGeographicLocations(CrudCollection):
__tablename__ = "address_geographic_locations"
__exclude__fields__ = []
geo_table: Mapped[str] = mapped_column(String, nullable=False, comment="Address Table Name")
geo_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="Address Table ID")
geo_name: Mapped[str] = mapped_column(String, nullable=False, comment="Geographic Location Name")
geo_table: Mapped[str] = mapped_column(
String, nullable=False, comment="Address Table Name"
)
geo_id: Mapped[int] = mapped_column(
Integer, nullable=False, comment="Address Table ID"
)
geo_name: Mapped[str] = mapped_column(
String, nullable=False, comment="Geographic Location Name"
)
geo_latitude: Mapped[float] = mapped_column(
Numeric(20, 6), server_default="0", comment="Geographic Location Name"
)
@ -572,10 +584,18 @@ class AddressCountry(CrudCollection):
__tablename__ = "address_country"
__exclude__fields__ = []
country_code: Mapped[str] = mapped_column(String(16), nullable=False, comment="Country Code")
country_name: Mapped[str] = mapped_column(String, nullable=False, comment="Country Name")
money_code: Mapped[str] = mapped_column(String(12), nullable=True, comment="Money Code")
language: Mapped[str] = mapped_column(String, nullable=True, comment="Language Code")
country_code: Mapped[str] = mapped_column(
String(16), nullable=False, comment="Country Code"
)
country_name: Mapped[str] = mapped_column(
String, nullable=False, comment="Country Name"
)
money_code: Mapped[str] = mapped_column(
String(12), nullable=True, comment="Money Code"
)
language: Mapped[str] = mapped_column(
String, nullable=True, comment="Language Code"
)
address_geographic_id: Mapped[int] = mapped_column(
BigInteger, nullable=True, comment="Address Geographic Id"
)
@ -595,17 +615,29 @@ class AddressState(CrudCollection):
__tablename__ = "address_state"
__exclude__fields__ = []
state_code: Mapped[str] = mapped_column(String(16), nullable=False, comment="State Code")
state_name: Mapped[str] = mapped_column(String, nullable=False, comment="State Name")
licence_plate: Mapped[str] = mapped_column(String(24), nullable=True, comment="Sign Code")
phone_code: Mapped[str] = mapped_column(String(36), nullable=True, comment="Phone Code")
gov_code: Mapped[str] = mapped_column(String(128), nullable=True, comment="Government Code")
state_code: Mapped[str] = mapped_column(
String(16), nullable=False, comment="State Code"
)
state_name: Mapped[str] = mapped_column(
String, nullable=False, comment="State Name"
)
licence_plate: Mapped[str] = mapped_column(
String(24), nullable=True, comment="Sign Code"
)
phone_code: Mapped[str] = mapped_column(
String(36), nullable=True, comment="Phone Code"
)
gov_code: Mapped[str] = mapped_column(
String(128), nullable=True, comment="Government Code"
)
address_geographic_id: Mapped[int] = mapped_column(
BigInteger, nullable=True, comment="Address Geographic Id"
)
country_id: Mapped[int] = mapped_column(ForeignKey("address_country.id"))
country_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="Country UUID")
country_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="Country UUID"
)
__table_args__ = (
Index(
@ -626,17 +658,27 @@ class AddressCity(CrudCollection):
__tablename__ = "address_city"
__exclude__fields__ = []
city_code: Mapped[str] = mapped_column(String(24), nullable=False, comment="City Code")
city_code: Mapped[str] = mapped_column(
String(24), nullable=False, comment="City Code"
)
city_name: Mapped[str] = mapped_column(String, nullable=False, comment="City Name")
licence_plate: Mapped[str] = mapped_column(String(24), nullable=True, comment="Sign Code")
phone_code: Mapped[str] = mapped_column(String(36), nullable=True, comment="Phone Code")
gov_code: Mapped[str] = mapped_column(String(128), nullable=True, comment="Government Code")
licence_plate: Mapped[str] = mapped_column(
String(24), nullable=True, comment="Sign Code"
)
phone_code: Mapped[str] = mapped_column(
String(36), nullable=True, comment="Phone Code"
)
gov_code: Mapped[str] = mapped_column(
String(128), nullable=True, comment="Government Code"
)
address_geographic_id: Mapped[int] = mapped_column(
BigInteger, nullable=True, comment="Address Geographic Id"
)
state_id: Mapped[int] = mapped_column(ForeignKey("address_state.id"))
state_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="State UUID")
state_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="State UUID"
)
__table_args__ = (
Index(
@ -657,10 +699,18 @@ class AddressDistrict(CrudCollection):
__tablename__ = "address_district"
__exclude__fields__ = []
district_code: Mapped[str] = mapped_column(String(16), nullable=False, comment="District Code")
district_name: Mapped[str] = mapped_column(String, nullable=False, comment="District Name")
phone_code: Mapped[str] = mapped_column(String(36), nullable=True, comment="Phone Code")
gov_code: Mapped[str] = mapped_column(String(128), nullable=True, comment="Government Code")
district_code: Mapped[str] = mapped_column(
String(16), nullable=False, comment="District Code"
)
district_name: Mapped[str] = mapped_column(
String, nullable=False, comment="District Name"
)
phone_code: Mapped[str] = mapped_column(
String(36), nullable=True, comment="Phone Code"
)
gov_code: Mapped[str] = mapped_column(
String(128), nullable=True, comment="Government Code"
)
address_geographic_id: Mapped[int] = mapped_column(
BigInteger, nullable=True, comment="Address Geographic Id"
)
@ -668,7 +718,9 @@ class AddressDistrict(CrudCollection):
city_id: Mapped[int] = mapped_column(
ForeignKey("address_city.id"), nullable=False, comment="City ID"
)
city_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="City UUID")
city_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="City UUID"
)
__table_args__ = (
Index(
@ -689,11 +741,19 @@ class AddressLocality(CrudCollection):
__tablename__ = "address_locality"
__exclude__fields__ = []
locality_code: Mapped[str] = mapped_column(String(16), nullable=False, comment="Locality Code")
locality_name: Mapped[str] = mapped_column(String, nullable=False, comment="Locality Name")
locality_code: Mapped[str] = mapped_column(
String(16), nullable=False, comment="Locality Code"
)
locality_name: Mapped[str] = mapped_column(
String, nullable=False, comment="Locality Name"
)
type_code: Mapped[str] = mapped_column(String, nullable=True, comment="Type Name")
type_description: Mapped[str] = mapped_column(String, nullable=True, comment="Type Name")
gov_code: Mapped[str] = mapped_column(String(128), nullable=True, comment="Government Code")
type_description: Mapped[str] = mapped_column(
String, nullable=True, comment="Type Name"
)
gov_code: Mapped[str] = mapped_column(
String(128), nullable=True, comment="Government Code"
)
address_show: Mapped[bool] = mapped_column(Boolean, server_default="1")
address_geographic_id: Mapped[int] = mapped_column(
BigInteger, nullable=True, comment="Address Geographic Id"
@ -702,7 +762,9 @@ class AddressLocality(CrudCollection):
district_id: Mapped[int] = mapped_column(
ForeignKey("address_district.id"), nullable=False, comment="District ID"
)
district_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="District UUID")
district_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="District UUID"
)
__table_args__ = (
Index(
@ -730,8 +792,12 @@ class AddressNeighborhood(CrudCollection):
String, nullable=False, comment="Neighborhood Name"
)
type_code: Mapped[str] = mapped_column(String, nullable=True, comment="Type Name")
type_description: Mapped[str] = mapped_column(String, nullable=True, comment="Type Name")
gov_code: Mapped[str] = mapped_column(String(128), nullable=True, comment="Government Code")
type_description: Mapped[str] = mapped_column(
String, nullable=True, comment="Type Name"
)
gov_code: Mapped[str] = mapped_column(
String(128), nullable=True, comment="Government Code"
)
address_show: Mapped[bool] = mapped_column(Boolean, server_default="1")
address_geographic_id: Mapped[int] = mapped_column(
BigInteger, nullable=True, comment="Address Geographic Id"
@ -740,11 +806,15 @@ class AddressNeighborhood(CrudCollection):
district_id: Mapped[int] = mapped_column(
ForeignKey("address_district.id"), nullable=True, comment="District ID"
)
district_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="District UUID")
district_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="District UUID"
)
locality_id: Mapped[int] = mapped_column(
ForeignKey("address_locality.id"), nullable=True, comment="Locality ID"
)
locality_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="Locality UUID")
locality_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="Locality UUID"
)
__table_args__ = (
Index(
@ -765,11 +835,19 @@ class AddressStreet(CrudCollection):
__tablename__ = "address_street"
__exclude__fields__ = []
street_code: Mapped[str] = mapped_column(String(16), nullable=False, comment="Street Code")
street_name: Mapped[str] = mapped_column(String, nullable=False, comment="Street Name")
street_code: Mapped[str] = mapped_column(
String(16), nullable=False, comment="Street Code"
)
street_name: Mapped[str] = mapped_column(
String, nullable=False, comment="Street Name"
)
type_code: Mapped[str] = mapped_column(String, nullable=True, comment="Type Name")
type_description: Mapped[str] = mapped_column(String, nullable=True, comment="Type Name")
gov_code: Mapped[str] = mapped_column(String(128), nullable=True, comment="Government Code")
type_description: Mapped[str] = mapped_column(
String, nullable=True, comment="Type Name"
)
gov_code: Mapped[str] = mapped_column(
String(128), nullable=True, comment="Government Code"
)
address_geographic_id: Mapped[int] = mapped_column(
BigInteger, nullable=True, comment="Address Geographic Id"
@ -858,7 +936,9 @@ class OccupantTypes(CrudCollection):
__tablename__ = "occupant_types"
__exclude__fields__ = []
occupant_type: Mapped[str] = mapped_column(String, nullable=False, comment="Occupant Type")
occupant_type: Mapped[str] = mapped_column(
String, nullable=False, comment="Occupant Type"
)
occupant_description: Mapped[str] = mapped_column(String, server_default="")
occupant_code: Mapped[str] = mapped_column(String, server_default="")
occupant_category: Mapped[str] = mapped_column(String, server_default="")
@ -908,11 +988,19 @@ class Contracts(CrudCollection):
"expire start is the start date of the contract, expire en is the end date of the contract.",
)
company_id: Mapped[int] = mapped_column(Integer, ForeignKey("companies.id"), nullable=True)
company_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="Company UUID")
company_id: Mapped[int] = mapped_column(
Integer, ForeignKey("companies.id"), nullable=True
)
company_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="Company UUID"
)
person_id: Mapped[int] = mapped_column(Integer, ForeignKey("people.id"), nullable=True)
person_uu_id: Mapped[str] = mapped_column(String, server_default="", comment="Person UUID")
person_id: Mapped[int] = mapped_column(
Integer, ForeignKey("people.id"), nullable=True
)
person_uu_id: Mapped[str] = mapped_column(
String, server_default="", comment="Person UUID"
)
@classmethod
def retrieve_contact_no(cls):

View File

@ -37,7 +37,9 @@ class ApiEnumDropdown(CrudCollection):
def get_debit_search(cls, search_debit: str = None, search_uu_id: str = None):
if search_uu_id:
if search := cls.filter_one(
cls.enum_class.in_(["DebitTypes"]), cls.uu_id == search_uu_id, system=True
cls.enum_class.in_(["DebitTypes"]),
cls.uu_id == search_uu_id,
system=True,
).data:
return search
elif search_debit:
@ -45,16 +47,14 @@ class ApiEnumDropdown(CrudCollection):
cls.enum_class.in_(["DebitTypes"]), cls.key == search_debit, system=True
).data:
return search
return cls.filter_all(
cls.enum_class.in_(["DebitTypes"]), system=True
).data
return cls.filter_all(cls.enum_class.in_(["DebitTypes"]), system=True).data
@classmethod
def get_due_types(cls):
if due_list := cls.filter_all(
cls.enum_class == "BuildDuesTypes",
cls.key.in_(["BDT-A", "BDT-D"]),
system=True
system=True,
).data:
return [due.uu_id.__str__() for due in due_list]
raise HTTPException(
@ -66,20 +66,19 @@ class ApiEnumDropdown(CrudCollection):
def due_type_search(cls, search_management: str = None, search_uu_id: str = None):
if search_uu_id:
if search := cls.filter_one(
cls.enum_class.in_(["BuildDuesTypes"]), cls.uu_id == search_uu_id,
system=True
cls.enum_class.in_(["BuildDuesTypes"]),
cls.uu_id == search_uu_id,
system=True,
).data:
return search
elif search_management:
if search := cls.filter_one(
cls.enum_class.in_(["BuildDuesTypes"]), cls.key == search_management,
system=True
cls.enum_class.in_(["BuildDuesTypes"]),
cls.key == search_management,
system=True,
).data:
return search
return cls.filter_all(
cls.enum_class.in_(["BuildDuesTypes"]),
system=True
).data
return cls.filter_all(cls.enum_class.in_(["BuildDuesTypes"]), system=True).data
def get_enum_dict(self):
return {
@ -94,7 +93,9 @@ class ApiEnumDropdown(CrudCollection):
def uuid_of_enum(cls, enum_class: str, key: str):
return str(
getattr(
cls.filter_one(cls.enum_class == enum_class, cls.key == key, system=True).data,
cls.filter_one(
cls.enum_class == enum_class, cls.key == key, system=True
).data,
"uu_id",
None,
)

View File

@ -10,7 +10,7 @@ engine_config = {
"pool_size": 10,
"max_overflow": 0,
"echo": False,
"isolation_level": "READ COMMITTED"
"isolation_level": "READ COMMITTED",
}
engine = create_engine(**engine_config)

View File

@ -20,7 +20,7 @@ class FilterAttributes:
__session__ = Base.session # The session to use in the model.
pre_query = None # The query to use before the filtering such as: query = cls.query.filter_by(active=True)
total_count = None # The query to use before the filtering such as: query = cls.query.filter_by(active=True)
total_count = None # The query to use before the filtering such as: query = cls.query.filter_by(active=True)
filter_attr = None # The filter attributes to use in the model.
FilterModel = ListOptions
@ -56,6 +56,20 @@ class FilterAttributes:
message=str(e.__context__).split("\n")[0],
)
@classmethod
def save_and_confirm(cls):
"""Saves the updated model to the current entity db."""
try:
cls.is_confirmed = True
cls.__session__.commit()
except SQLAlchemyError as e:
cls.raise_http_exception(
status_code="HTTP_400_BAD_REQUEST",
error_case=e.__class__.__name__,
data={},
message=str(e.__context__).split("\n")[0],
)
@classmethod
def _query(cls):
"""Returns the query to use in the model."""
@ -124,15 +138,9 @@ class FilterAttributes:
@classmethod
def get_active_and_confirmed_query_arg(cls, arg):
"""Add active and confirmed to the query."""
arg = cls.add_new_arg_to_args(
arg, "is_confirmed", cls.is_confirmed == True
)
arg = cls.add_new_arg_to_args(
arg, "active", cls.active == True
)
arg = cls.add_new_arg_to_args(
arg, "deleted", cls.deleted == False
)
arg = cls.add_new_arg_to_args(arg, "is_confirmed", cls.is_confirmed == True)
arg = cls.add_new_arg_to_args(arg, "active", cls.active == True)
arg = cls.add_new_arg_to_args(arg, "deleted", cls.deleted == False)
return arg
@classmethod
@ -190,7 +198,7 @@ class FilterAttributes:
args = cls.get_not_expired_query_arg(args)
filter_list = cls.get_filter_attributes()
if filter_list.get("query", None):
for smart_iter in cls.filter_expr(**filter_list.get('query', {})):
for smart_iter in cls.filter_expr(**filter_list.get("query", {})):
if key := arg_left(smart_iter):
args = cls.add_new_arg_to_args(args, key, smart_iter)
query = cls._query().filter(*args)

View File

@ -23,11 +23,7 @@ def exception_handler_http(request: Request, exc: HTTPException):
except Exception as e:
return JSONResponse(
status_code=exc.status_code,
content={
"Error": str(exc_detail),
"Message": f"{str(e)}",
"Data": {}
},
content={"Error": str(exc_detail), "Message": f"{str(e)}", "Data": {}},
)

View File

@ -39,8 +39,10 @@ def authentication_select_company_or_occupant_type(
request: Request, data: Union[EmployeeSelection, OccupantSelection]
):
token_dict = parse_token_object_to_dict(request=request)
return AuthenticationSelectEventMethod.authentication_select_company_or_occupant_type(
data=data, request=request, token_dict=token_dict
return (
AuthenticationSelectEventMethod.authentication_select_company_or_occupant_type(
data=data, request=request, token_dict=token_dict
)
)

View File

@ -21,7 +21,9 @@ def building_types_list(request: Request, list_options: ListOptions):
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
@build_types_route.post(path="/create", summary="Create BuildParts with given auth levels")
@build_types_route.post(
path="/create", summary="Create BuildParts with given auth levels"
)
def building_types_create(request: Request, data: InsertBuildTypes):
token_dict = parse_token_object_to_dict(request=request)
return token_dict.available_event(data=data, token_dict=token_dict)

View File

@ -31,7 +31,9 @@ def modules_create(request: Request, data: DepartmentsPydantic):
)
def modules_update(request: Request, module_uu_id: str, data: DepartmentsPydantic):
token_dict = parse_token_object_to_dict(request=request)
return token_dict.available_event(data=data, module_uu_id=module_uu_id, token_dict=token_dict)
return token_dict.available_event(
data=data, module_uu_id=module_uu_id, token_dict=token_dict
)
@modules_route.patch(
@ -39,4 +41,6 @@ def modules_update(request: Request, module_uu_id: str, data: DepartmentsPydanti
)
def modules_patch(request: Request, module_uu_id: str, data: PatchRecord):
token_dict = parse_token_object_to_dict(request=request)
return token_dict.available_event(data=data, module_uu_id=module_uu_id, token_dict=token_dict)
return token_dict.available_event(
data=data, module_uu_id=module_uu_id, token_dict=token_dict
)

View File

@ -103,9 +103,7 @@ def add_events_all_services_and_occupant_types():
event_id=event_id,
event_uu_id=event_uu_id,
)
service_events.save()
service_events.is_confirmed = True
service_events.save()
service_events.save_and_confirm()
return

View File

@ -141,9 +141,7 @@ def create_occupant_types_defaults():
for list_occupant_type in list_occupant_types:
created_type = OccupantTypes.find_or_create(**list_occupant_type)
created_type.save()
created_type.is_confirmed = True
created_type.save()
created_type.save_and_confirm()
def create_application_defaults():
@ -438,6 +436,5 @@ def create_application_defaults():
)
People.save()
for created_list_item in created_list:
created_list_item.is_confirmed = True
created_list_item.save()
created_list_item.save_and_confirm()
print("All Defaults Create is now completed")

View File

@ -94,9 +94,14 @@ def init_api_enums_build_types():
},
{
"enum_class": "BuildDuesTypes",
"type_code": "BDT-sf",
"type_code": "BDT-S",
"type_name": "Service fee",
},
{
"enum_class": "BuildDuesTypes",
"type_code": "BDT-I",
"type_name": "Information",
},
{
"enum_class": "AccountingReceiptTypes",
"type_code": "ART-A",

View File

@ -29,9 +29,7 @@ def create_endpoints_from_api_functions(routers):
)
)
restriction.endpoint_code = f"AR{str(restriction.id).zfill(3)}"
restriction.save()
restriction.is_confirmed = True
restriction.save()
restriction.save_and_confirm()
EndpointRestriction.save()
return api_app
@ -54,72 +52,56 @@ def create_services_building(module_dict: dict):
service_description="Building Management Service",
service_code="SR-BLD-MNG",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Building Legal Affairs",
service_description="Building Legal Affairs Service",
service_code="SR-BLD-LGL",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Building Cleaning",
service_description="Building Cleaning Service",
service_code="SR-BLD-CLN",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Building Heating System",
service_description="Building Heating System Service",
service_code="SR-BLD-HTS",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Building Security System",
service_description="Building Security System Service",
service_code="SR-BLD-SEC",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Building Maintenance",
service_description="Building Maintenance Service",
service_code="SR-BLD-MNT",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Building Repair",
service_description="Building Repair Service",
service_code="SR-BLD-RPR",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Building Observation",
service_description="Building Observation Service",
service_code="SR-BLD-OBS",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
return
@ -137,46 +119,35 @@ def create_services_flat(module_dict: dict):
service_description="Flat Rent Service",
service_code="SR-FLT-RNT",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Flat Sale",
service_description="Flat Sale Service",
service_code="SR-FLT-SAL",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Flat Renovation",
service_description="Flat Renovation Service",
service_code="SR-FLT-RNV",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Flat Cleaning",
service_description="Flat Cleaning Service",
service_code="SR-FLT-CLN",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Flat Observation",
service_description="Flat Observation Service",
service_code="SR-FLT-OBS",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
return
@ -187,9 +158,7 @@ def create_services_authenticate(module_dict: dict):
service_description="Authenticate Service",
service_code="AUTH",
)
authentication_service.save()
authentication_service.is_confirmed = True
authentication_service.save()
authentication_service.save_and_confirm()
return
@ -201,27 +170,21 @@ def create_services_meeting(module_dict: dict):
service_description="Regular Meeting Service",
service_code="MEET-REG",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Meeting Emergency",
service_description="Emergency Meeting Service",
service_code="MEET-EMR",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
created_service = Services.find_or_create(
**module_dict,
service_name="Meeting Demand",
service_description="Demand Meeting Service",
service_code="MEET-DMN",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
return
@ -236,9 +199,7 @@ def create_modules_and_services_and_actions():
"is_default_module": False,
}
)
erp_module.save()
erp_module.is_confirmed = True
erp_module.save()
erp_module.save_and_confirm()
build_module = Modules.find_or_create(
**{
@ -249,9 +210,7 @@ def create_modules_and_services_and_actions():
"is_default_module": False,
}
)
build_module.save()
build_module.is_confirmed = True
build_module.save()
build_module.save_and_confirm()
user_module = Modules.find_or_create(
**{
@ -262,9 +221,7 @@ def create_modules_and_services_and_actions():
"is_default_module": True,
}
)
user_module.save()
user_module.is_confirmed = True
user_module.save()
user_module.save_and_confirm()
erp_module_module_dict = dict(
module_id=erp_module.id,
@ -289,9 +246,7 @@ def create_modules_and_services_and_actions():
service_description=duty_object.duty_description,
service_code=f"SRE-{duty_object.duty_code}",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
occupant_types = OccupantTypes.filter_all()
for occupant_type in occupant_types.data:
@ -301,9 +256,7 @@ def create_modules_and_services_and_actions():
service_description=occupant_type.occupant_description,
service_code=f"SRO-{occupant_type.occupant_code}",
)
created_service.save()
created_service.is_confirmed = True
created_service.save()
created_service.save_and_confirm()
create_services_authenticate(module_dict=user_module_module_dict)
create_services_meeting(module_dict=build_module_module_dict)

View File

@ -82,9 +82,7 @@ def create_one_address():
)
address_list.append(street)
for address_single in address_list:
address_single.save()
address_single.is_confirmed = True
address_single.save()
address_single.save_and_confirm()
return

View File

@ -11,8 +11,8 @@ def get_account_records_from_json():
read_files_json, with_pydantic = read_json_file(json_file="account_records"), []
read_files = read_files_json.get("account_records")
for row in read_files:
if not row['bank_reference_code']:
row['bank_reference_code'] = "NOT FOUND"
if not row["bank_reference_code"]:
row["bank_reference_code"] = "NOT FOUND"
pydantic_row = InsertAccountRecord(**row)
with_pydantic.append(pydantic_row.model_dump())
if not with_pydantic:
@ -20,12 +20,11 @@ def get_account_records_from_json():
return with_pydantic
def migrate_account_records(requester: BothAPIS):
account_records = get_account_records_from_json()
for account_record in account_records:
response = requester.local_api.post(
endpoint="/account/records/create", data=account_record
)
print('response.text', response.text)
print('response.status_code', response.json())
print("response.text", response.text)
print("response.status_code", response.json())

View File

@ -1,6 +1,8 @@
from service_app_test.api_configs import BothAPIS
from service_app_test.test_application.evyos.address_building import post_code_dict
from service_app_test.test_application.migrate_old_data.get_occupants_codes import get_occupants_types
from service_app_test.test_application.migrate_old_data.get_occupants_codes import (
get_occupants_types,
)
from service_app_test.test_application.migrate_old_data.reader_and_alchemy_bulk_actions import (
read_json_file,
)
@ -90,6 +92,7 @@ address_dict = lambda post_code_uu_id: {
"build_number": "11",
}
def get_build_living_space_from_json():
read_files_json, with_pydantic = read_json_file(json_file="build_living_space"), []
read_files = read_files_json.get("build_living_space")
@ -173,15 +176,19 @@ def migrate_build_area(requester: BothAPIS, build_uu_id: str):
def migrate_build_part(
requester: BothAPIS, build_uu_id: str, build_part_type_uu_id: str, part_direction_uu_id: str
requester: BothAPIS,
build_uu_id: str,
build_part_type_uu_id: str,
part_direction_uu_id: str,
):
# build_uu_id = grab_new_build_uu_id(requester=requester, build_uu_id=build_uu_id)
response_datas = get_build_part_from_json(
build_part_type_uu_id=build_part_type_uu_id, part_direction_uu_id=part_direction_uu_id
build_part_type_uu_id=build_part_type_uu_id,
part_direction_uu_id=part_direction_uu_id,
)
for response_data in response_datas:
if response_data.get('part_no') == 0:
if response_data.get("part_no") == 0:
continue
response_data["build_uu_id"] = build_uu_id
response = requester.local_api.post(
@ -209,28 +216,42 @@ def migrate_build_living_space(requester: BothAPIS):
print("b response_data[person_uu_id]", response_data["person_uu_id"])
response = requester.local_api.post(
endpoint="/people/list",
data={"page": 1, "size": 1, "query": {"ref_id": response_data["person_uu_id"]}},
data={
"page": 1,
"size": 1,
"query": {"ref_id": response_data["person_uu_id"]},
},
)
print("/people/list response", response.text)
response_data["person_uu_id"] = response.json()["data"][0]["uu_id"]
print("a response_data[person_uu_id]", response_data["person_uu_id"])
response = requester.local_api.post(
endpoint="/building/parts/list",
data={"page": 1, "size": 30, "query": {"ref_id": response_data.get("build_parts_uu_id")}},
data={
"page": 1,
"size": 30,
"query": {"ref_id": response_data.get("build_parts_uu_id")},
},
)
print("/building/parts/list response", response.text)
response_data["build_parts_uu_id"] = response.json()["data"][0]["uu_id"]
flat_owner = "b9392bef-32cb-4c7d-b99f-5f613c2e2120"
flat_tenants = "a40aea36-0dce-48cc-9334-2e776ba22a49"
if response_data.get('occupant_type_uu_id') == flat_owner:
response = get_occupants_types(occupant_code="FL-OWN", requester=requester.local_api)
if response_data.get("occupant_type_uu_id") == flat_owner:
response = get_occupants_types(
occupant_code="FL-OWN", requester=requester.local_api
)
response_data["occupant_type_uu_id"] = response["data"]["uu_id"]
elif response_data.get('occupant_type_uu_id') == flat_tenants:
response = get_occupants_types(occupant_code="FL-TEN", requester=requester.local_api)
elif response_data.get("occupant_type_uu_id") == flat_tenants:
response = get_occupants_types(
occupant_code="FL-TEN", requester=requester.local_api
)
response_data["occupant_type_uu_id"] = response["data"]["uu_id"]
else:
response = get_occupants_types(occupant_code="FL-RES", requester=requester.local_api)
response = get_occupants_types(
occupant_code="FL-RES", requester=requester.local_api
)
response_data["occupant_type_uu_id"] = response["data"]["uu_id"]
response = requester.local_api.post(
@ -240,27 +261,31 @@ def migrate_build_living_space(requester: BothAPIS):
return
def migrate_build(requester: BothAPIS):
from service_app_test.test_application.migrate_old_data.get_building_types import (
list_building_types,
)
from service_app_test.test_application.migrate_old_data.get_type_codes import (
get_type_codes_key_and_class
get_type_codes_key_and_class,
)
building_type_flat = list_building_types(requester=requester.local_api, type_code="daire").get("uu_id")
building_type_build = list_building_types(requester=requester.local_api, type_code="apt").get("uu_id")
building_type_flat = list_building_types(
requester=requester.local_api, type_code="daire"
).get("uu_id")
building_type_build = list_building_types(
requester=requester.local_api, type_code="apt"
).get("uu_id")
api_enum_dropdown_nn = get_type_codes_key_and_class(
class_name="Directions", key_name="NN", requester=requester.local_api
)
api_enum_dropdown_nn_uuid = api_enum_dropdown_nn.get("data").get("uu_id")
street_uu_id = search_street("Reşat Nuri", requester=requester)
post_code_uuid = create_address(requester=requester, post_code=post_code_dict(uu_id_street=street_uu_id))
post_code_uuid = create_address(
requester=requester, post_code=post_code_dict(uu_id_street=street_uu_id)
)
created_address = create_addresses(
address=address_dict(post_code_uu_id=post_code_uuid),
requester=requester
address=address_dict(post_code_uu_id=post_code_uuid), requester=requester
)
created_address_uu_id = created_address["data"]["uu_id"]
for response_data in get_build_from_json():
@ -274,7 +299,7 @@ def migrate_build(requester: BothAPIS):
requester=requester,
build_uu_id=build_uu_id,
build_part_type_uu_id=building_type_flat,
part_direction_uu_id=api_enum_dropdown_nn_uuid
part_direction_uu_id=api_enum_dropdown_nn_uuid,
)
# migrate_build_iban(requester=requester, build_uu_id=build_uu_id)
return

View File

@ -1,5 +1,3 @@
def list_building_types(requester, lang: str = "TR", type_code: str = None):
from service_app_test.test_application.evyos.datas.company_employee_data import (
list_options,

View File

@ -1,11 +1,13 @@
import random
from service_app_test.api_configs import BothAPIS
from api_validations.validations_request import InsertPerson
from api_validations.validations_request import InsertPerson, InsertUsers
from service_app_test.test_application.migrate_old_data.reader_and_alchemy_bulk_actions import (
read_json_file,
)
# from service_app_test.test_application.evyos.people import generate_random_phone_number
requester_dict_build = lambda data: {"endpoint": "/people/create", "data": data}
@ -15,18 +17,40 @@ def get_people_from_json():
for row in read_files:
row["ref_id"] = row["uu_id"]
pydantic_row = InsertPerson(**row)
with_pydantic.append(pydantic_row.model_dump())
data_dict = pydantic_row.model_dump()
data_dict["email"] = row.get("emails")
with_pydantic.append(data_dict)
if not with_pydantic:
raise Exception("No data found")
return with_pydantic
generate_random_national_identity_id = lambda n: str(random.randint(10 ** (n - 1), 10**n))
generate_random_national_identity_id = lambda n: str(
random.randint(10 ** (n - 1), 10**n)
)
def migrate_people(requester: BothAPIS):
for response_data in get_people_from_json():
users_email = response_data.get("email")
response_data["national_identity_id"] = generate_random_national_identity_id(11)
response_data.pop("email", None)
response = requester.local_api.post(**requester_dict_build(data=response_data))
print("response", response.text)
if response.ok:
user_json = response.json().get("data", None)
if not user_json:
raise Exception("User can not be created user json is invalid")
created_user = InsertUsers(
people_uu_id=user_json.get("uu_id"),
user_tag=user_json.get("firstname"),
email=users_email,
# phone_number=generate_random_phone_number(),
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
)
response = requester.local_api.post(
endpoint="/user/create",
data=created_user.model_dump(),
)
print("response", response.text)
return

View File

@ -1,51 +1,49 @@
import arrow
from service_app_test.bases import RequestToApi
from service_app_test.api_configs import WagAPI, LocalAPI, BothAPIS
from service_app_test.test_application.evyos.decision_book import run_decision_book_depends
from service_app_test.api_configs import LocalAPI, BothAPIS
from service_app_test.test_application.evyos.decision_book import (
run_decision_book_depends, list_decision_books,
)
from service_app_test.test_application.evyos.decision_book_items import (
send_invitation_to_building_residents,
collect_invitation_to_building_residents,
assign_people_to_pre_or_wrt
assign_people_to_pre_or_wrt, run_decision_book_items,
)
from service_app_test.test_application.migrate_old_data.get_type_codes import get_type_codes_key_and_class
from service_app_test.test_application.migrate_old_data.people import migrate_people
from service_app_test.test_application.migrate_old_data.building import (
migrate_build, migrate_build_living_space,
migrate_build,
migrate_build_living_space,
)
from service_app_test.test_application.migrate_old_data.company import migrate_company
from service_app_test.test_application.migrate_old_data.accounts import migrate_account_records
from service_app_test.test_application.migrate_old_data.accounts import (
migrate_account_records,
)
password_token = "CDWs5ASBD4LVbmhNeilKSqBLKjKKt0odOL9h6NY082xqwln7Bo1opvC12j07iP8Gx-vpJSpF5nqUWs-Q9klQUJ6uLc8vuPmVKYVCXE0nz2yU_xyFGOrlqrVro1FSZG1EXwWopuLA_gKH5qkiiQwI1tM3UDFLJjbnR4xjwnH4m6RHe0gYKOZbpkd-uxFxzYbw"
password_token = ""
login_data = {
"domain": "evyos.com.tr",
"access_key": "karatay.berkay.sup@evyos.com.tr",
"password": "string",
"remember_me": False,
"password_token": password_token
"password_token": password_token,
}
login_data_wag = {
"domain": "evyos.com.tr",
"access_key": "karatay.berkay.sup@evyos.com.tr",
"password": "string",
"remember_me": False,
"password_token": "",
}
login_creds_employee = {
"domain": "evyos.com.tr",
"access_key": "karatay.berkay.sup@evyos.com.tr",
"password": "string",
"remember_me": False,
"password_token": "z5nPguDu6PrY_94KlTGxGBCMcK6rZcDl5AGqO5aHWY7TcQF8LJGYikMQs9labvqdz5yM7vE_f8Zq_vqp00o3EnWwWCWhel-EsMcAujBKNRjV3jC_4xk0_1r_unIYogWAjz_spZipX6pncsch2ngvv0dpx4lHSiZ5QrDTA1RefQ",
"password_token": password_token,
}
access_key_president = "bmanco@example.net"
access_key_president = "mehmet.karatay@hotmail.com"
login_creds_occupant = {
"domain": "evyos.com.tr",
"access_key": access_key_president,
"password": "string",
"remember_me": False,
"password_token": "o_2Y_yXS-cl6MxLbzLrXQetXTlDLD3UBDTQNa_mBMyzSOVIgx3LGbnufLRJjd4g6BWFbwVgJIUxbK-Pi0R5dwxfVJKyoEeDdej40uRHSsElKR16nvnqgFB_BJ4nmyN0KSunZHra5NqHJor17EGExOSmlttZV5dC7vFsrc-GUkg",
"password_token": "n6CCVhj0gvEqENWhA7OqG1NNczJWPuPgI2U6G9yE_OS8gIYGkFhqsZ9c0K9He7yx7O7T9zgaj7ZDxb1JVKzTnGIGrpv8mDdOhuB0IV20XsTsir_jzzHspXsrcHDLk6l32_qsI4fLswDPjY0qvB1yqnEjRvHuYGhfPYTifwfax2O2ceNwwYoTFU9P2s4eWzDb"
}
wrt_creds_occupant = {
"domain": "evyos.com.tr",
@ -55,59 +53,83 @@ wrt_creds_occupant = {
"password_token": "",
}
wag_api = RequestToApi()
wag_api.overwrite_base_url(base_url=WagAPI.base_url)
wag_api.selected_object = wag_api.login_via_email_and_password(
login_data=login_data_wag, is_password_valid=True
)
# wag_api = RequestToApi()
# wag_api.overwrite_base_url(base_url=WagAPI.base_url)
# wag_api.selected_object = wag_api.login_via_email_and_password(
# login_data=login_data_wag, is_password_valid=True
# )
local_api = RequestToApi()
local_api.overwrite_base_url(base_url=LocalAPI.base_url)
local_api.selected_object = local_api.login_via_email_and_password(
login_data=login_data, is_password_valid=False
)
both_apis = BothAPIS()
both_apis.wag_api = wag_api
# both_apis.wag_api = wag_api
both_apis.local_api = local_api
do_migrates = False
assign_people_to_create_item = -1
assign_people_to_create_item = 2
# selection_list = None
selection_list = []
selection_list = [
"98f1207d-f241-4cb8-a95a-b51266632cc8",
"a8eaf383-7bb6-489b-b9e8-f19f9fd1c197",
]
# selection_list = None
manager_token = ""
manager_token = "9TdLKsYaGIrDQrKHnB13SZ5Z7XIjvGRquMBXu4om5z30hKXIH7J55Q"
writers_token = manager_token
people_uu_id_list = []
list_of_attendees = []
people_uu_id_list = [
"af411e80-29ad-4540-9e74-3c805700f461",
"af411e80-29ad-4540-9e74-3c805700f461",
"af411e80-29ad-4540-9e74-3c805700f461",
]
list_of_attendees = [
"Qsf0XO6c-wTZDhACY66S4Ck21fgW-6E0f1dSi61bSskMAI7qUTH2Eg",
"fjAc8_mktkBw46islaa8H1yM5jptwLcsdDbNz_MuH7gPmZtuNZ4zLw",
"JwVbDMl6CQZTIFu4LEwdEaX8BB6syWPgygF0f3M0fiu9VhPaqdLzfw",
"PFBj2hlhRAFxrxpUMCpE0O_kwKrWvTov4Zxn94MMnYcVMzC1kQNmiQ",
"e8MKAguhQnSyuZtL1UVP4a3xx0zbXGEmLUQrbCEJu15VoO0r33otdA",
"VPmcs0xD3N5RUGDyYRCe-adgvspkhiMb5YWfr7oN8fCvcQq9BTLSkA",
"3xtEg2r1qi8PozE2Qte4fFuz2EjARP8uxRRS18nz6_OFGQ142rZk4g",
"89XH0UXxbujs-uKxBMV8fZEMJkBDnxOr_8ZBbxS7isGD2noY_OpI4w",
"jSb8rH1ZI7BSHYUtBsKsOoTW4LnHDY2JlJhid_YgpIg05CI-veX0fA",
"fMysLzIehzVfYlnqcyPLpaAKaxD8IODe5QXmWbiM1gEVYtUMyTg-xw",
"aS5AydqghcvTGMQHGpi3m9C5OgyQQ_Yyc_jnkNUzrBvuEuNGOgMgPA",
]
living_space_data = dict(
build_parts_uu_id="98f1207d-f241-4cb8-a95a-b51266632cc8",
person_uu_id="07a14d03-d8c8-4d84-9f71-ff81b732b030",
occupant_type_uu_id="a8eaf383-7bb6-489b-b9e8-f19f9fd1c197",
expiry_starts=arrow.now().date().__str__(),
)
if do_migrates:
if assign_people_to_create_item == -1:
local_api.selected_object = local_api.login_via_email_and_password(
login_data=login_data, is_password_valid=False
)
migrate_company(requester=both_apis)
migrate_people(requester=both_apis)
migrate_build(requester=both_apis)
migrate_build_living_space(requester=both_apis)
migrate_account_records(requester=both_apis)
# migrate_account_records(requester=both_apis)
if assign_people_to_create_item == 0:
# local_api.post(
# endpoint="/building/living_space/create",
# data=dict(
# build_parts_uu_id="b23d32d2-e80c-4ca4-8d4a-bae6f710608c",
# person_uu_id="cf47be44-ec58-4585-be41-178160be5b7e",
# occupant_type_uu_id="30512a47-1b3e-4602-ac1a-75fcabb076b4",
# expiry_starts=arrow.now().date().__str__(),
# )
# )
if not bool(selection_list):
local_api.selected_object = local_api.login_via_email_and_password(
login_data=login_data, is_password_valid=True
)
response = local_api.post(endpoint="/building/living_space/create", data=living_space_data)
print('response', response.text)
local_api.selected_object = local_api.login_via_email_and_password(
login_data=login_creds_occupant,
is_password_valid=False,
is_password_valid=bool(selection_list),
selection_list=selection_list,
)
selected_decision_book_uu_id = run_decision_book_depends(requester=both_apis.local_api)
selected_decision_book_uu_id = run_decision_book_depends(
requester=both_apis.local_api
)
send_invitation = {
"build_decision_book_uu_id": selected_decision_book_uu_id,
"message": "Request for a Regular Building Meeting",
@ -116,29 +138,119 @@ if assign_people_to_create_item == 0:
send_invitation_to_building_residents(
send_invitation_dict=send_invitation, requester=both_apis.local_api
)
if assign_people_to_create_item == 1:
count = 17
elif assign_people_to_create_item == 1:
local_api.selected_object = local_api.login_via_email_and_password(
login_data=login_creds_occupant,
is_password_valid=True,
selection_list=selection_list,
)
count = 7
list_of_attendees.insert(0, manager_token)
collect_invitation_to_building_residents(
attended_dict_list=list_of_attendees, attend_count=count + 1,
requester=both_apis.local_api
attended_dict_list=list_of_attendees,
attend_count=count + 1,
requester=both_apis.local_api,
)
elif assign_people_to_create_item == 2:
local_api.selected_object = local_api.login_via_email_and_password(
login_data=login_creds_occupant,
is_password_valid=True,
selection_list=selection_list,
)
assign_people_to_pre_or_wrt(
person_uu_id=people_uu_id_list[0],
manager_token=manager_token,
occupant_code="MT-VPR",
requester=both_apis.local_api
requester=both_apis.local_api,
)
assign_people_to_pre_or_wrt(
person_uu_id=people_uu_id_list[1],
manager_token=manager_token,
occupant_code="MT-WRT",
requester=both_apis.local_api
requester=both_apis.local_api,
)
assign_people_to_pre_or_wrt(
person_uu_id=people_uu_id_list[2],
manager_token=manager_token,
occupant_code="MT-PRS",
requester=both_apis.local_api,
)
elif assign_people_to_create_item == 3:
local_api.selected_object = local_api.login_via_email_and_password(
login_data=wrt_creds_occupant,
is_password_valid=True,
selection_list=selection_list,
)
selected_decision_book_uu_id = list_decision_books(requester=both_apis.local_api)["data"][0]["uu_id"]
print("select_company_uu_id", local_api.selected_object)
is_fixed_price = False
info_type_d_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-D", requester=both_apis.local_api
)["data"]["uu_id"]
unit_price = 15.90
run_decision_book_items(
writers_token=writers_token,
unit_price=unit_price,
is_fixed=is_fixed_price,
info_type_uu_id=info_type_d_uu_id,
requester=both_apis.local_api
)
is_fixed_price = True
info_type_a_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-A", requester=both_apis.local_api
)["data"]["uu_id"]
start_date, end_date = "2024-11-01", "2025-02-01"
unit_price = 850
run_decision_book_items(
writers_token=writers_token,
unit_price=unit_price,
is_fixed=is_fixed_price,
info_type_uu_id=info_type_a_uu_id,
start_date=start_date,
end_date=end_date,
requester=both_apis.local_api
)
info_type_a_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-R", requester=both_apis.local_api
)["data"]["uu_id"]
unit_price = 5000
run_decision_book_items(
writers_token=writers_token,
unit_price=unit_price,
is_fixed=is_fixed_price,
info_type_uu_id=info_type_a_uu_id,
start_date=start_date,
end_date=end_date,
requester=both_apis.local_api
)
info_type_a_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-R", requester=both_apis.local_api
)["data"]["uu_id"]
unit_price = 2000
run_decision_book_items(
writers_token=writers_token,
unit_price=unit_price,
is_fixed=is_fixed_price,
info_type_uu_id=info_type_a_uu_id,
start_date=start_date,
end_date=end_date,
requester=both_apis.local_api
)
info_type_a_uu_id = get_type_codes_key_and_class(
class_name="BuildDuesTypes", key_name="BDT-L", requester=both_apis.local_api
)["data"]["uu_id"]
unit_price = 750
run_decision_book_items(
writers_token=writers_token,
unit_price=unit_price,
is_fixed=is_fixed_price,
info_type_uu_id=info_type_a_uu_id,
start_date=start_date,
end_date=end_date,
requester=both_apis.local_api
)