Skip to content

Commit

Permalink
Fix SE reg type amendment set up. (#1979)
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett authored Jul 15, 2024
1 parent 93d4668 commit 5d62285
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ppr-api/src/ppr_api/models/financing_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ def securities_act_notices_json(self, registration_id):
notice_json['added'] = True
if notice_json:
notices_list.append(notice.json)
if notices_list and self.current_view_json: # Current view remove existing amendment notice/order links.
for notice in notices_list:
if 'amendNoticeId' in notice:
del notice['amendNoticeId']
if notice.get('securitiesActOrders'):
for order in notice.get('securitiesActOrders'):
if 'amendOrderId' in order:
del order['amendOrderId']
return notices_list

def validate_debtor_name(self, debtor_name_json, staff: bool = False):
Expand Down
7 changes: 7 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 @@ -752,3 +752,10 @@ def set_modified_notice(statement):
# Amend order check
if del_notice and del_notice.get('securitiesActOrders') and add_notice.get('securitiesActOrders'):
set_modified_order(add_notice, del_notice)
elif del_notice and del_notice.get('securitiesActOrders'): # Notice amended, all orders removed.
del_orders = []
for del_order in del_notice.get('securitiesActOrders'):
order = copy.deepcopy(del_order)
order['amendDeleted'] = True
del_orders.append(order)
add_notice['securitiesActOrders'] = del_orders
6 changes: 6 additions & 0 deletions ppr-api/tests/unit/models/test_financing_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ def test_find_by_registration_number(session, desc, reg_number, reg_type, accoun
assert result['generalCollateral'][0]
assert result.get('securitiesActNotices')
assert result['securitiesActNotices'][0].get('securitiesActOrders')
if statement.current_view_json:
for notice in result.get('securitiesActNotices'):
assert 'amendNoticeId' not in notice
if notice.get('securitiesActOrders'):
for order in notice.get('securitiesActOrders'):
assert 'amendOrderId' not in order
else:
with pytest.raises(BusinessException) as request_err:
FinancingStatement.find_by_registration_number(reg_number, account_id, staff, create)
Expand Down

0 comments on commit 5d62285

Please sign in to comment.