Skip to content

Commit

Permalink
CRM-21027 Fix next recurring payment not accurately calculated when e…
Browse files Browse the repository at this point in the history
…ffective date passed in
  • Loading branch information
eileenmcnaughton committed Aug 4, 2017
1 parent 0efad9e commit 5258fac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions CRM/Contribute/BAO/ContributionRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,8 @@ public static function getRecurringFields() {
* @throws \CiviCRM_API3_Exception
*/
public static function updateOnNewPayment($recurringContributionID, $paymentStatus, $effectiveDate) {
if (empty($effectiveDate)) {
$effectiveDate = date('Y-m-d');
}

$effectiveDate = $effectiveDate ? date('Y-m-d', strtotime($effectiveDate)) : date('Y-m-d');
if (!in_array($paymentStatus, array('Completed', 'Failed'))) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ public function testCancelRecur() {
*/
public function testSupportFinancialTypeChange() {
$contributionRecur = $this->callAPISuccess('contribution_recur', 'create', $this->_params);
$contribution = $this->callAPISuccess('contribution', 'create', array(
$this->callAPISuccess('contribution', 'create', array(
'contribution_recur_id' => $contributionRecur['id'],
'total_amount' => '3.00',
'financial_type_id' => 1,
'payment_instrument_id' => 1,
'currency' => 'USD',
'contact_id' => $this->individualCreate(),
'contribution_status_id' => 1,
'recieve_date' => 'yesterday',
'receive_date' => 'yesterday',
));
$this->assertTrue(CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($contributionRecur['id']));
}
Expand Down
10 changes: 10 additions & 0 deletions tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2671,6 +2671,16 @@ public function getScheduledDateData() {
'receive_date' => '2012-02-29',
'expected' => '2012-03-29 00:00:00',
);
$result['receive_date_includes_time']['2012-01-01-1-month'] = array(
'data' => array(
'start_date' => '2012-01-01',
'frequency_interval' => 1,
'frequency_unit' => 'month',
'next_sched_contribution_date' => '2012-02-29',
),
'receive_date' => '2012-02-29 16:00:00',
'expected' => '2012-03-29 00:00:00',
);
return $result;
}

Expand Down

0 comments on commit 5258fac

Please sign in to comment.