From 16e268ad71868be534d4f82daaa97cfd2dec418c Mon Sep 17 00:00:00 2001 From: eileenmcnaughton Date: Wed, 6 Jan 2016 08:23:51 +0000 Subject: [PATCH] e-notice fix for test --- CRM/Contribute/BAO/Contribution.php | 13 +++++++------ CRM/Core/DAO.php | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 1fa916f38d..e44de0544d 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -129,12 +129,17 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { } } + //set defaults in create mode + if (!$contributionID) { + CRM_Core_DAO::setCreateDefaults($params, self::getDefaults()); + } + //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'); if (($params['contribution_status_id'] == array_search('Refunded', $contributionStatus) - || $params['contribution_status_id'] == array_search('Cancelled', $contributionStatus)) + || $params['contribution_status_id'] == array_search('Cancelled', $contributionStatus)) ) { if (empty($params['creditnote_id']) || $params['creditnote_id'] == "null") { $params['creditnote_id'] = self::createCreditNoteId(); @@ -144,13 +149,9 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { else { // Since the fee amount is expecting this (later on) ensure it is always set. // It would only not be set for an update where it is unchanged. - $params['contribution_status_id'] = civicrm_api3('Contribution', 'getvalue', array('id' => $params['id'], 'return' => 'contribution_status_id')); + $params['contribution_status_id'] = civicrm_api3('Contribution', 'getvalue', array('id' => $contributionID, 'return' => 'contribution_status_id')); } - //set defaults in create mode - if (!$contributionID) { - CRM_Core_DAO::setCreateDefaults($params, self::getDefaults()); - } self::calculateMissingAmountParams($params, $contributionID); if (!empty($params['payment_instrument_id'])) { diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 065a468558..dd77b7fb23 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1768,7 +1768,7 @@ SELECT contact_id * @param $defaults */ public static function setCreateDefaults(&$params, $defaults) { - if (isset($params['id'])) { + if (!empty($params['id'])) { return; } foreach ($defaults as $key => $value) { -- 2.25.1