From 7142a4c85b623890f2f972f7a189a4a5f132907b Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Jul 2019 20:41:56 +1200 Subject: [PATCH] Fix refund payment not recording from additional payment form --- CRM/Contribute/BAO/Contribution.php | 2 ++ CRM/Contribute/Form/AdditionalPayment.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index a45652a17a..82a3e3d682 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3891,6 +3891,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac 'In Progress' => ['Cancelled', 'Completed', 'Failed'], 'Refunded' => ['Cancelled', 'Completed'], 'Partially paid' => ['Completed'], + 'Pending refund' => ['Completed', 'Refunded'], ]; if (!in_array($contributionStatuses[$fields['contribution_status_id']], @@ -4013,6 +4014,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac elseif ($paymentType == 'refund') { $trxnsData['total_amount'] = -$trxnsData['total_amount']; $trxnsData['participant_id'] = $participantId; + $trxnsData['contribution_id'] = $contributionId; return civicrm_api3('Payment', 'create', $trxnsData)['id']; } } diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 1c580d37fd..f34854f597 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -294,7 +294,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract if ($self->_paymentType == 'refund' && $fields['total_amount'] != abs($self->_refund)) { $errors['total_amount'] = ts('Refund amount must equal refund due amount.'); } - $netAmt = $fields['total_amount'] - CRM_Utils_Array::value('fee_amount', $fields, 0); + $netAmt = (float) $fields['total_amount'] - (float) CRM_Utils_Array::value('fee_amount', $fields, 0); if (!empty($fields['net_amount']) && $netAmt != $fields['net_amount']) { $errors['net_amount'] = ts('Net amount should be equal to the difference between payment amount and fee amount.'); } -- 2.25.1