diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 492d0fd524f1cdd1bade048dae16a93b67999e6e..772206e079e76102d9de56e91d39622eb8836da5 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3919,6 +3919,11 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $fieldName = 'soft_credit_type_id'; $params['condition'] = "v.name IN ('in_honor_of','in_memory_of')"; break; + + case 'contribution_status_id': + if ($context !== 'validate') { + $params['condition'] = "v.name <> 'Template'"; + } } return CRM_Core_PseudoConstant::get($className, $fieldName, $params, $context); } diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index 8872707de7ad249b7ee01b379a111279353d6e5e..8ab4f3e822d9faaeb10578b44510f230dd747e6c 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -545,14 +545,22 @@ LIMIT 1 $statusNames = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate'); } - $statusNamesToUnset = []; + $statusNamesToUnset = [ + // For records which represent a data template for a recurring + // contribution that may not yet have a payment. This status should not + // be available from forms. 'Template' contributions should only be created + // in conjunction with a ContributionRecur record, and should have their + // is_template field set to 1. This status excludes them from reports + // that are still ignorant of the is_template field. + 'Template', + ]; // on create fetch statuses on basis of component if (!$id) { - $statusNamesToUnset = [ + $statusNamesToUnset = array_merge($statusNamesToUnset, [ 'Refunded', 'Chargeback', 'Pending refund', - ]; + ]); // Event registration and New Membership backoffice form support partially paid payment, // so exclude this status only for 'New Contribution' form diff --git a/CRM/Upgrade/Incremental/php/FiveTwenty.php b/CRM/Upgrade/Incremental/php/FiveTwenty.php index ac9ccbfc683d1b0e4d63410a971389258157584b..1dc223b1508780dbda862fc7853bf9b417b54c60 100644 --- a/CRM/Upgrade/Incremental/php/FiveTwenty.php +++ b/CRM/Upgrade/Incremental/php/FiveTwenty.php @@ -94,6 +94,18 @@ class CRM_Upgrade_Incremental_php_FiveTwenty extends CRM_Upgrade_Incremental_Bas $this->addTask('Change direction of autoassignees in case type xml', 'changeCaseTypeAutoassignee'); } $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + $this->addTask('Add "Template" contribution status', 'templateStatus'); + } + + public static function templateStatus(CRM_Queue_TaskContext $ctx) { + CRM_Core_BAO_OptionValue::ensureOptionValueExists([ + 'option_group_id' => 'contribution_status', + 'name' => 'Template', + 'label' => ts('Template'), + 'is_active' => TRUE, + 'component_id' => 'CiviContribute', + ]); + return TRUE; } /** diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 42eff2a277c96b61f9e01dc2df12dcf1c9711310..50c0050423b12356350862411403ceba2d1746b7 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -448,6 +448,7 @@ VALUES (@option_group_id_cs, '{ts escape="sql"}Partially paid{/ts}', 8, 'Partially paid', NULL, 0, NULL, 8, NULL, 0, 1, 1, NULL, NULL, NULL), (@option_group_id_cs, '{ts escape="sql"}Pending refund{/ts}', 9, 'Pending refund', NULL, 0, NULL, 9, NULL, 0, 1, 1, NULL, NULL, NULL), (@option_group_id_cs, '{ts escape="sql"}Chargeback{/ts}', 10, 'Chargeback', NULL, 0, NULL, 10, NULL, 0, 1, 1, NULL, NULL, NULL), + (@option_group_id_cs, '{ts escape="sql"}Template{/ts}' , 11, 'Template', NULL, 0, NULL, 11, '{ts escape="sql"}Status for contribution records which represent a template for a recurring contribution rather than an actual contribution. This status is transitional, to ensure that said contributions don\'t appear in reports. The is_template field is the preferred way to find and filter these contributions.{/ts}', 0, 1, 1, NULL, NULL, NULL), (@option_group_id_pcp, '{ts escape="sql"}Waiting Review{/ts}', 1, 'Waiting Review', NULL, 0, NULL, 1, NULL, 0, 1, 1, NULL, NULL, NULL), (@option_group_id_pcp, '{ts escape="sql"}Approved{/ts}' , 2, 'Approved' , NULL, 0, NULL, 2, NULL, 0, 1, 1, NULL, NULL, NULL),