Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

validation/microdeposits: add a config for withdrawing from savings accounts #551

Closed

Conversation

adamdecaf
Copy link
Member

Fixes: #541

@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2020

Codecov Report

Merging #551 into master will decrease coverage by 0.81%.
The diff coverage is 60.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #551      +/-   ##
==========================================
- Coverage   54.02%   53.21%   -0.82%     
==========================================
  Files         102      102              
  Lines        3815     3845      +30     
==========================================
- Hits         2061     2046      -15     
- Misses       1384     1433      +49     
+ Partials      370      366       -4     
Impacted Files Coverage Δ
pkg/config/validation.go 75.00% <ø> (ø)
pkg/validation/microdeposits/micro_deposits.go 70.51% <60.00%> (-0.73%) ⬇️
pkg/transfers/pipeline/notify/pagerduty.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/tenants/mock_repository.go 16.66% <0.00%> (-16.67%) ⬇️
pkg/tenants/router.go 62.50% <0.00%> (-5.07%) ⬇️
pkg/config/pipeline.go 61.29% <0.00%> (ø)
pkg/transfers/router.go 58.41% <0.00%> (+0.20%) ⬆️
pkg/upload/sftp.go 69.10% <0.00%> (+2.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77ea609...8f871b7. Read the comment docs.

docs/config.md Show resolved Hide resolved
@adamdecaf adamdecaf force-pushed the config-withdraw-savings-account branch 2 times, most recently from af1711d to 8f871b7 Compare September 17, 2020 03:54
@@ -57,6 +59,11 @@ func createMicroDeposits(
micro.TransferIDs = append(micro.TransferIDs, xfer.TransferID)
}

// skip the debit for Savings accounts when configured to do so
if skipDebit(cfg.Withdraw, dest.Account) {
Copy link
Member

@vxio vxio Oct 2, 2020

Choose a reason for hiding this comment

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

I suggest removing skipDebit and being explicit:

if !cfg.Withdraw.FromSavingsAccount && dest.Account.Type != customers.Savings {
 return micro, nil    
}

To figure out what skipDebit does I had to look into its implementation, and customers.Savings is baked into the implementation.
I'd suggest adding the helper method once another use case (e.g. Checking) pops up and you need to reuse the logic.

Copy link
Member

Choose a reason for hiding this comment

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

I'm hoping my bool logic is correct here, SKIP the debit from Savings if both match:

  • Not configured to withdraw from savings, FromSavingsAccount is false
  • account type is not Savings

Copy link
Contributor

@alovak alovak Oct 2, 2020

Choose a reason for hiding this comment

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

I would rework this part as you suggest @vxio. We already discussed it with @adamdecaf while ago as it was not clear for me as well. after our change it seems still unclear.

In code we should read it as this:

if (we should not withdraw from savings account && current account is savings)

what are the options to name this "we should not withdraw from savings account"?

  • config.Withdraw.NotFromSavings
  • config.Withdraw.SkipForSavings
  • ...?

Copy link
Member

Choose a reason for hiding this comment

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

config.Withdraw.FromSavingsAccount is ok since it defaults to false like @adamdecaf mentioned.

Something like config.Withdraw.IsSavingsActive could also work.

Copy link
Member Author

Choose a reason for hiding this comment

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

What if we renamed skipDebit to skipDebitFromSavings?

Copy link
Member

Choose a reason for hiding this comment

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

That could work.

Copy link
Contributor

@alovak alovak Oct 2, 2020

Choose a reason for hiding this comment

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

@adamdecaf maybe we can rename config option into skipDebitFromSavings to simplify if statement to this:

if cfg.Withdraw.SkipDebitFromSavings && dest.Account.Type == customers.Savings {
  ... 
}

Copy link
Member Author

Choose a reason for hiding this comment

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

The default behavior needs to skip debits from savings accounts, so skipDebitFromSavings bool would have a default of false - that wouldn't skip debits and so I'm opposed to that naming.

@adamdecaf adamdecaf force-pushed the master branch 2 times, most recently from fb477cf to effcefb Compare November 8, 2020 23:29
@adamdecaf adamdecaf added this to the v0.10.0 milestone Nov 8, 2020
@adamdecaf adamdecaf closed this Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

validation/microdeposits: config to disable debiting savings accounts
4 participants