-
Notifications
You must be signed in to change notification settings - Fork 83
32920 - Update Filer to Process Directors Based on ID Instead of Name for LEAR Filings #4256
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
Changes from all commits
b8282d4
2622125
c089bdc
69befa5
3b880fb
762845a
85a2dc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,55 @@ | |
|
|
||
| from business_filer.exceptions import QueueException | ||
| from business_filer.filing_meta import FilingMeta | ||
| from business_filer.filing_processors.filing_components import create_party, create_role, update_director | ||
| from business_filer.filing_processors.filing_components import ( | ||
| create_party, | ||
| create_role, | ||
| update_director, | ||
| ) | ||
|
|
||
|
|
||
| def process(business: Business, filing_rec: Filing, filing_meta: FilingMeta): # noqa: PLR0912 | ||
| def _update_director_using_name(director: dict, business_id: int): | ||
| """Update director information based on name matching.""" | ||
| if "nameChanged" in director["actions"]: | ||
| director_name = (director["officer"].get("prevFirstName") + | ||
| director["officer"].get("prevMiddleInitial", "") + | ||
| director["officer"].get("prevLastName")) | ||
| else: | ||
| director_name = (director["officer"].get("firstName") + | ||
| director["officer"].get("middleInitial", "") + | ||
| director["officer"].get("lastName")) | ||
| if not director_name: | ||
| current_app.logger.error("Could not resolve director name from json %s.", director) | ||
| raise QueueException | ||
|
|
||
| for current_director in PartyRole.get_parties_by_role(business_id, PartyRole.RoleTypes.DIRECTOR.value): | ||
| current_director_name = (current_director.party.first_name + | ||
| (current_director.party.middle_initial or "") + | ||
| current_director.party.last_name) | ||
| if current_director_name.upper() == director_name.upper() and current_director.cessation_date is None: | ||
| update_director(director=current_director, new_info=director) | ||
| break | ||
|
|
||
| def _update_director_using_party_id(director: dict, business_id: int): | ||
| """Update director information based on party ID matching.""" | ||
| party_id = director["officer"].get("id") | ||
| if not party_id: | ||
| current_app.logger.error("Could not resolve party id from json %s.", director) | ||
| raise QueueException | ||
|
|
||
| matched = False | ||
| for current_director in PartyRole.get_parties_by_role(business_id, PartyRole.RoleTypes.DIRECTOR.value): | ||
| if current_director.party_id == party_id and current_director.cessation_date is None: | ||
| update_director(director=current_director, new_info=director) | ||
| matched = True | ||
| break | ||
|
|
||
| if not matched: | ||
| current_app.logger.error("Could not find active director with party id %s for business %s.", | ||
| party_id, business_id) | ||
| raise QueueException | ||
|
|
||
| def process(business: Business, filing_rec: Filing, filing_meta: FilingMeta): # noqa: PLR0912 | ||
| """Render the change_of_directors onto the business model objects.""" | ||
| filing_json = copy.deepcopy(filing_rec.filing_json) | ||
| if not (directors := filing_json["filing"]["changeOfDirectors"].get("directors")): | ||
|
|
@@ -54,7 +99,8 @@ def process(business: Business, filing_rec: Filing, filing_meta: FilingMeta): # | |
| new_directors = [] | ||
|
|
||
| for director in directors: # pylint: disable=too-many-nested-blocks; | ||
| # Applies only for filings coming from colin. | ||
| # Applies to CoD filings originating from COLIN (currently COOPs only). | ||
| # Continue using name-based matching for directors. | ||
| if filing_rec.colin_event_ids: | ||
| director_found = False | ||
| director_name = (director["officer"].get("firstName") + | ||
|
|
@@ -88,32 +134,16 @@ def process(business: Business, filing_rec: Filing, filing_meta: FilingMeta): # | |
| new_directors.append(director) | ||
|
|
||
| elif any([action != "appointed" for action in director["actions"]]): # noqa: C419 | ||
| # get name of director in json for comparison * | ||
| if "nameChanged" in director["actions"]: | ||
| director_name = (director["officer"].get("prevFirstName") + | ||
| director["officer"].get("prevMiddleInitial", "") + | ||
| director["officer"].get("prevLastName")) | ||
| if filing_rec.colin_event_ids: | ||
| # Colin path: retain name-based matching for now. | ||
| _update_director_using_name(director=director, business_id=business.id) | ||
| else: | ||
| director_name = (director["officer"].get("firstName") + | ||
| director["officer"].get("middleInitial", "") + | ||
| director["officer"].get("lastName")) | ||
| if not director_name: | ||
| current_app.logger.error("Could not resolve director name from json %s.", director) | ||
| raise QueueException | ||
|
|
||
| for current_director in PartyRole.get_parties_by_role(business.id, PartyRole.RoleTypes.DIRECTOR.value): | ||
| # get name of director in database for comparison * | ||
| current_director_name = (current_director.party.first_name + | ||
| (current_director.party.middle_initial or "") + | ||
| current_director.party.last_name) | ||
| # Update only an active director | ||
| if current_director_name.upper() == director_name.upper() and current_director.cessation_date is None: | ||
| update_director(director=current_director, new_info=director) | ||
| break | ||
| # Lear path: match by party ID instead of name | ||
| _update_director_using_party_id(director=director, business_id=business.id) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For |
||
|
|
||
| for director in new_directors: | ||
| # add new diretor party role to the business | ||
| party = create_party(business_id=business.id, party_info=director) | ||
| party = create_party(business_id=business.id, party_info=director, create=False) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| role = { | ||
| "roleType": "Director", | ||
| "appointmentDate": director.get("appointmentDate"), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't maintain the director id from
learincolinand vice versa so keeping the existing logic for colin path (matching based on name) since there is no cross-reference for the id.