Skip to content

Commit

Permalink
Merge pull request #16349 from eileenmcnaughton/credit
Browse files Browse the repository at this point in the history
Remove unreachable code lines.
  • Loading branch information
yashodha authored Jan 22, 2020
2 parents afa06c5 + d7943ca commit c8fd50e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
12 changes: 0 additions & 12 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1106,12 +1106,6 @@ private static function updateFinancialAccountsOnContributionStatusChange(&$para
if (self::isContributionUpdateARefund($params['prevContribution']->contribution_status_id, $params['contribution']->contribution_status_id)) {
// @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)) {
// This is always set in the Contribution::create function.
CRM_Core_Error::deprecatedFunctionWarning('Logic says this line is never reached & can be removed');
$creditNoteId = self::createCreditNoteId();
CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution']->id, 'creditnote_id', $creditNoteId);
}
}
elseif (($previousContributionStatus == 'Pending'
&& $params['prevContribution']->is_pay_later) || $previousContributionStatus == 'In Progress'
Expand All @@ -1123,12 +1117,6 @@ private static function updateFinancialAccountsOnContributionStatusChange(&$para
// @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 (empty($params['contribution']->creditnote_id)) {
// This is always set in the Contribution::create function.
CRM_Core_Error::deprecatedFunctionWarning('Logic says this line is never reached & can be removed');
$creditNoteId = self::createCreditNoteId();
CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution']->id, 'creditnote_id', $creditNoteId);
}
}
else {
// @todo we should stop passing $params by reference - splitting this out would be a step towards that.
Expand Down
9 changes: 1 addition & 8 deletions CRM/Contribute/Form/Task/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) {
}

if ($contribution->contribution_status_id == $refundedStatusId || $contribution->contribution_status_id == $cancelledStatusId) {
if (is_null($contribution->creditnote_id)) {
CRM_Core_Error::deprecatedFunctionWarning('This it the wrong place to add a credit note id since the id is added when the status is changed in the Contribution::Create function- hopefully it is never hit');
$creditNoteId = CRM_Contribute_BAO_Contribution::createCreditNoteId();
CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'creditnote_id', $creditNoteId);
}
else {
$creditNoteId = $contribution->creditnote_id;
}
$creditNoteId = $contribution->creditnote_id;
}
if (!$contribution->invoice_number) {
$contribution->invoice_number = CRM_Contribute_BAO_Contribution::getInvoiceNumber($contribution->id);
Expand Down

0 comments on commit c8fd50e

Please sign in to comment.