decision book create update
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user