jenkins-bot has submitted this change and it was merged. (
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, 35 insertions(+), 1 deletion(-)
Approvals:
jenkins-bot: Verified
Ejegg: Looks good to me, approved
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..6d740e7 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -266,6 +266,13 @@
if (!empty($msg['street_address'])) {
wmf_civicrm_message_location_update($msg, array('id' =>
$msg['contact_id']));
}
+ elseif (!empty($msg['email'])) {
+ // location_update updates email, if set and address, if set.
+ // However, not quite ready to start dealing with the situation
+ // where less of the address is incoming than already exists
+ // hence only call this part if street_address is empty.
+ wmf_civicrm_message_email_update($msg, $msg['contact_id']);
+ }
}
// Make new recurring record if necessary
--
To view, visit https://gerrit.wikimedia.org/r/345268
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I17abe47e555056a6af082c8f03310d00b528d7d4
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Eileen <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits