Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d944c68

Browse files
authored
34467 Legal API - amalg UI mapping fix, filer test tweak (#4737)
Signed-off-by: Kial Jinnah <[email protected]>
1 parent 3bc88f4 commit d944c68

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

legal-api/src/legal_api/services/filings/validations/amalgamation_application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,8 @@ def _norm_directors(parties: list | None) -> set:
695695
officer = party.get("officer") or {}
696696
directors.add((
697697
_norm_value(officer.get("firstName")),
698-
_norm_value(officer.get("middleInitial")),
698+
# the UI submits "middleName" while LEAR/COLIN sources carry "middleInitial"
699+
_norm_value(officer.get("middleInitial") or officer.get("middleName")),
699700
_norm_value(officer.get("lastName")),
700701
_norm_value(officer.get("organizationName")),
701702
_norm_address(party.get("deliveryAddress")),

legal-api/tests/unit/services/filings/validations/test_amalgamation_application.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,8 @@ def test_foreign_business_region_bc_rejected(mocker, app, session, jwt):
22502250
'corrected outside of this filing before this amalgamation can be filed.')
22512251

22522252

2253-
def _factory_short_form_source_business(identifier='BC7654321', share_class_name='Class A Shares'):
2253+
def _factory_short_form_source_business(identifier='BC7654321', share_class_name='Class A Shares',
2254+
middle_initial=None):
22542255
"""Create a holding/primary business with offices, a director, shares and a resolution."""
22552256
business = factory_business(identifier, entity_type=Business.LegalTypes.COMP.value)
22562257
for office_type in ['registeredOffice', 'recordsOffice']:
@@ -2271,7 +2272,8 @@ def _factory_short_form_source_business(identifier='BC7654321', share_class_name
22712272
business.resolutions.append(Resolution(resolution_date=date(2020, 5, 13),
22722273
resolution_type=Resolution.ResolutionType.SPECIAL.value))
22732274

2274-
party = Party(first_name='DIRECTOR', last_name='ONE', party_type=Party.PartyTypes.PERSON.value)
2275+
party = Party(first_name='DIRECTOR', middle_initial=middle_initial, last_name='ONE',
2276+
party_type=Party.PartyTypes.PERSON.value)
22752277
party.delivery_address = factory_address(f'{identifier} director street', 'delivery')
22762278
party.save()
22772279
business.party_roles.append(PartyRole(role=PartyRole.RoleTypes.DIRECTOR.value,
@@ -2365,6 +2367,31 @@ def test_short_form_match_lear(app, session, jwt, test_status, expected_msg):
23652367
assert expected_msg in [x['error'] for x in err.msg]
23662368

23672369

2370+
@pytest.mark.parametrize('test_status', ['SUCCESS', 'MISMATCH'])
2371+
def test_short_form_match_director_middle_name(app, session, jwt, test_status):
2372+
"""Assert the comparator accepts the UI's officer "middleName" against the source's "middleInitial"."""
2373+
account_id = '123456'
2374+
holding = _factory_short_form_source_business(middle_initial='M')
2375+
factory_business('BC1111111', entity_type=Business.LegalTypes.COMP.value)
2376+
filing = _short_form_filing_from_lear(holding)
2377+
aml = filing['filing']['amalgamationApplication']
2378+
2379+
# the UI submits directors with "middleName" (renamed from the API's "middleInitial")
2380+
for party in aml['parties']:
2381+
officer = party['officer']
2382+
if officer.pop('middleInitial', None):
2383+
officer['middleName'] = 'M' if test_status == 'SUCCESS' else 'X'
2384+
2385+
with jwt_request_context(app, jwt, [STAFF_ROLE], 'staff-user', account_id):
2386+
err = validate(None, filing, account_id)
2387+
2388+
if test_status == 'SUCCESS':
2389+
assert not err, err.msg
2390+
else:
2391+
assert f"Directors do not match the holding business's current directors. {REFRESH_HINT}" in \
2392+
[x['error'] for x in err.msg]
2393+
2394+
23682395
def test_short_form_match_lear_ignores_db_artifacts(app, session, jwt):
23692396
"""Assert ids, priorities and numeric formatting differences do not fail the match."""
23702397
account_id = '123456'

queue_services/business-filer/tests/unit/test_filer/test_amalgamation_application.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,15 @@ def test_short_form_amalgamation_missing_sections(app, session, missing_section)
300300
assert 'short-form filing missing' in excinfo.value.error
301301

302302

303-
def test_colin_amalgamating_business(app, session):
303+
@pytest.mark.parametrize('colin_identifier_prefix', [
304+
'BC', # a BC corp in COLIN not yet loaded in LEAR
305+
'A', # an extraprovincial company (identifier-only entry, same path)
306+
])
307+
def test_colin_amalgamating_business(app, session, colin_identifier_prefix):
304308
"""Assert a COLIN business (not loaded in LEAR) is persisted by identifier and not dissolved."""
305309
filing_type = 'amalgamationApplication'
306310
amalgamating_identifier = f'BC{random.randint(1000000, 9999999)}'
307-
colin_identifier = f'BC{random.randint(1000000, 9999999)}'
311+
colin_identifier = f'{colin_identifier_prefix}{random.randint(1000000, 9999999)}'
308312
next_corp_num = f'BC{random.randint(1000000, 9999999)}'
309313

310314
amalgamating_business_id = create_entity(amalgamating_identifier, 'BC', 'amalgamating business').id

0 commit comments

Comments
 (0)