Skip to content

Commit

Permalink
22203 - Added furnishings logging (bcgov#2909)
Browse files Browse the repository at this point in the history
* 22203 - Added furnishings logging

* fixed lint issue

* fixed flake8 issue

* added some logging in post processor of furnishing job
  • Loading branch information
JazzarKarim authored Aug 14, 2024
1 parent 6a11f80 commit 3eb435c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@ def _update_furnishings_status(self, furnishing_group_id):
def process(self):
"""Postprocess to generate and upload file to external resources(BC Laws)."""
self._format_furnishings()
self._app.logger.debug('Formatted furnishing details presented in XML file')
self._set_meta_info()
payload = self._build_xml_data(self._xml_data)
furnishing_group, _ = self._save_xml_payload(payload)
self._app.logger.debug('Saved XML payload')
# TODO: SFTP to BC Laws

# mark furnishing records processed
self._update_furnishings_status(furnishing_group.id)
self._app.logger.debug(
f'furnishing records with group id: {furnishing_group.id} marked as processed')


class XmlMeta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,29 @@ async def _send_first_round_notification(self, batch_processing: BatchProcessing
business.legal_name,
email
)
self._app.logger.debug(f'New furnishing has been created with ID (first round): {new_furnishing.id}')

mailing_address = business.mailing_address.one_or_none()
if mailing_address:
self._create_furnishing_address(mailing_address, new_furnishing.id)
self._app.logger.debug(f'Created address (first round) with furnishing ID: {new_furnishing.id}')
if email:
# send email letter
await self._send_email(new_furnishing)
self._app.logger.debug(
f'Successfully put email message on the queue for furnishing entry with ID: {new_furnishing.id}')
else:
# send paper letter if business doesn't have email address
new_furnishing.furnishing_type = Furnishing.FurnishingType.MAIL
new_furnishing.save()
self._app.logger.debug(f'Changed furnishing type to MAIL for funishing with ID: {new_furnishing.id}')

# TODO: create and add letter to either AR or transition pdf
# TODO: send AR and transition pdf to BCMail+
new_furnishing.status = Furnishing.FurnishingStatus.PROCESSED
new_furnishing.processed_date = datetime.utcnow()
new_furnishing.save()
self._app.logger.debug(f'Changed furnishing status to PROCESSED for funishing with ID: {new_furnishing.id}')

async def _send_second_round_notification(self, batch_processing: BatchProcessing):
"""Send paper letter if business is still not in good standing after 5 days of email letter sent out."""
Expand All @@ -127,10 +134,12 @@ async def _send_second_round_notification(self, batch_processing: BatchProcessin
business.last_ar_date if business.last_ar_date else business.founding_date,
business.legal_name
)
self._app.logger.debug(f'New furnishing has been created with ID (second round): {new_furnishing.id}')

mailing_address = business.mailing_address.one_or_none()
if mailing_address:
self._create_furnishing_address(mailing_address, new_furnishing.id)
self._app.logger.debug(f'Created address (second round) with furnishing ID: {new_furnishing.id}')

# TODO: create and add letter to either AR or transition pdf
# TODO: send AR and transition pdf to BCMail+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def process(app: Flask):
business_name=business.legal_name
)
new_furnishing.save()
app.logger.debug(f'Created corp dissolved furnishing entry with ID: {new_furnishing.id}')
# TODO: create data files and SFTPing to BC Laws
# TODO: mark furnishings entry processed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def process(app: Flask, xml_furnishings: dict):
business_name=business.legal_name
)
new_furnishing.save()
app.logger.debug(f'Created intent to dissolve furnishing entry with ID: {new_furnishing.id}')

if business != Business.LegalTypes.EXTRA_PRO_A.value:
bc_furnishings.append(new_furnishing)
Expand Down
6 changes: 6 additions & 0 deletions jobs/furnishings/src/furnishings/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,16 @@ async def run(application: Flask, qsm: QueueService): # pylint: disable=redefin
xml_furnishings_dict = {}

if stage_1_valid:
application.logger.debug('Entering stage 1 of furnishings job.')
await stage_one.process(application, qsm)
application.logger.debug('Exiting stage 1 of furnishings job.')
if stage_2_valid:
application.logger.debug('Entering stage 2 of furnishings job.')
stage_two.process(application, xml_furnishings_dict)
application.logger.debug('Exiting stage 2 of furnishings job.')
if stage_3_valid:
application.logger.debug('Entering stage 3 of furnishings job.')
stage_three.process(application)
application.logger.debug('Exiting stage 3 of furnishings job.')

post_processor.process(application, xml_furnishings_dict)

0 comments on commit 3eb435c

Please sign in to comment.