events imports are checked
This commit is contained in:
@@ -10,7 +10,7 @@ from databases import (
|
||||
OccupantTypes,
|
||||
)
|
||||
|
||||
from validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertDecisionBook,
|
||||
ListOptions,
|
||||
)
|
||||
@@ -117,6 +117,7 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
||||
)
|
||||
data_dict["expiry_starts"] = str(data_dict["expiry_starts"])
|
||||
build_decision_book = BuildDecisionBook.find_or_create(**data_dict)
|
||||
BuildDecisionBook.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content=dict(
|
||||
@@ -157,6 +158,7 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
||||
)
|
||||
data_dict["expiry_starts"] = str(data_dict["expiry_starts"])
|
||||
build_decision_book = BuildDecisionBook.find_or_create(**data_dict)
|
||||
BuildDecisionBook.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content=dict(
|
||||
|
||||
@@ -21,9 +21,9 @@ from databases import (
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from api_library.date_time_actions.date_functions import DateTimeLocal
|
||||
from api_library.date_time_actions.date_functions import system_arrow, client_arrow
|
||||
|
||||
from validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildDecisionBookItems,
|
||||
ListDecisionBook,
|
||||
)
|
||||
@@ -123,7 +123,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
for build_part_single in build_parts_list:
|
||||
local_date = start_date
|
||||
while local_date.is_between(start_date, end_date, "[]"):
|
||||
local_date = DateTimeLocal.find_last_day_of_month(local_date)
|
||||
local_date = system_arrow.find_last_day_of_month(local_date)
|
||||
payment_amount = unit_price
|
||||
if not unit_price_is_fixed:
|
||||
unit_amount = str(build_part_single.due_part_key).replace(" ", "")
|
||||
@@ -176,9 +176,9 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
)
|
||||
payment_types = ApiEnumDropdown.get_debit_search(search_debit="DT-D")
|
||||
if data_info_type.key == "BDT-D":
|
||||
local_date = DateTimeLocal.get(DateTimeLocal.get(decision_book.expiry_starts).date())
|
||||
end_date = DateTimeLocal.get(DateTimeLocal.get(decision_book.expiry_ends).date())
|
||||
return cls.iterate_over_build_parts(
|
||||
local_date = system_arrow.get(system_arrow.get(decision_book.expiry_starts).date())
|
||||
end_date = system_arrow.get(system_arrow.get(decision_book.expiry_ends).date())
|
||||
cls.iterate_over_build_parts(
|
||||
build_parts_list=build_parts_list.data,
|
||||
payment_types=payment_types,
|
||||
local_date=local_date,
|
||||
@@ -188,10 +188,12 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
unit_price_is_fixed=unit_price_is_fixed,
|
||||
book_payment_dict=book_payment_dict,
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
return
|
||||
elif data_info_type.key == "BDT-A":
|
||||
local_date = DateTimeLocal.get(DateTimeLocal.get(debit_start_date).date())
|
||||
end_date = DateTimeLocal.get(DateTimeLocal.get(debit_end_date).date())
|
||||
return cls.iterate_over_build_parts(
|
||||
local_date = system_arrow.get(system_arrow.get(debit_start_date).date())
|
||||
end_date = system_arrow.get(system_arrow.get(debit_end_date).date())
|
||||
cls.iterate_over_build_parts(
|
||||
build_parts_list=build_parts_list.data,
|
||||
payment_types=payment_types,
|
||||
local_date=local_date,
|
||||
@@ -201,11 +203,13 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
unit_price_is_fixed=unit_price_is_fixed,
|
||||
book_payment_dict=book_payment_dict,
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
return
|
||||
elif data_info_type.key == "BDT-R" or data_info_type.key == "BDT-L":
|
||||
local_date = DateTimeLocal.get(DateTimeLocal.get(debit_start_date).date())
|
||||
end_date = DateTimeLocal.get(DateTimeLocal.get(debit_end_date).date())
|
||||
decision_date = DateTimeLocal.get(decision_book.expiry_starts).date()
|
||||
meeting_date = DateTimeLocal.get(decision_book.meeting_date).date()
|
||||
local_date = system_arrow.get(system_arrow.get(debit_start_date).date())
|
||||
end_date = system_arrow.get(system_arrow.get(debit_end_date).date())
|
||||
decision_date = system_arrow.get(decision_book.expiry_starts).date()
|
||||
meeting_date = system_arrow.get(decision_book.meeting_date).date()
|
||||
|
||||
already_book_projects = BuildDecisionBookProjects.filter_all(
|
||||
BuildDecisionBookProjects.build_decision_book_id==decision_book.id,
|
||||
@@ -242,22 +246,23 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
project_response_living_space_uu_id=str(manager_living_space.uu_id),
|
||||
)
|
||||
book_project_created = BuildDecisionBookProjects.find_or_create(**book_project_dict)
|
||||
if not book_project_created.is_found:
|
||||
decision_book_item.update(
|
||||
item_comment=f"{book_project_created.project_no}_{book_project_created.project_name} "
|
||||
f"is assigned to {occupant_man.occupant_description}"
|
||||
)
|
||||
project_lead = ApiEnumDropdown.find_one(
|
||||
key="PTT-LDR", enum_class="ProjectTeamTypes"
|
||||
)
|
||||
project_person = BuildDecisionBookProjectPerson.find_or_create(
|
||||
build_decision_book_project_id=book_project_created.id,
|
||||
build_decision_book_project_uu_id=str(book_project_created.uu_id),
|
||||
living_space_id=manager_living_space.id,
|
||||
living_space_uu_id=str(manager_living_space.uu_id),
|
||||
project_team_type_id=project_lead.id,
|
||||
project_team_type_uu_id=str(project_lead.uu_id),
|
||||
)
|
||||
decision_book_item.update(
|
||||
item_comment=f"{book_project_created.project_no}_{book_project_created.project_name} "
|
||||
f"is assigned to {occupant_man.occupant_description}"
|
||||
)
|
||||
project_lead = ApiEnumDropdown.find_one(
|
||||
key="PTT-LDR", enum_class="ProjectTeamTypes"
|
||||
)
|
||||
project_person = BuildDecisionBookProjectPerson.find_or_create(
|
||||
build_decision_book_project_id=book_project_created.id,
|
||||
build_decision_book_project_uu_id=str(book_project_created.uu_id),
|
||||
living_space_id=manager_living_space.id,
|
||||
living_space_uu_id=str(manager_living_space.uu_id),
|
||||
project_team_type_id=project_lead.id,
|
||||
project_team_type_uu_id=str(project_lead.uu_id),
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
return
|
||||
|
||||
elif data_info_type.key == "BDT-SF":
|
||||
raise HTTPException(
|
||||
|
||||
@@ -15,7 +15,7 @@ from databases import (
|
||||
OccupantTypes,
|
||||
)
|
||||
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
ListOptions,
|
||||
RemoveDecisionBookPerson,
|
||||
DecisionBookDecisionBookInvitationsAttend,
|
||||
@@ -126,6 +126,7 @@ class DecisionBookPersonAddEventMethods(MethodToEvent):
|
||||
occupant_type=assign_occupant_type.id,
|
||||
occupant_type_uu_id=str(assign_occupant_type.uu_id),
|
||||
)
|
||||
BuildDecisionBookPerson.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content={
|
||||
@@ -200,6 +201,7 @@ class DecisionBookPersonAttendEventMethods(MethodToEvent):
|
||||
invitation_person.update(
|
||||
is_attending=bool(data.is_attend), vicarious_person_id=None
|
||||
)
|
||||
BuildDecisionBookInvitations.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content={
|
||||
@@ -336,6 +338,7 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
|
||||
occupant_type=assign_occupant_type,
|
||||
build_living_space_id=selected_living_space.id,
|
||||
)
|
||||
BuildDecisionBookPersonOccupants.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content={
|
||||
|
||||
@@ -16,14 +16,14 @@ from databases import (
|
||||
ApiEnumDropdown,
|
||||
)
|
||||
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
DecisionBookDecisionBookInvitationsUpdate,
|
||||
DecisionBookDecisionBookInvitations,
|
||||
)
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from api_library.date_time_actions.date_functions import DateTimeLocal
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
|
||||
|
||||
class BuildDecisionBookInvitationsListEventMethods(MethodToEvent):
|
||||
@@ -95,8 +95,8 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
||||
|
||||
# Check planned decision book date is valid
|
||||
if (
|
||||
not DateTimeLocal.get(data.planned_date).date()
|
||||
>= DateTimeLocal.shift(days=1).date()
|
||||
not system_arrow.get(data.planned_date).date()
|
||||
>= system_arrow.shift(days=1).date()
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@@ -115,9 +115,9 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
||||
message=data.message,
|
||||
planned_date=data.planned_date,
|
||||
planned_date_expires=str(
|
||||
DateTimeLocal.get(data.planned_date).shift(days=15).date()
|
||||
system_arrow.get(data.planned_date).shift(days=15).date()
|
||||
),
|
||||
expiry_ends=str(DateTimeLocal.get(data.planned_date).shift(days=15).date()),
|
||||
expiry_ends=str(system_arrow.get(data.planned_date).shift(days=15).date()),
|
||||
is_confirmed=True,
|
||||
)
|
||||
if book_invitation.is_found:
|
||||
@@ -172,7 +172,7 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
||||
build_decision_book_uu_id=str(decision_book.uu_id),
|
||||
invite_id=book_invitation.id,
|
||||
invite_uu_id=str(book_invitation.uu_id),
|
||||
send_date=str(DateTimeLocal.now().date()),
|
||||
send_date=str(system_arrow.now().date()),
|
||||
expiry_starts=decision_book.expiry_starts,
|
||||
expiry_ends=decision_book.expiry_ends,
|
||||
is_confirmed=True,
|
||||
@@ -243,6 +243,7 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
||||
):
|
||||
book_person_manager.add_occupant_type(occupant_type=manager_occupant_type)
|
||||
print(f"Manager Token : {book_person_manager.token}")
|
||||
BuildDecisionBookPerson.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content={
|
||||
|
||||
Reference in New Issue
Block a user