From c6191312b0a65f8ebfb24972cf8c4ce4ac9118fc Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Mon, 5 May 2014 18:26:54 +0530 Subject: [PATCH] CRM-13973 : comment #comment-59922 --- CRM/Event/BAO/Participant.php | 4 ++-- templates/CRM/Event/Form/ParticipantFeeSelection.tpl | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 54cb729594..9ae755a99e 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1952,10 +1952,10 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI $pendngRefundStatusId = array_search('Pending refund', $contributionStatuses); if ($balanceAmt) { - if ($balanceAmt > 0) { + if ($balanceAmt > 0 && $paidAmount != 0) { $contributionStatusVal = $partiallyPaidStatusId; } - elseif ($balanceAmt < 0) { + elseif ($balanceAmt < 0 && $paidAmount != 0) { $contributionStatusVal = $pendngRefundStatusId; } diff --git a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl index 3a8b50787d..e6838e2f2e 100644 --- a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl +++ b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl @@ -69,13 +69,13 @@ function populatebalanceFee(updatedAmt, onlyStatusUpdate) { var balanceAmt = updatedTotalLineTotal - feePaid; // change the status selections according to updated selections - if (balanceAmt > 0) { + if (balanceAmt > 0 && feePaid != 0) { cj('#status_id').val(partiallyPaid); } else if(balanceAmt < 0) { cj('#status_id').val(pendingRefund); } - else if(balanceAmt == 0) { + else { cj('#status_id').val(participantStatus); } @@ -207,15 +207,19 @@ CRM.$(function($) { var statusId = cj('#status_id').val(); var statusLabel = cj('#status_id option:selected').text(); var balanceFee = cj('#balance-fee').text(); + + // fee actually paid + var feePaid = {/literal}{$feePaid}{literal}; + balanceFee = parseFloat(balanceFee.replace(/[^0-9-.]/g, '')); - if (balanceFee > 0 && statusId != partiallyPaid) { + if ((balanceFee > 0 && feePaid != 0) && statusId != partiallyPaid) { var result = confirm('Balance is owing for the updated selections. Expected participant status is \'Partially paid\'. Are you sure you want to set the participant status to ' + statusLabel + ' ? Click OK to continue, Cancel to change your entries.'); if (result == false) { e.preventDefault(); } } - else if (balanceFee < 0 && statusId != pendingRefund) { + else if ((balanceFee < 0 && feePaid != 0) && statusId != pendingRefund) { var result = confirm('Balance is overpaid for the updated selections. Expected participant status is \'Pending refund\'. Are you sure you want to set the participant status to ' + statusLabel + ' ? Click OK to continue, Cancel to change your entries'); if (result == false) { e.preventDefault(); -- 2.25.1