Adamw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59752


Change subject: civi required fields have changed.
......................................................................

civi required fields have changed.

Only McDefault the name if BOTH first and last are missing.

Empty strings were borking both name and email defaults.

Organization name can be set through the API now.

Change-Id: I25d6c4d788610a0d822ecceb9e381e665a8dc0d9
---
M sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
1 file changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/52/59752/1

diff --git a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
index 49be9a4..9adb526 100644
--- a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
@@ -119,7 +119,7 @@
 
         $contribution_result = civicrm_api( "Contribution", "Create", 
$contribution );
         if ( array_key_exists( 'is_error', $contribution_result ) && 
$contribution_result['is_error'] != 0 ) {
-            throw new Exception( "Couldn't update contribution with new 
settlement info. txn_id: {$contribution['trxn_id']}" );
+            throw new WmfException( "IMPORT_CONTRIB", "Couldn't update 
contribution with new settlement info. Original error: 
{$contribution_result['error_message']}. txn_id: {$contribution['trxn_id']}" );
         }
     }
 
@@ -628,9 +628,10 @@
     //if they don't exist (even if they're blank).
     $defaults = array(
         'date' => time(), //defaulting to now. @fixme: if you can think of a 
better thing to do in the name of historical exchange rates.
-        'first_name' => 'Chester',
+        'first_name' => '',
         'middle_name' => '',
-        'last_name' => 'McDefault',
+        'last_name' => '',
+        'email' => '',
         'street_address' => '',
         'supplemental_address_1' => '',
         'city' => '',
@@ -704,6 +705,7 @@
 
         $contact['sort_name'] = $msg['organization_name'];
         $contact['display_name'] = $msg['organization_name'];
+        $contact['organization_name'] = $msg['organization_name'];
     }
 
     // Attempt to insert the contact
@@ -767,7 +769,7 @@
 function wmf_civicrm_message_email_update( $msg, $contact_id ) {
     // unset the email address if the default is used
     // this enables us to properly dedupe contacts later on
-    if( $msg[ 'email' ] == '[email protected]' ){
+    if( empty( $msg['email'] ) or $msg[ 'email' ] === '[email protected]' ){
         return;
     }
 
@@ -957,6 +959,11 @@
         }
     }
 
+    if ( empty( $msg['first_name'] ) and empty( $msg['last_name'] ) ) {
+        $msg['first_name'] = 'Chester';
+        $msg['last_name'] = 'McDefault';
+    }
+
     watchdog( 'wmf_civicrm', 'Contribution (pre-conversion):<pre>' . 
check_plain(print_r($msg, TRUE)) . '</pre>' );
 
     return $msg;

-- 
To view, visit https://gerrit.wikimedia.org/r/59752
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25d6c4d788610a0d822ecceb9e381e665a8dc0d9
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to