From: Guanhuan Chen Date: Mon, 7 Sep 2015 11:25:42 +0000 (+0100) Subject: Allow credit note for cancellations X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=41e050b3afbc3be2bbd809eae498d1e7c8a0d005;p=civicrm-core.git Allow credit note for cancellations --- diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index 2baabaebb0..074fdf3c3a 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -244,6 +244,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'); @@ -300,7 +301,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; @@ -421,6 +422,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)), @@ -532,7 +534,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();