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

22353 correction of C, CBEN, CCC, CUL #2943

Merged
merged 2 commits into from
Aug 26, 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
2 changes: 1 addition & 1 deletion legal-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ PyPDF2==1.26.0
reportlab==3.6.12
html-sanitizer==2.4.1
lxml==5.2.2
git+https://github.com/bcgov/[email protected].27#egg=registry_schemas
git+https://github.com/bcgov/[email protected].28#egg=registry_schemas
2 changes: 1 addition & 1 deletion legal-api/requirements/bcregistry-libraries.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
git+https://github.com/bcgov/[email protected].27#egg=registry_schemas
git+https://github.com/bcgov/[email protected].28#egg=registry_schemas
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def validate(business: Business, filing: Dict) -> Error:
if legal_type := filing.get('filing', {}).get('business', {}).get('legalType'):
if legal_type in [Business.LegalTypes.SOLE_PROP.value, Business.LegalTypes.PARTNERSHIP.value]:
_validate_firms_correction(business, filing, legal_type, msg)
elif legal_type in [Business.LegalTypes.COMP.value, Business.LegalTypes.BCOMP.value,
Business.LegalTypes.BC_ULC_COMPANY.value,
Business.LegalTypes.BC_CCC.value]:
elif legal_type in Business.CORPS:
_validate_corps_correction(filing, legal_type, msg)
elif legal_type in [Business.LegalTypes.COOP.value]:
_validate_special_resolution_correction(filing, legal_type, msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ def validate_roles(filing_dict: dict, legal_type: str, filing_type: str = 'incor
Business.LegalTypes.BCOMP.value: 1,
Business.LegalTypes.COMP.value: 1,
Business.LegalTypes.BC_ULC_COMPANY.value: 1,
Business.LegalTypes.BC_CCC.value: 3
Business.LegalTypes.BC_CCC.value: 3,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This func is used in correction

Business.LegalTypes.BCOMP_CONTINUE_IN.value: 1,
Business.LegalTypes.CONTINUE_IN.value: 1,
Business.LegalTypes.ULC_CONTINUE_IN.value: 1,
Business.LegalTypes.CCC_CONTINUE_IN.value: 3
}
parties_array = filing_dict['filing'][filing_type]['parties']
msg = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from flask import current_app
from jinja2 import Template
from legal_api.core.filing_helper import is_special_resolution_correction_by_filing_json
from legal_api.models import Filing
from legal_api.models import Business, Filing

from entity_emailer.email_processors import get_filing_document, get_filing_info, substitute_template_parts
from entity_emailer.email_processors.special_resolution_helper import get_completed_pdfs
Expand Down Expand Up @@ -107,7 +107,7 @@ def _get_pdfs(
}
)
attach_order += 1
elif legal_type in ('BC', 'BEN', 'CC', 'ULC'):
elif legal_type in Business.CORPS:
# add notice of articles
noa_pdf_type = 'noticeOfArticles'
noa_encoded = get_filing_document(business['identifier'], filing.id, noa_pdf_type, token)
Expand Down Expand Up @@ -206,7 +206,7 @@ def process(email_info: dict, token: str) -> Optional[dict]: # pylint: disable=

if legal_type in ['SP', 'GP']:
prefix = 'FIRM'
elif legal_type in ['BC', 'BEN', 'CC', 'ULC']:
elif legal_type in Business.CORPS:
original_filing_type = filing.filing_json['filing']['correction']['correctedFilingType']
if original_filing_type in ['annualReport', 'changeOfAddress', 'changeOfDirectors']:
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
filing your annual report.
</p>

{% if business.legalType == 'BEN' %}
{% if business.legalType in ['BEN', 'CBEN'] %}
[[whitespace-16px.html]]
<p>
In addition to filing the annual report with the Business Registry, there is a legal requirement for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
<div class="name bold">Company Name:</div>
{% endif %}

