From 623712fb6a1b6ad6c627d742ab3d6441f02d96b2 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Tue, 9 Aug 2016 16:50:41 +0530 Subject: [PATCH] CRM-16189, Added function to check payment associated with contribution has Membership or participant ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 --- CRM/Contribute/BAO/Contribution.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index a8223d8089..f757472edf 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -5246,4 +5246,32 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co } } + /** + * Check if contribution has participant/membership payment. + * + * @param int $contributionId + * Contribution ID + * + * @return bool + */ + public static function allowUpdateRevenueRecognitionDate($contributionId) { + // get line item for contribution + $lineItems = CRM_Price_BAO_LineItem::getLineItems($contributionId, 'contribution', NULL, TRUE, TRUE); + // check if line item is for membership or participant + foreach ($lineItems as $items) { + if ($items['entity_table'] == 'civicrm_participant') { + $Update = FALSE; + break; + } + elseif ($items['entity_table'] == 'civicrm_membership') { + $Update = FALSE; + } + else { + $Update = TRUE; + break; + } + } + return $flag; + } + } -- 2.25.1