diff --git a/legal-api/src/legal_api/reports/report.py b/legal-api/src/legal_api/reports/report.py index 6d584cb0f3..00b64b1785 100644 --- a/legal-api/src/legal_api/reports/report.py +++ b/legal-api/src/legal_api/reports/report.py @@ -72,7 +72,7 @@ def _get_static_report(self): return current_app.response_class(response=response.data, status=response.status, mimetype="application/pdf") def _get_report(self): - if self._filing.legal_entity_id: + if self._filing.legal_entity_id or self._filing.alternate_name_id: self._business = BusinessService.fetch_business_by_filing(self._filing) Report._populate_business_info_to_filing(self._filing, self._business) if self._report_key == "alteration": @@ -315,7 +315,7 @@ def _set_completing_party(self, filing): self._filing.id, datetime.utcnow(), EntityRole.RoleTypes.completing_party.name ) if completing_party_role: - filing["completingParty"] = completing_party_role[0].party.json + filing["completingParty"] = completing_party_role[0].related_entity.party_json with suppress(KeyError): self._format_address(filing["completingParty"]["deliveryAddress"]) with suppress(KeyError): @@ -654,7 +654,7 @@ def _format_agm_extension_data(self, filing): filing["extended_agm_date"] = date_approved_obj.strftime(OUTPUT_DATE_FORMAT) filing["offices"] = VersionedBusinessDetailsService.get_office_revision( - self._filing.transaction_id, self._business.id # pylint: disable=no-member + self._filing, self._business # pylint: disable=no-member ) with suppress(KeyError): self._format_address(filing["offices"]["registeredOffice"]["mailingAddress"]) @@ -665,7 +665,7 @@ def _format_agm_location_change_data(self, filing): filing["location"] = self._filing.filing_json["filing"].get("agmLocationChange", {}).get("agmLocation", "") filing["offices"] = VersionedBusinessDetailsService.get_office_revision( - self._filing.transaction_id, self._business.id # pylint: disable=no-member + self._filing, self._business # pylint: disable=no-member ) with suppress(KeyError): @@ -837,7 +837,7 @@ def _format_change_of_registration_data( ): # noqa: E501 # pylint: disable=too-many-locals, too-many-branches, too-many-statements prev_completed_filing = Filing.get_previous_completed_filing(self._filing) versioned_business = VersionedBusinessDetailsService.get_business_revision_obj( - prev_completed_filing, self._business.id + prev_completed_filing, self._business ) # Change of Name diff --git a/legal-api/src/legal_api/resources/v2/business/business_filings/business_documents.py b/legal-api/src/legal_api/resources/v2/business/business_filings/business_documents.py index 14a48c1aba..19b995c807 100644 --- a/legal-api/src/legal_api/resources/v2/business/business_filings/business_documents.py +++ b/legal-api/src/legal_api/resources/v2/business/business_filings/business_documents.py @@ -121,6 +121,15 @@ def _get_receipt(business: any, filing: Filing, token): headers = {"Authorization": "Bearer " + token} url = f'{current_app.config.get("PAYMENT_SVC_URL")}/{filing.storage.payment_token}/receipts' + + business_number = "" + if business: + if business.is_alternate_name_entity and business.bn15: + business_number = business.bn15 + + if business.is_legal_entity and business.tax_id: + business_number = business.tax_id + receipt = requests.post( url, json={ @@ -130,7 +139,7 @@ def _get_receipt(business: any, filing: Filing, token): ), "effectiveDateTime": effective_date if effective_date else "", "filingIdentifier": str(filing.id), - "businessNumber": business.tax_id if business and business.tax_id else "", + "businessNumber": business_number, }, headers=headers, ) diff --git a/legal-api/src/legal_api/services/business_details_version.py b/legal-api/src/legal_api/services/business_details_version.py index e8cb49f133..b531a0cdff 100644 --- a/legal-api/src/legal_api/services/business_details_version.py +++ b/legal-api/src/legal_api/services/business_details_version.py @@ -230,7 +230,7 @@ def get_business_revision_obj(filing, business) -> any: business_revision = ( db.session.query(business_version) - .filter(business_version.change_filing_id == filing.id) + .filter(business_version.change_filing_id <= filing.id) .filter(business_version.id == business.id) .first() ) @@ -278,7 +278,7 @@ def get_office_revision(filing, business) -> dict: # pylint: disable=too-many-l offices_current = ( db.session.query(Office, null().label("changed")) - .filter(Office.change_filing_id == filing_id) + .filter(Office.change_filing_id <= filing_id) .filter(office_attribute == business.id) .filter(Office.deactivated_date == None) # noqa: E711,E501; ) # pylint: disable=singleton-comparison @@ -289,21 +289,21 @@ def get_office_revision(filing, business) -> dict: # pylint: disable=too-many-l ) offices_historical = ( db.session.query(office_history) - .filter(office_history.change_filing_id == filing_id) + .filter(office_history.change_filing_id <= filing_id) .filter(office_history_attribute == business.id) .filter(office_history.deactivated_date == None) # noqa: E711,E501; ) # pylint: disable=singleton-comparison - # Get all of the valid types in effect for this LegalEntity and Filing + # Get all of the valid types in effect for this Business and Filing current_types = ( db.session.query(Office.office_type.label("office_type")) - .filter(Office.change_filing_id == filing_id) + .filter(Office.change_filing_id <= filing_id) .filter(office_attribute == business.id) .filter(Office.deactivated_date == None) # noqa: E711,E501; ) # pylint: disable=singleton-comparison historical_types = ( db.session.query(office_history.office_type.label("office_type")) - .filter(office_history.change_filing_id == filing_id) + .filter(office_history.change_filing_id <= filing_id) .filter(office_history_attribute == business.id) .filter(office_history.deactivated_date == None) # noqa: E711,E501; ) # pylint: disable=singleton-comparison @@ -322,13 +322,13 @@ def get_office_revision(filing, business) -> dict: # pylint: disable=too-many-l addresses_current = ( db.session.query(Address, null().label("changed")) - .filter(Address.change_filing_id == filing_id) + .filter(Address.change_filing_id <= filing_id) .filter(Address.office_id == office.id) ) addresses_historical = ( db.session.query(address_history) - .filter(address_history.change_filing_id == filing_id) + .filter(address_history.change_filing_id <= filing_id) .filter(address_history.office_id == office.id) )