From 7ca3c666d612b0b3d1641c80863082350a1562d3 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Fri, 23 Aug 2013 19:24:44 +0530 Subject: [PATCH] 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 --- CRM/Pledge/BAO/PledgePayment.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 -- 2.25.1