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

Update amendment reports debtor birthdate change. #1775

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
{% if party.address_change is defined %}
<div class="pt-1"><span class="label">ADDRESS CHANGED</span></div>
{% endif %}
{% else %}
{% elif party.birthdate_change is not defined %}
<div class="pt-1"><span class="label">ADDED</span></div>
{% endif %}
</td>
Expand All @@ -83,7 +83,10 @@
{% if party.personName is defined %}
<div class="section-sub-title">Birthdate</div>
<div class="pt-2">{% if party.birthDate is defined %}{{ party.birthDate }}{% endif %}</div>
{% endif %}
{% if party.birthdate_change is defined %}
<div class="pt-1"><span class="label">CHANGED</span></div>
{% endif %}
{% endif %}
</td>
</tr>
{% if not loop.last %}
Expand Down Expand Up @@ -153,7 +156,7 @@
{% if party.address_change is defined %}
<div class="pt-1"><span class="label">ADDRESS CHANGED</span></div>
{% endif %}
{% else %}
{% elif party.birthdate_change is not defined %}
<div class="pt-1"><span class="label">ADDED</span></div>
{% endif %}
</td>
Expand All @@ -168,6 +171,9 @@
{% if party.personName is defined %}
<div class="section-sub-title">Birthdate</div>
<div class="pt-2">{% if party.birthDate is defined %}{{ party.birthDate }}{% endif %}</div>
{% if party.birthdate_change is defined %}
<div class="pt-1"><span class="label">CHANGED</span></div>
{% endif %}
{% endif %}
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{% if party.address_change is defined %}
<div class="pt-1"><span class="label">ADDRESS CHANGED</span></div>
{% endif %}
{% else %}
{% elif party.birthdate_change is not defined %}
<div class="pt-1"><span class="label">ADDED</span></div>
{% endif %}
</td>
Expand All @@ -77,6 +77,9 @@
{% if party.personName is defined %}
<div class="section-sub-title">Birthdate</div>
<div class="pt-2">{% if party.birthDate is defined %}{{ party.birthDate }}{% endif %}</div>
{% if party.birthdate_change is defined %}
<div class="pt-1"><span class="label">CHANGED</span></div>
{% endif %}
{% endif %}
</td>
</tr>
Expand Down
35 changes: 4 additions & 31 deletions ppr-api/src/ppr_api/reports/v2/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,40 +662,13 @@ def _set_amend_party_addresses(self, statement):
def _set_modified_party(add_party, delete_parties):
"""Set the update flags for a single party ."""
for delete_party in delete_parties:
if 'reg_id' in add_party and 'reg_id' in delete_party and \
if add_party.get('reg_id') and delete_party.get('reg_id') and \
add_party['reg_id'] == delete_party['reg_id'] and 'edit' not in delete_party:
if add_party.get('amendPartyId', 0) > 0 and add_party['amendPartyId'] == delete_party.get('partyId'):
delete_party['edit'] = True
if 'businessName' in add_party and 'businessName' in delete_party and \
add_party['businessName'] != delete_party['businessName']:
add_party['name_change'] = True
elif 'personName' in add_party and 'personName' in delete_party and \
add_party['personName'] != delete_party['personName']:
add_party['name_change'] = True
else:
add_party['address_change'] = True
break
report_utils.set_party_change_type(add_party, delete_party, True)
if 'amendPartyId' not in add_party:
if add_party['address'] == delete_party['address']:
if 'businessName' in add_party and 'businessName' in delete_party and \
add_party['businessName'] != delete_party['businessName']:
add_party['name_change'] = True
delete_party['edit'] = True
break
if 'personName' in add_party and 'personName' in delete_party and \
add_party['personName'] != delete_party['personName']:
add_party['name_change'] = True
delete_party['edit'] = True
break
elif 'businessName' in add_party and 'businessName' in delete_party and \
add_party['businessName'] == delete_party['businessName']:
add_party['address_change'] = True
delete_party['edit'] = True
break
elif 'personName' in add_party and 'personName' in delete_party and \
add_party['personName'] == delete_party['personName']:
add_party['address_change'] = True
delete_party['edit'] = True
report_utils.set_party_change_type(add_party, delete_party, True)
if delete_party.get('edit'):
break

def _set_modified_parties(self, statement):
Expand Down
44 changes: 44 additions & 0 deletions ppr-api/src/ppr_api/reports/v2/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,47 @@ def format_description(description: str) -> str:
doc_desc = doc_desc.replace(' Under ', ' under ')
doc_desc = doc_desc.replace(' In ', ' in ')
return doc_desc


def is_same_name(add_party: dict, delete_party: dict) -> bool:
"""Determine if party names are identical."""
if add_party.get('businessName') and delete_party.get('businessName') and \
add_party['businessName'] == delete_party['businessName']:
return True
if add_party.get('personName') and delete_party.get('personName') and \
add_party['personName'] == delete_party['personName']:
return True
return False


def set_party_change_type(add_party, delete_party, is_same_party_id: bool):
"""Conditionally set the name/address/birthdate change type for a single party ."""
name_change: bool = False
address_change: bool = False
birthdate_change: bool = False
if is_same_party_id:
delete_party['edit'] = True
if not is_same_name(add_party, delete_party):
name_change = True
if add_party.get('address') != delete_party.get('address'):
address_change = True
if not (address_change and name_change) \
and add_party.get('birthDate', '') != delete_party.get('birthDate', ''):
birthdate_change = True
else:
same_name: bool = is_same_name(add_party, delete_party)
same_address: bool = add_party['address'] == delete_party['address']
if not same_name:
name_change = True
if not same_address:
address_change = True
if (same_address or same_name) and add_party.get('birthDate', '') != delete_party.get('birthDate', ''):
birthdate_change = True
if name_change and not address_change:
add_party['name_change'] = True
elif not name_change and address_change:
add_party['address_change'] = True
if birthdate_change:
add_party['birthdate_change'] = True
if add_party.get('name_change') or add_party.get('address_change') or add_party.get('birthdate_change'):
delete_party['edit'] = True
2 changes: 1 addition & 1 deletion ppr-api/src/ppr_api/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '1.2.1' # pylint: disable=invalid-name
__version__ = '1.2.2' # pylint: disable=invalid-name
Loading