Adamw has uploaded a new change for review.

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


Change subject: (FR #902) import more columns from check spreadsheet
......................................................................

(FR #902) import more columns from check spreadsheet

Change-Id: Ice777e0c31d34423d4071336550bfa7444193047
---
M sites/all/modules/offline2civicrm/import_checks.drush.inc
M sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
2 files changed, 31 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/31/58631/1

diff --git a/sites/all/modules/offline2civicrm/import_checks.drush.inc 
b/sites/all/modules/offline2civicrm/import_checks.drush.inc
index 4a5cb2d..4fe2192 100644
--- a/sites/all/modules/offline2civicrm/import_checks.drush.inc
+++ b/sites/all/modules/offline2civicrm/import_checks.drush.inc
@@ -87,7 +87,11 @@
                                "fee" => "0",
                                "gross" => _get_value( "Total Amount", $row, 
$headers ),
                                "net" => _get_value( "Total Amount", $row, 
$headers ),
-                               "date" => strtotime( _get_value( "Received 
Date", $row, $headers ) )
+                               "date" => strtotime( _get_value( "Received 
Date", $row, $headers ) ),
+                               "thankyou_date" => strtotime( _get_value( 
"Thank You Date", $row, $headers ) ),
+                               "restrictions" => _get_value( "Restrictions", 
$row, $headers ),
+                               "gift_source" => _get_value( "Gift Source", 
$row, $headers ),
+                               "direct_mail_appeal" => _get_value( "Direct 
Mail Appeal", $row, $headers ),
                        );
 
                        if( _get_value( 'Organization Name', $row, $headers, 
FALSE ) === FALSE ){
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 f7480a0..c7d635d 100644
--- a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
@@ -266,13 +266,6 @@
         throw new WmfException("INVALID_MESSAGE", "No payment type found for 
message.", $msg);
     }
 
-    if ( !array_key_exists( 'check_number', $msg ) ){
-        $msg['check_number'] = NULL;
-    }
-    if ( !array_key_exists( 'letter_code', $msg ) ){
-        $msg['letter_code'] = NULL;
-    }
-
     $contribution = array(
         'contact_id' => $contact[ 'id' ],
         'total_amount' => $msg['gross'],
@@ -287,6 +280,7 @@
         'contribution_recur_id' => $recur_id,
         'check_number' => $msg['check_number'],
         'letter_code' => $msg['letter_code'],
+        'thankyou_date' => date( 'Y-m-d H:i:s', $msg['thankyou_date'] ),
 
         // API required fields
         'version' => '3'
@@ -324,6 +318,16 @@
         'Gift_Data' => $lettercode,
         'gateway_account' => $gateway_account,
     );
+    if ( array_key_exists( 'gift_source', $msg ) ) {
+        $custom_vars['Campaign'] = $msg['gift_source'];
+    }
+    if ( array_key_exists( 'direct_mail_appeal', $msg ) ) {
+        $custom_vars['Appeal'] = $msg['direct_mail_appeal'];
+    }
+    if ( array_key_exists( 'restrictions', $msg ) ) {
+        $custom_vars['Fund'] = $msg['restrictions'];
+    }
+
     wmf_civicrm_set_custom_field_values( $contribution_result[ 'id' ], 
$custom_vars );
 
     return $contribution_result[ 'values' ][ $contribution_result[ 'id' ] ];
@@ -640,6 +644,9 @@
         'state_province' => '',
         'postal_code' => '',
         'original_gross' => $msg['gross'],
+        'check_number' => null,
+        'letter_code' => null,
+        'thankyou_date' => null,
     );
 
     $msg = wmf_civicrm_normalize_msg( array_merge($defaults, $msg) );
@@ -948,6 +955,18 @@
         $msg['date'] = time();
     }
 
+    if ( !empty( $msg['thankyou_date'] ) ) {
+        if ( !is_numeric( $msg['thankyou_date'] ) ) {
+            $unix_time = strtotime( $msg['thankyou_date'] );
+            if ( $unix_time !== false ) {
+                $msg['thankyou_date'] = date( 'Y-m-d H:i:s', $unix_time );
+            } else {
+                watchdog( 'wmf_civicrm', 'Could not parse thankyou date: @date 
from @id', array( '@date' => $msg['thankyou_date'], '@id' => 
$msg['contribution_tracking_id'] ), WATCHDOG_DEBUG );
+                unset( $msg['thankyou_date'] );
+            }
+        }
+    }
+
     watchdog( 'wmf_civicrm', 'Contribution (pre-conversion):<pre>' . 
check_plain(print_r($msg, TRUE)) . '</pre>' );
 
     return $msg;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice777e0c31d34423d4071336550bfa7444193047
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