services are checked
This commit is contained in:
@@ -50,9 +50,9 @@ class MethodToEvent(ABC, ActionsSchemaFactory):
|
||||
|
||||
@classmethod
|
||||
def ban_token_objects(
|
||||
cls,
|
||||
token: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
ban_list: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
cls,
|
||||
token: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
ban_list: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
from fastapi import status
|
||||
from fastapi.exceptions import HTTPException
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
|
||||
class ApiEvents(MethodToEvent): ...
|
||||
|
||||
@@ -13,7 +13,7 @@ from api_validations.validations_request import (
|
||||
ListOptions,
|
||||
InsertAddress,
|
||||
InsertPostCode,
|
||||
SearchAddress
|
||||
SearchAddress,
|
||||
)
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
@@ -224,7 +224,7 @@ class AddressPatchEventMethods(MethodToEvent):
|
||||
def patch_address(cls, address_uu_id: str, data: InsertAddress, token_dict):
|
||||
address = Addresses.find_one_or_abort(uu_id=address_uu_id)
|
||||
post_code = RelationshipEmployee2PostCode.filter_one(
|
||||
RelationshipEmployee2PostCode.member_id==address.post_code_id
|
||||
RelationshipEmployee2PostCode.member_id == address.post_code_id
|
||||
)
|
||||
if not post_code:
|
||||
raise HTTPException(
|
||||
|
||||
@@ -263,7 +263,6 @@ class AuthenticationRefreshEventMethods(MethodToEvent):
|
||||
@classmethod
|
||||
def authentication_refresh_user_info(cls, request, token_dict: dict = None):
|
||||
|
||||
|
||||
access_token = str(request.headers.get(Auth.ACCESS_TOKEN_TAG))
|
||||
if token_user := get_object_via_access_key(request=request):
|
||||
if found_user := Users.find_one(uu_id=token_user.get("uu_id")):
|
||||
@@ -620,7 +619,9 @@ class AuthenticationDownloadAvatarEventMethods(MethodToEvent):
|
||||
found_user = Users.check_user_exits(
|
||||
access_key=data.access_key, domain=data.domain
|
||||
)
|
||||
expired_str = str(system_arrow.now() - system_arrow.get(str(found_user.expiry_ends)))
|
||||
expired_str = str(
|
||||
system_arrow.now() - system_arrow.get(str(found_user.expiry_ends))
|
||||
)
|
||||
expired_int = int(
|
||||
client_arrow.get(
|
||||
system_arrow.now() - system_arrow.get(str(found_user.expiry_ends))
|
||||
|
||||
@@ -17,7 +17,6 @@ from api_validations.validations_request import (
|
||||
UpdateBuild,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
|
||||
)
|
||||
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
@@ -147,7 +147,7 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
||||
).first()
|
||||
|
||||
last_living_space = BuildLivingSpace.filter_one(
|
||||
BuildLivingSpace.id==living_space_id[0] if living_space_id else None
|
||||
BuildLivingSpace.id == living_space_id[0] if living_space_id else None
|
||||
)
|
||||
|
||||
data_dict["expiry_starts"] = str(system_arrow.now())
|
||||
@@ -209,7 +209,9 @@ class BuildingLivingSpacesPartsUpdateEventMethods(MethodToEvent):
|
||||
)
|
||||
living_space_id = BuildLivingSpace.session.execute(living_spaces).first()
|
||||
last_living_space = BuildLivingSpace.filter_one(
|
||||
BuildLivingSpace.id==getattr(living_space_id[0], "id", None) if living_space_id else None
|
||||
BuildLivingSpace.id == getattr(living_space_id[0], "id", None)
|
||||
if living_space_id
|
||||
else None
|
||||
)
|
||||
|
||||
data_dict["expiry_starts"] = str(system_arrow.now())
|
||||
|
||||
@@ -93,7 +93,7 @@ class CompanyUpdateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def company_update(cls, company_uu_id: str, data: UpdateCompany, token_dict):
|
||||
find_one_company = Companies.filter_one(Companies.uu_id==company_uu_id)
|
||||
find_one_company = Companies.filter_one(Companies.uu_id == company_uu_id)
|
||||
access_authorized_company = Companies.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Companies.id == token_dict.get("")],
|
||||
|
||||
@@ -25,12 +25,14 @@ class DepartmentListEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def department_list(
|
||||
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
Departments.filter_attr = list_options
|
||||
records = Departments.filter_active(
|
||||
*Departments.get_smart_query(smart_query=list_options.query),
|
||||
Departments.company_id == token_dict.selected_company.company_id
|
||||
Departments.company_id == token_dict.selected_company.company_id,
|
||||
)
|
||||
return return_json_response_from_alchemy(
|
||||
response=records, pagination=list_options
|
||||
@@ -81,7 +83,7 @@ class DepartmentUpdateEventMethods(MethodToEvent):
|
||||
def department_update(
|
||||
cls, company_uu_id: str, data: DepartmentsPydantic, token_dict
|
||||
):
|
||||
find_one_company = Departments.filter_one(Departments.uu_id==company_uu_id)
|
||||
find_one_company = Departments.filter_one(Departments.uu_id == company_uu_id)
|
||||
access_authorized_company = Departments.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Departments.id == token_dict.get("")],
|
||||
|
||||
@@ -17,7 +17,6 @@ from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
|
||||
|
||||
class DutiesListEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "SELECT"
|
||||
@@ -27,12 +26,14 @@ class DutiesListEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def duties_list(
|
||||
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
Duties.filter_attr = list_options
|
||||
records = Duties.filter_all(
|
||||
*Duties.get_smart_query(smart_query=list_options.query),
|
||||
Duties.company_id == token_dict.selected_company.company_id
|
||||
Duties.company_id == token_dict.selected_company.company_id,
|
||||
)
|
||||
return {
|
||||
"completed": True if records.count else False,
|
||||
@@ -50,10 +51,12 @@ class DutiesGetByUUIDEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def duties_get_by_uuid(
|
||||
cls, data: SelectDuties, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: SelectDuties,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
|
||||
duty = Duty.filter_one(Duty.uu_id==data.duty_uu_id).data
|
||||
duty = Duty.filter_one(Duty.uu_id == data.duty_uu_id).data
|
||||
if not duty:
|
||||
return JSONResponse(
|
||||
content={
|
||||
@@ -93,10 +96,12 @@ class DutiesCreateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def duties_create(
|
||||
cls, data: InsertDuties, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: InsertDuties,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
duty = Duty.filter_one(Duty.uu_id==data.duties_uu_id).data
|
||||
department = Departments.filter_one(Duty.uu_id==data.department_uu_id).data
|
||||
duty = Duty.filter_one(Duty.uu_id == data.duties_uu_id).data
|
||||
department = Departments.filter_one(Duty.uu_id == data.department_uu_id).data
|
||||
|
||||
created_duties = Duties.find_or_create(
|
||||
company_id=token_dict.selected_company.company_id,
|
||||
|
||||
@@ -4,7 +4,9 @@ from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertCompanyDuty, PatchRecord, ListOptions
|
||||
InsertCompanyDuty,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from databases import Duty
|
||||
@@ -23,7 +25,9 @@ class DutyListEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def duty_list(
|
||||
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
records = Duty.filter_active(
|
||||
*Duty.get_smart_query(list_options.query),
|
||||
@@ -42,7 +46,9 @@ class DutyCreateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def duty_create(
|
||||
cls, data: InsertCompanyDuty, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: InsertCompanyDuty,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
created_duty = Duty.find_or_create(**data.excluded_dump())
|
||||
Duty.save()
|
||||
@@ -64,7 +70,12 @@ class DutyUpdateEventMethods(MethodToEvent):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def duty_update(cls, company_uu_id: str, data, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]):
|
||||
def duty_update(
|
||||
cls,
|
||||
company_uu_id: str,
|
||||
data,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
find_one_company = Duty.find_one_or_abort(uu_id=company_uu_id)
|
||||
access_authorized_company = Duty.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5), # ?
|
||||
@@ -104,9 +115,15 @@ class DutyPatchEventMethods(MethodToEvent):
|
||||
)
|
||||
if access_authorized_company.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_company.active = bool(action.get("active", find_one_company.active))
|
||||
find_one_company.is_confirmed = bool(action.get("confirm", find_one_company.is_confirmed))
|
||||
find_one_company.deleted = bool(action.get("delete", find_one_company.deleted))
|
||||
find_one_company.active = bool(
|
||||
action.get("active", find_one_company.active)
|
||||
)
|
||||
find_one_company.is_confirmed = bool(
|
||||
action.get("confirm", find_one_company.is_confirmed)
|
||||
)
|
||||
find_one_company.deleted = bool(
|
||||
action.get("delete", find_one_company.deleted)
|
||||
)
|
||||
find_one_company.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
|
||||
@@ -27,7 +27,9 @@ class EmployeeListEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def employee_list(
|
||||
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
Employees.filter_attr = list_options
|
||||
records = Employees.filter_active(
|
||||
@@ -48,7 +50,9 @@ class EmployeeCreateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def employee_create(
|
||||
cls, data: InsertEmployees, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: InsertEmployees,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
person = People.find_one(uu_id=data.people_uu_id)
|
||||
staff = Staff.find_one(uu_id=data.staff_uu_id)
|
||||
@@ -124,7 +128,10 @@ class EmployeePatchEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def employee_patch(
|
||||
cls, employee_uu_id: str, data: PatchRecord, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
employee_uu_id: str,
|
||||
data: PatchRecord,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
find_one_employee = Employees.find_one_or_abort(uu_id=employee_uu_id)
|
||||
access_authorized_employee = Employees.select_action(
|
||||
|
||||
@@ -109,15 +109,15 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def iterate_over_build_parts(
|
||||
cls,
|
||||
build_parts_list,
|
||||
payment_types,
|
||||
local_date,
|
||||
end_date,
|
||||
unit_price,
|
||||
unit_type,
|
||||
book_payment_dict,
|
||||
unit_price_is_fixed
|
||||
cls,
|
||||
build_parts_list,
|
||||
payment_types,
|
||||
local_date,
|
||||
end_date,
|
||||
unit_price,
|
||||
unit_type,
|
||||
book_payment_dict,
|
||||
unit_price_is_fixed,
|
||||
):
|
||||
start_date, payment_return_dict = local_date, {}
|
||||
for build_part_single in build_parts_list:
|
||||
@@ -129,7 +129,9 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
unit_amount = str(build_part_single.due_part_key).replace(" ", "")
|
||||
unit_amount = unit_amount.replace(str(unit_type).upper(), "")
|
||||
payment_amount = abs(unit_price * float(unit_amount)) * -1
|
||||
payment_amount = -1 * (abs(payment_amount) + (50 - float(abs(payment_amount)) % 50))
|
||||
payment_amount = -1 * (
|
||||
abs(payment_amount) + (50 - float(abs(payment_amount)) % 50)
|
||||
)
|
||||
BuildDecisionBookPayments.create(
|
||||
build_parts_id=build_part_single.id,
|
||||
build_parts_uu_id=str(build_part_single.uu_id),
|
||||
@@ -140,7 +142,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
process_date_m=int(local_date.month),
|
||||
process_date_y=int(local_date.year),
|
||||
period_time=f"{local_date.year}-{str(local_date.month).zfill(2)}",
|
||||
**book_payment_dict
|
||||
**book_payment_dict,
|
||||
)
|
||||
local_date = local_date.shift(days=2)
|
||||
part_key = str(build_part_single.due_part_key).upper()
|
||||
@@ -151,17 +153,17 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def create_payment_records_for_each_build_part(
|
||||
cls,
|
||||
data_info_type,
|
||||
build_id,
|
||||
unit_price,
|
||||
unit_type,
|
||||
decision_book,
|
||||
decision_book_item,
|
||||
unit_price_is_fixed,
|
||||
currency,
|
||||
debit_start_date: str = None,
|
||||
debit_end_date: str = None,
|
||||
cls,
|
||||
data_info_type,
|
||||
build_id,
|
||||
unit_price,
|
||||
unit_type,
|
||||
decision_book,
|
||||
decision_book_item,
|
||||
unit_price_is_fixed,
|
||||
currency,
|
||||
debit_start_date: str = None,
|
||||
debit_end_date: str = None,
|
||||
):
|
||||
build_parts_list = BuildParts.filter_active(
|
||||
BuildParts.human_livable == True,
|
||||
@@ -176,8 +178,12 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
)
|
||||
payment_types = ApiEnumDropdown.get_debit_search(search_debit="DT-D")
|
||||
if data_info_type.key == "BDT-D":
|
||||
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())
|
||||
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,
|
||||
@@ -212,8 +218,9 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
meeting_date = system_arrow.get(decision_book.meeting_date).date()
|
||||
|
||||
already_book_projects = BuildDecisionBookProjects.filter_all(
|
||||
BuildDecisionBookProjects.build_decision_book_id==decision_book.id,
|
||||
BuildDecisionBookProjects.project_type==f"{decision_book.decision_type}_{data_info_type.key}",
|
||||
BuildDecisionBookProjects.build_decision_book_id == decision_book.id,
|
||||
BuildDecisionBookProjects.project_type
|
||||
== f"{decision_book.decision_type}_{data_info_type.key}",
|
||||
)
|
||||
management_room = BuildParts.find_one(
|
||||
build_id=build_id, part_no=0, active=True, is_confirmed=True
|
||||
@@ -222,7 +229,8 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
occupant_code="MT-VPR", occupant_category_type="MT"
|
||||
)
|
||||
manager_living_space = BuildLivingSpace.filter_by_active(
|
||||
build_parts_id=management_room.id, occupant_type=occupant_man.id,
|
||||
build_parts_id=management_room.id,
|
||||
occupant_type=occupant_man.id,
|
||||
)
|
||||
if not manager_living_space.data:
|
||||
raise HTTPException(
|
||||
@@ -245,10 +253,12 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
project_response_living_space_id=manager_living_space.id,
|
||||
project_response_living_space_uu_id=str(manager_living_space.uu_id),
|
||||
)
|
||||
book_project_created = BuildDecisionBookProjects.find_or_create(**book_project_dict)
|
||||
book_project_created = BuildDecisionBookProjects.find_or_create(
|
||||
**book_project_dict
|
||||
)
|
||||
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}"
|
||||
f"is assigned to {occupant_man.occupant_description}"
|
||||
)
|
||||
project_lead = ApiEnumDropdown.find_one(
|
||||
key="PTT-LDR", enum_class="ProjectTeamTypes"
|
||||
@@ -332,13 +342,18 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
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",
|
||||
"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"])
|
||||
debit_start_date, debit_end_date = data_dict["debit_start_date"], data_dict["debit_end_date"]
|
||||
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"],
|
||||
)
|
||||
currency = data_dict["currency"]
|
||||
del (
|
||||
data_dict["token"],
|
||||
@@ -347,10 +362,12 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
data_dict["unit_price_is_fixed"],
|
||||
data_dict["debit_start_date"],
|
||||
data_dict["debit_end_date"],
|
||||
data_dict["currency"]
|
||||
data_dict["currency"],
|
||||
)
|
||||
|
||||
if new_decision_book_item := BuildDecisionBookItems.find_or_create(**data_dict):
|
||||
if new_decision_book_item := BuildDecisionBookItems.find_or_create(
|
||||
**data_dict
|
||||
):
|
||||
if new_decision_book_item.is_found:
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
@@ -361,32 +378,32 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||
),
|
||||
)
|
||||
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
|
||||
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(
|
||||
for key, value in dict(
|
||||
sorted(
|
||||
created_payment_records_dict.items(),
|
||||
key=lambda x: x[1],
|
||||
reverse=True
|
||||
)).items():
|
||||
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(item_comment=item_comment)
|
||||
new_decision_book_item.update(is_payment_created=True)
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
|
||||
@@ -26,7 +26,9 @@ class EventBindOccupantEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def bind_events_occupant_super_user(
|
||||
cls, data: RegisterEvents2Occupant, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: RegisterEvents2Occupant,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
|
||||
if not str(token_dict.user_type) == "1":
|
||||
@@ -138,7 +140,9 @@ class EventBindEmployeeEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def bind_events_employee(
|
||||
cls, data: RegisterEvents2Occupant, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: RegisterEvents2Occupant,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@@ -4,10 +4,15 @@ from databases import (
|
||||
Modules,
|
||||
BuildLivingSpace,
|
||||
)
|
||||
from api_validations.validations_request import RegisterModules2Occupant, RegisterModules2Employee
|
||||
from api_validations.validations_request import (
|
||||
RegisterModules2Occupant,
|
||||
RegisterModules2Employee,
|
||||
)
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_events.events.events.events_bind_services import ServiceBindOccupantEventMethods
|
||||
from api_events.events.events.events_bind_services import (
|
||||
ServiceBindOccupantEventMethods,
|
||||
)
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
@@ -24,11 +29,15 @@ class ModulesBindOccupantEventMethods(MethodToEvent):
|
||||
cls, build_living_space_id: int, modules_id: int, expires_at: str = None
|
||||
):
|
||||
|
||||
living_space = BuildLivingSpace.filter_one(Modules.id==build_living_space_id).data
|
||||
modules = Modules.filter_one(Modules.id==modules_id).data
|
||||
living_space = BuildLivingSpace.filter_one(
|
||||
Modules.id == build_living_space_id
|
||||
).data
|
||||
modules = Modules.filter_one(Modules.id == modules_id).data
|
||||
|
||||
service_build_dict = dict(build_living_space_id=living_space.id)
|
||||
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)
|
||||
)
|
||||
if not expires_at:
|
||||
service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
|
||||
|
||||
@@ -71,4 +80,4 @@ ModulesBindOccupantEventMethod = ModulesBindOccupantEventMethods(
|
||||
)
|
||||
ModulesBindEmployeeEventMethod = ModulesBindEmployeeEventMethods(
|
||||
action=ActionsSchema(endpoint="/bind/modules/employee")
|
||||
)
|
||||
)
|
||||
|
||||
@@ -15,7 +15,10 @@ from databases import (
|
||||
Event2Employee,
|
||||
Event2Occupant,
|
||||
)
|
||||
from api_validations.validations_request import RegisterServices2Occupant, RegisterServices2Employee
|
||||
from api_validations.validations_request import (
|
||||
RegisterServices2Occupant,
|
||||
RegisterServices2Employee,
|
||||
)
|
||||
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
|
||||
@@ -33,9 +36,13 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
||||
):
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
|
||||
living_space = BuildLivingSpace.filter_one(BuildLivingSpace.id==build_living_space_id)
|
||||
service = Services.filter_one(Services.id==service_id)
|
||||
add_events_list = Service2Events.filter_all(Service2Events.service_id == service.id).data
|
||||
living_space = BuildLivingSpace.filter_one(
|
||||
BuildLivingSpace.id == build_living_space_id
|
||||
)
|
||||
service = Services.filter_one(Services.id == service_id)
|
||||
add_events_list = Service2Events.filter_all(
|
||||
Service2Events.service_id == service.id
|
||||
).data
|
||||
if not add_events_list:
|
||||
raise Exception(
|
||||
"Service has no events registered. Please contact with your manager"
|
||||
|
||||
@@ -31,7 +31,11 @@ class EventsListEventMethods(MethodToEvent):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def events_list(cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]):
|
||||
def events_list(
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
records = Events.filter_active(
|
||||
*Events.get_smart_query(list_options.query),
|
||||
)
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
from api_validations.validations_request import DepartmentsPydantic, PatchRecord, ListOptions
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
from api_validations.validations_request import DepartmentsPydantic, PatchRecord, ListOptions
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
@@ -59,7 +59,9 @@ class PeopleCreateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def people_create(
|
||||
cls, data: InsertPerson, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: InsertPerson,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
created_user = People.create_action(data=data, token=token_dict)
|
||||
People.save()
|
||||
@@ -82,7 +84,10 @@ class PeopleUpdateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def people_update(
|
||||
cls, data: UpdateUsers, user_uu_id: str, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: UpdateUsers,
|
||||
user_uu_id: str,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
find_one_user = Users.find_one_or_abort(uu_id=user_uu_id)
|
||||
access_authorized_company = Companies.select_action(
|
||||
|
||||
@@ -15,7 +15,8 @@ from api_validations.validations_request import (
|
||||
InsertUsers,
|
||||
UpdateUsers,
|
||||
PatchRecord,
|
||||
ListOptions, RegisterServices2Occupant,
|
||||
ListOptions,
|
||||
RegisterServices2Occupant,
|
||||
)
|
||||
|
||||
|
||||
@@ -61,7 +62,9 @@ class UserCreateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def user_create(
|
||||
cls, data: InsertUsers, token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
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
|
||||
@@ -99,7 +102,10 @@ class UserUpdateEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def user_update(
|
||||
cls, data: UpdateUsers, user_uu_id: str, token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: UpdateUsers,
|
||||
user_uu_id: str,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
find_one_user = Users.find_one_or_abort(uu_id=user_uu_id)
|
||||
access_authorized_company = Companies.select_action(
|
||||
|
||||
Reference in New Issue
Block a user