From: Aidan Saunders Date: Mon, 7 Oct 2019 13:27:53 +0000 (+0100) Subject: Add is_template field to contribution entity X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=dc3968353bc2ff09aebbf7c642c13aec0239cfca;p=civicrm-core.git Add is_template field to contribution entity Update tests and examples --- diff --git a/CRM/Contribute/DAO/Contribution.php b/CRM/Contribute/DAO/Contribution.php index a30e2042ea..018f1e0c1f 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:b4e84298d9ba23d3b2fae0768fc5cb58) + * (GenCodeChecksum:a9f83aa612e82ee87ace74e75fe23466) */ /** @@ -226,6 +226,13 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO { */ public $revenue_recognition_date; + /** + * Shows this is a template for recurring contributions. + * + * @var bool + */ + public $is_template; + /** * Class constructor. */ @@ -839,6 +846,23 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO { 'formatType' => 'activityDateTime', ], ], + 'is_template' => [ + 'name' => 'is_template', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('Is a Template Contribution'), + 'description' => ts('Shows this is a template for recurring contributions.'), + 'import' => TRUE, + 'where' => 'civicrm_contribution.is_template', + 'export' => TRUE, + 'default' => '0', + 'table_name' => 'civicrm_contribution', + 'entity' => 'Contribution', + 'bao' => 'CRM_Contribute_BAO_Contribution', + 'localizable' => 0, + 'html' => [ + 'type' => 'CheckBox', + ], + ], ]; CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } diff --git a/CRM/Upgrade/Incremental/php/FiveTwenty.php b/CRM/Upgrade/Incremental/php/FiveTwenty.php index 782bd42ad9..94b9e029e7 100644 --- a/CRM/Upgrade/Incremental/php/FiveTwenty.php +++ b/CRM/Upgrade/Incremental/php/FiveTwenty.php @@ -67,19 +67,6 @@ class CRM_Upgrade_Incremental_php_FiveTwenty extends CRM_Upgrade_Incremental_Bas * (change the x in the function name): */ - // /** - // * Upgrade function. - // * - // * @param string $rev - // */ - // public function upgrade_5_0_x($rev) { - // $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - // $this->addTask('Do the foo change', 'taskFoo', ...); - // // Additional tasks here... - // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex. - // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. - // } - // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) { // return TRUE; // } @@ -92,6 +79,8 @@ class CRM_Upgrade_Incremental_php_FiveTwenty extends CRM_Upgrade_Incremental_Bas public function upgrade_5_20_alpha1($rev) { $this->addTask('Add frontend title column to contribution page table', 'addColumn', 'civicrm_contribution_page', 'frontend_title', "varchar(255) DEFAULT NULL COMMENT 'Contribution Page Public title'", TRUE, '5.20.alpha1'); + $this->addTask('Add is_template field to civicrm_contribution', 'addColumn', 'civicrm_contribution', 'is_template', + "tinyint(4) DEFAULT '0' COMMENT 'Shows this is a template for recurring contributions.'", FALSE, '5.20.alpha1'); $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); } diff --git a/api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.ex.php b/api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.ex.php index e775abbb76..a1e4172a0a 100644 --- a/api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.ex.php +++ b/api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.ex.php @@ -9,7 +9,7 @@ */ function contribution_create_example() { $params = [ - 'contact_id' => 31, + 'contact_id' => 32, 'receive_date' => '20120511', 'total_amount' => '100', 'financial_type_id' => 1, @@ -18,7 +18,7 @@ function contribution_create_example() { 'net_amount' => '95', 'source' => 'SSF', 'contribution_status_id' => 1, - 'honor_contact_id' => 32, + 'honor_contact_id' => 33, ]; try{ @@ -56,7 +56,7 @@ function contribution_create_expectedresult() { 'values' => [ '1' => [ 'id' => '1', - 'contact_id' => '31', + 'contact_id' => '32', 'financial_type_id' => '1', 'contribution_page_id' => '', 'payment_instrument_id' => '4', @@ -85,6 +85,7 @@ function contribution_create_expectedresult() { 'creditnote_id' => '', 'tax_amount' => '', 'revenue_recognition_date' => '', + 'is_template' => '', 'contribution_type_id' => '1', ], ], diff --git a/api/v3/examples/Contribution/ContributionCreateWithNote.ex.php b/api/v3/examples/Contribution/ContributionCreateWithNote.ex.php index 1c22dd7f1f..16bf6b2e4d 100644 --- a/api/v3/examples/Contribution/ContributionCreateWithNote.ex.php +++ b/api/v3/examples/Contribution/ContributionCreateWithNote.ex.php @@ -9,7 +9,7 @@ */ function contribution_create_example() { $params = [ - 'contact_id' => 25, + 'contact_id' => 26, 'receive_date' => '2012-01-01', 'total_amount' => '100', 'financial_type_id' => 1, @@ -59,7 +59,7 @@ function contribution_create_expectedresult() { 'values' => [ '1' => [ 'id' => '1', - 'contact_id' => '25', + 'contact_id' => '26', 'financial_type_id' => '1', 'contribution_page_id' => '', 'payment_instrument_id' => '1', @@ -88,6 +88,7 @@ function contribution_create_expectedresult() { 'creditnote_id' => '', 'tax_amount' => '', 'revenue_recognition_date' => '', + 'is_template' => '', 'contribution_type_id' => '1', ], ], diff --git a/api/v3/examples/Contribution/ContributionCreateWithSoftCredit.ex.php b/api/v3/examples/Contribution/ContributionCreateWithSoftCredit.ex.php index e4d36539ba..d830ef95e0 100644 --- a/api/v3/examples/Contribution/ContributionCreateWithSoftCredit.ex.php +++ b/api/v3/examples/Contribution/ContributionCreateWithSoftCredit.ex.php @@ -9,7 +9,7 @@ */ function contribution_create_example() { $params = [ - 'contact_id' => 27, + 'contact_id' => 28, 'receive_date' => '20120511', 'total_amount' => '100', 'financial_type_id' => 1, @@ -20,7 +20,7 @@ function contribution_create_example() { 'contribution_status_id' => 1, 'soft_credit' => [ '1' => [ - 'contact_id' => 28, + 'contact_id' => 29, 'amount' => 50, 'soft_credit_type_id' => 3, ], @@ -62,7 +62,7 @@ function contribution_create_expectedresult() { 'values' => [ '1' => [ 'id' => '1', - 'contact_id' => '27', + 'contact_id' => '28', 'financial_type_id' => '1', 'contribution_page_id' => '', 'payment_instrument_id' => '4', @@ -91,6 +91,7 @@ function contribution_create_expectedresult() { 'creditnote_id' => '', 'tax_amount' => '', 'revenue_recognition_date' => '', + 'is_template' => '', 'contribution_type_id' => '1', ], ], diff --git a/api/v3/examples/Contribution/ContributionCreateWithSoftCreditDefaults.ex.php b/api/v3/examples/Contribution/ContributionCreateWithSoftCreditDefaults.ex.php index 2c6729fb0a..915a68c5bc 100644 --- a/api/v3/examples/Contribution/ContributionCreateWithSoftCreditDefaults.ex.php +++ b/api/v3/examples/Contribution/ContributionCreateWithSoftCreditDefaults.ex.php @@ -9,7 +9,7 @@ */ function contribution_create_example() { $params = [ - 'contact_id' => 29, + 'contact_id' => 30, 'receive_date' => '20120511', 'total_amount' => '100', 'financial_type_id' => 1, @@ -18,7 +18,7 @@ function contribution_create_example() { 'net_amount' => '95', 'source' => 'SSF', 'contribution_status_id' => 1, - 'soft_credit_to' => 30, + 'soft_credit_to' => 31, ]; try{ @@ -56,7 +56,7 @@ function contribution_create_expectedresult() { 'values' => [ '1' => [ 'id' => '1', - 'contact_id' => '29', + 'contact_id' => '30', 'financial_type_id' => '1', 'contribution_page_id' => '', 'payment_instrument_id' => '4', @@ -85,6 +85,7 @@ function contribution_create_expectedresult() { 'creditnote_id' => '', 'tax_amount' => '', 'revenue_recognition_date' => '', + 'is_template' => '', 'contribution_type_id' => '1', ], ], diff --git a/api/v3/examples/Contribution/Create.ex.php b/api/v3/examples/Contribution/Create.ex.php index 7540683df7..2f724f44ca 100644 --- a/api/v3/examples/Contribution/Create.ex.php +++ b/api/v3/examples/Contribution/Create.ex.php @@ -7,7 +7,7 @@ */ function contribution_create_example() { $params = [ - 'contact_id' => 1, + 'contact_id' => 39, 'receive_date' => '20120511', 'total_amount' => '100', 'financial_type_id' => 1, @@ -54,7 +54,7 @@ function contribution_create_expectedresult() { 'values' => [ '1' => [ 'id' => '1', - 'contact_id' => '1', + 'contact_id' => '39', 'financial_type_id' => '1', 'contribution_page_id' => '1', 'payment_instrument_id' => '4', @@ -83,6 +83,7 @@ function contribution_create_expectedresult() { 'creditnote_id' => '', 'tax_amount' => '', 'revenue_recognition_date' => '', + 'is_template' => '', 'contribution_type_id' => '1', ], ], diff --git a/api/v3/examples/Contribution/CreateWithNestedLineItems.ex.php b/api/v3/examples/Contribution/CreateWithNestedLineItems.ex.php index 3c27c405c5..36e23c41c7 100644 --- a/api/v3/examples/Contribution/CreateWithNestedLineItems.ex.php +++ b/api/v3/examples/Contribution/CreateWithNestedLineItems.ex.php @@ -9,7 +9,7 @@ */ function contribution_create_example() { $params = [ - 'contact_id' => 12, + 'contact_id' => 13, 'receive_date' => '20120511', 'total_amount' => '100', 'financial_type_id' => 1, @@ -73,7 +73,7 @@ function contribution_create_expectedresult() { 'values' => [ '1' => [ 'id' => '1', - 'contact_id' => '12', + 'contact_id' => '13', 'financial_type_id' => '1', 'contribution_page_id' => '', 'payment_instrument_id' => '1', @@ -102,6 +102,7 @@ function contribution_create_expectedresult() { 'creditnote_id' => '', 'tax_amount' => 0, 'revenue_recognition_date' => '', + 'is_template' => '', 'contribution_type_id' => '1', 'api.line_item.create' => [ '0' => [ diff --git a/xml/schema/Contribute/Contribution.xml b/xml/schema/Contribute/Contribution.xml index 8c47a84fa8..d2f5593b3d 100644 --- a/xml/schema/Contribute/Contribution.xml +++ b/xml/schema/Contribute/Contribution.xml @@ -541,4 +541,16 @@ 4.7 + + is_template + Is a Template Contribution + boolean + 0 + true + Shows this is a template for recurring contributions. + + CheckBox + + 5.20 +