From 61107737892161f46941319c22c108638db19402 Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Mon, 6 Nov 2023 05:37:41 -0800 Subject: [PATCH 01/10] Email update --- .../src/pay_api/services/payment_account.py | 2 +- .../report-templates/payment_receipt.html | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index 3cc7d2835..1cea4f8cc 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -671,7 +671,7 @@ def unlock_frozen_accounts(account_id: int): cfs_account.save() payload = pay_account._create_account_event_payload( # pylint:disable=protected-access - 'bc.registry.payment.unlockAccount' + MessageType.NSF_UNLOCK_ACCOUNT.value ) try: diff --git a/report-api/report-templates/payment_receipt.html b/report-api/report-templates/payment_receipt.html index baa53295b..1c9db5956 100644 --- a/report-api/report-templates/payment_receipt.html +++ b/report-api/report-templates/payment_receipt.html @@ -368,10 +368,17 @@ font-family: 'BCSans-Bold', sans-serif; font-size: 18px; color: #234075; - border-bottom: 1px solid #b3bac3; font-weight: bold; } + .transaction-amount { + margin-left: 24px; + padding-bottom: 12px; + font-size: 16px; + font-weight: 800; + font-family: 'BCSans-Bold', sans-serif; + } + .section-payment-title { margin: 30px 24px 0px; /* padding-bottom: 8px; */ @@ -621,11 +628,18 @@ {% else %} -
+
Transactions
+ + +
+ Number of Transactions: {{invoice.lineItems|length}} +
+ + From 034cd7c8034ad3323daf9734e8942191e446d918 Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Thu, 9 Nov 2023 07:53:04 -0800 Subject: [PATCH 02/10] Passing payload data for PDF --- pay-api/src/pay_api/services/payment_account.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index 1cea4f8cc..b4b6ad4c0 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -658,7 +658,7 @@ def _create_account_event_payload(self, event_type: str, include_pay_info: bool return payload @staticmethod - def unlock_frozen_accounts(account_id: int): + def unlock_frozen_accounts(account_id: int, invoice_number: str, receipt_number: str, payment_method: str, filing_identifier: str): """Unlock frozen accounts.""" pay_account: PaymentAccount = PaymentAccount.find_by_id(account_id) if pay_account.cfs_account_status == CfsAccountStatus.FREEZE.value: @@ -674,15 +674,22 @@ def unlock_frozen_accounts(account_id: int): MessageType.NSF_UNLOCK_ACCOUNT.value ) + payload['data']['invoiceNumber'] = invoice_number + payload['data']['receiptNumber'] = receipt_number + payload['data']['paymentMethodDescription'] = payment_method + payload['data']['filingIdentifier'] = filing_identifier + try: publish_response(payload=payload, - client_name=current_app.config['NATS_ACCOUNT_CLIENT_NAME'], - subject=current_app.config['NATS_ACCOUNT_SUBJECT']) + client_name=current_app.config['NATS_ACCOUNT_CLIENT_NAME'], + subject=current_app.config['NATS_ACCOUNT_SUBJECT']) except Exception as e: # NOQA pylint: disable=broad-except current_app.logger.error(e) current_app.logger.error( - 'Notification to Queue failed for the Unlock Account %s - %s', pay_account.auth_account_id, - pay_account.name) + 'Notification to Queue failed for the Unlock Account {auth_account_id} - {account_name}'.format( + auth_account_id=pay_account.auth_account_id, + account_name=pay_account.name) + ) capture_message( f'Notification to Queue failed for the Unlock Account : {payload}.', level='error') From b9106f2d40d61ce443a9ca99f9ec91c968cb0450 Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Thu, 9 Nov 2023 08:41:31 -0800 Subject: [PATCH 03/10] PDF payload information --- pay-api/src/pay_api/services/payment_transaction.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pay-api/src/pay_api/services/payment_transaction.py b/pay-api/src/pay_api/services/payment_transaction.py index 898383a93..c8017d40c 100644 --- a/pay-api/src/pay_api/services/payment_transaction.py +++ b/pay-api/src/pay_api/services/payment_transaction.py @@ -411,7 +411,12 @@ def update_transaction(transaction_id: uuid, # pylint: disable=too-many-locals active_failed_payments = Payment.get_failed_payments(auth_account_id=payment_account.auth_account_id) current_app.logger.info('active_failed_payments %s', active_failed_payments) if not active_failed_payments: - PaymentAccount.unlock_frozen_accounts(payment.payment_account_id) + PaymentAccount.unlock_frozen_accounts( + payment.payment_account_id, + payment.invoice_number, + receipt_details[0], + payment.payment_method_code, + invoice.filing_id) transaction = PaymentTransaction.__wrap_dao(transaction_dao) From 8a0f788448feede789e616bfdc6fc00d84f2824e Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Thu, 9 Nov 2023 08:54:10 -0800 Subject: [PATCH 04/10] Error fix --- pay-api/src/pay_api/services/payment_account.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index b4b6ad4c0..4b5c2ae9f 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -686,10 +686,8 @@ def unlock_frozen_accounts(account_id: int, invoice_number: str, receipt_number: except Exception as e: # NOQA pylint: disable=broad-except current_app.logger.error(e) current_app.logger.error( - 'Notification to Queue failed for the Unlock Account {auth_account_id} - {account_name}'.format( - auth_account_id=pay_account.auth_account_id, - account_name=pay_account.name) - ) + 'Notification to Queue failed for the Unlock Account %s - %s', pay_account.auth_account_id, + pay_account.name) capture_message( f'Notification to Queue failed for the Unlock Account : {payload}.', level='error') From b7af147c14a797bc0843bc87613dc44522f348ea Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Tue, 14 Nov 2023 20:09:51 -0800 Subject: [PATCH 05/10] Moving payload over --- .../src/pay_api/services/payment_account.py | 33 +++++++++++++------ .../pay_api/services/payment_transaction.py | 7 +--- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index 4b5c2ae9f..ceffd8558 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -38,6 +38,8 @@ from pay_api.utils.util import ( current_local_time, get_local_formatted_date, get_outstanding_txns_from_date, get_str_by_path, mask) +from .payment import Payment + class PaymentAccount(): # pylint: disable=too-many-instance-attributes, too-many-public-methods """Service to manage Payment Account model related operations.""" @@ -631,7 +633,13 @@ def _publish_queue_message(self, payload): f'Notification to Queue failed for the Account Mailer : {payload}.', level='error') - def _create_account_event_payload(self, event_type: str, include_pay_info: bool = False): + def _create_account_event_payload( + self, + event_type: str, + payment: Payment = None, + filing_identifier: str = None, + receipt_number: str = None, + include_pay_info: bool = False): """Return event payload for account.""" payload: Dict[str, any] = { 'specversion': '1.x-wip', @@ -646,6 +654,13 @@ def _create_account_event_payload(self, event_type: str, include_pay_info: bool } } + if event_type == MessageType.NSF_UNLOCK_ACCOUNT.value: + payload['data']['invoiceNumber'] = payment.invoice_number + payload['data']['paymentMethodDescription'] = payment.payment_method_code + payload['data']['filingIdentifier'] = filing_identifier + payload['data']['receiptNumber'] = receipt_number + + if event_type == MessageType.PAD_ACCOUNT_CREATE.value: payload['data']['padTosAcceptedBy'] = self.pad_tos_accepted_by if include_pay_info: @@ -658,9 +673,9 @@ def _create_account_event_payload(self, event_type: str, include_pay_info: bool return payload @staticmethod - def unlock_frozen_accounts(account_id: int, invoice_number: str, receipt_number: str, payment_method: str, filing_identifier: str): + def unlock_frozen_accounts(payment: Payment, filing_identifier: str, receipt_number: str): """Unlock frozen accounts.""" - pay_account: PaymentAccount = PaymentAccount.find_by_id(account_id) + pay_account: PaymentAccount = PaymentAccount.find_by_id(payment.payment_account_id) if pay_account.cfs_account_status == CfsAccountStatus.FREEZE.value: current_app.logger.info(f'Unlocking Frozen Account {pay_account.auth_account_id}') # update CSF @@ -670,14 +685,12 @@ def unlock_frozen_accounts(account_id: int, invoice_number: str, receipt_number: cfs_account.status = CfsAccountStatus.ACTIVE.value cfs_account.save() - payload = pay_account._create_account_event_payload( # pylint:disable=protected-access - MessageType.NSF_UNLOCK_ACCOUNT.value + payload = pay_account._create_account_event_payload( + MessageType.NSF_UNLOCK_ACCOUNT.value, + payment, + filing_identifier, + receipt_number ) - - payload['data']['invoiceNumber'] = invoice_number - payload['data']['receiptNumber'] = receipt_number - payload['data']['paymentMethodDescription'] = payment_method - payload['data']['filingIdentifier'] = filing_identifier try: publish_response(payload=payload, diff --git a/pay-api/src/pay_api/services/payment_transaction.py b/pay-api/src/pay_api/services/payment_transaction.py index c8017d40c..e22ec60b8 100644 --- a/pay-api/src/pay_api/services/payment_transaction.py +++ b/pay-api/src/pay_api/services/payment_transaction.py @@ -411,12 +411,7 @@ def update_transaction(transaction_id: uuid, # pylint: disable=too-many-locals active_failed_payments = Payment.get_failed_payments(auth_account_id=payment_account.auth_account_id) current_app.logger.info('active_failed_payments %s', active_failed_payments) if not active_failed_payments: - PaymentAccount.unlock_frozen_accounts( - payment.payment_account_id, - payment.invoice_number, - receipt_details[0], - payment.payment_method_code, - invoice.filing_id) + PaymentAccount.unlock_frozen_accounts(payment, invoice.filing_id, receipt_details[0]) transaction = PaymentTransaction.__wrap_dao(transaction_dao) From 24f771fa1a546efecc2821e8ed95c7364edfeb00 Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Wed, 15 Nov 2023 08:55:20 -0800 Subject: [PATCH 06/10] Argument fix --- pay-api/src/pay_api/services/payment_account.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index ceffd8558..d8b66aaaf 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -687,9 +687,9 @@ def unlock_frozen_accounts(payment: Payment, filing_identifier: str, receipt_num payload = pay_account._create_account_event_payload( MessageType.NSF_UNLOCK_ACCOUNT.value, - payment, - filing_identifier, - receipt_number + payment=payment, + filing_identifier=filing_identifier, + receipt_number=receipt_number ) try: From a130ae24c56ccbe39f66651a5a72893bff905a64 Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Thu, 23 Nov 2023 18:05:14 -0800 Subject: [PATCH 07/10] Cleanup --- .../src/pay_api/services/payment_account.py | 22 ++++++++++--------- .../pay_api/services/payment_transaction.py | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index d8b66aaaf..d87e43b59 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -636,9 +636,7 @@ def _publish_queue_message(self, payload): def _create_account_event_payload( self, event_type: str, - payment: Payment = None, - filing_identifier: str = None, - receipt_number: str = None, + nsf_object: dict = None, include_pay_info: bool = False): """Return event payload for account.""" payload: Dict[str, any] = { @@ -655,10 +653,10 @@ def _create_account_event_payload( } if event_type == MessageType.NSF_UNLOCK_ACCOUNT.value: - payload['data']['invoiceNumber'] = payment.invoice_number - payload['data']['paymentMethodDescription'] = payment.payment_method_code - payload['data']['filingIdentifier'] = filing_identifier - payload['data']['receiptNumber'] = receipt_number + payload['data']['invoiceNumber'] = nsf_object.payment.invoice_number + payload['data']['paymentMethodDescription'] = nsf_object.payment.payment_method_code + payload['data']['filingIdentifier'] = nsf_object.filing_identifier + payload['data']['receiptNumber'] = nsf_object.receipt_number if event_type == MessageType.PAD_ACCOUNT_CREATE.value: @@ -685,11 +683,15 @@ def unlock_frozen_accounts(payment: Payment, filing_identifier: str, receipt_num cfs_account.status = CfsAccountStatus.ACTIVE.value cfs_account.save() + nsf_object = { + 'payment': payment, + 'filing_identifier': filing_identifier, + 'receipt_number': receipt_number + } + payload = pay_account._create_account_event_payload( MessageType.NSF_UNLOCK_ACCOUNT.value, - payment=payment, - filing_identifier=filing_identifier, - receipt_number=receipt_number + nsf_object=nsf_object ) try: diff --git a/pay-api/src/pay_api/services/payment_transaction.py b/pay-api/src/pay_api/services/payment_transaction.py index e22ec60b8..0ebd331a1 100644 --- a/pay-api/src/pay_api/services/payment_transaction.py +++ b/pay-api/src/pay_api/services/payment_transaction.py @@ -411,7 +411,7 @@ def update_transaction(transaction_id: uuid, # pylint: disable=too-many-locals active_failed_payments = Payment.get_failed_payments(auth_account_id=payment_account.auth_account_id) current_app.logger.info('active_failed_payments %s', active_failed_payments) if not active_failed_payments: - PaymentAccount.unlock_frozen_accounts(payment, invoice.filing_id, receipt_details[0]) + PaymentAccount.unlock_frozen_accounts(payment, invoice.filing_id, receipt_details) transaction = PaymentTransaction.__wrap_dao(transaction_dao) From 6ad32420aca66f18003f013f403dd457f5a5507e Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Mon, 11 Dec 2023 00:20:31 -0800 Subject: [PATCH 08/10] Payload reformatting --- pay-api/src/pay_api/services/payment_account.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index ae1e08bf4..b0064011c 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -713,10 +713,7 @@ def _publish_queue_message(self, payload): f'Notification to Queue failed for the Account Mailer : {payload}.', level='error') - def _create_account_event_payload( - self, - event_type: str, - nsf_object: dict = None, + def _create_account_event_payload(self, event_type: str, nsf_object: dict = None, include_pay_info: bool = False): """Return event payload for account.""" payload: Dict[str, any] = { From 0e691bb0943ed00e191398cf3f4c0b874e78e3a1 Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Mon, 11 Dec 2023 09:40:53 -0800 Subject: [PATCH 09/10] reminder --- pay-api/src/pay_api/services/payment_account.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index b0064011c..c9984f408 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -760,6 +760,8 @@ def unlock_frozen_accounts(payment: Payment, filing_identifier: str, receipt_num cfs_account.status = CfsAccountStatus.ACTIVE.value cfs_account.save() + # get nsf payment object associated with this payment + nsf_object = { 'payment': payment, 'filing_identifier': filing_identifier, From b78db55c359ecda905af29ffef29f9fba7974aa3 Mon Sep 17 00:00:00 2001 From: Rodrigo Barraza Date: Tue, 16 Jan 2024 08:58:32 -0800 Subject: [PATCH 10/10] Linting fixes --- pay-api/src/pay_api/services/payment_account.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pay-api/src/pay_api/services/payment_account.py b/pay-api/src/pay_api/services/payment_account.py index af685bdee..7e97b5724 100644 --- a/pay-api/src/pay_api/services/payment_account.py +++ b/pay-api/src/pay_api/services/payment_account.py @@ -773,7 +773,7 @@ def _publish_queue_message(self, payload): f'Notification to Queue failed for the Account Mailer : {payload}.', level='error') - def _create_account_event_payload(self, event_type: str, nsf_object: dict = None, + def create_account_event_payload(self, event_type: str, nsf_object: dict = None, include_pay_info: bool = False): """Return event payload for account.""" payload: Dict[str, any] = { @@ -794,8 +794,6 @@ def _create_account_event_payload(self, event_type: str, nsf_object: dict = None payload['data']['paymentMethodDescription'] = nsf_object.payment.payment_method_code payload['data']['filingIdentifier'] = nsf_object.filing_identifier payload['data']['receiptNumber'] = nsf_object.receipt_number - - if event_type == MessageType.PAD_ACCOUNT_CREATE.value: payload['data']['padTosAcceptedBy'] = self.pad_tos_accepted_by if include_pay_info: @@ -832,7 +830,7 @@ def unlock_frozen_accounts(payment: Payment, filing_identifier: str, receipt_num MessageType.NSF_UNLOCK_ACCOUNT.value, nsf_object=nsf_object ) - + try: publish_response(payload=payload, client_name=current_app.config['NATS_ACCOUNT_CLIENT_NAME'],