// 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');
$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;
'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)),
}
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();