Ejegg has uploaded a new change for review.

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

Change subject: Only scream about missing parents for negative txns
......................................................................

Only scream about missing parents for negative txns

Looks like we used to check for is_negative before complaining.
Move that check back up to the top level of the loop.

Change-Id: Ice36b11a1302d027f4845941ad6e53083495ce2e
---
M sites/all/modules/globalcollect_audit/globalcollect_audit.module
1 file changed, 33 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/78/281478/1

diff --git a/sites/all/modules/globalcollect_audit/globalcollect_audit.module 
b/sites/all/modules/globalcollect_audit/globalcollect_audit.module
index 4452285..db026ad 100644
--- a/sites/all/modules/globalcollect_audit/globalcollect_audit.module
+++ b/sites/all/modules/globalcollect_audit/globalcollect_audit.module
@@ -1017,34 +1017,40 @@
        globalcollect_audit_echo('Marking refunds and chargebacks');
        $count = 0;
        foreach ($missing as $index => $wr1) {
-    //get the real order ID.
-    $parents = 
globalcollect_audit_get_contributions_from_whatever_this_is(wr1_order_id($wr1));
-    $parent = null;
-    if (is_array($parents) && !empty($parents)) {
-      $parent = array_shift($parents);
-    }
+               if ( !wr1_is_negative_txn( $wr1 ) ) {
+                       continue;
+               }
+               //get the real order ID.
+               $parents = 
globalcollect_audit_get_contributions_from_whatever_this_is( wr1_order_id( $wr1 
) );
+               $parent = null;
+               if ( is_array( $parents ) && !empty( $parents ) ) {
+                       $parent = array_shift( $parents );
+               }
 
-    if (is_null($parent) || !array_key_exists('gateway_txn_id', $parent)) {
-      globalcollect_audit_log_error(__FUNCTION__ . ": Could not find parent 
(or any related) transaction for refund/chargeback, but that should be 
impossible to do here... " . wr1_order_id($wr1), 'MISSING_PARENT');
-    } else {
-      $real_oid = $parent['gateway_txn_id'];
-
-      if (wr1_is_negative_txn($wr1)) {
-        $send_message = array(
-          'gateway_parent_id' => $real_oid, //gateway transaction ID
-          'gross_currency' => wr1_currency($wr1), //currency code
-          'gross' => wr1_amount($wr1) / 100, //amount
-          'date' => wr1_date_to_timestamp($wr1), //timestamp
-          'gateway' => 'globalcollect', //lcase
-          'type' => wr1_get_negative_type($wr1), //refund or chargeback
-        );
-        echo print_r($send_message, true);
-        globalcollect_audit_send_stomp('refund', $send_message);
-        $count += 1;
-        globalcollect_audit_echo('.');
-      }
-      unset($missing[$index]); //only unset if we killed it
-    }
+               if ( is_null( $parent ) || !array_key_exists( 'gateway_txn_id', 
$parent ) ) {
+                       globalcollect_audit_log_error(
+                               __FUNCTION__ .
+                                   ': Could not find parent (or any related) 
transaction for refund/chargeback, ' .
+                                   'but that should be impossible to do 
here... ' .
+                                   wr1_order_id( $wr1 ),
+                               'MISSING_PARENT'
+                       );
+               } else {
+                       $real_oid = $parent['gateway_txn_id'];
+                       $send_message = array(
+                               'gateway_parent_id' => $real_oid, //gateway 
transaction ID
+                               'gross_currency' => wr1_currency( $wr1 ), 
//currency code
+                               'gross' => wr1_amount( $wr1 ) / 100, //amount
+                               'date' => wr1_date_to_timestamp( $wr1 ), 
//timestamp
+                               'gateway' => 'globalcollect', //lcase
+                               'type' => wr1_get_negative_type( $wr1 ), 
//refund or chargeback
+                       );
+                       echo print_r( $send_message, true );
+                       globalcollect_audit_send_stomp( 'refund', $send_message 
);
+                       $count += 1;
+                       globalcollect_audit_echo( '.' );
+                       unset( $missing[$index] ); //only unset if we killed it
+               }
        }
        globalcollect_audit_results_ball( 'refunds/chargebacks', $count );
        return $missing;

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

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

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

Reply via email to