Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/financial#72 Add is_template field to contribution entity #15433

Merged
merged 2 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion CRM/Contribute/DAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Contribute/Contribution.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:b4e84298d9ba23d3b2fae0768fc5cb58)
* (GenCodeChecksum:a9f83aa612e82ee87ace74e75fe23466)
*/

/**
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -839,6 +846,23 @@ public static function &fields() {
'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']);
}
Expand Down
15 changes: 2 additions & 13 deletions CRM/Upgrade/Incremental/php/FiveTwenty.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,6 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
* (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;
// }
Expand All @@ -92,6 +79,8 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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{
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -85,6 +85,7 @@ function contribution_create_expectedresult() {
'creditnote_id' => '',
'tax_amount' => '',
'revenue_recognition_date' => '',
'is_template' => '',
'contribution_type_id' => '1',
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -88,6 +88,7 @@ function contribution_create_expectedresult() {
'creditnote_id' => '',
'tax_amount' => '',
'revenue_recognition_date' => '',
'is_template' => '',
'contribution_type_id' => '1',
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
],
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -91,6 +91,7 @@ function contribution_create_expectedresult() {
'creditnote_id' => '',
'tax_amount' => '',
'revenue_recognition_date' => '',
'is_template' => '',
'contribution_type_id' => '1',
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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{
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -85,6 +85,7 @@ function contribution_create_expectedresult() {
'creditnote_id' => '',
'tax_amount' => '',
'revenue_recognition_date' => '',
'is_template' => '',
'contribution_type_id' => '1',
],
],
Expand Down
1 change: 1 addition & 0 deletions api/v3/examples/Contribution/Create.ex.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function contribution_create_expectedresult() {
'creditnote_id' => '',
'tax_amount' => '',
'revenue_recognition_date' => '',
'is_template' => '',
'contribution_type_id' => '1',
],
],
Expand Down
5 changes: 3 additions & 2 deletions api/v3/examples/Contribution/CreateWithNestedLineItems.ex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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' => [
Expand Down
12 changes: 12 additions & 0 deletions xml/schema/Contribute/Contribution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,16 @@
</html>
<add>4.7</add>
</field>
<field>
<name>is_template</name>
<title>Is a Template Contribution</title>
<type>boolean</type>
<default>0</default>
<import>true</import>
<comment>Shows this is a template for recurring contributions.</comment>
<html>
<type>CheckBox</type>
</html>
<add>5.20</add>
</field>
</table>