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

Fixes getTemplateContribution to use a more reliable way to load line items #20784

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jul 6, 2021

Overview

Fixes getTemplateContribution to use a more reliable way to load line items

My efforts to add testing a 'deprecate weird stuff' have identified an odd and fragile
flow for the line items in getTemplateContribution. It calls
getLineItemsByContributionID which, as it turns out, substitues the
actual entity table with 'civicrm_contribution'.

Then this line of weird handling swoops in and saves the day.

This PR switches us to something cleaner than just loads the line items (with v4 LineItem.get) and
no weird handling

Before

Line items loaded in correctly & then fixed later

After

Line items loaded correctly

Technical Details

This relies on a couple of fixes that I'll rebase out of the PR once merged #20079 and on top of that #20780

Comments

@civibot
Copy link

civibot bot commented Jul 6, 2021

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

Hmm - some of those failing tests have been marked as 'invalid financials' - I suspect the failures are issues with the tests - but I will work through

@monishdeb
Copy link
Member

@eileenmcnaughton the test failures seems to be related:

Test Result (4 failures / +4)
CRM_Contribute_BAO_ContributionRecurTest.testAutoRenewalWhenOneMemberIsDeceased
CRM_Member_BAO_MembershipTest.testMembershipPaymentForSingleContributionMultipleMembership
api_v3_ContributionTest.testRepeatTransactionLineItems
api_v3_ContributionTest.testRepeatTransactionPassedInFinancialTypeTwoLineItems

@eileenmcnaughton eileenmcnaughton force-pushed the pay_fix branch 4 times, most recently from 76f9166 to 509229c Compare July 8, 2021 06:10
@@ -179,7 +201,7 @@ public function _unserialize(array $data): void {
public function getOverrideTotalAmount() {
// The override amount is only valid for quick config price sets where more
// than one field has not been selected.
if (!$this->overrideTotalAmount || !$this->supportsOverrideAmount() || count($this->getPriceOptions()) > 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditching the supportsOverrideAmount because

  1. it creates order issues - the prices set needs to be determined before it can be accessed and
  2. it just came out of logic moved from a form - but really I don't think there is any real reason at a BAO level why only quickconfig can support amount overrides. Quick config was always envisaged as a form presentation issue but the implementation got greedy. I think it's a form layer issue

@eileenmcnaughton eileenmcnaughton force-pushed the pay_fix branch 5 times, most recently from 10ad7ea to 95f8f44 Compare July 11, 2021 22:45
… items

My efforts to add testing a 'deprecate weird stuff' have identified an odd and fragile
flow for the line items in getTemplateContribution. It calls
getLineItemsByContributionID which, as it turns out, substitues the
actual entity table with 'civicrm_contribution'.

Then this line of weird handling swoops in and saves the day.

https://github.com/civicrm/civicrm-core/pull/20775/files#diff-a16d4d7449cf5f3a0616d1d282a32f27ab6d3f7d2726d076c02ad1d4d655af41R393

This switches us to something cleaner than just loads the line items (with v4 LineItem.get) and
no weird handling
@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

@monishdeb I finally got this to pass - note #20775 is just this plus a deprecation warning in the code this allows us to not call

@monishdeb
Copy link
Member

Looks good and mergeable based on:

  • General standards

    • (r-explain) PASS
    • (r-run) PASS (Tested on local, works fine doesn't cause any breakage/regression)
  • Developer standards

    • (r-tech) PASS (ensured the changes to rely on Order entity to fetch formatted line-item instead of reformatLineItemsForRepeatContribution doesn't cause regression)
    • (r-code) PASS (Looks good)
    • (r-test) PASS (existing unit-tests which is been updated captures the scenario accurately and test build passes)

    Merging now.

@monishdeb monishdeb merged commit 22b2466 into civicrm:master Jul 13, 2021
@eileenmcnaughton eileenmcnaughton deleted the pay_fix branch July 13, 2021 03:37
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.

2 participants