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] Follow up clean up - remove contribution_mode #20656

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -3377,7 +3377,7 @@ public static function isSubscriptionCancelled($contributionId) {
* @return null|\CRM_Core_BAO_FinancialTrxn
*/
public static function recordFinancialAccounts(&$params, $financialTrxnValues = NULL) {
$skipRecords = $update = $return = $isRelatedId = FALSE;
$skipRecords = $update = $return = FALSE;
$isUpdate = !empty($params['prevContribution']);

$additionalParticipantId = [];
Expand All @@ -3400,10 +3400,6 @@ public static function recordFinancialAccounts(&$params, $financialTrxnValues =
$entityTable = 'civicrm_contribution';
}

if (CRM_Utils_Array::value('contribution_mode', $params) == 'membership') {
$isRelatedId = TRUE;
}

$entityID[] = $entityId;
if (!empty($additionalParticipantId)) {
$entityID += $additionalParticipantId;
Expand Down
3 changes: 0 additions & 3 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1585,9 +1585,6 @@ protected function submit($submittedValues, $action, $pledgePaymentID) {
$params['participant_id'] = $pId;
Copy link
Member

@monishdeb monishdeb Jun 30, 2021

Choose a reason for hiding this comment

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

@eileenmcnaughton why don't we also get rid of this assignment

- $params['contribution_mode'] = 'participant';

And later in Contribution::create

-  if (CRM_Utils_Array::value('contribution_mode', $params) == 'participant') {
+ if (!empty($params['participant_id'])) {
      $entityId = $params['participant_id'];
      $entityTable = 'civicrm_participant';
      $additionalParticipantId = CRM_Event_BAO_Participant::getAdditionalParticipantIds($entityId);
    }
    elseif (!empty($params['membership_id'])) {
      //so far $params['membership_id'] should only be set coming in from membershipBAO::create so the situation where multiple memberships
      // are created off one contribution should be handled elsewhere
      $entityId = $params['membership_id'];
      $entityTable = 'civicrm_membership';
    }
    else {
      $entityId = $params['contribution']->id;
      $entityTable = 'civicrm_contribution';
    }

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 I'm happy to - I didn't remove it because I haven't worked through anything on the participant side yet & am only focussing on membership so far - I was going to switch my focus once the current PRs are merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Acutally that is not quite true - I had started on the participant side over here #20650 & I wanted to get that additional test cover before going further on it

$params['skipLineItem'] = 1;
}
elseif ($isRelatedId) {
$params['contribution_mode'] = 'membership';
}
$params['line_item'] = $lineItem;
$params['payment_processor_id'] = $params['payment_processor'] = $this->_paymentProcessor['id'] ?? NULL;
$params['tax_amount'] = CRM_Utils_Array::value('tax_amount', $submittedValues, CRM_Utils_Array::value('tax_amount', $this->_values));
Expand Down
2 changes: 1 addition & 1 deletion api/v3/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function civicrm_api3_order_create(array $params): array {
}
$entityParams['participant_status_id'] = $entityParams['participant_status_id'] ?? 'Pending from incomplete transaction';
$entityParams['status_id'] = $entityParams['participant_status_id'];
$params['contribution_mode'] = 'participant';
break;

case 'membership':
Expand All @@ -116,7 +117,6 @@ function civicrm_api3_order_create(array $params): array {
if ($supportedEntity) {
$entityParams['skipLineItem'] = TRUE;
$entityResult = civicrm_api3($entity, 'create', $entityParams);
$params['contribution_mode'] = $entity;
$entityIds[] = $params[$entity . '_id'] = $entityResult['id'];
foreach ($lineItems['line_item'] as &$items) {
$items['entity_id'] = $entityResult['id'];
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3509,7 +3509,6 @@ public function testPendingToCompleteContribution(): void {
'payment_processor_id' => $this->paymentProcessorID,
'currency' => 'USD',
'contribution_page_id' => $this->_ids['contribution_page'],
'contribution_mode' => 'membership',
'source' => 'Membership Signup and Renewal',
];

Expand Down