Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MHR API QS transfer data validation fix #2079

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions mhr-api/src/mhr_api/utils/registration_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,13 @@ def validate_transfer_non_staff(registration: MhrRegistration, json_data, reg_ty
json_data.get("deleteOwnerGroups")
and len(json_data.get("deleteOwnerGroups")) != 1
and group == QUALIFIED_USER_GROUP
and len(json_data.get("deleteOwnerGroups")) != validator_owner_utils.get_existing_group_count(registration)
):
error_msg += TRAN_QUALIFIED_DELETE
if validator_owner_utils.get_delete_group_count(
registration, json_data
) != 1 and validator_owner_utils.get_existing_group_count(registration) != len(
json_data.get("deleteOwnerGroups")
):
error_msg += TRAN_QUALIFIED_DELETE
error_msg += validate_transfer_dealer(registration, json_data, reg_type, group)
if json_data.get("transferDocumentType"):
error_msg += TRANS_DOC_TYPE_NOT_ALLOWED
Expand Down
17 changes: 17 additions & 0 deletions mhr-api/src/mhr_api/utils/validator_owner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,23 @@ def get_death_group_count(registration: MhrRegistration, json_data: dict) -> int
return add_count - edit_count


def get_delete_group_count(registration: MhrRegistration, json_data: dict) -> int:
"""Transfer non-staff registration get deleted group count ignoring owner edits."""
del_count: int = len(json_data.get("deleteOwnerGroups"))
if del_count == 1:
return 1
# Ignore groups with valid owner edits.
edit_count: int = 0
for group in json_data.get("addOwnerGroups"):
if is_edit_group(registration, group):
edit_count += 1
if edit_count == 0:
return del_count
if del_count - edit_count == 0:
return 1
return del_count - edit_count


def get_death_add_group(json_data: dict) -> dict:
"""Transfer death registration get single added group ignoring owner edits."""
if len(json_data.get("addOwnerGroups")) == 1:
Expand Down