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

Handle participant payment create in line item #20790

Merged
merged 1 commit into from
Jul 7, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Handling participant payments the same way as membership payments - ie ensure they exist when the line item is created

Before

Done for membership payment in the line item bao but not participant payments

After

ALso for participant payments

Technical Details

Note the BAO handles the scenario where it already exists

Comments

@monishdeb this is pulled out from #20650 - the test in there shows it works but it needs #20670 merged first

Remove participant payment create from order api

This is now done in the line item create & we went through to 'prove' that it works with
extra validation
@civibot civibot bot added the master label Jul 7, 2021
@civibot
Copy link

civibot bot commented Jul 7, 2021

(Standard links)

if (!civicrm_api3('ParticipantPayment', 'getcount', $participantPaymentParams)) {
civicrm_api3('ParticipantPayment', 'create', $participantPaymentParams);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

@eileenmcnaughton I was thinking to make these parts a bit generalised as I can few common pattern like:

...
$paymentEntites = CRM_Core_SelectValues::getPaymentEntites();
foreach ($paymentEntites as $entity => $paymentEntity) {
  if ($lineItemBAO->entity_table == 'civicrm_' . $entity && $lineItemBAO->contribution_id && $lineItemBAO->entity_id) {
     $entityParams = [
        $entity . '_id' => $lineItemBAO->entity_id,
        'contribution_id' => $lineItemBAO->contribution_id,
      ];
      if (!civicrm_api3($paymentEntity, 'getcount', $entityParams)) {
         $entityParams['isSkipLineItem'] = TRUE;
        civicrm_api3($paymentEntity, 'create', $entityParams);
      }
  }
}

Copy link
Member

Choose a reason for hiding this comment

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

but in a separate PR, not blocker for this patch. Overall agree with the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - if we get a use case (& tests) we can look at that. I don't want to be generic if there really are just 2 entities

@monishdeb
Copy link
Member

Patch looks good.

@eileenmcnaughton eileenmcnaughton merged commit 42ab5fa into civicrm:master Jul 7, 2021
@eileenmcnaughton eileenmcnaughton deleted the partor branch July 7, 2021 05:24
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.

2 participants