From 21eca17bfce84816dc168a9faa0f218ccecf3c0d Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Thu, 22 Jun 2023 06:28:07 -0700 Subject: [PATCH 1/3] Add in condition to not create NSF invoices if the account is already in NSF. --- .../src/reconciliations/payment_reconciliations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/queue_services/payment-reconciliations/src/reconciliations/payment_reconciliations.py b/queue_services/payment-reconciliations/src/reconciliations/payment_reconciliations.py index 54a4c3ec2..2cb3fd351 100644 --- a/queue_services/payment-reconciliations/src/reconciliations/payment_reconciliations.py +++ b/queue_services/payment-reconciliations/src/reconciliations/payment_reconciliations.py @@ -453,6 +453,9 @@ def _process_failed_payments(row): # Set CFS Account Status. payment_account: PaymentAccountModel = _get_payment_account(row) cfs_account: CfsAccountModel = CfsAccountModel.find_effective_by_account_id(payment_account.id) + if cfs_account.status == CfsAccountStatus.FREEZE.value: + logger.info('Ignoring NSF message for invoice : %s as the account is already FREEZE', inv_number) + return False logger.info('setting payment account id : %s status as FREEZE', payment_account.id) cfs_account.status = CfsAccountStatus.FREEZE.value # Call CFS to stop any further PAD transactions on this account. From 541d83c58995310533a0c99f746dfb11035186e1 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Thu, 22 Jun 2023 06:40:21 -0700 Subject: [PATCH 2/3] Move already frozen check down after suspend. Update build reqs. --- .../payment-reconciliations/requirements.txt | 67 +++++++++++-------- .../payment_reconciliations.py | 7 +- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/queue_services/payment-reconciliations/requirements.txt b/queue_services/payment-reconciliations/requirements.txt index 6d5859aeb..d8cb9cfbe 100644 --- a/queue_services/payment-reconciliations/requirements.txt +++ b/queue_services/payment-reconciliations/requirements.txt @@ -1,6 +1,6 @@ --e git+https://github.com/bcgov/lear.git@757ebe62916fe4e9467cf8505ddd41e15ae3282e#egg=entity_queue_common&subdirectory=queue_services/common --e git+https://github.com/bcgov/sbc-common-components.git@a8a2074b12dbf36cc23634206e37d57ccfa5a33d#egg=sbc_common_components&subdirectory=python --e git+https://github.com/bcgov/sbc-pay.git@858402b14285103f9c2f168d9541531893184b04#egg=pay_api&subdirectory=pay-api +-e git+https://github.com/bcgov/lear.git@30dba30463c99aaedfdcfd463213e71ba0d35b51#egg=entity_queue_common&subdirectory=queue_services/common +-e git+https://github.com/bcgov/sbc-common-components.git@b93585ea3ac273b9e51c4dd5ddbc8190fd95da6a#egg=sbc_common_components&subdirectory=python +-e git+https://github.com/bcgov/sbc-pay.git@3cc3fc5685a6f419bf92bf6601834b24cab290b1#egg=pay_api&subdirectory=pay-api Flask-Caching==2.0.2 Flask-Migrate==2.7.0 Flask-Moment==1.0.5 @@ -10,29 +10,32 @@ Flask-Script==2.0.6 Flask==1.1.2 Jinja2==3.0.3 Mako==1.2.4 -MarkupSafe==2.1.2 -SQLAlchemy-Continuum==1.3.14 -SQLAlchemy-Utils==0.40.0 +MarkupSafe==2.1.3 +PyMeeus==0.5.12 +SQLAlchemy-Continuum==1.3.15 +SQLAlchemy-Utils==0.41.1 SQLAlchemy==1.3.24 Werkzeug==1.0.1 aiohttp==3.8.4 aiosignal==1.3.1 -alembic==1.10.2 +alembic==1.11.1 aniso8601==9.0.1 async-timeout==4.0.2 asyncio-nats-client==0.11.5 asyncio-nats-streaming==0.4.0 -attrs==22.2.0 -blinker==1.5 +attrs==23.1.0 +blinker==1.6.2 cachelib==0.9.0 -cattrs==22.2.0 -certifi==2022.12.7 +cachetools==5.3.1 +cattrs==23.1.2 +certifi==2023.5.7 cffi==1.15.1 charset-normalizer==3.1.0 click==8.1.3 -croniter==1.3.8 -cryptography==41.0.0 -dpath==2.1.5 +convertdate==2.4.0 +croniter==1.4.1 +cryptography==41.0.1 +dpath==2.1.6 ecdsa==0.18.0 exceptiongroup==1.1.1 expiringdict==1.2.2 @@ -40,41 +43,49 @@ flask-jwt-oidc==0.3.0 flask-marshmallow==0.11.0 flask-restx==1.1.0 frozenlist==1.3.3 +google-api-core==2.11.1 +google-auth==2.18.1 +google-cloud-pubsub==2.17.0 +googleapis-common-protos==1.59.1 +grpc-google-iam-v1==0.12.6 +grpcio-status==1.48.2 +grpcio==1.54.2 gunicorn==20.1.0 +hijri-converter==2.3.1 +holidays==0.23 idna==3.4 -importlib-metadata==6.1.0 -importlib-resources==5.12.0 itsdangerous==2.0.1 jaeger-client==4.8.0 jsonschema==4.17.3 -launchdarkly-server-sdk==8.1.1 +korean-lunar-calendar==0.3.1 +launchdarkly-server-sdk==8.1.4 marshmallow-sqlalchemy==0.25.0 marshmallow==3.19.0 -minio==7.1.14 +minio==7.1.15 multidict==6.0.4 opentracing==2.4.0 -packaging==23.0 -pkgutil_resolve_name==1.3.10 +packaging==23.1 +proto-plus==1.22.2 protobuf==3.19.6 -psycopg2-binary==2.9.5 +psycopg2-binary==2.9.6 pyRFC3339==1.1 -pyasn1==0.4.8 +pyasn1-modules==0.3.0 +pyasn1==0.5.0 pycountry==22.3.5 pycparser==2.21 pyrsistent==0.19.3 python-dateutil==2.8.2 python-dotenv==1.0.0 python-jose==3.3.0 -pytz==2023.2 +pytz==2023.3 requests==2.31.0 rsa==4.9 semver==2.13.0 -sentry-sdk==1.18.0 +sentry-sdk==1.26.0 six==1.16.0 threadloop==1.0.2 thrift==0.16.0 tornado==6.3.2 -typing_extensions==4.5.0 -urllib3==1.26.15 -yarl==1.8.2 -zipp==3.15.0 +typing_extensions==4.6.3 +urllib3==1.26.16 +yarl==1.9.2 diff --git a/queue_services/payment-reconciliations/src/reconciliations/payment_reconciliations.py b/queue_services/payment-reconciliations/src/reconciliations/payment_reconciliations.py index 2cb3fd351..6d623abff 100644 --- a/queue_services/payment-reconciliations/src/reconciliations/payment_reconciliations.py +++ b/queue_services/payment-reconciliations/src/reconciliations/payment_reconciliations.py @@ -453,13 +453,14 @@ def _process_failed_payments(row): # Set CFS Account Status. payment_account: PaymentAccountModel = _get_payment_account(row) cfs_account: CfsAccountModel = CfsAccountModel.find_effective_by_account_id(payment_account.id) - if cfs_account.status == CfsAccountStatus.FREEZE.value: - logger.info('Ignoring NSF message for invoice : %s as the account is already FREEZE', inv_number) - return False + is_already_frozen = cfs_account.status == CfsAccountStatus.FREEZE.value logger.info('setting payment account id : %s status as FREEZE', payment_account.id) cfs_account.status = CfsAccountStatus.FREEZE.value # Call CFS to stop any further PAD transactions on this account. CFSService.suspend_cfs_account(cfs_account) + if is_already_frozen: + logger.info('Ignoring NSF message for invoice : %s as the account is already FREEZE', inv_number) + return False # Find the invoice_reference for this invoice and mark it as ACTIVE. inv_references: List[InvoiceReferenceModel] = db.session.query(InvoiceReferenceModel). \ filter(InvoiceReferenceModel.status_code == InvoiceReferenceStatus.COMPLETED.value). \ From 7a085db964f63e0cc9fdbaf0e7b9cc610a7f4d98 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Thu, 22 Jun 2023 06:47:15 -0700 Subject: [PATCH 3/3] Update reqs --- queue_services/payment-reconciliations/requirements.txt | 2 ++ .../requirements/bcregistry-libraries.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/queue_services/payment-reconciliations/requirements.txt b/queue_services/payment-reconciliations/requirements.txt index d8cb9cfbe..3d3341e0c 100644 --- a/queue_services/payment-reconciliations/requirements.txt +++ b/queue_services/payment-reconciliations/requirements.txt @@ -82,7 +82,9 @@ requests==2.31.0 rsa==4.9 semver==2.13.0 sentry-sdk==1.26.0 +simple-cloudevent @ git+https://github.com/daxiom/simple-cloudevent.py.git@447cabb988202206ac69e71177d7cd11b6c0b002 six==1.16.0 +strict-rfc3339==0.7 threadloop==1.0.2 thrift==0.16.0 tornado==6.3.2 diff --git a/queue_services/payment-reconciliations/requirements/bcregistry-libraries.txt b/queue_services/payment-reconciliations/requirements/bcregistry-libraries.txt index aab6c1cf2..623fffcbd 100644 --- a/queue_services/payment-reconciliations/requirements/bcregistry-libraries.txt +++ b/queue_services/payment-reconciliations/requirements/bcregistry-libraries.txt @@ -2,3 +2,4 @@ -e git+https://github.com/bcgov/sbc-common-components.git#egg=sbc-common-components&subdirectory=python # -e git+https://github.com/bcgov/sbc-pay.git@refunds#egg=pay-api&subdirectory=pay-api -e git+https://github.com/bcgov/sbc-pay.git@main#egg=pay-api&subdirectory=pay-api +git+https://github.com/daxiom/simple-cloudevent.py.git