From 3293fb2da0372d7286f8038568d661eff98f2fa9 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 18 Jan 2020 10:37:01 +1300 Subject: [PATCH] Extract code for isPaymentOnExistingContribution. This allows us to make the meaning of the IF clause clearer --- CRM/Event/Form/Participant.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index e410ffc457..c48703d543 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1851,7 +1851,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $contributionParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate)); } } - if (($this->_id && $this->_action & CRM_Core_Action::UPDATE) && $this->_paymentId) { + if ($this->isPaymentOnExistingContribution()) { $participantBAO = new CRM_Event_BAO_Participant(); $participantBAO->id = $this->_id; $participantBAO->find(TRUE); @@ -1987,4 +1987,17 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } } + /** + * Is a payment being made on an existing contribution. + * + * Note + * 1) ideally we should not permit this on this form! Perhaps we don't & this is just cruft. + * 2) _paymentID is the contribution id. + * + * @return bool + */ + protected function isPaymentOnExistingContribution(): bool { + return ($this->_id && $this->_action & CRM_Core_Action::UPDATE) && $this->_paymentId; + } + } -- 2.25.1