From e393138e12649869f3ae11a9ca8b73daed828a2b Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 10:35:56 -0700 Subject: [PATCH 1/9] Small changes to compute amount --- .../email_templates/pad_invoice_email.html | 6 +++++- .../src/account_mailer/resources/worker.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html index 6c6b47a1ec..52dff3bc47 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html @@ -1,6 +1,10 @@ # Your {{ account_number }}: {{ account_name_with_branch }} account completed ${{ invoice_total }} in transactions during business hours on {{ invoice_process_date }}. -This amount will be debited from your financial institution in 2 business days. Please ensure you have sufficient funds in your financial institution account to cover this debit. +Transaction amount: $ {{ invoice_total}} +{ % if credits_total > 0 % }Account credits: -$ {{ credits_total }}{ % endif % } +Amount to be charged: {{ withdraw_total }} + +{{ withdraw_total }} will be debited from your financial institution in 2 business days. Please ensure you have sufficient funds in your financial institution account to cover this debit. Your account will be suspended and charged a ${{ nsf_fee }} dishonoured bank instrument fee for every failed payment. diff --git a/queue_services/account-mailer/src/account_mailer/resources/worker.py b/queue_services/account-mailer/src/account_mailer/resources/worker.py index 15b8eba921..d1d80a9d8f 100644 --- a/queue_services/account-mailer/src/account_mailer/resources/worker.py +++ b/queue_services/account-mailer/src/account_mailer/resources/worker.py @@ -13,6 +13,7 @@ # limitations under the License. """The unique worker functionality for this service is contained here.""" import dataclasses +from decimal import Decimal import json from datetime import datetime, timezone from http import HTTPStatus @@ -210,10 +211,15 @@ def handle_pad_invoice_created(message_type, email_msg): admin_coordinator_emails = get_member_emails(org_id, (ADMIN,)) subject = SubjectType.PAD_INVOICE_CREATED.value invoice_process_date = datetime.fromisoformat(email_msg.get('invoice_process_date')) + credit_total = email_msg.get('credit_total', 0) + invoice_total = email_msg.get('invoice_total', 0) + withdraw_total = Decimal(str(invoice_total)) - Decimal(str(credit_total)) args = { + 'credit_total': format_currency(credit_total), 'nsf_fee': format_currency(email_msg.get('nsfFee')), - 'invoice_total': format_currency(email_msg.get('invoice_total')), - 'invoice_process_date': get_local_formatted_date(invoice_process_date, '%m-%d-%Y') + 'invoice_total': format_currency(invoice_total), + 'invoice_process_date': get_local_formatted_date(invoice_process_date, '%m-%d-%Y'), + 'withdraw_total': format_currency(str(withdraw_total)) } logo_url = email_msg.get('logo_url') email_dict = common_mailer.process(org_id, admin_coordinator_emails, template_name, From 887eca02a0fd305143e369b012dcc9750e453367 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 10:37:24 -0700 Subject: [PATCH 2/9] Fix subject --- .../src/account_mailer/email_templates/pad_invoice_email.html | 2 +- queue_services/account-mailer/src/account_mailer/enums.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html index 52dff3bc47..2361674460 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html @@ -1,6 +1,6 @@ # Your {{ account_number }}: {{ account_name_with_branch }} account completed ${{ invoice_total }} in transactions during business hours on {{ invoice_process_date }}. -Transaction amount: $ {{ invoice_total}} +Transaction amount: $ {{ invoice_total }} { % if credits_total > 0 % }Account credits: -$ {{ credits_total }}{ % endif % } Amount to be charged: {{ withdraw_total }} diff --git a/queue_services/account-mailer/src/account_mailer/enums.py b/queue_services/account-mailer/src/account_mailer/enums.py index 5de5443768..1a5207104a 100644 --- a/queue_services/account-mailer/src/account_mailer/enums.py +++ b/queue_services/account-mailer/src/account_mailer/enums.py @@ -21,7 +21,7 @@ class SubjectType(Enum): NSF_LOCK_ACCOUNT_SUBJECT = '[BC Registries and Online Services] Your account has been suspended' NSF_UNLOCK_ACCOUNT_SUBJECT = 'Your Account Was Successfully Restored' ACCOUNT_CONF_OVER_SUBJECT = '[BC Registries and Online Services] Your account is now active' - PAD_INVOICE_CREATED = '[BC Registries and Online Services] Your accounts PAD transaction details' + PAD_INVOICE_CREATED = '[BC Registries and Online Services] Your PAD Transaction Details' ADMIN_REMOVED_SUBJECT = '[BC Registries and Online Services] You have been removed as an administrator' TEAM_MODIFIED_SUBJECT = '[BC Registries and Online Services] Change in Team members' ONLINE_BANKING_PAYMENT_SUBJECT = '[BC Registries and Online Services] Online Banking payment has been received' From d243f4769a633f20f9abb4cc1e81f9483245f2f9 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 10:40:13 -0700 Subject: [PATCH 3/9] typo --- .../src/account_mailer/email_templates/pad_invoice_email.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html index 2361674460..586ad88648 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html @@ -1,7 +1,7 @@ # Your {{ account_number }}: {{ account_name_with_branch }} account completed ${{ invoice_total }} in transactions during business hours on {{ invoice_process_date }}. Transaction amount: $ {{ invoice_total }} -{ % if credits_total > 0 % }Account credits: -$ {{ credits_total }}{ % endif % } +{ % if credit_total > 0 % }Account credits: -$ {{ credit_total }}{ % endif % } Amount to be charged: {{ withdraw_total }} {{ withdraw_total }} will be debited from your financial institution in 2 business days. Please ensure you have sufficient funds in your financial institution account to cover this debit. From cbc2978ef18a227574e408800e6fe4b04cb3baf5 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 10:40:50 -0700 Subject: [PATCH 4/9] spacing --- .../src/account_mailer/email_templates/pad_invoice_email.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html index 586ad88648..4b0f49ff9b 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html @@ -1,7 +1,7 @@ # Your {{ account_number }}: {{ account_name_with_branch }} account completed ${{ invoice_total }} in transactions during business hours on {{ invoice_process_date }}. Transaction amount: $ {{ invoice_total }} -{ % if credit_total > 0 % }Account credits: -$ {{ credit_total }}{ % endif % } +{% if credit_total > 0 %}Account credits: -$ {{ credit_total }}{% endif %} Amount to be charged: {{ withdraw_total }} {{ withdraw_total }} will be debited from your financial institution in 2 business days. Please ensure you have sufficient funds in your financial institution account to cover this debit. From 4c74db35d8e19dfb65c9cd200fab47d220c9519d Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 10:44:22 -0700 Subject: [PATCH 5/9] flake8 fix --- .../account-mailer/src/account_mailer/resources/worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queue_services/account-mailer/src/account_mailer/resources/worker.py b/queue_services/account-mailer/src/account_mailer/resources/worker.py index d1d80a9d8f..09eba23a60 100644 --- a/queue_services/account-mailer/src/account_mailer/resources/worker.py +++ b/queue_services/account-mailer/src/account_mailer/resources/worker.py @@ -13,9 +13,9 @@ # limitations under the License. """The unique worker functionality for this service is contained here.""" import dataclasses -from decimal import Decimal import json from datetime import datetime, timezone +from decimal import Decimal from http import HTTPStatus from auth_api.models import db From 9e44d26fe7195e318d9320084b46354fc03789cc Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 10:54:21 -0700 Subject: [PATCH 6/9] tweak --- .../src/account_mailer/email_templates/pad_invoice_email.html | 2 +- .../account-mailer/src/account_mailer/resources/worker.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html index 4b0f49ff9b..6ab97e5396 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html @@ -1,7 +1,7 @@ # Your {{ account_number }}: {{ account_name_with_branch }} account completed ${{ invoice_total }} in transactions during business hours on {{ invoice_process_date }}. Transaction amount: $ {{ invoice_total }} -{% if credit_total > 0 %}Account credits: -$ {{ credit_total }}{% endif %} +{% if credit_total != '0' %}Account credits: -$ {{ credit_total }}{% endif %} Amount to be charged: {{ withdraw_total }} {{ withdraw_total }} will be debited from your financial institution in 2 business days. Please ensure you have sufficient funds in your financial institution account to cover this debit. diff --git a/queue_services/account-mailer/src/account_mailer/resources/worker.py b/queue_services/account-mailer/src/account_mailer/resources/worker.py index 09eba23a60..67bf357f62 100644 --- a/queue_services/account-mailer/src/account_mailer/resources/worker.py +++ b/queue_services/account-mailer/src/account_mailer/resources/worker.py @@ -211,8 +211,8 @@ def handle_pad_invoice_created(message_type, email_msg): admin_coordinator_emails = get_member_emails(org_id, (ADMIN,)) subject = SubjectType.PAD_INVOICE_CREATED.value invoice_process_date = datetime.fromisoformat(email_msg.get('invoice_process_date')) - credit_total = email_msg.get('credit_total', 0) - invoice_total = email_msg.get('invoice_total', 0) + credit_total = email_msg.get('credit_total', '0') + invoice_total = email_msg.get('invoice_total', '0') withdraw_total = Decimal(str(invoice_total)) - Decimal(str(credit_total)) args = { 'credit_total': format_currency(credit_total), From b41e8da4b0c70528a459b058039fa71b87d161d5 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 10:54:45 -0700 Subject: [PATCH 7/9] fix string --- .../src/account_mailer/email_templates/pad_invoice_email.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html index 6ab97e5396..d6188035b4 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html @@ -1,7 +1,7 @@ # Your {{ account_number }}: {{ account_name_with_branch }} account completed ${{ invoice_total }} in transactions during business hours on {{ invoice_process_date }}. Transaction amount: $ {{ invoice_total }} -{% if credit_total != '0' %}Account credits: -$ {{ credit_total }}{% endif %} +{% if credit_total != '0.00' %}Account credits: -$ {{ credit_total }}{% endif %} Amount to be charged: {{ withdraw_total }} {{ withdraw_total }} will be debited from your financial institution in 2 business days. Please ensure you have sufficient funds in your financial institution account to cover this debit. From 73b4c6c23675fe2b76ee2108caeec6aba5df0956 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 10:59:50 -0700 Subject: [PATCH 8/9] add in extra fields --- queue_services/account-mailer/tests/unit/test_worker_queue.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/queue_services/account-mailer/tests/unit/test_worker_queue.py b/queue_services/account-mailer/tests/unit/test_worker_queue.py index ad097ae9f2..c6d0b3b0a4 100644 --- a/queue_services/account-mailer/tests/unit/test_worker_queue.py +++ b/queue_services/account-mailer/tests/unit/test_worker_queue.py @@ -224,9 +224,11 @@ def test_account_pad_invoice_mailer_queue(app, session, client): # add an event to queue, these are provided by cfs_create_invoice_task. mail_details = { 'accountId': id, + 'credit_total': '20', 'nsfFee': '30', 'invoice_total': '100', - 'invoice_process_date': f'{datetime.now()}' + 'invoice_process_date': f'{datetime.now()}', + 'withdraw_total': '80' } helper_add_event_to_queue(client, message_type=QueueMessageTypes.PAD_INVOICE_CREATED.value, From f231cf268eec98f71658405d22cd95ca1e1ed167 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 29 Oct 2024 11:03:30 -0700 Subject: [PATCH 9/9] feedback fixes --- .../account_mailer/email_templates/pad_invoice_email.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html index d6188035b4..1e415648fc 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/pad_invoice_email.html @@ -1,10 +1,10 @@ # Your {{ account_number }}: {{ account_name_with_branch }} account completed ${{ invoice_total }} in transactions during business hours on {{ invoice_process_date }}. -Transaction amount: $ {{ invoice_total }} -{% if credit_total != '0.00' %}Account credits: -$ {{ credit_total }}{% endif %} -Amount to be charged: {{ withdraw_total }} +Transaction amount: ${{ invoice_total }} +{% if credit_total != '0.00' %}Account credits: -${{ credit_total }}{% endif %} +Amount to be charged: ${{ withdraw_total }} -{{ withdraw_total }} will be debited from your financial institution in 2 business days. Please ensure you have sufficient funds in your financial institution account to cover this debit. +${{ withdraw_total }} will be debited from your financial institution in 2 business days. Please ensure you have sufficient funds in your financial institution account to cover this debit. Your account will be suspended and charged a ${{ nsf_fee }} dishonoured bank instrument fee for every failed payment.