Skip to content

Commit

Permalink
Merge pull request #14739 from kcristiano/5.15-backport-14733
Browse files Browse the repository at this point in the history
Fix refund payment not recording from additional payment form
  • Loading branch information
monishdeb authored Jul 5, 2019
2 parents c782348 + d7f9080 commit d8a2070
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -3893,6 +3893,7 @@ public static function checkStatusValidation($values, &$fields, &$errors) {
'In Progress' => ['Cancelled', 'Completed', 'Failed'],
'Refunded' => ['Cancelled', 'Completed'],
'Partially paid' => ['Completed'],
'Pending refund' => ['Completed', 'Refunded'],
];

if (!in_array($contributionStatuses[$fields['contribution_status_id']],
Expand Down Expand Up @@ -4015,6 +4016,7 @@ public static function recordAdditionalPayment($contributionId, $trxnsData, $pay
elseif ($paymentType == 'refund') {
$trxnsData['total_amount'] = -$trxnsData['total_amount'];
$trxnsData['participant_id'] = $participantId;
$trxnsData['contribution_id'] = $contributionId;
return civicrm_api3('Payment', 'create', $trxnsData)['id'];
}
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/AdditionalPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public static function formRule($fields, $files, $self) {
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.');
}
Expand Down

0 comments on commit d8a2070

Please sign in to comment.