{% if filing_status == 'PAID' and filing_type in ['amalgamationApplication', 'incorporationApplication',
'continuationIn'] %}
{% if filing_status == 'PAID' and filing_type in ['amalgamationApplication', 'continuationIn', 'incorporationApplication'] %}
{% if filing.nameRequest.legalName %}
<!-- try to get legal name from Name Request object -->
<div class="value">{{ filing.nameRequest.legalName }}</div>
Expand All @@ -36,7 +35,7 @@
{% else %}
<div class="name bold">Incorporation Number:</div>
{% endif %}
{% if filing_status == 'PAID' and filing_type in ['amalgamationApplication', 'incorporationApplication'] %}
{% if filing_status == 'PAID' and filing_type in ['amalgamationApplication', 'continuationIn', 'incorporationApplication'] %}
<div class="value">Pending</div>
{% else %}
<!-- Eg, BC0878529 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def process(correction_filing: Filing, filing: Dict, filing_meta: FilingMeta, bu
)

corrected_filing_type = filing['correction']['correctedFilingType']
# added CP, change of directors / change of address for CP is allowed
if business.legal_type in ['SP', 'GP', 'BC', 'BEN', 'CC', 'ULC', 'CP'] and \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary if condition, this contains all legal types

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we add new legal types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be handled in allowable actions

corrected_filing_type != 'conversion':
if corrected_filing_type != 'conversion':
vysakh-menon-aot marked this conversation as resolved.
Show resolved Hide resolved
correct_business_data(business, correction_filing, filing, filing_meta)
else:
# set correction filing to PENDING_CORRECTION, for manual intervention
Expand Down
60 changes: 0 additions & 60 deletions queue_services/entity-filer/tests/unit/test_worker/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,66 +422,6 @@ async def test_process_filing_completed(app, session, mocker):
assert business.last_ar_date


async def test_correction_filing(app, session, mocker):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not valid anymore. CP will not go to PENDING_CORRECTION status

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That status was for "local corrections", right?

Yes, local corrections are removed from UI code. The only possibility is something like a conversion correction (as above), but even that's not allowed, I think.

"""Assert we can process a correction filing."""
# vars
payment_id = str(random.SystemRandom().getrandbits(0x58))
identifier = 'CP1111111'
correction_filing_comment = 'We need to fix directors'

# get a fixed datetime to use in comparisons, in "local" (Pacific) timezone
local_timezone = pytz.timezone('US/Pacific')
correction_filing_date = \
datetime.datetime(2019, 9, 17, 0, 0).replace(tzinfo=datetime.timezone.utc).astimezone(tz=local_timezone)

# setup - create business, staff user, and original filing to be corrected
business_id = create_business(identifier).id
staff_user_id = create_user(username='staff_user').id
original_filing_id = create_filing(payment_id, copy.deepcopy(ANNUAL_REPORT), business_id).id

# setup - create correction filing
filing = copy.deepcopy(CORRECTION_AR)
filing['filing']['header']['identifier'] = identifier
filing['filing']['correction']['comment'] = correction_filing_comment
filing['filing']['correction']['correctedFilingId'] = original_filing_id
correction_filing = create_filing(payment_id, filing, business_id, filing_date=correction_filing_date)
correction_filing.submitter_id = staff_user_id
correction_filing.save()

correction_filing_id = correction_filing.id
filing_msg = {'filing': {'id': correction_filing_id}}

mocker.patch('legal_api.services.bootstrap.AccountService.update_entity', return_value=None)
# TEST
await process_filing(filing_msg, app)

# Get modified data
original_filing = Filing.find_by_id(original_filing_id)
correction_filing = Filing.find_by_id(correction_filing_id)
staff_user = User.find_by_username('staff_user')

# check that the correction filing is linked to the original filing
assert original_filing.parent_filing
assert original_filing.parent_filing == correction_filing

# check that the correction comment has been added to the correction filing
assert 0 < len(correction_filing.comments.all())
assert correction_filing_comment == correction_filing.comments.all()[-1].comment
assert staff_user.id == correction_filing.comments.all()[-1].staff.id

# check that the correction filing is PENDING_CORRECTION
assert correction_filing.status == 'PENDING_CORRECTION'

# check that the original filing is marked as corrected
# assert True is original_filing.is_corrected

# check that the original filing has the new comment
assert 0 < len(original_filing.comments.all())
assert f'This filing was corrected on {correction_filing_date.date().isoformat()}.' == \
original_filing.comments.all()[-1].comment
assert staff_user.id == original_filing.comments.all()[-1].staff.id


async def test_publish_event():
"""Assert that publish_event is called with the correct struct."""
import uuid
Expand Down
Loading