Skip to content

Commit

Permalink
CRM-15380 : Handles civicrm#1 and civicrm#2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CiviCRM committed Sep 30, 2014
1 parent 59da031 commit 523bae5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions CRM/Event/BAO/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ static function deleteContactParticipant($contactId) {
static function changeFeeSelections($params, $participantId, $contributionId, $feeBlock, $lineItems, $paidAmount, $priceSetId) {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
$pendngRefundStatusId = array_search('Pending refund', $contributionStatuses);
$pendingRefundStatusId = array_search('Pending refund', $contributionStatuses);
$previousLineItems = CRM_Price_BAO_LineItem::getLineItems($participantId, 'participant');
CRM_Price_BAO_PriceSet::processAmount($feeBlock,
$params, $lineItems
Expand Down Expand Up @@ -1937,6 +1937,7 @@ static function changeFeeSelections($params, $participantId, $contributionId, $f
foreach ($insertLines as $valueId => $lineParams) {
$lineParams['entity_table'] = 'civicrm_participant';
$lineParams['entity_id'] = $participantId;
$lineParams['contribution_id'] = $contributionId;
$lineObj = CRM_Price_BAO_LineItem::create($lineParams);
}

Expand Down Expand Up @@ -1984,28 +1985,30 @@ static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId)
$balanceAmt = $updatedAmount - $paidAmount;
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
$pendngRefundStatusId = array_search('Pending refund', $contributionStatuses);
$pendingRefundStatusId = array_search('Pending refund', $contributionStatuses);
$completedStatusId = array_search('Completed', $contributionStatuses);

$updatedContributionDAO = new CRM_Contribute_BAO_Contribution();

$skip = FALSE;
if ($balanceAmt) {
if ($balanceAmt > 0 && $paidAmount != 0) {
$contributionStatusVal = $partiallyPaidStatusId;
}
elseif ($balanceAmt < 0 && $paidAmount != 0) {
$contributionStatusVal = $pendngRefundStatusId;
$contributionStatusVal = $pendingRefundStatusId;
}
elseif ($paidAmount == 0) {
$contributionStatusVal = $completedStatusId;
//skip updating the contribution status if no payment is made
$skip = TRUE;
$updatedContributionDAO->cancel_date = 'null';
$updatedContributionDAO->cancel_reason = NULL;
}

// update contribution status and total amount without trigger financial code
// as this is handled in current BAO function used for change selection
$updatedContributionDAO->id = $contributionId;
$updatedContributionDAO->contribution_status_id = $contributionStatusVal;
if (!$skip) {
$updatedContributionDAO->contribution_status_id = $contributionStatusVal;
}
$updatedContributionDAO->total_amount = $updatedAmount;
$updatedContributionDAO->save();

Expand Down

0 comments on commit 523bae5

Please sign in to comment.