From 0fedbc88cf983f72e8cd4f6b0a006c0560c3cf13 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Tue, 8 Sep 2015 00:49:44 +0530 Subject: [PATCH] CRM-15187, added checks for financial type and amount ---------------------------------------- * CRM-15187: Accounting implications of Membership Type changes https://issues.civicrm.org/jira/browse/CRM-15187 --- CRM/Member/Form/Membership.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 2c7fb5a744..73f5a1b2ef 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1832,14 +1832,22 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { //CRM-15187 // display message when membership type is changed if (($this->_action & CRM_Core_Action::UPDATE) && $this->_id && !in_array($this->_memType, $this->_memTypeSelected)) { - CRM_Core_Session::setStatus( - ts('The financial types associated with the old and new membership types are different. You may want to edit the contribution associated with this membership to adjust its financial type.'), - ts('Warning') - ); - CRM_Core_Session::setStatus( - ts('The cost of the old and new membership types are different. You may want to edit the contribution associated with this membership to adjust its amount.'), - ts('Warning') - ); + $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'membership'); + $maxID = max(array_keys($lineItem)); + $lineItem = $lineItem[$maxID]; + $membershipTypeDetails = $this->allMembershipTypeDetails[$membership->membership_type_id]; + if ($membershipTypeDetails['financial_type_id'] != $lineItem['financial_type_id']) { + CRM_Core_Session::setStatus( + ts('The financial types associated with the old and new membership types are different. You may want to edit the contribution associated with this membership to adjust its financial type.'), + ts('Warning') + ); + } + if ($membershipTypeDetails['minimum_fee'] != $lineItem['line_total']) { + CRM_Core_Session::setStatus( + ts('The cost of the old and new membership types are different. You may want to edit the contribution associated with this membership to adjust its amount.'), + ts('Warning') + ); + } } } -- 2.25.1