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

[REF] Simplify getContributionStatuses #22280

Merged
merged 2 commits into from
Dec 30, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Dec 20, 2021

Overview

[REF] Simplify getContributionStatuses

The existing function is really confusing - but all that confusion is designed for one
form - back office contribution form - and augmented by overloading by other functions.

This splits it out. The same options are returned - however if sites have added their own options they would not be returned - we don't support that in the UI and our financial code really does expect a limited range of statuses so I don't know if that is a thing - maybe highlight in release notes?

Before

Function is super hard to read - being called to do different things makes that hard to unwravel. The function is used to get the drop down options for available statuses in 5 scenarions

  1. new contribution backoffice (available options are Pending, Completed, Failed, Cancelled)
    image
  2. new membership with record payment (available options are Pending & Completed)
  3. new participant with record payment (available options are Pending & Completed)
  4. Profile form with contribution status included (available options are Pending, Completed, Failed, Cancelled)
  5. edit contribution back-office - this one is all over the show and untouched by this PR

After

The first 4 scenarios call simpler functions - leaving the last to be fixed up.

Technical Details

Could sites be using 'weird and wonderful other statuses'? Our system really is set up
around supporting specific statuses and doing financial entries for those so I think maybe
we are right to not try to pander to any that could exist

Comments

@civibot civibot bot added the master label Dec 20, 2021
@civibot
Copy link

civibot bot commented Dec 20, 2021

(Standard links)

@seamuslee001
Copy link
Contributor

Jenkins re test this please

@@ -1733,7 +1733,7 @@ public function buildEventFeeForm($form) {
}

$form->add('select', 'contribution_status_id',
ts('Payment Status'), CRM_Contribute_BAO_Contribution_Utils::getContributionStatuses('participant')
ts('Payment Status'), CRM_Contribute_BAO_Contribution_Utils::getPendingAndCompleteStatuses('participant')
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still trying to get my head around the earlier function but this function doesn't take a parameter here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah - that was lazy of me

The effect of the altered calls to getContributionStatus is to get a small set of options returned.

In the cases of participant & membership forms this is pending or completed. For
the ufGroup option it seems cancelled & failed are also data entry options (this method
should still cope if they don't exist).

The existing function is really confusing - but all that confusion is designed for one
form - back office contribution form - and augmented by overloading by other functions.

This splits it out.

Could sites be using 'weird and wonderful other statuses'? Our system really is set up
around supporting specific statuses and doing financial entries for those so I think maybe
we are right to not try to pander to any that could exist
@demeritcowboy
Copy link
Contributor

Jenkins retest this please - E2E\Core\AssetBuilderTest.testInvalid

@demeritcowboy
Copy link
Contributor

Good job unravelling that function. Contribution status = "better".

@demeritcowboy demeritcowboy merged commit cacfc64 into civicrm:master Dec 30, 2021
@eileenmcnaughton eileenmcnaughton deleted the statuses branch December 30, 2021 20:43
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Dec 30, 2021
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Dec 30, 2021
It is no longer used in core but I found 2 universe places so I added back
some handling for other entities & deprecated it and stopped using it
entirely in core

See civicrm#22280
@eileenmcnaughton
Copy link
Contributor Author

Just noting I was going to remove the $usedFor param but found a couple of universe calls so I re-instated it & deprecated the function in #22345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants