From: monishdeb Date: Fri, 23 Aug 2013 13:54:44 +0000 (+0530) Subject: CRM-13224 fix X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7ca3c666d612b0b3d1641c80863082350a1562d3;p=civicrm-core.git CRM-13224 fix ---------------------------------------- * CRM-13224: Contribution entries are not being created while recording 'adjusted payment' for installments of a pledge http://issues.civicrm.org/jira/browse/CRM-13224 --- diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index cdd5a1168f..f1690ff2e5 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -776,8 +776,18 @@ WHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId} $oldScheduledAmount = $oldestPayment['amount']; $newScheduledAmount = $oldScheduledAmount + ($pledgeScheduledAmount - $actualAmount); //store new amount in oldest pending payment record. - CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'scheduled_amount', $newScheduledAmount); - CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'contribution_id', $paymentContributionId); + CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', + $oldestPayment['id'], + 'scheduled_amount', + $newScheduledAmount + ); + if (CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'contribution_id', 'id')) { + CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', + $oldestPayment['id'], + 'contribution_id', + $paymentContributionId + ); + } } elseif (($actualAmount > $pledgeScheduledAmount) && (($actualAmount - $pledgeScheduledAmount) >= $oldestPayment['amount'])) { // here the actual amount is greater than expected and also greater than the next installment amount, so update the next installment as complete and again add it to next subsequent pending payment