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

dev/core#88 Make sure financial_type_id is set when contribution is created #11907

Merged
merged 2 commits into from
Jun 14, 2018

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Mar 31, 2018

Overview

When a contribution is created via a contribution page (with a confirmation page) the parameter financial_type_id is not set if the contribution is not being created with a recurring contribution.

https://lab.civicrm.org/dev/core/issues/88

Before

financial_type_id is not set when a non-recurring contribution is submitted via a contribution page (with a confirmation page). But it is set when a recurring contribution is being created at the same time.

After

financial_type_id is always set for contribution params when submitted via a contribution page (with a confirmation page).
This makes it more consistent for use in payment processor extensions etc.

@mattwire mattwire changed the title WIP Make sure financial_type_id is properly assigned Make sure financial_type_id is properly assigned Apr 5, 2018
@mattwire mattwire changed the title Make sure financial_type_id is properly assigned Make sure financial_type_id is set when contribution is created Apr 28, 2018
@mattwire mattwire changed the title Make sure financial_type_id is set when contribution is created dev/core#88 Make sure financial_type_id is set when contribution is created Apr 28, 2018
@eileenmcnaughton
Copy link
Contributor

@mattwire so we are winding up with contributions with financial_type_id is null? Is that a regression?

@monishdeb ping

@mattwire
Copy link
Contributor Author

@mattwire so we are winding up with contributions with financial_type_id is null? Is that a regression?

I think it depends on if the payment processor wants to do some extra work to identify what the financial_type_id is meant to be, so we don't necessarily end up with no financial_type. I found this while testing smartdebit with non-recurring payments.

@eileenmcnaughton
Copy link
Contributor

Hmm - can you explain further? Payment processor should set the payment_instrument but that is separate

*
* @return null|string
*/
public function wrangleFinancialTypeID($contributionTypeId) {
if (isset($paymentParams['financial_type'])) {
$contributionTypeId = $paymentParams['financial_type'];
Copy link
Member

@monishdeb monishdeb Apr 29, 2018

Choose a reason for hiding this comment

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

This is a bit strange as $paymentParams is not a parameter nor initialised inside the function yet this is in existence, seems like something to do with past refactoring. Also we should change the variable name to financialTypeId from contributionTypeId as what we all know and in past why that column was renamed :)

so changes here would be:

public function wrangleFinancialTypeID($financialTypeID) {
 if (empty($financialTypeID) && !empty($this->_values['pledge_id'])) {
   $financialTypeID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge',
         $this->_values['pledge_id'],
         'financial_type_id'
       );
}
 return $financialTypeID;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@monishdeb Thanks for the review. I've updated that function to match what you suggested as that's much cleaner.

@mattwire mattwire force-pushed the contribution_financialtype_fix branch from 1adbeb3 to 14d47fe Compare April 29, 2018 09:30
@mattwire mattwire force-pushed the contribution_financialtype_fix branch from 14d47fe to 248a226 Compare April 29, 2018 19:41
@monishdeb
Copy link
Member

Jenkins test this please

@monishdeb
Copy link
Member

@monishdeb monishdeb merged commit 07f3638 into civicrm:master Jun 14, 2018
@eileenmcnaughton
Copy link
Contributor

@monishdeb @mattwire I closed the gitlab issue - as a matter of process everyone (submitted, merger, review etc) should feel it's incumbent on them to close the issue since 2/3 will probably forget :-)

@monishdeb
Copy link
Member

Thanks @eileenmcnaughton My bad that I forgot to close the ticket :(

@mattwire mattwire deleted the contribution_financialtype_fix branch September 25, 2018 11:03
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.

4 participants