diff --git a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py index ebbc37540e..b606e57fa9 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/stage_one.py +++ b/jobs/furnishings/src/furnishings/stage_processors/stage_one.py @@ -44,8 +44,7 @@ async def process(self, batch_processing: BatchProcessing): business_id=batch_processing.business_id ) if not furnishings: - # send first notification if no furnishing entry exists - await self._send_first_round_notification(batch_processing) + await self._send_first_round_notification(batch_processing, batch_processing.business) else: # send paper letter if business is still not in good standing after 5 days of email letter sent out valid_furnishing_names = [ @@ -72,7 +71,7 @@ async def process(self, batch_processing: BatchProcessing): if has_elapsed_email_entry and not has_mail_entry: await self._send_second_round_notification(batch_processing) - async def _send_first_round_notification(self, batch_processing: BatchProcessing): + async def _send_first_round_notification(self, batch_processing: BatchProcessing, business: Business): """Process first round of notification(email/letter).""" _, eligible_details = InvoluntaryDissolutionService.check_business_eligibility( batch_processing.business_identifier, @@ -91,8 +90,10 @@ async def _send_first_round_notification(self, batch_processing: BatchProcessing batch_processing, eligible_details, Furnishing.FurnishingType.EMAIL, + business.last_ar_date if business.last_ar_date else business.founding_date, + business.legal_name, email - ) + ) # notify emailer await self._send_email(new_furnishing) else: @@ -100,7 +101,9 @@ async def _send_first_round_notification(self, batch_processing: BatchProcessing new_furnishing = self._create_new_furnishing( batch_processing, eligible_details, - Furnishing.FurnishingType.MAIL + Furnishing.FurnishingType.MAIL, + business.last_ar_date if business.last_ar_date else business.founding_date, + business.legal_name ) mailing_address = business.mailing_address.one_or_none() @@ -126,7 +129,9 @@ async def _send_second_round_notification(self, batch_processing: BatchProcessin new_furnishing = self._create_new_furnishing( batch_processing, eligible_details, - Furnishing.FurnishingType.MAIL + Furnishing.FurnishingType.MAIL, + business.last_ar_date if business.last_ar_date else business.founding_date, + business.legal_name ) mailing_address = business.mailing_address.one_or_none() @@ -138,11 +143,13 @@ async def _send_second_round_notification(self, batch_processing: BatchProcessin new_furnishing.status = Furnishing.FurnishingStatus.PROCESSED new_furnishing.processed_date = datetime.utcnow() - def _create_new_furnishing( + def _create_new_furnishing( # pylint: disable=too-many-arguments self, batch_processing: BatchProcessing, eligible_details: InvoluntaryDissolutionService.EligibilityDetails, furnishing_type: Furnishing.FurnishingType, + last_ar_date: datetime, + business_name: str, email: str = None ) -> Furnishing: """Create new furnishing entry.""" @@ -172,6 +179,8 @@ def _create_new_furnishing( last_modified=datetime.utcnow(), status=Furnishing.FurnishingStatus.QUEUED, grouping_identifier=grouping_identifier, + last_ar_date=last_ar_date, + business_name=business_name, email=email ) new_furnishing.save() diff --git a/jobs/furnishings/src/furnishings/stage_processors/stage_two.py b/jobs/furnishings/src/furnishings/stage_processors/stage_two.py index 448f80b692..997cb75239 100644 --- a/jobs/furnishings/src/furnishings/stage_processors/stage_two.py +++ b/jobs/furnishings/src/furnishings/stage_processors/stage_two.py @@ -58,7 +58,8 @@ def process(app: Flask): created_date=datetime.utcnow(), last_modified=datetime.utcnow(), status=Furnishing.FurnishingStatus.QUEUED, - grouping_identifier=grouping_identifier + grouping_identifier=grouping_identifier, + business_name=business.legal_name ) new_furnishing.save() # TODO: create data files and SFTPing to BC Laws diff --git a/jobs/furnishings/tests/unit/__init__.py b/jobs/furnishings/tests/unit/__init__.py index 6c1c1d24ee..06e205683a 100644 --- a/jobs/furnishings/tests/unit/__init__.py +++ b/jobs/furnishings/tests/unit/__init__.py @@ -136,7 +136,9 @@ def factory_furnishing(batch_id, furnishing_type=Furnishing.FurnishingType.EMAIL, status=Furnishing.FurnishingStatus.QUEUED, created_date=datetime.datetime.utcnow(), - last_modified=datetime.datetime.utcnow() + last_modified=datetime.datetime.utcnow(), + last_ar_date=None, + business_name=None ): """Create a furnishing entry.""" furnishing = Furnishing( @@ -148,6 +150,8 @@ def factory_furnishing(batch_id, status=status, created_date=created_date, last_modified=last_modified, + last_ar_date=last_ar_date, + business_name=business_name ) furnishing.save() return furnishing diff --git a/jobs/furnishings/tests/unit/stage_processors/test_stage_one.py b/jobs/furnishings/tests/unit/stage_processors/test_stage_one.py index df00954759..6f431ec164 100644 --- a/jobs/furnishings/tests/unit/stage_processors/test_stage_one.py +++ b/jobs/furnishings/tests/unit/stage_processors/test_stage_one.py @@ -113,6 +113,8 @@ async def test_process_first_notification(app, session, test_name, entity_type, assert furnishing.furnishing_name == expected_furnishing_name assert furnishing.status == Furnishing.FurnishingStatus.QUEUED assert furnishing.grouping_identifier is not None + assert furnishing.last_ar_date == business.founding_date + assert furnishing.business_name == business.legal_name else: mock_send_email.assert_not_called() furnishings = Furnishing.find_by(business_id=business.id) diff --git a/jobs/furnishings/tests/unit/stage_processors/test_stage_two.py b/jobs/furnishings/tests/unit/stage_processors/test_stage_two.py index e970ec3d1d..ea04e3fa01 100644 --- a/jobs/furnishings/tests/unit/stage_processors/test_stage_two.py +++ b/jobs/furnishings/tests/unit/stage_processors/test_stage_two.py @@ -74,7 +74,8 @@ def test_process_create_furnishings(app, session, test_name, entity_type, step, furnishing_name=Furnishing.FurnishingName.INTENT_TO_DISSOLVE, furnishing_type=Furnishing.FurnishingType.GAZETTE, created_date=datetime.utcnow()+datedelta(years=1), - last_modified=datetime.utcnow()+datedelta(years=1) + last_modified=datetime.utcnow()+datedelta(years=1), + business_name=business.legal_name ) process(app) @@ -84,6 +85,7 @@ def test_process_create_furnishings(app, session, test_name, entity_type, step, assert len(furnishings) == 1 furnishing = furnishings[0] assert furnishing.furnishing_type == Furnishing.FurnishingType.GAZETTE + assert furnishing.business_name == business.legal_name if entity_type == Business.LegalTypes.EXTRA_PRO_A.value: assert furnishing.furnishing_name == Furnishing.FurnishingName.INTENT_TO_DISSOLVE_XPRO else: diff --git a/legal-api/migrations/versions/feb206b2ce65_add_columns_to_furnishings.py b/legal-api/migrations/versions/feb206b2ce65_add_columns_to_furnishings.py new file mode 100644 index 0000000000..691699a63b --- /dev/null +++ b/legal-api/migrations/versions/feb206b2ce65_add_columns_to_furnishings.py @@ -0,0 +1,26 @@ +"""add_columns_to_furnishings + +Revision ID: feb206b2ce65 +Revises: ac0065d92893 +Create Date: 2024-07-10 17:33:24.126671 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'feb206b2ce65' +down_revision = 'ac0065d92893' +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column('furnishings', sa.Column('last_ar_date', sa.DateTime(timezone=True), autoincrement=False, nullable=True)) + op.add_column('furnishings', sa.Column('business_name', sa.String(length=1000), autoincrement=False, nullable=True)) + + +def downgrade(): + op.drop_column('furnishings', 'last_ar_date') + op.drop_column('furnishings', 'business_name') diff --git a/legal-api/src/legal_api/models/furnishing.py b/legal-api/src/legal_api/models/furnishing.py index 1674b92ea3..9ce9ba149e 100644 --- a/legal-api/src/legal_api/models/furnishing.py +++ b/legal-api/src/legal_api/models/furnishing.py @@ -71,6 +71,8 @@ class FurnishingStatus(BaseEnum): last_name = db.Column('last_name', db.String(30), default='', nullable=True) first_name = db.Column('first_name', db.String(30), default='', nullable=True) middle_name = db.Column('middle_name', db.String(30), default='', nullable=True) + last_ar_date = db.Column('last_ar_date', db.DateTime(timezone=True), nullable=True) + business_name = db.Column('business_name', db.String(1000), nullable=True) # parent keys batch_id = db.Column('batch_id', db.Integer, db.ForeignKey('batches.id'), index=True, nullable=False) diff --git a/legal-api/tests/unit/models/test_furnishing.py b/legal-api/tests/unit/models/test_furnishing.py index d09d044f73..f0103b7e81 100644 --- a/legal-api/tests/unit/models/test_furnishing.py +++ b/legal-api/tests/unit/models/test_furnishing.py @@ -31,7 +31,9 @@ def test_valid_furnishing_save(session): batch_id = batch.id, business_id = business.id, business_identifier = business.identifier, - status = Furnishing.FurnishingStatus.QUEUED + status = Furnishing.FurnishingStatus.QUEUED, + last_ar_date=business.last_ar_date, + business_name=business.legal_name ) furnishing.save()