event decision book item updated
This commit is contained in:
@@ -117,7 +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()
|
||||
build_decision_book.save_and_confirm()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content=dict(
|
||||
|
||||
@@ -136,8 +136,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
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(" ", "")
|
||||
unit_amount = unit_amount.replace(str(unit_type).upper(), "")
|
||||
unit_amount = int(build_part_single.part_net_size)
|
||||
payment_amount = abs(unit_price * float(unit_amount)) * -1
|
||||
payment_amount = -1 * (
|
||||
abs(payment_amount) + (50 - float(abs(payment_amount)) % 50)
|
||||
@@ -179,6 +178,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
BuildParts.human_livable == True,
|
||||
BuildParts.build_id == build_id,
|
||||
)
|
||||
print('data_info_type.key', data_info_type.key)
|
||||
book_payment_dict = dict(
|
||||
payment_plan_time_periods=str(data_info_type.key),
|
||||
build_decision_book_item_id=decision_book_item.id,
|
||||
@@ -193,7 +193,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
end_date = system_arrow.get(
|
||||
system_arrow.get(decision_book.expiry_ends).date()
|
||||
)
|
||||
cls.iterate_over_build_parts(
|
||||
payment_return_dict = cls.iterate_over_build_parts(
|
||||
build_parts_list=build_parts_list.data,
|
||||
payment_types=payment_types,
|
||||
local_date=local_date,
|
||||
@@ -203,12 +203,11 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
unit_price_is_fixed=unit_price_is_fixed,
|
||||
book_payment_dict=book_payment_dict,
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
return
|
||||
return payment_return_dict
|
||||
elif data_info_type.key == "BDT-A":
|
||||
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(
|
||||
payment_return_dict = cls.iterate_over_build_parts(
|
||||
build_parts_list=build_parts_list.data,
|
||||
payment_types=payment_types,
|
||||
local_date=local_date,
|
||||
@@ -218,8 +217,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
unit_price_is_fixed=unit_price_is_fixed,
|
||||
book_payment_dict=book_payment_dict,
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
return
|
||||
return payment_return_dict
|
||||
elif data_info_type.key == "BDT-R" or data_info_type.key == "BDT-L":
|
||||
local_date = system_arrow.get(system_arrow.get(debit_start_date).date())
|
||||
end_date = system_arrow.get(system_arrow.get(debit_end_date).date())
|
||||
@@ -230,7 +228,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
BuildDecisionBookProjects.build_decision_book_id == decision_book.id,
|
||||
BuildDecisionBookProjects.project_type
|
||||
== f"{decision_book.decision_type}_{data_info_type.key}",
|
||||
).data
|
||||
)
|
||||
management_room = BuildParts.filter_one(
|
||||
BuildParts.build_id == build_id,
|
||||
BuildParts.part_no == 0,
|
||||
@@ -242,13 +240,12 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
BuildLivingSpace.build_parts_id == management_room.id,
|
||||
BuildLivingSpace.occupant_type == occupant_man.id,
|
||||
).data
|
||||
if not manager_living_space.data:
|
||||
if not manager_living_space:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"{occupant_man.occupant_description} Living Space is not found. Check manager living space and try again",
|
||||
)
|
||||
already_book_project_count = already_book_projects.count + 1
|
||||
manager_living_space = manager_living_space.get(1)
|
||||
book_project_dict = dict(
|
||||
project_no=f"{data_info_type.key}_{decision_date.year}_{already_book_project_count}",
|
||||
project_name=f"{str(meeting_date)}_{decision_book.decision_type} Project {already_book_projects.count + 1}",
|
||||
@@ -266,10 +263,12 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
book_project_created = BuildDecisionBookProjects.find_or_create(
|
||||
**book_project_dict
|
||||
)
|
||||
print('book_project_created', book_project_created)
|
||||
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}"
|
||||
)
|
||||
decision_book_item.save_and_confirm()
|
||||
project_lead = ApiEnumDropdown.filter_by_one(
|
||||
system=True, key="PTT-LDR", enum_class="ProjectTeamTypes"
|
||||
).data
|
||||
@@ -281,7 +280,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
project_team_type_id=project_lead.id,
|
||||
project_team_type_uu_id=str(project_lead.uu_id),
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
project_person.save_and_confirm()
|
||||
return book_project_created
|
||||
|
||||
elif data_info_type.key == "BDT-S":
|
||||
@@ -325,18 +324,25 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
decision_book = BuildDecisionBook.filter_one(
|
||||
BuildDecisionBook.id == decision_book_person.build_decision_book_id,
|
||||
).data
|
||||
BuildDecisionBookItems.check_meeting_is_valid_to_start_add_attendance(
|
||||
decision_book=decision_book,
|
||||
token_dict=token_dict,
|
||||
)
|
||||
|
||||
book_items = BuildDecisionBookItems.filter_all(
|
||||
BuildDecisionBookItems.build_decision_book_id == decision_book.id,
|
||||
system=True
|
||||
)
|
||||
if int(book_items.count) < 3:
|
||||
BuildDecisionBookItems.check_meeting_is_valid_to_start_add_attendance(
|
||||
decision_book=decision_book,
|
||||
token_dict=token_dict,
|
||||
)
|
||||
|
||||
book_items = BuildDecisionBookItems.filter_all(
|
||||
BuildDecisionBookItems.build_decision_book_id == decision_book.id,
|
||||
system=True
|
||||
)
|
||||
|
||||
data_dict["item_order"] = int(book_items.count) + 1
|
||||
data_dict["build_decision_book_id"] = decision_book.id
|
||||
data_dict["build_decision_book_uu_id"] = str(decision_book.uu_id)
|
||||
data_dict["is_confirmed"] = True
|
||||
|
||||
data_info_type = ApiEnumDropdown.filter_by_one(
|
||||
system=True, enum_class="BuildDuesTypes", key="BDT-I",
|
||||
@@ -376,9 +382,9 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
data_dict["currency"],
|
||||
)
|
||||
|
||||
new_decision_book_item = BuildDecisionBookItems.find_or_create(
|
||||
**data_dict
|
||||
)
|
||||
new_decision_book_item = BuildDecisionBookItems.find_or_create(**data_dict)
|
||||
new_decision_book_item.save_and_confirm()
|
||||
print('new_decision_book_item', new_decision_book_item)
|
||||
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,
|
||||
@@ -406,7 +412,14 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
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)
|
||||
new_decision_book_item.update(is_payment_created=True)
|
||||
elif row_is_project:
|
||||
project_no = str(created_payment_records_dict.project_no)
|
||||
item_comment = f"{data.item_comment} | @ Project is created no : {project_no}."
|
||||
new_decision_book_item.update(item_comment=item_comment)
|
||||
new_decision_book_item.update(is_payment_created=True)
|
||||
new_decision_book_item.save_and_confirm()
|
||||
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content=dict(
|
||||
|
||||
Reference in New Issue
Block a user