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

Skip to content

Commit fa42d11

Browse files
authored
Merge pull request #4689 from mruff-aeq/34457-coop-ar-report-types
34457 - Distinct DRS report types for coop annual report bundled outputs
2 parents a3d597f + 7bba08b commit fa42d11

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

legal-api/src/legal_api/reports/document_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ def get_filing_report(self, drs_id: str, report_type: str):
354354
headers = self._get_request_headers(BUSINESS_API_ACCOUNT_ID, APP_PDF)
355355
url: str = self.url.replace(DOC_PATH, "")
356356
get_url = GET_REPORT_PATH
357-
if report_type in [ReportTypes.FILING.value, ReportTypes.FILING_2.value, ReportTypes.NOA.value]:
357+
if report_type in [ReportTypes.FILING.value, ReportTypes.FILING_2.value, ReportTypes.FILING_4.value,
358+
ReportTypes.NOA.value]:
358359
get_url = GET_REPORT_CERTIFIED_PATH
359360
get_url = get_url.format(url=url, product=self.product_code, drsId=drs_id)
360361
response = requests.get(url=get_url, headers=headers)

legal-api/src/legal_api/reports/report.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ def _get_report(self, regenerate: bool = False):
127127
# the FILING report type with that filing's own report, or the DRS lookup below serves
128128
# whichever of the two documents was stored first (#34299).
129129
report_meta = {**report_meta, "reportType": ReportTypes.FILING_2.value}
130+
if self._filing.filing_type == "annualReport" and \
131+
(accompanying_type := {"changeOfDirectors": ReportTypes.FILING_2.value,
132+
"changeOfAddress": ReportTypes.FILING_4.value}.get(self._report_key)):
133+
# A coop annual report can bundle director and address changes as additional legal filings;
134+
# each output must have its own report type or the DRS lookup below serves whichever of the
135+
# documents was stored first (#34457).
136+
report_meta = {**report_meta, "reportType": accompanying_type}
130137
report_type = report_meta.get("reportType")
131138
if business_identifier and not regenerate: # Skip if regenerating and replacing DRS doc.
132139
document, status = self._document_service.get_filing_report_by_filing_id(

legal-api/tests/unit/reports/test_report.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,46 @@ def test_special_resolution_drs_report_type(session, filing_type, expected_repor
11911191
assert response.status_code == HTTPStatus.OK
11921192

11931193

1194+
@pytest.mark.parametrize('filing_type,report_key,expected_report_type', [
1195+
('annualReport', 'annualReport', 'FILING'),
1196+
('annualReport', 'changeOfDirectors', 'FILING-2'),
1197+
('annualReport', 'changeOfAddress', 'FILING-4'),
1198+
('changeOfDirectors', 'changeOfDirectors', 'FILING'),
1199+
('changeOfAddress', 'changeOfAddress', 'FILING'),
1200+
])
1201+
def test_coop_annual_report_drs_report_types(session, filing_type, report_key, expected_report_type):
1202+
"""Assert each legal filing bundled in a coop annual report uses a distinct DRS report type (#34457).
1203+
1204+
When stored with the same FILING report type as the annual report's own output, the DRS-first
1205+
lookup serves whichever of the documents was stored first, so every output shows the same content.
1206+
"""
1207+
identifier = 'CP1234567'
1208+
business = factory_business(identifier=identifier, entity_type='CP')
1209+
1210+
filing_json = copy.deepcopy(FILING_HEADER)
1211+
filing_json['filing']['header']['name'] = filing_type
1212+
filing_json['filing']['business']['identifier'] = identifier
1213+
filing_json['filing']['business']['legalType'] = 'CP'
1214+
if filing_type == 'annualReport':
1215+
filing_json['filing']['annualReport'] = copy.deepcopy(ANNUAL_REPORT['filing']['annualReport'])
1216+
if report_key == 'changeOfDirectors':
1217+
filing_json['filing']['changeOfDirectors'] = copy.deepcopy(CHANGE_OF_DIRECTORS)
1218+
if report_key == 'changeOfAddress':
1219+
filing_json['filing']['changeOfAddress'] = copy.deepcopy(CHANGE_OF_ADDRESS)
1220+
filing = factory_completed_filing(business, filing_json)
1221+
1222+
report = Report(filing)
1223+
report._report_key = report_key
1224+
report._document_service = MagicMock()
1225+
report._document_service.get_filing_report_by_filing_id.return_value = (b'pdf', HTTPStatus.OK)
1226+
1227+
response = report._get_report()
1228+
1229+
report._document_service.get_filing_report_by_filing_id.assert_called_once_with(
1230+
identifier, filing.id, expected_report_type)
1231+
assert response.status_code == HTTPStatus.OK
1232+
1233+
11941234
def _make_static_report_filing(identifier, document_type, file_key):
11951235
"""Create a completed coop dissolution filing with an uploaded document row."""
11961236
from business_model.models import Document

0 commit comments

Comments
 (0)