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

Extract code to set isEmailReceipt in Contribution.completeOrder #18039

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 2, 2020

Overview

This consolidates all the code in the completeOrder that determines whether or not to send an email receipt.

Looking at it here it seems deceptively simple but this calculation has always done my head in and I think it needs some pretty careful eyes on this to verify it.

I'm still evaluating the adequacy of test cover but I've described the tests I've found so far

Before

isEmailReceipt calculation 'distributed' in the main function

After

isEmailReceipt calculation extracted. Note that this does an extra lookup for recurring contributions but the (very small) performance cost seems acceptable given the readability issues and the fact we reduced the columns retrieved in the other look up

Technical Details

Note that

  • testCompleteTransactionWithEmailReceiptInput tests that input is respected
  • for events the event::sendMail function will not send unless it's configured for the event - which
    explains our final default of TRUE (testCompleteTransactionWithParticipantRecord)
  • testCompleteTransaction covers the back-office case which also defaults to true
  • I figure the cost of reloading the value for contribution_recur is pretty cheap compared to the confusion of passing values around
  • testpayLater covers contribution_page with is_email_receipt

Comments

I'm thinking about making this not-a-static-function - so it becomes $contribution->isSendEmailReceipt - the only issue would be if $this->contribution_page-id were empty due to no ->find(). Then only input would need to be passed in.

@civibot
Copy link

civibot bot commented Aug 2, 2020

(Standard links)

@civibot civibot bot added the master label Aug 2, 2020
@eileenmcnaughton
Copy link
Contributor Author

@mattwire this removes another chunk & I suspect the addActivity above it can go too

@mattwire
Copy link
Contributor

mattwire commented Aug 2, 2020

@KarinG @artfulrobot @jitendrapurohit If any of you are able to confirm the logic here - on first glance it seems correct and a good cleanup

@eileenmcnaughton
Copy link
Contributor Author

Warning this may hurt your brains

@seamuslee001
Copy link
Contributor

Jenkins re test this please

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

Might be a cleanup issue or a CI server issue

ok 571 - api_v3_ContactTypeTest::testContactUpdateSubtypeInvalid with data set "APIv3" (3)
ok 572 - api_v3_ContactTypeTest::testContactUpdateSubtypeInvalid with data set "APIv4" (4)
ok 573 - api_v3_ContributionPageTest::testCreateContributionPage with data set "APIv3" (3)
not ok 574 - api_v3_ContributionPageTest::testCreateContributionPage with data set "APIv4" (4) # TODO Incomplete Test
ok 575 - api_v3_ContributionPageTest::testGetBasicContributionPage with data set "APIv3" (3)
not ok 576 - api_v3_ContributionPageTest::testGetBasicContributionPage with data set "APIv4" (4) # TODO Incomplete Test
ok 577 - api_v3_ContributionPageTest::testGetContributionPageByAmount
ok 578 - api_v3_ContributionPageTest::testDeleteContributionPage with data set "APIv3" (3)
not ok 579 - api_v3_ContributionPageTest::testDeleteContributionPage with data set "APIv4" (4) # TODO Incomplete Test
ok 580 - api_v3_ContributionPageTest::testGetFieldsContributionPage
ok 581 - api_v3_ContributionPageTest::testSubmit
not ok 582 - Error: api_v3_ContributionPageTest::testSubmitZeroDollar
not ok 583 - Failure: api_v3_ContributionPageTest::testSubmitNewBillingNameData

message: 'Failure in api call for price_set create: DB Error: already exists'
severity: fail
...
ok 584 - api_v3_ContributionPageTest::testSubmitNewBillingNameDoNotOverwrite

@eileenmcnaughton
Copy link
Contributor Author

test this please

@mattwire
Copy link
Contributor

mattwire commented Aug 3, 2020

@eileenmcnaughton Check your style

This consolidates all the code in the completeOrder that determines whether or not to send an email receipt.

Note that
- testCompleteTransactionWithEmailReceiptInput tests that input is respected
- for events the event::sendMail function will not send unless it's configured for the event - which
explains our final default of TRUE (testCompleteTransactionWithParticipantRecord)
- testCompleteTransaction covers the back-office case which also defaults to true
- I figure the cost of reloading the value for contribution_recur is pretty cheap compared to the confusion of passing values around
- testpayLater covers contribution_page with is_email_receipt
@eileenmcnaughton
Copy link
Contributor Author

Jenkins is a grumpy bum

@mattwire mattwire merged commit 32d96d9 into civicrm:master Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants