Eileen has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/345268 )
Change subject: Fix Benevity to update existing contact with email.
......................................................................
Fix Benevity to update existing contact with email.
Bug: T161666
Change-Id: I17abe47e555056a6af082c8f03310d00b528d7d4
---
M sites/all/modules/offline2civicrm/BenevityFile.php
M sites/all/modules/offline2civicrm/tests/BenevityTest.php
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
3 files changed, 29 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/68/345268/1
diff --git a/sites/all/modules/offline2civicrm/BenevityFile.php
b/sites/all/modules/offline2civicrm/BenevityFile.php
index b42eec2..9c65520 100644
--- a/sites/all/modules/offline2civicrm/BenevityFile.php
+++ b/sites/all/modules/offline2civicrm/BenevityFile.php
@@ -168,7 +168,7 @@
if (!empty($msg['matching_amount']) && $msg['matching_amount'] > 0) {
$matchedMsg = $msg;
- unset($matchedMsg['net'], $matchedMsg['fee']);
+ unset($matchedMsg['net'], $matchedMsg['fee'], $matchedMsg['email']);
$matchedMsg['contact_id'] = $msg['employer_id'];
$matchedMsg['soft_credit_to_id'] = ($msg['contact_id'] ==
$this->getAnonymousContactID() ? NULL : $msg['contact_id']);
$matchedMsg['gross'] = $msg['matching_amount'];
diff --git a/sites/all/modules/offline2civicrm/tests/BenevityTest.php
b/sites/all/modules/offline2civicrm/tests/BenevityTest.php
index d3fb4f6..718d7fb 100644
--- a/sites/all/modules/offline2civicrm/tests/BenevityTest.php
+++ b/sites/all/modules/offline2civicrm/tests/BenevityTest.php
@@ -124,6 +124,8 @@
'contact_id_b' => $thaMouseMeister['id'])
);
$this->assertEquals(1, $relationships['count']);
+ $minnie = $this->callAPISuccessGetSingle('Contact', array('id' =>
$contribution['contact_id'], 'return' => 'email'));
+ $this->assertEquals('[email protected]', $minnie['email']);
}
/**
@@ -209,6 +211,31 @@
}
/**
+ * Test that import resolves ambiguous individuals by choosing based on the
employer.
+ */
+ function testImportSucceedIndividualDisambiguateByEmployerEmailAdded() {
+ $organization = $this->callAPISuccess('Contact', 'create',
array('organization_name' => 'Mickey Mouse Inc', 'contact_type' =>
'Organization'));
+ $minnie = $this->callAPISuccess('Contact', 'create', array(
+ 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' =>
'Individual',
+ ));
+ $betterMinnie = $this->callAPISuccess('Contact', 'create', array(
+ 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' =>
'Individual', 'employer_id' => $organization['id'],
+ ));
+ $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" );
+ $importer->import();
+ $messages = $importer->getMessages();
+ $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']);
+ $contributions = $this->callAPISuccess('Contribution', 'get',
array('contact_id' => $minnie['id']));
+ $this->assertEquals(0, $contributions['count']);
+
+ $contributions = $this->callAPISuccess('Contribution', 'get',
array('contact_id' => $betterMinnie['id']));
+ $this->assertEquals(1, $contributions['count']);
+ $relationships = $this->callAPISuccess('Relationship', 'get',
array('contact_id_a' => $betterMinnie['id'], 'contact_id_b' =>
$organization['id']));
+ $this->assertEquals(1, $relationships['count']);
+ $this->callAPISuccessGetSingle('Email', array('email' =>
'[email protected]'));
+ }
+
+ /**
* Test that import creates new contacts when it can't resolve to a single
contact.
*/
function testImportSucceedIndividualTooManyChoicesCantDecideSpamTheDB() {
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 9fae35e..d9db736 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -263,7 +263,7 @@
// We have set the bar for invoking a location update fairly high here -
ie state,
// city or postal_code is not enough, as historically this update has
not occurred at
// all & introducing it this conservatively feels like a safe strategy.
- if (!empty($msg['street_address'])) {
+ if (!empty($msg['street_address']) || !empty($msg['email'])) {
wmf_civicrm_message_location_update($msg, array('id' =>
$msg['contact_id']));
}
}
--
To view, visit https://gerrit.wikimedia.org/r/345268
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I17abe47e555056a6af082c8f03310d00b528d7d4
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits