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] Clean up handling of financial_type_id override #18032

Merged
merged 1 commit into from
Aug 3, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Consolidates handling of calculation as to whether to permit the financial_type_id to be overriden when repeating the transactionn

Before

This is calculated in getTemplateContribution - however there is an additional attempt to calculate it in the main completeOrder function. The calculation is only relevant for repeattransaction & code (which I added comments to) later ensures it is is unset for the complete flow

After

The $input['financial_type_id'] (if any) reaches repeattransaction and all relevant calculations as to whether to permit the override are done in getTemplateContribution

Technical Details

Currently we use the primaryContributionID to determine whether the templateContribution will
have more than one line item & unset the parameter. It makes much more sense to do evaluations
on how many line items the template contribution will have when we have loaded it's line items.

The logic is that the financial_type_id can be overriden either by editing the recurring contribution
(which you are permitted to do if only one line item exists) or by passing it in via input (which
is ignored if there is more than one line item.

This change ensures the input parameter reaches repeatTrannsaction - which is the appropriate
place to determine whether to apply it.

It removes one of 2 places that refers to primaryContributionID. The other is also inappropriate
as it is basically used to look up the line items to see the number of terms for the membership. However,
we already know that for any repeat transactions as we have already loaded the line items. In
completeOrder the line items are that of the contribution being saved.

We could pass the saved contribution id into this function as a quick way to eliminate the primaryContributionID
or we could just determine num_terms rather than primaryContributionID earlier on

Comments

@civibot
Copy link

civibot bot commented Aug 1, 2020

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

test this please

);
'contribution_status_id' => 'Pending',
], $generalParams);
$contributionParams['api.Payment.creaate'] = $contributionParams['total_amount'];
Copy link
Contributor

Choose a reason for hiding this comment

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

creaate...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

argh - fixed

@seamuslee001
Copy link
Contributor

@eileenmcnaughton test fail may relate here

@eileenmcnaughton
Copy link
Contributor Author

test fail related to this line https://github.com/civicrm/civicrm-core/pull/18032/files#diff-40e2e0f106ba620465acf3a9a81f2498R3051 being missing. It has have been the beneficiary of some leakage before this patch

Currently we use the primaryContributionID to determine whether the templateContribution will
have more than one line item & unset the parameter. It makes much more sense to do evaluations
on how many line items the template contribution will have when we have loaded it's line items.

The logic is that the financial_type_id can be overriden either by editing the recurring contribution
(which you are permitted to do if only one line item exists) or by passing it in via input (which
is ignored if there is more than one line item.

This change ensures the input parameter reaches repeatTrannsaction - which is the appropriate
place to determine whether to apply it.

It removes one of 2 places that refers to primaryContributionID. The other is also inappropriate
as it is basically used to look up the line items to see the number of terms for the membership. However,
we already know that for any repeat transactions as we have already loaded the line items. In
completeOrder the line items are that of the contribution being saved.

We could pass the saved contribution id into this function as a quick way to eliminate the primaryContributionID
or we could just determine num_terms rather than primaryContributionID earlier on
@@ -4486,7 +4485,6 @@ public static function completeOrder($input, &$ids, $objects, $transaction = NUL
$changeDate = CRM_Utils_Array::value('trxn_date', $input, date('YmdHis'));

$contributionResult = self::repeatTransaction($contribution, $input, $contributionParams);
$contributionParams['financial_type_id'] = $contribution->financial_type_id;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattwire with the other merged I'm just removing the setting & unsetting of $contributionParams['financial_type_id']

@mattwire mattwire merged commit 4dd0bc5 into civicrm:master Aug 3, 2020
@eileenmcnaughton eileenmcnaughton deleted the single branch August 3, 2020 23:58
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