Skip to content

Commit

Permalink
20362 - Filing outputs (bcgov#2564)
Browse files Browse the repository at this point in the history
* 20362-Filing outputs

* 20362-fix formatting issue

* 20362-fix flake 8 issue

* 20362-fix header for dissolution statement

* 20362-fixes after review
  • Loading branch information
ketaki-deodhar authored and PaulGarewal committed Apr 12, 2024
1 parent 34fc0aa commit 460aa8f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
10 changes: 5 additions & 5 deletions legal-api/src/legal_api/reports/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"])
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand All @@ -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,
)
Expand Down
16 changes: 8 additions & 8 deletions legal-api/src/legal_api/services/business_details_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
)

Expand Down

0 comments on commit 460aa8f

Please sign in to comment.