Skip to content
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: 2 additions & 0 deletions legal-api/report-templates/template-parts/certification.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if not business.isCorp %}
<div class="no-page-break">
<div class="separator mt-4"></div>
<div class="section-title mt-4">Certification</div>
Expand All @@ -12,3 +13,4 @@
{% endif %}
</div>
</div>
{% endif %}
11 changes: 11 additions & 0 deletions legal-api/src/legal_api/reports/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def _get_template_data(self):
self._set_meta_info(filing)
self._set_registrar_info(filing)
self._set_completing_party(filing)
self._set_corp_flag(filing)

filing["enable_new_ben_statements"] = flags.is_on("enable-new-ben-statements")
filing["enable_sandbox"] = flags.is_on("enable-sandbox")
Expand Down Expand Up @@ -359,6 +360,16 @@ def _handle_special_resolution_filing_data(self, filing):
elif self._report_key == "specialResolutionApplication":
self._format_special_resolution_application(filing, "alteration")

def _set_corp_flag(self, filing):
"""Set a flag indicating whether the entity is a corporation."""
if self._business:
legal_type = self._business.legal_type
else:
filing_json = self._filing.filing_json.get("filing", {})
filing_type = self._filing.filing_type
legal_type = filing_json.get(filing_type, {}).get("nameRequest", {}).get("legalType")
filing["business"]["isCorp"] = legal_type in Business.CORPS

def _set_completing_party(self, filing):
completing_party_role = PartyRole.get_party_roles_by_filing(
self._filing.id, datetime.utcnow(), PartyRole.RoleTypes.COMPLETING_PARTY.value)
Expand Down
35 changes: 35 additions & 0 deletions legal-api/tests/unit/reports/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,38 @@ def test_document_service_not_create_document(session, mock_doc_service, mocker)
assert False
except BusinessException as err:
assert err.status_code == HTTPStatus.NOT_FOUND

@pytest.mark.parametrize(
'test_name, identifier, entity_type, expected_is_corp',
[
# Corporation types - should be True
('BC corp', 'BC1234567', 'BC', True),
('BEN corp', 'BC1234567', 'BEN', True),
('CC corp', 'BC1234567', 'CC', True),
('ULC corp', 'BC1234567', 'ULC', True),
('C continuation', 'C1234567', 'C', True),
('CBEN continuation', 'C1234567', 'CBEN', True),
('CCC continuation', 'C1234567', 'CCC', True),
('CUL continuation', 'C1234567', 'CUL', True),
# Non-corporation types - should be False
('CP cooperative', 'CP1234567', 'CP', False),
('SP sole prop', 'FM1234567', 'SP', False),
('GP partnership', 'FM1234567', 'GP', False),
]
)
def test_set_corp_flag(session, test_name, identifier, entity_type, expected_is_corp):
"""Assert _set_corp_flag correctly identifies corporation vs non-corporation types."""
report = create_report(
identifier=identifier,
entity_type=entity_type,
report_type='annualReport',
filing_type='annualReport',
template=ANNUAL_REPORT
)
report._populate_business_info_to_filing(report._filing, report._business)

filing = report._filing.filing_json['filing']
report._set_corp_flag(filing)

assert filing['business']['isCorp'] == expected_is_corp, \
f'{test_name}: expected isCorp={expected_is_corp} for legalType={entity_type}'