Skip to content

Commit

Permalink
Fix metadata on member export
Browse files Browse the repository at this point in the history
Note auto_renew seems un-exportable so I removed it from return properties
  • Loading branch information
eileenmcnaughton committed Aug 3, 2019
1 parent fe5c9a7 commit 208c115
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 18 deletions.
1 change: 1 addition & 0 deletions CRM/Core/BAO/UFField.php
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ public static function getAvailableFields($gid = NULL, $defaults = []) {
'membership_type_id',
'member_is_test',
'is_override',
'member_is_override',
'status_override_end_date',
'status_id',
'member_is_pay_later'
Expand Down
8 changes: 5 additions & 3 deletions CRM/Member/DAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Member/Membership.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:64ef044391b9dee565e8e2a9d893f4cf)
* (GenCodeChecksum:40f3b0813c1e13fab544ae1f8fa2ebb3)
*/

/**
Expand Down Expand Up @@ -328,7 +328,7 @@ public static function &fields() {
'labelColumn' => 'label',
],
],
'is_override' => [
'member_is_override' => [
'name' => 'is_override',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Status Override'),
Expand Down Expand Up @@ -381,6 +381,7 @@ public static function &fields() {
'title' => ts('Max Related'),
'description' => ts('Maximum number of related memberships (membership_type override).'),
'where' => 'civicrm_membership.max_related',
'export' => TRUE,
'table_name' => 'civicrm_membership',
'entity' => 'Membership',
'bao' => 'CRM_Member_BAO_Membership',
Expand Down Expand Up @@ -423,12 +424,13 @@ public static function &fields() {
'type' => 'CheckBox',
],
],
'contribution_recur_id' => [
'membership_recur_id' => [
'name' => 'contribution_recur_id',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Membership Recurring Contribution'),
'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'),
'where' => 'civicrm_membership.contribution_recur_id',
'export' => TRUE,
'table_name' => 'civicrm_membership',
'entity' => 'Membership',
'bao' => 'CRM_Member_BAO_Membership',
Expand Down
5 changes: 5 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveSeventeen.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public function upgrade_5_17_alpha1($rev) {
'contribution_recur_failure_retry_date',
],
]);
$this->addTask('Update smart groups to reflect change of unique name for is_override', 'updateSmartGroups', [
'renameField' => [
['old' => 'is_override', 'new' => 'member_is_override'],
],
]);
}

}
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Export/BAO/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ public function testExportComponentsMembership() {
'Membership Status' => 'Expired',
'Membership ID' => '2',
'Primary Member ID' => '',
'max_related' => '',
'membership_recur_id' => '',
'Max Related' => '',
'Membership Recurring Contribution' => '',
'Campaign ID' => '',
'member_is_override' => '',
'Status Override' => '',
'member_auto_renew' => '',
'Total Amount' => '100.00',
'Contribution Status' => 'Completed',
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function testImportOverriddenMembershipButWithoutStatus() {
'mapper[0][0]' => 'email',
'mapper[1][0]' => 'membership_type_id',
'mapper[2][0]' => 'membership_start_date',
'mapper[3][0]' => 'is_override',
'mapper[3][0]' => 'member_is_override',
];
$membershipImporter = new CRM_Member_Import_Parser_Membership($fieldMapper);
$membershipImporter->init();
Expand Down Expand Up @@ -184,7 +184,7 @@ public function testImportOverriddenMembershipWithStatus() {
'email',
'membership_type_id',
'membership_start_date',
'is_override',
'member_is_override',
'status_id',
]);

Expand All @@ -207,7 +207,7 @@ public function testImportOverriddenMembershipWithValidOverrideEndDate() {
'mapper[0][0]' => 'email',
'mapper[1][0]' => 'membership_type_id',
'mapper[2][0]' => 'membership_start_date',
'mapper[3][0]' => 'is_override',
'mapper[3][0]' => 'member_is_override',
'mapper[4][0]' => 'status_id',
'mapper[5][0]' => 'status_override_end_date',
];
Expand Down Expand Up @@ -235,7 +235,7 @@ public function testImportOverriddenMembershipWithInvalidOverrideEndDate() {
'mapper[0][0]' => 'email',
'mapper[1][0]' => 'membership_type_id',
'mapper[2][0]' => 'membership_start_date',
'mapper[3][0]' => 'is_override',
'mapper[3][0]' => 'member_is_override',
'mapper[4][0]' => 'status_id',
'mapper[5][0]' => 'status_override_end_date',
];
Expand Down
16 changes: 8 additions & 8 deletions tests/phpunit/api/v3/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ public function testGetWithParamsContactId() {
$this->callAPISuccess('Membership', 'Delete', [
'id' => $this->_membershipID,
]);
$this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__);
$this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__);
$this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
$this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__);
$this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__);
$this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__);
$this->assertEquals($result['source'], 'Payment', "In line " . __LINE__);
$this->assertEquals($result['is_override'], 1, "In line " . __LINE__);
$this->assertEquals($result['contact_id'], $this->_contactID);
$this->assertEquals($result['membership_type_id'], $this->_membershipTypeID);
$this->assertEquals($result['status_id'], $this->_membershipStatusID);
$this->assertEquals($result['join_date'], '2009-01-21');
$this->assertEquals($result['start_date'], '2009-01-21');
$this->assertEquals($result['end_date'], '2009-12-21');
$this->assertEquals($result['source'], 'Payment');
$this->assertEquals($result['is_override'], 1);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions xml/schema/Member/Membership.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@
</foreignKey>
<field>
<name>is_override</name>
<uniqueName>member_is_override</uniqueName>
<title>Status Override</title>
<import>true</import>
<export>true</export>
<headerPattern>/override$/i</headerPattern>
<type>boolean</type>
<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.</comment>
Expand Down Expand Up @@ -203,6 +205,7 @@
<type>int</type>
<comment>Maximum number of related memberships (membership_type override).</comment>
<add>4.3</add>
<export>true</export>
<html>
<type>Text</type>
</html>
Expand Down Expand Up @@ -234,8 +237,10 @@
</field>
<field>
<name>contribution_recur_id</name>
<uniqueName>membership_recur_id</uniqueName>
<title>Membership Recurring Contribution</title>
<type>int unsigned</type>
<export>true</export>
<comment>Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.</comment>
<add>3.3</add>
</field>
Expand Down

0 comments on commit 208c115

Please sign in to comment.