From 6e7cc0f578e814459b1e1b80c7a922684da46140 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 9 Jun 2019 13:43:28 +1000 Subject: [PATCH] [REF] dev/core#561 Convert Contribution Date field and contribution cancel date field to use date picker on search form Update ContributionAggregate search as well as it uses the field name contribution_date as well as core search Add in Upgrade Step to handle change in export and profiles and update default return properties and tests and api for the new unique field names Convert Cancel Date field as well Inlcude schema changes Fix test Fix some more reports Update generated data Revert namespace change to contribution --- .../Search/Custom/ContributionAggregate.php | 33 ++++++++++++++---- CRM/Contribute/BAO/Query.php | 34 ++----------------- CRM/Contribute/DAO/Contribution.php | 6 ++-- CRM/Contribute/Tokens.php | 3 +- .../Form/Contribute/DeferredRevenue.php | 2 ++ CRM/Report/Form/Contribute/Detail.php | 2 ++ CRM/Upgrade/Incremental/SmartGroups.php | 11 +++++- CRM/Upgrade/Incremental/php/FiveSixteen.php | 23 +++++++++++++ .../Incremental/sql/5.16.alpha1.mysql.tpl | 4 +++ api/v3/Contribution.php | 3 +- api/v3/utils.php | 4 +++ .../Search/Custom/ContributionAggregate.tpl | 10 ++++-- .../CRM/Contribute/Form/Search/Common.tpl | 25 +++++--------- .../CRM/Contribute/Form/SearchTest.php | 28 +++++---------- tests/phpunit/CRM/Export/BAO/ExportTest.php | 6 ++-- tests/phpunit/api/v3/ContributionTest.php | 2 +- xml/schema/Contribute/Contribution.xml | 2 ++ 17 files changed, 112 insertions(+), 86 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index f776f8448e..df9d090461 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -63,6 +63,8 @@ class CRM_Contact_Form_Search_Custom_ContributionAggregate extends CRM_Contact_F * @param CRM_Core_Form $form */ public function buildForm(&$form) { + $form->addSearchFieldMetadata(['Contribution' => self::getSearchFieldMetadata()]); + $form->addFormFieldsFromMetadata(); /** * You can define a custom title for the search form @@ -83,7 +85,6 @@ class CRM_Contact_Form_Search_Custom_ContributionAggregate extends CRM_Contact_F ts('...and $') ); $form->addRule('max_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money'); - CRM_Core_Form_Date::buildDateRange($form, 'contribution_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); $form->addSelect('financial_type_id', ['entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search'] @@ -187,6 +188,20 @@ civicrm_contact AS contact_a {$this->_aclFrom} return $from; } + /** + * Get the metadata for fields to be included on the contact search form. + */ + public static function getSearchFieldMetadata() { + $fields = [ + 'receive_date' => ['title' => ''], + ]; + $metadata = civicrm_api3('Contribution', 'getfields', [])['values']; + foreach ($fields as $fieldName => $field) { + $fields[$fieldName] = array_merge(CRM_Utils_Array::value($fieldName, $metadata, []), $field); + } + return $fields; + } + /** * WHERE clause is an array built from any required JOINS plus conditional filters based on search criteria field values. * @@ -201,9 +216,9 @@ civicrm_contact AS contact_a {$this->_aclFrom} ]; foreach ([ - 'contribution_date_relative', - 'contribution_date_low', - 'contribution_date_high', + 'receive_date_relative', + 'receive_date_low', + 'receive_date_high', ] as $dateFieldName) { $dateParams[$dateFieldName] = CRM_Utils_Array::value( $dateFieldName, @@ -214,10 +229,16 @@ civicrm_contact AS contact_a {$this->_aclFrom} foreach (CRM_Contact_BAO_Query::convertFormValues($dateParams) as $values) { list($name, $op, $value) = $values; if (strstr($name, '_low')) { - $clauses[] = "contrib.receive_date >= " . CRM_Utils_Date::processDate($value); + if (strlen($value) == 10) { + $value .= ' 00:00:00'; + } + $clauses[] = "contrib.receive_date >= '{$value}'"; } else { - $clauses[] = "contrib.receive_date <= " . CRM_Utils_Date::processDate($value); + if (strlen($value) == 10) { + $value .= ' 23:59:59'; + } + $clauses[] = "contrib.receive_date <= '{$value}'"; } } diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index e2ad53b260..7c03293413 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -835,7 +835,7 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { // site 'thankyou_date' => 1, // performance - 'cancel_date' => 1, + 'contribution_cancel_date' => 1, // and 'total_amount' => 1, // torture @@ -927,6 +927,8 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { 'contribution_source', 'cancel_reason', 'invoice_number', + 'receive_date', + 'contribution_cancel_date', ]; $metadata = civicrm_api3('Contribution', 'getfields', [])['values']; return array_intersect_key($metadata, array_flip($fields)); @@ -944,11 +946,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { $form->addSearchFieldMetadata(['Contribution' => self::getSearchFieldMetadata()]); $form->addFormFieldsFromMetadata(); - CRM_Core_Form_Date::buildDateRange($form, 'contribution_date', 1, '_low', '_high', ts('From:'), FALSE); - // CRM-17602 - // This hidden element added for displaying Date Range error correctly. Definitely a dirty hack, but... it works. - $form->addElement('hidden', 'contribution_date_range_error'); - $form->addFormRule(['CRM_Contribute_BAO_Query', 'formRule'], $form); $form->add('text', 'contribution_amount_low', ts('From'), ['size' => 8, 'maxlength' => 8]); $form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money'); @@ -956,9 +953,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { $form->add('text', 'contribution_amount_high', ts('To'), ['size' => 8, 'maxlength' => 8]); $form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); - CRM_Core_Form_Date::buildDateRange($form, 'contribution_cancel_date', 1, '_low', '_high', ts('From:'), FALSE); - $form->addElement('hidden', 'contribution_cancel_date_range_error'); - // Adding select option for curreny type -- CRM-4711 $form->add('select', 'contribution_currency_type', ts('Currency Type'), @@ -1127,28 +1121,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { return TRUE; } - /** - * Custom form rules. - * - * @param array $fields - * @param array $files - * @param CRM_Core_Form $form - * - * @return bool|array - */ - public static function formRule($fields, $files, $form) { - $errors = []; - - if (!empty($fields['contribution_date_high']) && !empty($fields['contribution_date_low'])) { - CRM_Utils_Rule::validDateRange($fields, 'contribution_date', $errors, ts('Date Received')); - } - if (!empty($fields['contribution_cancel_date_high']) && !empty($fields['contribution_cancel_date_low'])) { - CRM_Utils_Rule::validDateRange($fields, 'contribution_cancel_date', $errors, ts('Cancel Date')); - } - - return empty($errors) ? TRUE : $errors; - } - /** * Add the soft credit fields to the select fields. * diff --git a/CRM/Contribute/DAO/Contribution.php b/CRM/Contribute/DAO/Contribution.php index b628edef8c..c26b67242e 100644 --- a/CRM/Contribute/DAO/Contribution.php +++ b/CRM/Contribute/DAO/Contribution.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contribute/Contribution.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:7a81b495b5661ae881321938d4ee38c9) + * (GenCodeChecksum:da1e3ab214960a38728f763464c00f8b) */ /** @@ -552,10 +552,10 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO { 'nameColumn' => 'name', ], ], - 'cancel_date' => [ + 'contribution_cancel_date' => [ 'name' => 'cancel_date', 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, - 'title' => ts('Cancel Date'), + 'title' => ts('Cancelled / Refunded Date'), 'description' => ts('when was gift cancelled'), 'import' => TRUE, 'where' => 'civicrm_contribution.cancel_date', diff --git a/CRM/Contribute/Tokens.php b/CRM/Contribute/Tokens.php index 25d247c51f..6c97c765df 100644 --- a/CRM/Contribute/Tokens.php +++ b/CRM/Contribute/Tokens.php @@ -50,7 +50,7 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { 'trxn_id', 'invoice_id', 'currency', - 'cancel_date', + 'contribution_cancel_date', 'receipt_date', 'thankyou_date', 'tax_amount', @@ -69,6 +69,7 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { 'source' => 'contribution_source', 'status' => 'contribution_status_id', 'type' => 'financial_type_id', + 'cancel_date' => 'contribution_cancel_date', ]; } diff --git a/CRM/Report/Form/Contribute/DeferredRevenue.php b/CRM/Report/Form/Contribute/DeferredRevenue.php index 321c5378e3..75718bb137 100644 --- a/CRM/Report/Form/Contribute/DeferredRevenue.php +++ b/CRM/Report/Form/Contribute/DeferredRevenue.php @@ -95,6 +95,7 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { 'type' => CRM_Utils_Type::T_DATE, ], 'cancel_date' => [ + 'name' => 'contribution_cancel_date', 'title' => ts('Cancel Date'), 'type' => CRM_Utils_Type::T_DATE, ], @@ -113,6 +114,7 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { 'title' => ts('Cancel Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, + 'name' => 'contribution_cancel_date', ], 'revenue_recognition_date' => [ 'title' => ts('Revenue Recognition Date'), diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 82060fafdd..a4c6e0d31f 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -180,6 +180,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { ], 'cancel_date' => [ 'title' => ts('Cancelled / Refunded Date'), + 'name' => 'contribution_cancel_date', ], 'cancel_reason' => [ 'title' => ts('Cancellation / Refund Reason'), @@ -243,6 +244,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { 'cancel_date' => [ 'title' => ts('Cancelled / Refunded Date'), 'operatorType' => CRM_Report_Form::OP_DATE, + 'name' => 'contribution_cancel_date', ], 'cancel_reason' => [ 'title' => ts('Cancellation / Refund Reason'), diff --git a/CRM/Upgrade/Incremental/SmartGroups.php b/CRM/Upgrade/Incremental/SmartGroups.php index a92aa9e649..feb9c6438a 100644 --- a/CRM/Upgrade/Incremental/SmartGroups.php +++ b/CRM/Upgrade/Incremental/SmartGroups.php @@ -39,7 +39,14 @@ class CRM_Upgrade_Incremental_SmartGroups { */ public function updateGroups($actions) { foreach ($actions as $func => $fields) { - $this->{$func}($fields); + if ($func == 'renameField') { + foreach ($fields as $fieldConversion) { + $this->{$func}($fieldConversion['old'], $fieldConversion['new']); + } + } + else { + $this->{$func}($fields); + } } } @@ -57,6 +64,8 @@ class CRM_Upgrade_Incremental_SmartGroups { $relativeDateMappings = [ 'activity_date_time' => 'activity', 'participant_register_date' => 'participant', + 'receive_date' => 'contribution', + 'contribution_cancel_date' => 'contribution_cancel', ]; foreach ($fields as $field) { diff --git a/CRM/Upgrade/Incremental/php/FiveSixteen.php b/CRM/Upgrade/Incremental/php/FiveSixteen.php index d763798440..554d884b62 100644 --- a/CRM/Upgrade/Incremental/php/FiveSixteen.php +++ b/CRM/Upgrade/Incremental/php/FiveSixteen.php @@ -80,6 +80,29 @@ class CRM_Upgrade_Incremental_php_FiveSixteen extends CRM_Upgrade_Incremental_Ba // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. // } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_5_16_alpha1($rev) { + $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + $this->addTask('Update smart groups to rename filters on contribution_date to receive_date', 'updateSmartGroups', [ + 'renameField' => [ + ['old' => 'contribution_date', 'new' => 'receive_date'], + ['old' => 'contribution_date_low', 'new' => 'receive_date_low'], + ['old' => 'contribution_date_high', 'new' => 'receive_date_high'], + ['old' => 'contribution_date_relative', 'new' => 'receive_date_relative'], + ], + ]); + $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [ + 'datepickerConversion' => [ + 'receive_date', + 'contribution_cancel_date', + ], + ]); + } + // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) { // return TRUE; // } diff --git a/CRM/Upgrade/Incremental/sql/5.16.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.16.alpha1.mysql.tpl index 2e799db330..be013c10a8 100644 --- a/CRM/Upgrade/Incremental/sql/5.16.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.16.alpha1.mysql.tpl @@ -1 +1,5 @@ {* file to handle db changes in 5.16.alpha1 during upgrade *} + +-- dev/core#561 Update fields to take into account receive_date and cancel_date have unique names now +UPDATE civicrm_uf_field SET field_name = 'contribution_cancel_date' WHERE field_name = 'cancel_date'; +UPDATE civicrm_mapping_field SET name = 'contribution_cancel_date' WHERE name = 'cancel_date'; diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 8366a44528..48c58ee736 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -294,7 +294,7 @@ function civicrm_api3_contribution_get($params) { function _civicrm_api3_contribution_get_support_nonunique_returns($params) { $additionalOptions = []; $options = _civicrm_api3_get_options_from_params($params, TRUE); - foreach (['check_number', 'address_id'] as $changedVariable) { + foreach (['check_number', 'address_id', 'cancel_date'] as $changedVariable) { if (isset($options['return']) && !empty($options['return'][$changedVariable])) { $additionalOptions['return']['contribution_' . $changedVariable] = 1; } @@ -316,6 +316,7 @@ function _civicrm_api3_contribution_add_supported_fields(&$contribution) { 'contribution_check_number' => 'check_number', 'contribution_address_id' => 'address_id', 'payment_instrument_id' => 'instrument_id', + 'contribution_cancel_date' => 'cancel_date', ]; foreach ($outputAliases as $returnName => $copyTo) { if (array_key_exists($returnName, $contribution)) { diff --git a/api/v3/utils.php b/api/v3/utils.php index f28c07aeed..5a8c0e54b7 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -173,6 +173,10 @@ function civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, // 4.3 legacy handling. $values[$key]['contribution_type_id'] = $item['financial_type_id']; } + if (!empty($item['contribution_cancel_date'])) { + // 5.16 legacy handling. + $values[$key]['cancel_date'] = $item['contribution_cancel_date']; + } 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/Contact/Form/Search/Custom/ContributionAggregate.tpl b/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl index 4f9da68e16..0022ef836c 100644 --- a/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl +++ b/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl @@ -39,11 +39,15 @@ {/foreach} - {ts}Contribution Dates{/ts} - {include file="CRM/Core/DateRange.tpl" fieldName="contribution_date" from='_low' to='_high'} + + + + {include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="receive_date" colspan="2"} - {ts}Financial Type{/ts} + + + {$form.financial_type_id.html|crmAddClass:twenty} diff --git a/templates/CRM/Contribute/Form/Search/Common.tpl b/templates/CRM/Contribute/Form/Search/Common.tpl index 368d31ecc4..e2ff246741 100644 --- a/templates/CRM/Contribute/Form/Search/Common.tpl +++ b/templates/CRM/Contribute/Form/Search/Common.tpl @@ -24,9 +24,8 @@ +--------------------------------------------------------------------+ *} - -{include file="CRM/Core/DateRange.tpl" fieldName="contribution_date" from='_low' to='_high'} +{include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="receive_date" colspan="2"}
@@ -157,27 +156,21 @@ {$form.contribution_pcp_made_through_id.html} {include file="CRM/Contribute/Form/PCP.js.tpl"} - - {$form.cancel_reason.label}
- {$form.cancel_reason.html} - +   {$form.contribution_pcp_display_in_roll.label} {$form.contribution_pcp_display_in_roll.html} + + + {include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="contribution_cancel_date" colspan="2"} + + - - - - - - {include file="CRM/Core/DateRange.tpl" fieldName="contribution_cancel_date" from='_low' to='_high'} - -
- -
+ {$form.cancel_reason.label}
+ {$form.cancel_reason.html} diff --git a/tests/phpunit/CRM/Contribute/Form/SearchTest.php b/tests/phpunit/CRM/Contribute/Form/SearchTest.php index f773d1dd5b..92c346a465 100644 --- a/tests/phpunit/CRM/Contribute/Form/SearchTest.php +++ b/tests/phpunit/CRM/Contribute/Form/SearchTest.php @@ -83,7 +83,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type' => 1, 'total_amount' => 70, 'receive_date' => '2013-07-24', - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'check_number' => NULL, 'contribution_status_id' => 1, @@ -92,7 +91,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type' => 1, 'total_amount' => 30, 'receive_date' => '2014-07-24', - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'check_number' => NULL, 'contribution_status_id' => 1, @@ -106,7 +104,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'total_amount' => 123, 'receive_date' => '2014-07-24', - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'check_number' => NULL, 'contribution_status_id' => 1, @@ -182,7 +179,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'total_amount' => 100, 'receive_date' => date('Ymd'), - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'contribution_status_id' => 1, 'contact_id' => $contactID1, @@ -200,7 +196,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'total_amount' => 150, 'receive_date' => date('Ymd'), - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'contribution_status_id' => 1, 'contact_id' => $contactID1, @@ -209,7 +204,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'total_amount' => 200, 'receive_date' => date('Ymd'), - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'contribution_status_id' => 1, 'contact_id' => $contactID2, @@ -287,7 +281,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'total_amount' => 100, 'receive_date' => date('Ymd'), - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'contribution_status_id' => 1, 'contact_id' => $contactID1, @@ -306,7 +299,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'total_amount' => 150, 'receive_date' => date('Ymd'), - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'contribution_status_id' => 1, 'contact_id' => $contactID1, @@ -315,7 +307,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'total_amount' => 200, 'receive_date' => date('Ymd'), - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'contribution_status_id' => 1, 'contact_id' => $contactID2, @@ -437,8 +428,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $Contribution1 = $this->callAPISuccess('Contribution', 'create', [ 'financial_type_id' => 1, 'total_amount' => 100, - 'receive_date' => date('Ymd'), - 'receive_date_time' => NULL, + 'receive_date' => date('Y-m-d'), 'payment_instrument' => 1, 'contribution_status_id' => 3, 'cancel_date' => date('Ymd'), @@ -448,11 +438,10 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $this->callAPISuccess('Contribution', 'create', [ 'financial_type_id' => 1, 'total_amount' => 150, - 'receive_date' => date('Ymd', strtotime(date('Y-m-d') . ' - 1 days')), - 'receive_date_time' => NULL, + 'receive_date' => date('Y-m-d', strtotime(date('Y-m-d') . ' - 1 days')), 'payment_instrument' => 1, 'contribution_status_id' => 3, - 'cancel_date' => date('Ymd', strtotime(date('Y-m-d') . ' - 1 days')), + 'cancel_date' => date('Y-m-d', strtotime(date('Y-m-d') . ' - 1 days')), 'cancel_reason' => 'Insufficient funds', 'contact_id' => $contactID2, ]); @@ -460,7 +449,6 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'total_amount' => 200, 'receive_date' => date('Ymd'), - 'receive_date_time' => NULL, 'payment_instrument' => 1, 'contribution_status_id' => 3, 'cancel_date' => date('Ymd'), @@ -471,10 +459,10 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $useCases = [ // Case 1: Search for Cancelled Date [ - 'form_value' => ['cancel_date' => date('Y-m-d')], + 'form_value' => ['contribution_cancel_date' => date('Y-m-d')], 'expected_count' => 2, 'expected_contribution' => [$Contribution1['id'], $Contribution3['id']], - 'expected_qill' => "Cancel Date Like '%" . date('Y-m-d') . "%'", + 'expected_qill' => "Cancelled / Refunded Date = " . date('F dS, Y') . " 12:00 AM", ], // Case 2: Search for Cancelled Reason [ @@ -485,16 +473,16 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { ], // Case 3: Search for Cancelled Date and Cancelled Reason [ - 'form_value' => ['cancel_date' => date('Y-m-d'), 'cancel_reason' => 'Insufficient funds'], + 'form_value' => ['contribution_cancel_date' => date('Y-m-d'), 'cancel_reason' => 'Insufficient funds'], 'expected_count' => 1, 'expected_contribution' => [$Contribution1['id']], - 'expected_qill' => "Cancel Date Like '%" . date('Y-m-d') . "%'ANDCancellation / Refund Reason Like '%Insufficient funds%'", + 'expected_qill' => "Cancellation / Refund Reason Like '%Insufficient funds%'ANDCancelled / Refunded Date = " . date('F dS, Y') . " 12:00 AM", ], ]; foreach ($useCases as $case) { $fv = $case['form_value']; - CRM_Contact_BAO_Query::processSpecialFormValue($fv, ['cancel_date', 'cancel_reason']); + CRM_Contact_BAO_Query::processSpecialFormValue($fv, ['cancel_reason']); $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv)); list($select, $from, $where) = $query->query(); diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index 156cc1d295..68e049b1e1 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -1619,7 +1619,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'contribution_source' => 1, 'receive_date' => 1, 'thankyou_date' => 1, - 'cancel_date' => 1, + 'contribution_cancel_date' => 1, 'total_amount' => 1, 'accounting_code' => 1, 'payment_instrument' => 1, @@ -2195,7 +2195,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 82 => 'Contribution Source', 83 => 'Date Received', 84 => 'Thank-you Date', - 85 => 'Cancel Date', + 85 => 'Cancelled / Refunded Date', 86 => 'Total Amount', 87 => 'Accounting Code', 88 => 'Payment Methods', @@ -2596,7 +2596,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'contribution_source' => 'contribution_source varchar(255)', 'receive_date' => 'receive_date varchar(32)', 'thankyou_date' => 'thankyou_date varchar(32)', - 'cancel_date' => 'cancel_date varchar(32)', + 'contribution_cancel_date' => 'contribution_cancel_date varchar(32)', 'total_amount' => 'total_amount varchar(32)', 'accounting_code' => 'accounting_code varchar(64)', 'payment_instrument' => 'payment_instrument varchar(255)', diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 27a776fc52..4a32122f71 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -282,7 +282,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $fieldsLockedIn = array( 'contribution_id', 'contribution_contact_id', 'financial_type_id', 'contribution_page_id', 'payment_instrument_id', 'receive_date', 'non_deductible_amount', 'total_amount', - 'fee_amount', 'net_amount', 'trxn_id', 'invoice_id', 'currency', 'cancel_date', 'cancel_reason', + 'fee_amount', 'net_amount', 'trxn_id', 'invoice_id', 'currency', 'contribution_cancel_date', 'cancel_reason', 'receipt_date', 'thankyou_date', 'contribution_source', 'amount_level', 'contribution_recur_id', 'is_test', 'is_pay_later', 'contribution_status_id', 'address_id', 'check_number', 'contribution_campaign_id', 'creditnote_id', 'tax_amount', 'revenue_recognition_date', 'decoy', diff --git a/xml/schema/Contribute/Contribution.xml b/xml/schema/Contribute/Contribution.xml index 63b8d13023..376f5675be 100644 --- a/xml/schema/Contribute/Contribution.xml +++ b/xml/schema/Contribute/Contribution.xml @@ -272,6 +272,7 @@ cancel_date + Cancelled / Refunded Date datetime true /cancel(.?date)?/i @@ -282,6 +283,7 @@ Select Date activityDateTime + contribution_cancel_date cancel_reason -- 2.25.1