From 963e82f54a93861d22d0ba64c0b1f682491fdb5e Mon Sep 17 00:00:00 2001 From: Guanhuan Chen Date: Mon, 7 Sep 2015 12:25:42 +0100 Subject: [PATCH] Allow credit note for cancellations --- CRM/Contribute/Form/Task/Invoice.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index ab7a50ebfa..a93a3c3bff 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -254,6 +254,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { // gives the status id when contribution status is 'Refunded' $contributionStatusID = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $refundedStatusId = CRM_Utils_Array::key('Refunded', $contributionStatusID); + $cancelledStatusId = CRM_Utils_Array::key('Cancelled', $contributionStatusID); // getting data from admin page $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); @@ -310,7 +311,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $stateProvinceAbbreviation = ''; } - if ($contribution->contribution_status_id == $refundedStatusId) { + if ($contribution->contribution_status_id == $refundedStatusId || $contribution->contribution_status_id == $cancelledStatusId) { $creditNoteId = CRM_Utils_Array::value('credit_notes_prefix', $prefixValue) . "" . $contribution->id; } $invoiceId = CRM_Utils_Array::value('invoice_prefix', $prefixValue) . "" . $contribution->id; @@ -431,6 +432,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { 'lineItem' => $lineItem, 'dataArray' => $dataArray, 'refundedStatusId' => $refundedStatusId, + 'cancelledStatusId' => $cancelledStatusId, 'contribution_status_id' => $contribution->contribution_status_id, 'subTotal' => $subTotal, 'street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), @@ -542,7 +544,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { } CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'invoice_id', $invoiceId); - if ($contribution->contribution_status_id == $refundedStatusId) { + if ($contribution->contribution_status_id == $refundedStatusId || $contribution->contribution_status_id == $cancelledStatusId) { CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'creditnote_id', $creditNoteId); } $invoiceTemplate->clearTemplateVars(); -- 2.25.1