From 07b62c0fcff0c711738eea3fd49e6e99a862b0a7 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 4 Sep 2023 16:12:14 +1200 Subject: [PATCH] Fix bug exposed by invalid data warning The invalid data warning exposed a bug where the email is being sent before the line item has been fixed - so line item data in the email would be incorrect. This is not a regression but the potential for someone to be aware of it is. --- CRM/Event/Form/SelfSvcTransfer.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Event/Form/SelfSvcTransfer.php b/CRM/Event/Form/SelfSvcTransfer.php index c76b3e2ac1..c9a6ccacbc 100644 --- a/CRM/Event/Form/SelfSvcTransfer.php +++ b/CRM/Event/Form/SelfSvcTransfer.php @@ -481,12 +481,6 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { foreach ($participantPayments as $payment) { civicrm_api3('ParticipantPayment', 'create', ['id' => $payment['id'], 'participant_id' => $participant->id]); } - //send a confirmation email to the new participant - $this->participantTransfer($participant); - //now update registered_by_id - $query = "UPDATE civicrm_participant cp SET cp.registered_by_id = %1 WHERE cp.id = ({$participant->id})"; - $params = [1 => [$fromParticipantID, 'Integer']]; - CRM_Core_DAO::executeQuery($query, $params); //copy line items to new participant $line_items = CRM_Price_BAO_LineItem::getLineItems($fromParticipantID); foreach ($line_items as $id => $item) { @@ -504,6 +498,12 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { $prevFinancialItem['entity_id'] = $tolineItem->id; CRM_Financial_BAO_FinancialItem::create($prevFinancialItem); } + //send a confirmation email to the new participant + $this->participantTransfer($participant); + //now update registered_by_id + $query = "UPDATE civicrm_participant cp SET cp.registered_by_id = %1 WHERE cp.id = ({$participant->id})"; + CRM_Core_DAO::executeQuery($query, [1 => [$fromParticipantID, 'Integer']]); + //now cancel the from participant record, leaving the original line-item(s) $value_from = []; $value_from['id'] = $fromParticipantID; -- 2.25.1