decision book create update
This commit is contained in:
parent
1ae1264ace
commit
6ccb13809a
|
|
@ -27,6 +27,12 @@ from api_events.events.authentication import (
|
|||
AuthenticationForgotPasswordEventMethod,
|
||||
AuthenticationDownloadAvatarEventMethod,
|
||||
)
|
||||
from api_events.events.account.account_records import (
|
||||
AccountRecordsListEventMethod,
|
||||
AccountRecordsCreateEventMethod,
|
||||
AccountRecordsUpdateEventMethod,
|
||||
AccountRecordsPatchEventMethod,
|
||||
)
|
||||
from api_events.events.identity.users import (
|
||||
UserListEventMethod,
|
||||
UserCreateEventMethod,
|
||||
|
|
@ -163,6 +169,10 @@ __all__ = [
|
|||
"AuthenticationRefreshTokenEventMethod",
|
||||
"AuthenticationForgotPasswordEventMethod",
|
||||
"AuthenticationDownloadAvatarEventMethod",
|
||||
"AccountRecordsListEventMethod",
|
||||
"AccountRecordsCreateEventMethod",
|
||||
"AccountRecordsUpdateEventMethod",
|
||||
"AccountRecordsPatchEventMethod",
|
||||
"UserListEventMethod",
|
||||
"UserCreateEventMethod",
|
||||
"UserUpdateEventMethod",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import typing
|
||||
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from api_validations.validations_request import (
|
||||
InsertAccountRecord,
|
||||
UpdateAccountRecord,
|
||||
|
|
@ -13,6 +14,8 @@ from databases import (
|
|||
AccountRecords,
|
||||
BuildIbans,
|
||||
)
|
||||
from databases.sql_models.building.build import Build
|
||||
from databases.sql_models.others.enums import ApiEnumDropdown
|
||||
|
||||
|
||||
class AccountRecordsListEventMethods(MethodToEvent):
|
||||
|
|
@ -61,12 +64,11 @@ class AccountRecordsCreateEventMethods(MethodToEvent):
|
|||
data: InsertAccountRecord,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
|
||||
data_dict = data.excluded_dump()
|
||||
if isinstance(token_dict, OccupantTokenObject):
|
||||
build_iban = BuildIbans.filter_one(
|
||||
BuildIbans.iban == data.iban,
|
||||
BuildIbans.company_id
|
||||
== token_dict.selected_occupant.responsible_company_id,
|
||||
BuildIbans.build_id == token_dict.selected_occupant.build_id,
|
||||
).data
|
||||
if not build_iban:
|
||||
BuildIbans.raise_http_exception(
|
||||
|
|
@ -84,23 +86,47 @@ class AccountRecordsCreateEventMethods(MethodToEvent):
|
|||
result=account_record.get_dict(),
|
||||
)
|
||||
elif isinstance(token_dict, EmployeeTokenObject):
|
||||
build_iban = BuildIbans.filter_one(
|
||||
BuildIbans.iban == data.iban,
|
||||
BuildIbans.company_id == token_dict.selected_company.company_id,
|
||||
).data
|
||||
if not build_iban:
|
||||
BuildIbans.raise_http_exception(
|
||||
status_code="HTTP_404_NOT_FOUND",
|
||||
error_case="UNAUTHORIZED",
|
||||
message=f"{data.iban} is not found in company related to your organization",
|
||||
data={
|
||||
"iban": data.iban,
|
||||
},
|
||||
)
|
||||
account_record = AccountRecords.find_or_create(**data.excluded_dump())
|
||||
# Build.pre_query = Build.select_action(
|
||||
# employee_id=token_dict.selected_employee.employee_id,
|
||||
# )
|
||||
# build_ids_list = Build.filter_all(
|
||||
# *Build.valid_record_args(Build),
|
||||
# )
|
||||
# build_iban = BuildIbans.filter_one(
|
||||
# BuildIbans.iban == data.iban,
|
||||
# BuildIbans.build_id.in_([build.id for build in build_ids_list.data]),
|
||||
# ).data
|
||||
# if not build_iban:
|
||||
# BuildIbans.raise_http_exception(
|
||||
# status_code="HTTP_404_NOT_FOUND",
|
||||
# error_case="UNAUTHORIZED",
|
||||
# message=f"{data.iban} is not found in company related to your organization",
|
||||
# data={
|
||||
# "iban": data.iban,
|
||||
# },
|
||||
# )
|
||||
bank_date = system_arrow.get(data.bank_date)
|
||||
data_dict["bank_date_w"] = bank_date.weekday()
|
||||
data_dict["bank_date_m"] = bank_date.month
|
||||
data_dict["bank_date_d"] = bank_date.day
|
||||
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
|
||||
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
|
||||
data_dict["receive_debit"] = debit_type.id
|
||||
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
||||
|
||||
account_record = AccountRecords.find_or_create(**data_dict)
|
||||
account_record.save()
|
||||
account_record.update(is_confirmed=True)
|
||||
account_record.save()
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Update Build record",
|
||||
message="Create Account record are successful",
|
||||
result=account_record.get_dict(),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class BuildListEventMethods(MethodToEvent):
|
|||
Build.filter_attr = list_options
|
||||
records = Build.filter_all(
|
||||
*Build.valid_record_args(Build),
|
||||
).data
|
||||
)
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Building Records are listed",
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class BuildingBuildPartsListEventMethods(MethodToEvent):
|
|||
build_list_ids = [build.id for build in build_list_query.all()]
|
||||
BuildParts.pre_query = BuildParts.filter_all(
|
||||
BuildParts.build_id.in_(build_list_ids),
|
||||
*BuildParts.valid_record_args(BuildParts),
|
||||
).query
|
||||
BuildParts.filter_attr = list_options
|
||||
records = BuildParts.filter_all(
|
||||
|
|
@ -64,6 +63,8 @@ class BuildingBuildPartsCreateEventMethods(MethodToEvent):
|
|||
):
|
||||
created_build = BuildParts.create_action(data=data, token=token_dict)
|
||||
created_build.save()
|
||||
created_build.update(is_confirmed=True)
|
||||
created_build.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
|||
error_case="UNAUTHORIZED",
|
||||
message=f"{data.build_parts_uu_id} - Build Part is not found in database. Check build part uu_id",
|
||||
data={
|
||||
"life_person_uu_id": data.life_person_uu_id,
|
||||
"build_parts_uu_id": data.build_parts_uu_id,
|
||||
},
|
||||
)
|
||||
life_person = People.filter_one(
|
||||
|
|
@ -148,9 +148,9 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
|||
BuildLivingSpace.raise_http_exception(
|
||||
status_code="HTTP_404_NOT_FOUND",
|
||||
error_case="UNAUTHORIZED",
|
||||
message=f"{data.life_person_uu_id} - Living Person is not found in database.",
|
||||
message=f"{data.person_uu_id} - Living Person is not found in database.",
|
||||
data={
|
||||
"life_person_uu_id": data.life_person_uu_id,
|
||||
"person_uu_id": data.person_uu_id,
|
||||
},
|
||||
)
|
||||
occupant_type = OccupantTypes.filter_by_one(uu_id=data.occupant_type_uu_id).data
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
|||
)
|
||||
build = Build.filter_one(
|
||||
Build.uu_id == data.build_uu_id,
|
||||
Build.active == True,
|
||||
).get(1)
|
||||
*Build.valid_record_args(Build),
|
||||
).data
|
||||
if not build:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
|
|
@ -102,7 +102,7 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
|||
company = Companies.filter_one(
|
||||
Companies.uu_id == data.resp_company_uu_id,
|
||||
*Companies.valid_record_args(Companies),
|
||||
).get(1)
|
||||
).data
|
||||
if not company:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
|
|
@ -144,11 +144,11 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
|||
occupant_build = Build.filter_one(
|
||||
Build.id == token_dict.selected_occupant.build_id,
|
||||
*Build.valid_record_args(Build),
|
||||
).get(1)
|
||||
).data
|
||||
occupant_company = Companies.filter_one(
|
||||
Companies.id == token_dict.selected_occupant.responsible_company_id,
|
||||
*Companies.valid_record_args(Companies),
|
||||
).get(1)
|
||||
).data
|
||||
data_dict["build_id"] = occupant_build.id
|
||||
data_dict["build_uu_id"] = str(occupant_build.uu_id)
|
||||
data_dict["resp_company_id"] = occupant_company.id
|
||||
|
|
@ -160,12 +160,12 @@ 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)
|
||||
BuildDecisionBook.save()
|
||||
build_decision_book.save()
|
||||
build_decision_book.update(is_confirmed=True)
|
||||
build_decision_book.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content=dict(
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class PeopleListEventMethods(MethodToEvent):
|
|||
People.filter_attr = list_options
|
||||
records = People.filter_all(
|
||||
*People.valid_record_args(People),
|
||||
).data
|
||||
)
|
||||
elif isinstance(token_dict, OccupantTokenObject):
|
||||
related_users = Users.filter_all(
|
||||
Users.related_company
|
||||
|
|
@ -54,7 +54,7 @@ class PeopleListEventMethods(MethodToEvent):
|
|||
People.filter_attr = list_options
|
||||
records = People.filter_all(
|
||||
*People.valid_record_args(People),
|
||||
).data
|
||||
)
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="People are listed successfully",
|
||||
|
|
|
|||
|
|
@ -90,6 +90,10 @@ class SuperUserEventBlock(AddEventFunctionality):
|
|||
{"function_code": "76f11a08-5f4a-4e1f-961f-aaef21699acd"},
|
||||
{"function_code": "41ea7f29-006a-4310-b5c4-b2a0e1a504bd"},
|
||||
{"function_code": "5344d03c-fc47-43ec-8c44-6c2acd7e5d9f"},
|
||||
{"function_code": "31f4f32f-0cd4-4995-8a6a-f9f56335848a"},
|
||||
{"function_code": "7192c2aa-5352-4e36-98b3-dafb7d036a3d"},
|
||||
{"function_code": "ec98ef2c-bcd0-432d-a8f4-1822a56c33b2"},
|
||||
{"function_code": "34c38937-42a2-45f1-b2ef-a23978650aee"},
|
||||
]
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -26,7 +26,20 @@ class AlchemyJsonResponse:
|
|||
cls.result = result
|
||||
cls.completed = completed
|
||||
|
||||
first_item = cls.result.get(1)
|
||||
if isinstance(cls.result, dict) or isinstance(cls.result, list):
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
content=dict(
|
||||
total_count=len(cls.result),
|
||||
count=len(cls.result),
|
||||
pagination=None,
|
||||
completed=cls.completed,
|
||||
message=cls.message,
|
||||
data=cls.result,
|
||||
),
|
||||
)
|
||||
|
||||
first_item = getattr(cls.result, 'data', None)
|
||||
if not first_item:
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
|
|
@ -39,6 +52,7 @@ class AlchemyJsonResponse:
|
|||
data=[],
|
||||
),
|
||||
)
|
||||
|
||||
if cls.result.first:
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
|
|
@ -52,7 +66,7 @@ class AlchemyJsonResponse:
|
|||
),
|
||||
)
|
||||
|
||||
if not first_item.filter_attr:
|
||||
if not cls.result.get(1).filter_attr and isinstance(cls.result.data, list):
|
||||
counts = cls.result.count
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
|
|
@ -66,9 +80,10 @@ class AlchemyJsonResponse:
|
|||
),
|
||||
)
|
||||
|
||||
filter_model = first_item.filter_attr
|
||||
total_count = cls.result.query.limit(None).offset(None).count()
|
||||
total_page_number = round(total_count / int(first_item.filter_attr.size), 0)
|
||||
filter_model = cls.result.get(1).filter_attr
|
||||
total_count = cls.result.get(1).query.limit(None).offset(None).count()
|
||||
|
||||
total_page_number = round(total_count / int(filter_model.size), 0)
|
||||
|
||||
pagination_dict = {
|
||||
"size/total_count": [cls.result.count, total_count],
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class InsertAccountRecord(BaseModelRegular):
|
|||
accounting_receipt_number: Optional[int] = None
|
||||
approved_record: Optional[bool] = None
|
||||
import_file_name: Optional[str] = None
|
||||
receive_debit_uu_id: Optional[str] = None
|
||||
# receive_debit_uu_id: Optional[str] = None
|
||||
budget_type_uu_id: Optional[str] = None
|
||||
company_uu_id: Optional[str] = None
|
||||
send_company_uu_id: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class InsertBuildParts(PydanticBaseModel):
|
|||
default_accessory: Optional[str] = None
|
||||
human_livable: Optional[bool] = False
|
||||
part_direction_uu_id: Optional[str] = None
|
||||
ref_id: Optional[str] = None
|
||||
|
||||
# current_owner_person_uu_id: Optional[str] = None
|
||||
# current_tenant_person_uu_id: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class InsertPerson(BaseModelRegular):
|
|||
birth_place: Optional[str] = None
|
||||
birth_date: Optional[str] = None
|
||||
tax_no: Optional[str] = None
|
||||
ref_id: Optional[str] = None
|
||||
|
||||
|
||||
class ResponsePersonSalesMange(PydanticBaseModel):
|
||||
|
|
|
|||
|
|
@ -430,48 +430,44 @@ class AccountRecords(CrudCollection):
|
|||
approving_accounting_record: Mapped[bool] = mapped_column(
|
||||
Boolean, server_default="0"
|
||||
)
|
||||
accounting_receipt_date = mapped_column(
|
||||
accounting_receipt_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, server_default="1900-01-01 00:00:00"
|
||||
)
|
||||
accounting_receipt_number = mapped_column(Integer, server_default="0")
|
||||
status_id = mapped_column(SmallInteger, server_default="0")
|
||||
accounting_receipt_number: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
status_id: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
approved_record: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
import_file_name = 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"))
|
||||
receive_debit_uu_id = 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
|
||||
)
|
||||
budget_type_uu_id = mapped_column(
|
||||
budget_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Budget Type UU ID"
|
||||
)
|
||||
|
||||
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
company_uu_id = mapped_column(String, nullable=True, comment="Company UU ID")
|
||||
send_company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
send_company_uu_id = mapped_column(
|
||||
String, nullable=True, comment="Send Company UU ID"
|
||||
)
|
||||
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" )
|
||||
|
||||
customer_id: Mapped[int] = mapped_column(ForeignKey("people.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"))
|
||||
send_person_uu_id = mapped_column(
|
||||
String, nullable=True, comment="Send Person UU ID"
|
||||
)
|
||||
approving_accounting_person: Mapped[int] = mapped_column(ForeignKey("people.id"))
|
||||
approving_accounting_person_uu_id = mapped_column(
|
||||
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)
|
||||
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"))
|
||||
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"
|
||||
)
|
||||
build_decision_book_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book.id")
|
||||
ForeignKey("build_decision_book.id"), nullable=True
|
||||
)
|
||||
build_decision_book_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Build Decision Book UU ID"
|
||||
|
|
|
|||
|
|
@ -20,6 +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)
|
||||
filter_attr = None # The filter attributes to use in the model.
|
||||
FilterModel = ListOptions
|
||||
|
||||
|
|
@ -130,6 +131,7 @@ class FilterAttributes:
|
|||
)
|
||||
args = cls.get_not_expired_query_arg(args)
|
||||
query = cls._query().filter(*args).with_entities(*select_args)
|
||||
cls.total_count = query.count()
|
||||
if order_by is not None:
|
||||
query = query.order_by(order_by)
|
||||
if limit:
|
||||
|
|
@ -145,9 +147,11 @@ class FilterAttributes:
|
|||
kwargs["is_confirmed"] = True
|
||||
kwargs.pop("system", None)
|
||||
query = cls._query().filter_by(**kwargs)
|
||||
cls.total_count = query.count()
|
||||
if cls.filter_attr:
|
||||
filter_list = cls.get_filter_attributes()
|
||||
data_query = cls.add_query_to_filter(query, filter_list)
|
||||
cls.filter_attr = None
|
||||
return AlchemyResponse(query=data_query, first=False)
|
||||
return AlchemyResponse(query=query, first=False)
|
||||
|
||||
|
|
@ -160,6 +164,7 @@ class FilterAttributes:
|
|||
kwargs["is_confirmed"] = True
|
||||
kwargs.pop("system", None)
|
||||
query = cls._query().filter_by(**kwargs)
|
||||
cls.total_count = 1
|
||||
return AlchemyResponse(query=query, first=True)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -174,9 +179,11 @@ class FilterAttributes:
|
|||
args = cls.get_not_expired_query_arg(args)
|
||||
|
||||
query = cls._query().filter(*args)
|
||||
cls.total_count = query.count()
|
||||
if cls.filter_attr:
|
||||
filter_list = cls.get_filter_attributes()
|
||||
data_query = cls.add_query_to_filter(query, filter_list)
|
||||
cls.filter_attr = None
|
||||
return AlchemyResponse(query=data_query, first=False)
|
||||
return AlchemyResponse(query=query, first=False)
|
||||
|
||||
|
|
@ -191,6 +198,7 @@ class FilterAttributes:
|
|||
)
|
||||
args = cls.get_not_expired_query_arg(args)
|
||||
query = cls._query().filter(*args)
|
||||
cls.total_count = 1
|
||||
return AlchemyResponse(query=query, first=True)
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
from service_app_test.api_configs import BothAPIS
|
||||
from service_app_test.test_application.migrate_old_data.reader_and_alchemy_bulk_actions import (
|
||||
read_json_file,
|
||||
)
|
||||
from api_validations.validations_request import (
|
||||
InsertAccountRecord,
|
||||
)
|
||||
|
||||
|
||||
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"
|
||||
pydantic_row = InsertAccountRecord(**row)
|
||||
with_pydantic.append(pydantic_row.model_dump())
|
||||
if not with_pydantic:
|
||||
raise Exception("No data found")
|
||||
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())
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
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.reader_and_alchemy_bulk_actions import (
|
||||
read_json_file,
|
||||
)
|
||||
|
|
@ -58,10 +59,15 @@ def get_build_part_from_json(build_part_type_uu_id: str, part_direction_uu_id: s
|
|||
for row in read_files:
|
||||
row["build_part_type_uu_id"] = build_part_type_uu_id
|
||||
row["part_direction_uu_id"] = part_direction_uu_id
|
||||
row["ref_id"] = row.get("uu_id")
|
||||
pydantic_row = InsertBuildParts(**row)
|
||||
with_pydantic.append(pydantic_row.model_dump())
|
||||
print(f"get buildpart row {pydantic_row.dump()}")
|
||||
model_dump = pydantic_row.dump()
|
||||
with_pydantic.append(model_dump)
|
||||
|
||||
if not with_pydantic:
|
||||
raise Exception("No data found")
|
||||
|
||||
return with_pydantic
|
||||
|
||||
|
||||
|
|
@ -203,15 +209,40 @@ def migrate_build_iban(requester: BothAPIS, build_uu_id: str):
|
|||
return
|
||||
|
||||
|
||||
def migrate_build_living_space(requester: BothAPIS, build_uu_id: str):
|
||||
# build_uu_id = grab_new_build_uu_id(requester=requester, build_uu_id=build_uu_id)
|
||||
response_datas = get_build_iban_from_json()
|
||||
def migrate_build_living_space(requester: BothAPIS):
|
||||
response_datas = get_build_living_space_from_json()
|
||||
for response_data in response_datas:
|
||||
response_data["build_uu_id"] = build_uu_id
|
||||
response = requester.local_api.post(
|
||||
endpoint="/people/list",
|
||||
data={"page": 1, "size": 1, "query": {"ref_id": response_data.get("person_uu_id")}},
|
||||
)
|
||||
print("/people/list response", response.text)
|
||||
|
||||
response_data["person_uu_id"] = response.json()["data"][0]["uu_id"]
|
||||
|
||||
response = requester.local_api.post(
|
||||
endpoint="/building/parts/list",
|
||||
data={"page": 1, "size": 1, "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)
|
||||
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)
|
||||
response_data["occupant_type_uu_id"] = response["data"]["uu_id"]
|
||||
else:
|
||||
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(
|
||||
**requester_dict_build_living_space(data=response_data)
|
||||
)
|
||||
print("response", response.text)
|
||||
print("migrate_build_living_space", response.text)
|
||||
return
|
||||
|
||||
|
||||
|
|
@ -251,5 +282,5 @@ def migrate_build(requester: BothAPIS):
|
|||
build_part_type_uu_id=building_type_flat,
|
||||
part_direction_uu_id=api_enum_dropdown_nn_uuid
|
||||
)
|
||||
migrate_build_iban(requester=requester, build_uu_id=build_uu_id)
|
||||
# migrate_build_iban(requester=requester, build_uu_id=build_uu_id)
|
||||
return
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,11 +3,13 @@ from service_app_test.api_configs import WagAPI, LocalAPI, BothAPIS
|
|||
|
||||
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, 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
|
||||
|
||||
password_token = "b-4liqvEJIX9wtmMScnJhDOkPTIvyra1I_1HQCgTKG3Mp6Oaj-Vh8dVqqpZFC-fGlQ-5bnuDpzrju4Jg6qoi48EB5brdNT4YQCLdQqMlO8uUrL8iuJmRPk4L9AOQl82NFXD0U4pbZ9fhZkp4vHl487S9HcO1Dz5qUYR1VOs5mt2p0d96c5qrWB4QcDkkbz2F"
|
||||
|
||||
password_token = "D0UjFwQjReEjhQuXzytYXj_tPkkFPbRJsj_0Pp9ha2dlvaEj5jC9b76J7UPfKb-s_UqJQAXvRgP3jaKyfTvc_POtMQFALiLzlPUp4Sg-Qjiz9wEECJNc8fWqbfNPtLOFzV5XktV72Whnb4AJYr4pQ9AnuGm4txQnjB_NTPnuZYjyLVnqj9mrLkDKzuXLPSVd"
|
||||
login_data = {
|
||||
"domain": "evyos.com.tr",
|
||||
"access_key": "karatay.berkay.sup@evyos.com.tr",
|
||||
|
|
@ -42,3 +44,6 @@ both_apis.local_api = local_api
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue