From 2d49f76f9e0db8deba6a3cc1b1c574cf1aa17699 Mon Sep 17 00:00:00 2001 From: Monish Deb Date: Thu, 7 Apr 2022 18:12:17 -0700 Subject: [PATCH] Schema - Fix boolean fields in 'Member' --- CRM/Member/DAO/Membership.php | 12 +++++++---- CRM/Member/DAO/MembershipBlock.php | 14 ++++++++----- CRM/Member/DAO/MembershipStatus.php | 20 ++++++++++++------ .../php/FiveFortyNine/Member.bool.php | 21 +++++++++++++++++++ .../phpunit/CRM/Member/BAO/MembershipTest.php | 2 -- xml/schema/Member/Membership.xml | 4 ++++ xml/schema/Member/MembershipBlock.xml | 4 ++++ xml/schema/Member/MembershipStatus.xml | 8 +++++++ 8 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 CRM/Upgrade/Incremental/php/FiveFortyNine/Member.bool.php diff --git a/CRM/Member/DAO/Membership.php b/CRM/Member/DAO/Membership.php index 94bcb0f9b0..dd6995cd30 100644 --- a/CRM/Member/DAO/Membership.php +++ b/CRM/Member/DAO/Membership.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Member/Membership.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:0619aa3946bcadcab1919672c9ecf35a) + * (GenCodeChecksum:1668d4d8a9f2e1686bf9f5b6ea1c55dc) */ /** @@ -123,7 +123,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO { /** * Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record. * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -157,14 +157,14 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO { public $max_related; /** - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ public $is_test; /** - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -421,10 +421,12 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Status Override'), 'description' => ts('Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.'), + 'required' => TRUE, 'import' => TRUE, 'where' => 'civicrm_membership.is_override', 'headerPattern' => '/override$/i', 'export' => TRUE, + 'default' => '0', 'table_name' => 'civicrm_membership', 'entity' => 'Membership', 'bao' => 'CRM_Member_BAO_Membership', @@ -491,6 +493,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO { 'name' => 'is_test', 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Test'), + 'required' => TRUE, 'import' => TRUE, 'where' => 'civicrm_membership.is_test', 'headerPattern' => '/(is.)?test(.member(ship)?)?/i', @@ -509,6 +512,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO { 'name' => 'is_pay_later', 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Is Pay Later'), + 'required' => TRUE, 'import' => TRUE, 'where' => 'civicrm_membership.is_pay_later', 'headerPattern' => '/(is.)?(pay(.)?later)$/i', diff --git a/CRM/Member/DAO/MembershipBlock.php b/CRM/Member/DAO/MembershipBlock.php index a8fdf704d6..d51f917e04 100644 --- a/CRM/Member/DAO/MembershipBlock.php +++ b/CRM/Member/DAO/MembershipBlock.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Member/MembershipBlock.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:8e0e93f6f480d279cbf4ac53db86a8f3) + * (GenCodeChecksum:b8779f341fdb53bc75c0928fea73f06f) */ /** @@ -79,7 +79,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { /** * Display minimum membership fee * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -88,7 +88,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { /** * Should membership transactions be processed separately * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -133,7 +133,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { /** * Is membership sign up optional * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -142,7 +142,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { /** * Is this membership_block enabled * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -274,6 +274,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Membership Block Display Minimum Fee'), 'description' => ts('Display minimum membership fee'), + 'required' => TRUE, 'where' => 'civicrm_membership_block.display_min_fee', 'default' => '1', 'table_name' => 'civicrm_membership_block', @@ -287,6 +288,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Membership Block Is Separate Payment'), 'description' => ts('Should membership transactions be processed separately'), + 'required' => TRUE, 'where' => 'civicrm_membership_block.is_separate_payment', 'default' => '1', 'table_name' => 'civicrm_membership_block', @@ -352,6 +354,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Is Required'), 'description' => ts('Is membership sign up optional'), + 'required' => TRUE, 'where' => 'civicrm_membership_block.is_required', 'default' => '0', 'table_name' => 'civicrm_membership_block', @@ -365,6 +368,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Is Active'), 'description' => ts('Is this membership_block enabled'), + 'required' => TRUE, 'where' => 'civicrm_membership_block.is_active', 'default' => '1', 'table_name' => 'civicrm_membership_block', diff --git a/CRM/Member/DAO/MembershipStatus.php b/CRM/Member/DAO/MembershipStatus.php index 764946fbb8..0b4d58277a 100644 --- a/CRM/Member/DAO/MembershipStatus.php +++ b/CRM/Member/DAO/MembershipStatus.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Member/MembershipStatus.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:5c4442b352b42ed23368f5dbb0bc0531) + * (GenCodeChecksum:baf51df46a12becf1b8ed3f8a25e2237) */ /** @@ -122,7 +122,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { /** * Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE). * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -131,7 +131,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { /** * Is this status for admin/manual assignment only. * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -147,7 +147,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { /** * Assign this status to a membership record if no other status match is found. * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -156,7 +156,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { /** * Is this membership_status enabled. * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -165,7 +165,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { /** * Is this membership_status reserved. * - * @var bool|string|null + * @var bool|string * (SQL type: tinyint) * Note that values will be retrieved from the database as a string. */ @@ -367,7 +367,9 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Current Membership?'), 'description' => ts('Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).'), + 'required' => TRUE, 'where' => 'civicrm_membership_status.is_current_member', + 'default' => '0', 'table_name' => 'civicrm_membership_status', 'entity' => 'MembershipStatus', 'bao' => 'CRM_Member_BAO_MembershipStatus', @@ -379,7 +381,9 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Administrator Only?'), 'description' => ts('Is this status for admin/manual assignment only.'), + 'required' => TRUE, 'where' => 'civicrm_membership_status.is_admin', + 'default' => '0', 'table_name' => 'civicrm_membership_status', 'entity' => 'MembershipStatus', 'bao' => 'CRM_Member_BAO_MembershipStatus', @@ -405,7 +409,9 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Default Status?'), 'description' => ts('Assign this status to a membership record if no other status match is found.'), + 'required' => TRUE, 'where' => 'civicrm_membership_status.is_default', + 'default' => '0', 'table_name' => 'civicrm_membership_status', 'entity' => 'MembershipStatus', 'bao' => 'CRM_Member_BAO_MembershipStatus', @@ -420,6 +426,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Is Active'), 'description' => ts('Is this membership_status enabled.'), + 'required' => TRUE, 'where' => 'civicrm_membership_status.is_active', 'default' => '1', 'table_name' => 'civicrm_membership_status', @@ -436,6 +443,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Is Reserved'), 'description' => ts('Is this membership_status reserved.'), + 'required' => TRUE, 'where' => 'civicrm_membership_status.is_reserved', 'default' => '0', 'table_name' => 'civicrm_membership_status', diff --git a/CRM/Upgrade/Incremental/php/FiveFortyNine/Member.bool.php b/CRM/Upgrade/Incremental/php/FiveFortyNine/Member.bool.php new file mode 100644 index 0000000000..f410b90d04 --- /dev/null +++ b/CRM/Upgrade/Incremental/php/FiveFortyNine/Member.bool.php @@ -0,0 +1,21 @@ + [ + 'is_override' => "DEFAULT 0 COMMENT 'Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.'", + 'is_test' => "DEFAULT 0", + 'is_pay_later' => "DEFAULT 0", + ], + 'civicrm_membership_block' => [ + 'display_min_fee' => "DEFAULT 1 COMMENT 'Display minimum membership fee'", + 'is_separate_payment' => "DEFAULT 1 COMMENT 'Should membership transactions be processed separately'", + 'is_required' => "DEFAULT 0 COMMENT 'Is membership sign up optional'", + 'is_active' => "DEFAULT 1 COMMENT 'Is this membership_block enabled'", + ], + 'civicrm_membership_status' => [ + 'is_current_member' => "DEFAULT 0 COMMENT 'Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).'", + 'is_admin' => "DEFAULT 0 COMMENT 'Is this status for admin/manual assignment only.'", + 'is_default' => "DEFAULT 0 COMMENT 'Assign this status to a membership record if no other status match is found.'", + 'is_active' => "DEFAULT 1 COMMENT 'Is this membership_status enabled.'", + 'is_reserved' => "DEFAULT 0 COMMENT 'Is this membership_status reserved.'", + ], +]; diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTest.php index 8df9749e31..616998c9c0 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTest.php @@ -622,7 +622,6 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { ])['values'][0]; $this->assertEquals($createdMembershipID, $membershipAfterProcess['id']); - $this->assertArrayNotHasKey('is_override', $membershipAfterProcess); $this->assertArrayNotHasKey('status_override_end_date', $membershipAfterProcess); } @@ -654,7 +653,6 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { ])['values'][0]; $this->assertEquals($createdMembershipID, $membershipAfterProcess['id']); - $this->assertArrayNotHasKey('is_override', $membershipAfterProcess); $this->assertArrayNotHasKey('status_override_end_date', $membershipAfterProcess); } diff --git a/xml/schema/Member/Membership.xml b/xml/schema/Member/Membership.xml index 3ed25d6adc..f2ed08d0ea 100644 --- a/xml/schema/Member/Membership.xml +++ b/xml/schema/Member/Membership.xml @@ -182,6 +182,8 @@ CheckBox + 0 + true 1.5 @@ -237,6 +239,7 @@ member_is_test boolean 0 + true true /(is.)?test(.member(ship)?)?/i @@ -249,6 +252,7 @@ Is Pay Later boolean 0 + true true /(is.)?(pay(.)?later)$/i 2.1 diff --git a/xml/schema/Member/MembershipBlock.xml b/xml/schema/Member/MembershipBlock.xml index a31e85e413..fc87946353 100644 --- a/xml/schema/Member/MembershipBlock.xml +++ b/xml/schema/Member/MembershipBlock.xml @@ -80,6 +80,7 @@ Membership Block Display Minimum Fee boolean 1 + true Display minimum membership fee 1.5 @@ -88,6 +89,7 @@ Membership Block Is Separate Payment boolean 1 + true Should membership transactions be processed separately 1.5 @@ -130,6 +132,7 @@ Is Required boolean 0 + true Is membership sign up optional 1.5 @@ -138,6 +141,7 @@ Is Active boolean 1 + true Is this membership_block enabled 1.5 diff --git a/xml/schema/Member/MembershipStatus.xml b/xml/schema/Member/MembershipStatus.xml index 2bf75d8ad6..782ed48bac 100644 --- a/xml/schema/Member/MembershipStatus.xml +++ b/xml/schema/Member/MembershipStatus.xml @@ -125,6 +125,8 @@ is_current_member Current Membership? boolean + 0 + true Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE). 1.5 @@ -136,6 +138,8 @@ CheckBox + 0 + true 1.5 @@ -148,6 +152,8 @@ is_default Default Status? boolean + 0 + true CheckBox @@ -159,6 +165,7 @@ Is Active boolean 1 + true CheckBox @@ -170,6 +177,7 @@ Is Reserved boolean 0 + true CheckBox -- 2.25.1