From 64041b1417d21766943bcc2e0e5fc20d9b8fd2f8 Mon Sep 17 00:00:00 2001 From: kurund Date: Thu, 22 Aug 2013 17:22:40 +0530 Subject: [PATCH] indentation fixes --- CRM/Pledge/BAO/PledgePayment.php | 157 ++++++++++++++++--------------- 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index 00619f1577..cdd5a1168f 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -318,24 +318,24 @@ WHERE pledge_id = %1 /** * update Pledge Payment Status * - * @param int $pledgeID, id of pledge + * @param int $pledgeID, id of pledge * @param array $paymentIDs, ids of pledge payment(s) to update - * @param int $paymentStatusID, payment status to set - * @param int $pledgeStatus, pledge status to change (if needed) + * @param int $paymentStatusID, payment status to set + * @param int $pledgeStatus, pledge status to change (if needed) * @param float $actualAmount, actual amount being paid - * @param bool $adjustTotalAmount, is amount being paid different from scheduled amount? - * @param bool $isScriptUpdate, is function being called from bin script? + * @param bool $adjustTotalAmount, is amount being paid different from scheduled amount? + * @param bool $isScriptUpdate, is function being called from bin script? * * @return int $newStatus, updated status id (or 0) */ static function updatePledgePaymentStatus( $pledgeID, - $paymentIDs = NULL, - $paymentStatusID = NULL, - $pledgeStatusID = NULL, - $actualAmount = 0, + $paymentIDs = NULL, + $paymentStatusID = NULL, + $pledgeStatusID = NULL, + $actualAmount = 0, $adjustTotalAmount = FALSE, - $isScriptUpdate = FALSE + $isScriptUpdate = FALSE ) { $totalAmountClause = ''; $paymentContributionId = NULL; @@ -395,8 +395,8 @@ WHERE pledge_id = %1 if ($pledgeStatusId && $pledgeStatusId == array_search('Completed', $allStatus) || $lastPending) { // last scheduled payment if ($actualAmount >= $pledgeScheduledAmount) { - $adjustTotalAmount = TRUE; - } + $adjustTotalAmount = TRUE; + } elseif (!$adjustTotalAmount) { // actual amount is less than the scheduled amount, so enter new pledge payment record $pledgeFrequencyUnit = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $pledgeID, 'frequency_unit', 'id'); @@ -408,8 +408,8 @@ WHERE pledge_id = %1 $date['day'] = (int) substr($scheduled_date, 6, 2); $newDate = date('YmdHis', mktime(0, 0, 0, $date['month'], $date['day'], $date['year'])); $ScheduledDate = CRM_Utils_Date::format(CRM_Utils_Date::intervalAdd($pledgeFrequencyUnit, - $pledgeFrequencyInterval, $newDate - )); + $pledgeFrequencyInterval, $newDate + )); $pledgeParams = array( 'status_id' => array_search('Pending', $allStatus), 'pledge_id' => $pledgeID, @@ -422,7 +422,7 @@ WHERE pledge_id = %1 CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $payments, 'scheduled_amount', $actualAmount); } } - } + } elseif (!$adjustTotalAmount) { // not last schedule amount and also not selected to adjust Total $paymentContributionId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', @@ -482,7 +482,8 @@ UPDATE civicrm_pledge WHERE civicrm_pledge.id = %2 "; - $params = array(1 => array($pledgeStatusID, 'Integer'), + $params = array( + 1 => array($pledgeStatusID, 'Integer'), 2 => array($pledgeID, 'Integer'), ); @@ -504,11 +505,11 @@ WHERE civicrm_pledge.id = %2 * @static */ static function calculateBaseScheduleDate(&$params) { - $date = array(); + $date = array(); $scheduled_date = CRM_Utils_Date::processDate($params['scheduled_date']); - $date['year'] = (int) substr($scheduled_date, 0, 4); - $date['month'] = (int) substr($scheduled_date, 4, 2); - $date['day'] = (int) substr($scheduled_date, 6, 2); + $date['year'] = (int) substr($scheduled_date, 0, 4); + $date['month'] = (int) substr($scheduled_date, 4, 2); + $date['day'] = (int) substr($scheduled_date, 6, 2); //calculation of schedule date according to frequency day of period //frequency day is not applicable for daily installments if ($params['frequency_unit'] != 'day' && $params['frequency_unit'] != 'year') { @@ -524,11 +525,11 @@ WHERE civicrm_pledge.id = %2 $frequencyDay = $params['frequency_day'] - $dayOfWeek; $scheduleDate = explode("-", date('n-j-Y', mktime(0, 0, 0, $date['month'], - $date['day'] + $frequencyDay, $date['year'] - ))); + $date['day'] + $frequencyDay, $date['year'] + ))); $date['month'] = $scheduleDate[0]; - $date['day'] = $scheduleDate[1]; - $date['year'] = $scheduleDate[2]; + $date['day'] = $scheduleDate[1]; + $date['year'] = $scheduleDate[2]; } } $newdate = date('YmdHis', mktime(0, 0, 0, $date['month'], $date['day'], $date['year'])); @@ -602,20 +603,20 @@ WHERE civicrm_pledge.id = %2 /** * Function to update pledge payment table * - * @param int $pledgeId pledge id + * @param int $pledgeId pledge id * @param array $paymentIds payment ids to be updated - * @param int $paymentStatusId payment status id to set + * @param int $paymentStatusId payment status id to set * @param float $actualAmount, actual amount being paid * @param int $contributionId, Id of associated contribution when payment is recorded - * @param bool $isScriptUpdate, is function being called from bin script? + * @param bool $isScriptUpdate, is function being called from bin script? * @static */ static function updatePledgePayments($pledgeId, - $paymentStatusId, - $paymentIds = NULL, - $actualAmount = 0, - $contributionId = NULL, - $isScriptUpdate = FALSE + $paymentStatusId, + $paymentIds = NULL, + $actualAmount = 0, + $contributionId = NULL, + $isScriptUpdate = FALSE ) { $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $paymentClause = NULL; @@ -689,10 +690,10 @@ ORDER BY civicrm_pledge_payment.scheduled_date ASC LIMIT 0, %2 "; - $params[1] = array($pledgeID, 'Integer'); - $params[2] = array($limit, 'Integer'); - $payment = CRM_Core_DAO::executeQuery($query, $params); - $count = 1; + $params[1] = array($pledgeID, 'Integer'); + $params[2] = array($limit, 'Integer'); + $payment = CRM_Core_DAO::executeQuery($query, $params); + $count = 1; $paymentDetails = array(); while ($payment->fetch()) { $paymentDetails[] = array( @@ -720,7 +721,7 @@ WHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId} $paymentIDs[] = $paymentsAffected->id; } // Reset the affected values by the amount paid more than the scheduled amount - foreach($paymentIDs as $key => $value) { + foreach ($paymentIDs as $key => $value) { $payment = new CRM_Pledge_DAO_PledgePayment(); $payment->id = $value; if ($payment->find(TRUE)) { @@ -744,7 +745,7 @@ WHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId} $pledgeFrequencyUnit = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $pledgeID, 'frequency_unit', 'id'); $pledgeFrequencyInterval = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $pledgeID, 'frequency_interval', 'id'); - $pledgeScheduledDate = $lastPayment['scheduled_date']; + $pledgeScheduledDate = $lastPayment['scheduled_date']; $scheduled_date = CRM_Utils_Date::processDate($pledgeScheduledDate); $date['year'] = (int) substr($scheduled_date, 0, 4); $date['month'] = (int) substr($scheduled_date, 4, 2); @@ -760,53 +761,53 @@ WHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId} $payment = self::add($pledgeParams); } else { - $oldestPayment = self::getOldestPledgePayment($pledgeID); - if (!$paymentContributionId) { - // means we are editing payment scheduled payment, so get the second pending to update. - $oldestPayment = self::getOldestPledgePayment($pledgeID, 2); - if (($oldestPayment['count'] != 1) && ($oldestPayment['id'] == $pPaymentId)) { - $oldestPayment = self::getOldestPledgePayment($pledgeID); + $oldestPayment = self::getOldestPledgePayment($pledgeID); + if (!$paymentContributionId) { + // means we are editing payment scheduled payment, so get the second pending to update. + $oldestPayment = self::getOldestPledgePayment($pledgeID, 2); + if (($oldestPayment['count'] != 1) && ($oldestPayment['id'] == $pPaymentId)) { + $oldestPayment = self::getOldestPledgePayment($pledgeID); + } } - } - if ($oldestPayment) { - // not the last scheduled payment and the actual amount is less than the expected , add it to oldest pending. - if (($actualAmount != $pledgeScheduledAmount) && (($actualAmount < $pledgeScheduledAmount) || (($actualAmount - $pledgeScheduledAmount) < $oldestPayment['amount']))) { - $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); - } - 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 - // set the actual amount of the next pending to '0', set contribution Id to current contribution Id and status as completed - $paymentId = array($oldestPayment['id']); - self::updatePledgePayments($pledgeID, array_search('Completed', $allStatus), $paymentId, 0, $paymentContributionId); - CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'scheduled_amount', 0, 'id'); - $oldestPayment = self::getOldestPledgePayment($pledgeID); - if (!$paymentContributionId) { - // means we are editing payment scheduled payment. - $oldestPaymentAmount = self::getOldestPledgePayment($pledgeID, 2); + if ($oldestPayment) { + // not the last scheduled payment and the actual amount is less than the expected , add it to oldest pending. + if (($actualAmount != $pledgeScheduledAmount) && (($actualAmount < $pledgeScheduledAmount) || (($actualAmount - $pledgeScheduledAmount) < $oldestPayment['amount']))) { + $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); } - $newActualAmount = ($actualAmount - $pledgeScheduledAmount); - $newPledgeScheduledAmount = $oldestPayment['amount']; - if (!$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 + // set the actual amount of the next pending to '0', set contribution Id to current contribution Id and status as completed + $paymentId = array($oldestPayment['id']); + self::updatePledgePayments($pledgeID, array_search('Completed', $allStatus), $paymentId, 0, $paymentContributionId); + CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'scheduled_amount', 0, 'id'); + $oldestPayment = self::getOldestPledgePayment($pledgeID); + if (!$paymentContributionId) { + // means we are editing payment scheduled payment. + $oldestPaymentAmount = self::getOldestPledgePayment($pledgeID, 2); + } $newActualAmount = ($actualAmount - $pledgeScheduledAmount); - $newPledgeScheduledAmount = $oldestPaymentAmount['amount']; - // means we are editing payment scheduled payment, so update scheduled amount. - CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', - $oldestPaymentAmount['id'], - 'scheduled_amount', - $newActualAmount - ); - } - if ($newActualAmount > 0) { - self::adjustPledgePayment($pledgeID, $newActualAmount, $newPledgeScheduledAmount, $paymentContributionId); + $newPledgeScheduledAmount = $oldestPayment['amount']; + if (!$paymentContributionId) { + $newActualAmount = ($actualAmount - $pledgeScheduledAmount); + $newPledgeScheduledAmount = $oldestPaymentAmount['amount']; + // means we are editing payment scheduled payment, so update scheduled amount. + CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', + $oldestPaymentAmount['id'], + 'scheduled_amount', + $newActualAmount + ); + } + if ($newActualAmount > 0) { + self::adjustPledgePayment($pledgeID, $newActualAmount, $newPledgeScheduledAmount, $paymentContributionId); + } } } } - } } } -- 2.25.1