Skip to content
Snippets Groups Projects
Verified Commit fc629796 authored by Kevin Cristiano's avatar Kevin Cristiano :earth_americas:
Browse files

Fix refund payment not recording from additional payment form #14739


Backport of 5.16 PR

Signed-off-by: default avatarKevin Cristiano <kcristiano@kcristiano.com>
parent d55c2ce8
No related branches found
No related tags found
No related merge requests found
......@@ -3893,6 +3893,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']],
......@@ -4015,6 +4016,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'];
}
}
......
......@@ -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.');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment