From 797b807e76046eacc20366a8fb5ddacc8ef71fc9 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 5 Aug 2013 13:17:14 +1200 Subject: [PATCH] CRM-13155 rename next_sched_contribution to end in date as search logic expects that & conformance seems better than hackery --- CRM/Contribute/BAO/ContributionRecur.php | 2 +- CRM/Core/Payment/PayflowPro.php | 28 +++++++++--------- .../Incremental/sql/4.4.alpha1.mysql.tpl | 5 ++++ api/v3/examples/ContributionRecurCreate.php | 2 +- api/v3/utils.php | 5 ++++ .../CRM/Contribute/Page/ContributionRecur.tpl | 4 +-- xml/schema/Contribute/ContributionRecur.xml | 29 ++++++++++++++++++- 7 files changed, 56 insertions(+), 19 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 269a8d69f3..4028966fbd 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -335,7 +335,7 @@ SELECT r.payment_processor_id $params[$recurDAO->id]['contactId'] = $recurDAO->contact_id; $params[$recurDAO->id]['start_date'] = $recurDAO->start_date; $params[$recurDAO->id]['end_date'] = $recurDAO->end_date; - $params[$recurDAO->id]['next_sched_contribution'] = $recurDAO->next_sched_contribution; + $params[$recurDAO->id]['next_sched_contribution_date'] = $recurDAO->next_sched_contribution; $params[$recurDAO->id]['amount'] = $recurDAO->amount; $params[$recurDAO->id]['currency'] = $recurDAO->currency; $params[$recurDAO->id]['frequency_unit'] = $recurDAO->frequency_unit; diff --git a/CRM/Core/Payment/PayflowPro.php b/CRM/Core/Payment/PayflowPro.php index 442a61d7ca..e22c303412 100644 --- a/CRM/Core/Payment/PayflowPro.php +++ b/CRM/Core/Payment/PayflowPro.php @@ -161,78 +161,78 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { switch ($params['frequency_unit']) { case '1 week': - $params['next_sched_contribution'] = mktime(0, 0, 0, date("m"), date("d") + 7, + $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m"), date("d") + 7, date("Y") ); $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (7 * $payflow_query_array['TERM']), date("Y") ); - $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution']); + $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']); $payflow_query_array['PAYPERIOD'] = "WEEK"; $params['frequency_unit'] = "week"; $params['frequency_interval'] = 1; break; case '2 weeks': - $params['next_sched_contribution'] = mktime(0, 0, 0, date("m"), date("d") + 14, date("Y")); + $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m"), date("d") + 14, date("Y")); $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (14 * $payflow_query_array['TERM']) , date("Y ") ); - $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution']); + $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']); $payflow_query_array['PAYPERIOD'] = "BIWK"; $params['frequency_unit'] = "week"; $params['frequency_interval'] = 2; break; case '4 weeks': - $params['next_sched_contribution'] = mktime(0, 0, 0, date("m"), date("d") + 28, date("Y") + $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m"), date("d") + 28, date("Y") ); $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (28 * $payflow_query_array['TERM']) , date("Y") ); - $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution']); + $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']); $payflow_query_array['PAYPERIOD'] = "FRWK"; $params['frequency_unit'] = "week"; $params['frequency_interval'] = 4; break; case '1 month': - $params['next_sched_contribution'] = mktime(0, 0, 0, date("m") + 1, + $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m") + 1, date("d"), date("Y") ); $params['end_date'] = mktime(0, 0, 0, date("m") + (1 * $payflow_query_array['TERM']), date("d"), date("Y") ); - $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution']); + $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']); $payflow_query_array['PAYPERIOD'] = "MONT"; $params['frequency_unit'] = "month"; $params['frequency_interval'] = 1; break; case '3 months': - $params['next_sched_contribution'] = mktime(0, 0, 0, date("m") + 3, date("d") + $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m") + 3, date("d") , date("Y") ); $params['end_date'] = mktime(0, 0, 0, date("m") + (3 * $payflow_query_array['TERM']), date("d"), date("Y") ); - $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution']); + $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']); $payflow_query_array['PAYPERIOD'] = "QTER"; $params['frequency_unit'] = "month"; $params['frequency_interval'] = 3; break; case '6 months': - $params['next_sched_contribution'] = mktime(0, 0, 0, date("m") + 6, date("d"), + $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m") + 6, date("d"), date("Y") ); $params['end_date'] = mktime(0, 0, 0, date("m") + (6 * $payflow_query_array['TERM']), date("d"), date("Y") ); - $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution' + $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date' ] ); $payflow_query_array['PAYPERIOD'] = "SMYR"; @@ -241,14 +241,14 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { break; case '1 year': - $params['next_sched_contribution'] = mktime(0, 0, 0, date("m"), date("d"), + $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1 ); $params['end_date'] = mktime(0, 0, 0, date("m"), date("d"), date("Y") + (1 * $payflow_query_array['TEM']) ); - $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution']); + $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']); $payflow_query_array['PAYPERIOD'] = "YEAR"; $params['frequency_unit'] = "year"; $params['frequency_interval'] = 1; diff --git a/CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl index 8f9ae77128..264eae1f36 100644 --- a/CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl @@ -147,3 +147,8 @@ UPDATE civicrm_uf_group ug ON uf.uf_group_id = ug.id AND ug.is_reserved = 1 AND name = 'membership_batch_entry' SET uf.is_reserved = 0 WHERE uf.field_name IN ('join_date', 'membership_start_date', 'membership_end_date'); + +--CRM-13155 - Add searching for recurring contribution data to search has been successfully created. +ALTER TABLE `civicrm_contribution_recur` + CHANGE COLUMN `next_sched_contribution` `next_sched_contribution_date` DATETIME NULL DEFAULT NULL COMMENT 'At Groundspring this was used by the cron job which triggered payments. If we\'re not doing that but we know about payments, it might still be useful to store for display to org andor contributors.' AFTER `cycle_day`; + diff --git a/api/v3/examples/ContributionRecurCreate.php b/api/v3/examples/ContributionRecurCreate.php index 6fe28ad389..9caa2ac865 100644 --- a/api/v3/examples/ContributionRecurCreate.php +++ b/api/v3/examples/ContributionRecurCreate.php @@ -59,7 +59,7 @@ function contribution_recur_create_expectedresult(){ 'contribution_status_id' => '1', 'is_test' => '', 'cycle_day' => '', - 'next_sched_contribution' => '', + 'next_sched_contribution_date' => '', 'failure_count' => '', 'failure_retry_date' => '', 'auto_renew' => '', diff --git a/api/v3/utils.php b/api/v3/utils.php index 84b7f24dc2..f8aeff580e 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -187,8 +187,13 @@ function civicrm_api3_create_success($values = 1, $params = array( $values[$key]['id'] = $item[$entity . "_id"]; } if(!empty($item['financial_type_id'])){ + //4.3 legacy handling $values[$key]['contribution_type_id'] = $item['financial_type_id']; } + if(!empty($item['next_sched_contribution_date'])){ + // 4.4 legacy handling + $values[$key]['next_sched_contribution'] = $item['next_sched_contribution_date']; + } } } diff --git a/templates/CRM/Contribute/Page/ContributionRecur.tpl b/templates/CRM/Contribute/Page/ContributionRecur.tpl index f8cd8b4b12..d70021f312 100644 --- a/templates/CRM/Contribute/Page/ContributionRecur.tpl +++ b/templates/CRM/Contribute/Page/ContributionRecur.tpl @@ -44,9 +44,9 @@ {ts}Transaction ID{/ts}{$recur.trxn_id} {if $recur.invoice_id}{ts}Invoice ID{/ts}{$recur.invoice_id}{/if} {ts}Cycle Day{/ts}{$recur.cycle_day} - {if $recur.contribution_status_id neq 3}{ts}Next Contribution{/ts}{$recur.next_sched_contribution|crmDate}{/if} + {if $recur.contribution_status_id neq 3}{ts}Next Contribution{/ts}{$recur.next_sched_contribution_date|crmDate}{/if} {ts}Failure Count{/ts}{$recur.failure_count} - {if $recur.invoice_id}{ts}Failure Retry Date{/ts}{$recur.next_sched_contribution|crmDate}{/if} + {if $recur.invoice_id}{ts}Failure Retry Date{/ts}{$recur.next_sched_contribution_date|crmDate}{/if} {ts}Auto Renew?{/ts}{if $recur.auto_renew}{ts}Yes{/ts}{else}{ts}No{/ts}{/if} {if $recur.payment_processor}{ts}Payment Processor{/ts}{$recur.payment_processor}{/if} diff --git a/xml/schema/Contribute/ContributionRecur.xml b/xml/schema/Contribute/ContributionRecur.xml index 2f348683fa..2de454e272 100644 --- a/xml/schema/Contribute/ContributionRecur.xml +++ b/xml/schema/Contribute/ContributionRecur.xml @@ -7,6 +7,7 @@ true id + Recurring Contribution ID int unsigned true Contribution Recur ID @@ -18,6 +19,7 @@ contact_id + Contact ID int unsigned true Foreign key to civicrm_contact.id . @@ -32,6 +34,7 @@ amount + Amount decimal true Amount to be contributed or charged each recurrence. @@ -39,6 +42,7 @@ currency + Currency varchar 3 NULL @@ -53,6 +57,7 @@ frequency_unit + Frequency Unit enum day,week,month,year 'month' @@ -61,6 +66,7 @@ frequency_interval + Interval (number of units) int unsigned true Number of time units for recurrence of payment. @@ -68,12 +74,14 @@ installments + Number of Installments int unsigned Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date. 1.6 start_date + Recurring Contribution Started Date datetime true The date the first scheduled recurring contribution occurs. @@ -81,6 +89,7 @@ create_date + Recurring Contribution Created Date datetime true When this recurring contribution record was created. @@ -88,24 +97,28 @@ modified_date + Recurring Contribution Modified Date datetime Last updated date for this record. mostly the last time a payment was received 1.6 cancel_date + Recurring Contribution Cancel Date datetime Date this recurring contribution was cancelled by contributor- if we can get access to it 1.6 end_date + Recurring Contribution End Date datetime Date this recurring contribution finished successfully 1.6 processor_id + Payment Processor varchar 255 Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor?? @@ -161,6 +174,7 @@ cycle_day + Number of Cycle Day int unsigned 1 true @@ -172,9 +186,18 @@ datetime At Groundspring this was used by the cron job which triggered payments. If we\'re not doing that but we know about payments, it might still be useful to store for display to org andor contributors. 1.6 + 4.4 + + + next_sched_contribution_date + Next Scheduled Contribution Date + datetime + Next scheduled date + 4.4 failure_count + Number of Failures int unsigned 0 Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures. @@ -183,11 +206,13 @@ failure_retry_date datetime - At Groundspring we set a business rule to retry failed payments every 7 days - and stored the next scheduled attempt date there. + Retry Failed Attempt Date + Date to retry failed attempt 1.6 auto_renew + Auto Renew boolean true 0 @@ -196,6 +221,7 @@ payment_processor_id + Payment Processor int unsigned Foreign key to civicrm_payment_processor.id 3.3 @@ -271,6 +297,7 @@ is_email_receipt + Send email Receipt? boolean if true, receipt is automatically emailed to contact on each successful payment 1 -- 2.25.1