Merge pull request #15232 from eileenmcnaughton/credit
authorMatthew Wire <mjw@mjwconsult.co.uk>
Wed, 9 Oct 2019 16:47:42 +0000 (18:47 +0200)
committerGitHub <noreply@github.com>
Wed, 9 Oct 2019 16:47:42 +0000 (18:47 +0200)
Respect calling code passing in 'null'  for creditnote_id.

CRM/Contribute/BAO/Contribution.php

index 3a78b420d541a93cf1efa66e0c4476eee4b3539a..9c3a52b2e10c1c5521af268be5cbee06a5f14766 100644 (file)
@@ -155,7 +155,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
       if (($params['contribution_status_id'] == array_search('Refunded', $contributionStatus)
         || $params['contribution_status_id'] == array_search('Cancelled', $contributionStatus))
       ) {
-        if (empty($params['creditnote_id']) || $params['creditnote_id'] == "null") {
+        if (empty($params['creditnote_id'])) {
           $params['creditnote_id'] = self::createCreditNoteId();
         }
       }
@@ -1126,7 +1126,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
         $isARefund = TRUE;
         // @todo we should stop passing $params by reference - splitting this out would be a step towards that.
         $params['trxnParams']['total_amount'] = -$params['total_amount'];
-        if (empty($params['contribution']->creditnote_id) || $params['contribution']->creditnote_id == "null") {
+        if (empty($params['contribution']->creditnote_id)) {
           $creditNoteId = self::createCreditNoteId();
           CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution']->id, 'creditnote_id', $creditNoteId);
         }
@@ -1141,7 +1141,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
           // @todo we should stop passing $params by reference - splitting this out would be a step towards that.
           $params['trxnParams']['to_financial_account_id'] = $arAccountId;
           $params['trxnParams']['total_amount'] = -$params['total_amount'];
-          if (is_null($params['contribution']->creditnote_id) || $params['contribution']->creditnote_id == "null") {
+          if (empty($params['contribution']->creditnote_id)) {
             $creditNoteId = self::createCreditNoteId();
             CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution']->id, 'creditnote_id', $creditNoteId);
           }