Eileen has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/341749 )
Change subject: Benevity import, still create relationship when no individual gift ...................................................................... Benevity import, still create relationship when no individual gift Bug: T115044 Change-Id: I9f00f1d74a9ba8ecf680089d0cc0ad557489e160 --- M sites/all/modules/offline2civicrm/BenevityFile.php M sites/all/modules/offline2civicrm/tests/BenevityTest.php A sites/all/modules/offline2civicrm/tests/data/benevity_mice_no_email_matched_only.csv 3 files changed, 47 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/49/341749/1 diff --git a/sites/all/modules/offline2civicrm/BenevityFile.php b/sites/all/modules/offline2civicrm/BenevityFile.php index 13d01a6..b072fc1 100644 --- a/sites/all/modules/offline2civicrm/BenevityFile.php +++ b/sites/all/modules/offline2civicrm/BenevityFile.php @@ -160,6 +160,11 @@ // soft credit it. wmf_civicrm_message_create_contact($msg); } + if (isset($msg['employer_id'])) { + // This is done in the import but if we have no donation let's still do this update. + civicrm_api3('Contact', 'create', array('contact_id' => $msg['contact_id'],'employer_id' => $msg['employer_id'])); + } + if (!empty($msg['matching_amount']) && $msg['matching_amount'] > 0) { $matchedMsg = $msg; diff --git a/sites/all/modules/offline2civicrm/tests/BenevityTest.php b/sites/all/modules/offline2civicrm/tests/BenevityTest.php index bf170b4..89f2347 100644 --- a/sites/all/modules/offline2civicrm/tests/BenevityTest.php +++ b/sites/all/modules/offline2civicrm/tests/BenevityTest.php @@ -135,6 +135,45 @@ */ function testImportSucceedIndividualNoExistingMatchOnlyMatchingGift() { $thaMouseMeister = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); + $relationships = $this->callAPISuccess('Relationship', 'get', array( + 'contact_id_b' => $thaMouseMeister['id']) + ); + $this->assertEquals(0, $relationships['count']); + + $importer = new BenevityFile( __DIR__ . "/data/benevity_only_match.csv" ); + $importer->import(); + $messages = $importer->getMessages(); + $this->assertEquals('All rows were imported', $messages['Result']); + $contribution = $this->callAPISuccessGetSingle('Contribution', array('trxn_id' => 'BENEVITY TRXN-SQUEAK_MATCHED')); + $relationship = $this->callAPISuccessGetSingle('Relationship', array( + 'contact_id_b' => $thaMouseMeister['id']) + ); + $this->assertEquals( $relationship['contact_id_a'], $contribution['soft_credit_to']); + } + + /** + * Test when creating a contact just for the matching gift on a soft credit match. + * + * In this scenario the contact is matched based on a prior soft credit. Their + * email is ignored to make this match. + * + * The contact does not make a donation but is soft credited the organisation's donation. + * + * We are checking the relationship is created. + */ + function testImportSucceedIndividualSofCreditMatchMatchingGiftNoDonorGift() { + $thaMouseMeister = $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', 'email' => 'minnie@mouse_home.org' + )); + // Create a contribution on the organisation, soft credited to Better Minnie. + $this->callAPISuccess('Contribution', 'create', array( + 'total_amount' => 4, + 'financial_type_id' => 'Donation', + 'soft_credit_to' => $minnie['id'], + 'contact_id' => $thaMouseMeister['id'], + )); + $importer = new BenevityFile( __DIR__ . "/data/benevity_only_match.csv" ); $importer->import(); $messages = $importer->getMessages(); @@ -257,7 +296,6 @@ $this->assertEquals(0, $emails['values'][1]['is_primary']); $this->assertEquals('min...@mouse.org', $emails['values'][1]['email']); } - /** * Check that without an email the match is only accepted with an employer connection. diff --git a/sites/all/modules/offline2civicrm/tests/data/benevity_mice_no_email_matched_only.csv b/sites/all/modules/offline2civicrm/tests/data/benevity_mice_no_email_matched_only.csv new file mode 100644 index 0000000..c06a645 --- /dev/null +++ b/sites/all/modules/offline2civicrm/tests/data/benevity_mice_no_email_matched_only.csv @@ -0,0 +1,3 @@ +Participating Corporation,Project,Date of Donation,Donor First Name,Donor Last Name,Email,Address,City,State/Province,Postal Code,Comment,Transaction ID,Donation Frequency,Donation Amount,Matched Amount,Total +Mickey Mouse Inc,,2015-11-02,Minnie,Mouse,Not shared by donor,Not shared by donor,Not shared by donor,Not shared by donor,90210,Very stingy,trxn-AARF,Recurring,0,0.5,10.5 +Mickey Mouse Inc,,2015-11-02,Not shared by donor,Mouse,Not shared by donor,Not shared by donor,Not shared by donor,Not shared by donor,90210,,trxn-PEEP,Recurring,0,10000.5,11500.5 -- To view, visit https://gerrit.wikimedia.org/r/341749 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9f00f1d74a9ba8ecf680089d0cc0ad557489e160 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits