Skip to content

Commit

Permalink
CRM-19153 Fixed future payment dates for future start pledge dates
Browse files Browse the repository at this point in the history
----------------------------------------
* CRM-19153: Future pledge start date causes improper future pledge payment dates
  https://issues.civicrm.org/jira/browse/CRM-19153
  • Loading branch information
Edzelopez committed Jul 29, 2016
1 parent 2b6622c commit 3ffb3cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CRM/Contribute/BAO/Contribution/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public static function processConfirm(
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;

//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
if (empty($form->_params['receive_date'])) {
$form->_params['receive_date'] = date('YmdHis');
}
if (!empty($form->_params['start_date'])) {
$form->_params['start_date'] = date('YmdHis');
}
$form->assign('receive_date',
CRM_Utils_Date::mysqlToIso($form->_params['receive_date'])
);
Expand Down
7 changes: 3 additions & 4 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -932,10 +932,9 @@ public static function processFormContribution(
$pledgeParams['frequency_day'] = 1;
}
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($contribution->contribution_page_id);
if (CRM_Utils_Array::value('start_date', $params) || !CRM_Utils_Array::value('is_pledge_start_date_visible', $pledgeBlock)) {
$pledgeStartDate = CRM_Utils_Array::value('start_date', $params, NULL);
$pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = CRM_Pledge_BAO_Pledge::getPledgeStartDate($pledgeStartDate, $pledgeBlock);
if (CRM_Utils_Array::value('start_date', $params)) {
$pledgeParams['frequency_day'] = intval(date("d", strtotime(CRM_Utils_Array::value('start_date', $params))));
$pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = CRM_Utils_Array::value('start_date', $params);
}
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
Expand Down
5 changes: 4 additions & 1 deletion CRM/Pledge/BAO/Pledge.php
Original file line number Diff line number Diff line change
Expand Up @@ -1231,9 +1231,12 @@ public static function getPledgeStartDate($date, $pledgeBlock) {
$startDate = (array) json_decode($pledgeBlock['pledge_start_date']);
list($field, $value) = each($startDate);
if (!CRM_Utils_Array::value('is_pledge_start_date_visible', $pledgeBlock)) {
if ($field == 'calendar_month') {
$value = self::getPaymentDate($value);
}
return date('Ymd', strtotime($value));
}
if (!CRM_Utils_Array::value('is_pledge_start_date_editable', $pledgeBlock)) {
if (!empty($date) && !CRM_Utils_Array::value('is_pledge_start_date_editable', $pledgeBlock)) {
return $date;
}
switch ($field) {
Expand Down

0 comments on commit 3ffb3cd

Please sign in to comment.