Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18099 - PAY API - endpoint to add EFT Allowed flag to an account #1307

Merged
merged 12 commits into from
Oct 30, 2023

Conversation

Jxio
Copy link
Collaborator

@Jxio Jxio commented Oct 25, 2023

Issue #:
bcgov/entity#18099

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the sbc-pay license (Apache 2.0).

@Jxio Jxio added the enhancement New feature or request label Oct 25, 2023
@Jxio Jxio self-assigned this Oct 25, 2023
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Merging #1307 (5b9735f) into main (79924ce) will increase coverage by 0.56%.
Report is 30 commits behind head on main.
The diff coverage is 95.58%.

@@            Coverage Diff             @@
##             main    #1307      +/-   ##
==========================================
+ Coverage   91.45%   92.02%   +0.56%     
==========================================
  Files         186      199      +13     
  Lines       11319    11750     +431     
==========================================
+ Hits        10352    10813     +461     
+ Misses        967      937      -30     
Flag Coverage Δ
eventlistenerqueue 82.00% <100.00%> (+0.18%) ⬆️
payadmin ∅ <ø> (?)
payapi 93.76% <94.54%> (+0.03%) ⬆️
paymentjobs 83.51% <93.10%> (+3.28%) ⬆️
paymentreconciliationsqueue 92.71% <97.50%> (+1.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
.../payment-jobs/tasks/statement_notification_task.py 79.74% <100.00%> (+47.92%) ⬆️
pay-api/src/pay_api/models/__init__.py 100.00% <100.00%> (ø)
pay-api/src/pay_api/models/eft_file.py 100.00% <100.00%> (ø)
...-api/src/pay_api/models/eft_process_status_code.py 100.00% <100.00%> (ø)
pay-api/src/pay_api/models/eft_short_names.py 100.00% <100.00%> (ø)
pay-api/src/pay_api/models/eft_transaction.py 100.00% <100.00%> (ø)
pay-api/src/pay_api/models/invoice.py 100.00% <100.00%> (ø)
pay-api/src/pay_api/models/payment.py 95.87% <ø> (ø)
pay-api/src/pay_api/models/payment_account.py 97.72% <100.00%> (+0.05%) ⬆️
pay-api/src/pay_api/models/statement.py 97.67% <100.00%> (+0.05%) ⬆️
... and 23 more

... and 7 files with indirect coverage changes

@seeker25
Copy link
Collaborator

seeker25 commented Oct 25, 2023

Shouldn't this be an endpoint you can use to enable EFT on a user's account? Aka they can't choose EFT until someone goes into the backend and flips the switch via notebook?

enabled_eft probably should just be in the payment_accounts model

a resource should be built that can be called via notebook that sets enable_eft - if enable_eft is enabled on their payment account, it should show or hide the extra options in the payment methods? etc

@seeker25
Copy link
Collaborator

@ochiu

FAILED tests/integration/test_worker_queue.py::test_update_credit_payment - sqlalchemy.exc.StatementError: (builtins.KeyError) 'LEGISLATIVE_TIMEZONE'

@ochiu
Copy link
Collaborator

ochiu commented Oct 25, 2023

@ochiu

FAILED tests/integration/test_worker_queue.py::test_update_credit_payment - sqlalchemy.exc.StatementError: (builtins.KeyError) 'LEGISLATIVE_TIMEZONE'

@Jxio @seeker25 caused by a recent change to the invoice model to have a default for the overdue_date and it uses the current_local_time() function requiring the LEGISLATIVE_TIMEZONE.

@Jxio would you be able to add the below to the config.py for the event_listener in this PR please? If preferred I can also submit another PR. Just let me know thanks!

LEGISLATIVE_TIMEZONE = os.getenv('LEGISLATIVE_TIMEZONE', 'America/Vancouver')

@seeker25
Copy link
Collaborator

I figured as much

@Jxio
Copy link
Collaborator Author

Jxio commented Oct 25, 2023

@seeker25
image
I probably got misunderstanding on this ticket. Is it not a flag just indicate if eft allowed? -> if an account had EFT invoices historically, then it allows to have EFT payment option?

@seeker25
Copy link
Collaborator

seeker25 commented Oct 25, 2023

Yeah but we don't want to enable eft for every client only the 300 in the list mostly. Thus why we need a flag to enable or disable on an account basis.

@seeker25
Copy link
Collaborator

seeker25 commented Oct 25, 2023

image

  1. Add enable_eft to datamodel for payment_accounts
  2. This flag should control if the EFT payment method can be switched to in the payment method screen
  3. Case by case basis, so a route needs to be built that a notebook can be ran to enable EFT to peoples accounts, payload org_id probably
  4. When this flag is added.. it should trigger a welcome email.. so it needs to fire down a queue message and call the account mailer


def upgrade():
op.execute("set statement_timeout=20000;")
op.add_column('payment_accounts', sa.Column('eft_enable', sa.Boolean, nullable=True))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably default the new flag to false and make it not nullable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sounds good

# eft_enable set to true when it has invoices paid with EFT/DIRECT_PAY payment method historically
op.execute("set statement_timeout=20000;")
conn = op.get_bind()
conn.execute('UPDATE payment_accounts \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary, we want to enable specific accounts via notebook. It will also give us flexibility to enable a subset of accounts if we want and we want to send a welcome email when we enable it for accounts.

A new route/endpoint is beneficial as we can secure it differently than the existing payment account endpoints and have separate logic like the welcome email when we enable this flag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this file, it gonna handle by ticket 18100

@seeker25
Copy link
Collaborator

seeker25 commented Oct 27, 2023

lint + unit tests before merging pls

@@ -564,6 +577,7 @@ def asdict(self, **kwargs):
# to handle PAD 3 day period..UI needs bank details even if PAD is not activated
is_future_pad = (self.payment_method == PaymentMethod.DRAWDOWN.value) and (self._is_pad_in_pending_activation())
show_cfs_details = is_ob_or_pad or is_future_pad
d['eft_enable'] = self._dao.eft_enable
Copy link
Collaborator

@seeker25 seeker25 Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this? because you've added it up here:

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with postman, when the eft_enable is false, it doesn't show up. I'm removing eft_enable = fields.Boolean(...)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be able to mess with something in here -^

@seeker25
Copy link
Collaborator

Something else I noticed, what about the route?

@Jxio
Copy link
Collaborator Author

Jxio commented Oct 27, 2023

Something else I noticed, what about the route?

a separate route? I don't think we need it. it can be passed with payment-accounts route:
image

@seeker25
Copy link
Collaborator

seeker25 commented Oct 27, 2023

That's the GET, we still need a PATCH route so we can set ENABLE_EFT, I see routes for GET, POST, PUT

It needs to check for the SYSTEM role

@classmethod
def enable_eft(cls, auth_account_id: str) -> PaymentAccount:
"""Enable EFT on the payment account."""
current_app.logger.debug('<patch_account')
Copy link
Collaborator

@seeker25 seeker25 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't part of patch account, this is enable_eft - patch account calls enable_eft

except ServiceUnavailableException as exception:
return exception.response()

status = HTTPStatus.ACCEPTED \
Copy link
Collaborator

@seeker25 seeker25 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this be ACCEPTED or OK? I don't see you providing any option to disable eft

I'd just return OK

@sonarcloud
Copy link

sonarcloud bot commented Oct 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@seeker25 seeker25 merged commit 69d2fd3 into bcgov:main Oct 30, 2023
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants