Skip to content
Open
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/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "legal-api"
version = "3.0.0"
version = "3.0.1"
description = ""
authors = [
{name = "thor",email = "1042854+thorwolpert@users.noreply.github.com"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,7 @@
{% endif %}
</div>

<!-- Retrieved Date and Time: -->
{% if reportType == 'summary' %}
<div class="retrieved-date-time mt-2">Information current as of {{report_date_time}}</div>
{% else %}
<div class="retrieved-date-time mt-2">Document retrieved on {{report_date_time}}</div>
{% endif %}
<!-- Retrieved Date and Time: remove as now added by the DRS when retrieving the NOA/filing report. -->

<!-- this block is hidden but is needed for the footer: -->
<div class="filing-identifier">
Expand Down
19 changes: 15 additions & 4 deletions legal-api/src/legal_api/core/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from legal_api.core.meta import FilingMeta
from legal_api.models import Business, Document, DocumentType, UserRoles
from legal_api.models import Filing as FilingStorage
from legal_api.reports.document_service import DocumentService
from legal_api.services import VersionedBusinessDetailsService
from legal_api.services.authz import has_roles, is_competent_authority

Expand Down Expand Up @@ -402,6 +403,9 @@

query = query.order_by(desc(FilingStorage.filing_date))

drs_service: DocumentService = DocumentService()
drs_docs = drs_service.get_documents_by_business_id(business.identifier) if business else []

ledger = []
for filing in query.all():

Expand Down Expand Up @@ -443,6 +447,10 @@
if filing.court_order_file_number or filing.order_details:
Filing._add_ledger_order(filing, ledger_filing)

core_filing: Filing = Filing() # Filing.get_document_list needs a core Filing.
core_filing._storage = filing # pylint: disable=protected-access
filing_docs = Filing.get_document_list(business, core_filing, jwt)
ledger_filing["documents"] = drs_service.update_filing_documents(drs_docs, filing_docs, filing)
ledger.append(ledger_filing)

return ledger
Expand Down Expand Up @@ -480,7 +488,7 @@
ledger_filing["data"]["order"] = court_order_data

@staticmethod
def get_document_list(business, # noqa: PLR0912
def get_document_list(business, # noqa: PLR0912, PLR0915 NOSONAR(S3776)

Check warning on line 491 in legal-api/src/legal_api/core/filing.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Fix the syntax of this issue suppression comment.

See more on https://sonarcloud.io/project/issues?id=bcgov_lear&issues=AZzoQuMqo-l2g5cZ0_E8&open=AZzoQuMqo-l2g5cZ0_E8&pullRequest=4149

Check failure on line 491 in legal-api/src/legal_api/core/filing.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 52 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=bcgov_lear&issues=AZzoQuMqo-l2g5cZ0_E7&open=AZzoQuMqo-l2g5cZ0_E7&pullRequest=4149
filing,
jwt: JwtManager) -> dict | None:
"""Return a list of documents for a particular filing."""
Expand Down Expand Up @@ -512,7 +520,6 @@
identifier = withdrawn_filing.storage.temp_reg

doc_url = url_for("API2.get_documents", identifier=identifier, filing_id=filing.id, legal_filing_name=None)

documents = {"documents": {}}
# for paper_only filings return and empty documents list
if filing.storage and filing.storage.paper_only:
Expand All @@ -531,6 +538,8 @@
Document.type == DocumentType.COURT_ORDER.value).one_or_none()):
documents["documents"]["uploadedCourtOrder"] = f"{base_url}{doc_url}/uploadedCourtOrder"
documents["documents"]["receipt"] = f"{base_url}{doc_url}/receipt"
elif filing.storage and filing.storage.source == filing.storage.Source.COLIN.value:
documents["documents"]["receipt"] = f"{base_url}{doc_url}/receipt"

no_outputs_except_receipt = filing.filing_type in [
Filing.FilingTypes.CHANGEOFLIQUIDATORS.value,
Expand Down Expand Up @@ -568,10 +577,13 @@
del documents["documents"]["receipt"]
return documents

legal_filings = filing.storage.meta_data.get("legalFilings") if filing.storage.meta_data else None
if not legal_filings and filing.storage and filing.storage.source == filing.storage.Source.COLIN.value:
legal_filings = [filing.filing_type]
if (
filing.status in (Filing.Status.COMPLETED, Filing.Status.CORRECTED) and
filing.storage.meta_data and
(legal_filings := filing.storage.meta_data.get("legalFilings"))
legal_filings
and not (no_outputs_except_receipt or no_outputs_except_receipt_dissolution)
):
legal_filings_copy = copy.deepcopy(legal_filings)
Expand Down Expand Up @@ -612,7 +624,6 @@

adds = [FilingMeta.get_all_outputs(business.legal_type, doc) for doc in legal_filings]
additional = {item for sublist in adds for item in sublist}

FilingMeta.alter_outputs(filing.storage, business, additional)
for doc in additional:
documents["documents"][doc] = f"{base_url}{doc_url}/{doc}"
Expand Down
Loading