From b929cdb46e0f44b756024c7229b2b02519d0f5b5 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Wed, 6 Apr 2016 21:03:28 +1200 Subject: [PATCH] CRM-18368 preliminary tidy-up, standarise setting of contributionStatusID --- CRM/Contribute/BAO/Contribution.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index eaa08dfa1a..1d3ba32cff 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -134,9 +134,9 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { CRM_Core_DAO::setCreateDefaults($params, self::getDefaults()); } + $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); //if contribution is created with cancelled or refunded status, add credit note id if (!empty($params['contribution_status_id'])) { - $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); // @todo - should we include Chargeback? If so use self::isContributionStatusNegative($params['contribution_status_id']) if (($params['contribution_status_id'] == array_search('Refunded', $contributionStatus) || $params['contribution_status_id'] == array_search('Cancelled', $contributionStatus)) @@ -4354,8 +4354,10 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']}) $recurContrib = CRM_Utils_Array::value('contributionRecur', $objects); $event = CRM_Utils_Array::value('event', $objects); + $completedContributionStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); + $contributionParams = array_merge(array( - 'contribution_status_id' => 'Completed', + 'contribution_status_id' => $completedContributionStatusID, 'source' => self::getRecurringContributionDescription($contribution, $event), ), array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1) )); @@ -4524,11 +4526,11 @@ LIMIT 1;"; elseif (!empty($contribution->_relatedObjects['membership'])) { $input['skipLineItem'] = TRUE; $input['contribution_mode'] = 'membership'; - $contribution->contribution_status_id = $contributionStatuses['Completed']; + $contribution->contribution_status_id = $completedContributionStatusID; $contribution->trxn_id = CRM_Utils_Array::value('trxn_id', $input); $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date); } - $input['contribution_status_id'] = $contributionStatuses['Completed']; + $input['contribution_status_id'] = $contributionParams['contribution_status_id']; $input['total_amount'] = $input['amount']; $input['contribution'] = $contribution; $input['financial_type_id'] = $contribution->financial_type_id; -- 2.25.1