Skip to content

Commit

Permalink
20087 - Add in additional emails (#1654)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Aug 1, 2024
1 parent 012af27 commit de5eaa0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
8 changes: 4 additions & 4 deletions jobs/payment-jobs/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jobs/payment-jobs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
pay-api = {git = "https://github.com/seeker25/sbc-pay.git", subdirectory = "pay-api", branch = "20087_p2"}
pay-api = {git = "https://github.com/bcgov/sbc-pay.git", subdirectory = "pay-api"}
gunicorn = "^21.2.0"
flask = "^3.0.2"
flask-sqlalchemy = "^3.1.1"
Expand Down
12 changes: 5 additions & 7 deletions jobs/payment-jobs/tasks/statement_due_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ def _notify_for_monthly(cls):
current_app.logger.info('Freezing payment account id: %s locking auth account id: %s',
payment_account.id, payment_account.auth_account_id)
# The locking email is sufficient for overdue, no seperate email required.
AuthEvent.publish_lock_account_event(payment_account)
additional_emails = current_app.config.get('EFT_OVERDUE_NOTIFY_EMAILS')
AuthEvent.publish_lock_account_event(payment_account, additional_emails)
cls.add_to_non_sufficient_funds(payment_account)
statement.overdue_notification_date = datetime.now(tz=timezone.utc)
statement.save()
continue
if emails := cls._determine_recipient_emails(statement, action):
if emails := cls._determine_recipient_emails(statement):
publish_payment_notification(
StatementNotificationInfo(auth_account_id=payment_account.auth_account_id,
statement=statement,
Expand Down Expand Up @@ -165,13 +166,10 @@ def _determine_action_and_due_date_by_invoice(cls, statement_id: int):
return None, day_before_invoice_overdue

@classmethod
def _determine_recipient_emails(cls,
statement: StatementRecipientsModel, action: StatementNotificationAction) -> str:
def _determine_recipient_emails(cls, statement: StatementRecipientsModel) -> str:
if (recipients := StatementRecipientsModel.find_all_recipients_for_payment_id(statement.payment_account_id)):
recipients = ','.join([str(recipient.email) for recipient in recipients])
if action == StatementNotificationAction.OVERDUE:
if overdue_notify_emails := current_app.config.get('EFT_OVERDUE_NOTIFY_EMAILS'):
recipients += ',' + overdue_notify_emails

return recipients

current_app.logger.error(f'No recipients found for statement: {statement.payment_account_id}. Skipping.')
Expand Down
9 changes: 5 additions & 4 deletions jobs/payment-jobs/utils/auth_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class AuthEvent:
"""Publishes to the auth-queue as an auth event though PUBSUB, this message gets sent to account-mailer after."""

@staticmethod
def publish_lock_account_event(pay_account: PaymentAccountModel):
def publish_lock_account_event(pay_account: PaymentAccountModel, additional_emails=''):
"""Publish NSF lock account event to the auth queue."""
try:
payload = AuthEvent._create_event_payload(pay_account)
payload = AuthEvent._create_event_payload(pay_account, additional_emails)
gcp_queue_publisher.publish_to_queue(
QueueMessage(
source=QueueSources.PAY_JOBS.value,
Expand Down Expand Up @@ -55,9 +55,10 @@ def publish_unlock_account_event(payment_account: PaymentAccountModel):
payment_account.auth_account_id}, {unlock_payload}.', level='error')

@staticmethod
def _create_event_payload(pay_account):
def _create_event_payload(pay_account, additional_emails=''):
return {
'accountId': pay_account.auth_account_id,
'paymentMethod': PaymentMethod.EFT.value,
'suspensionReasonCode': SuspensionReasonCodes.OVERDUE_EFT.value
'suspensionReasonCode': SuspensionReasonCodes.OVERDUE_EFT.value,
'additionalEmails': additional_emails
}

0 comments on commit de5eaa0

Please sign in to comment.