Uptravel updates
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Jul 2019 17:26:39 +0000 (13:26 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Jul 2019 17:26:39 +0000 (13:26 -0400)
This is for the import accounts and verify billing data

models/admin/management/importAccounts.php
models/admin/management/verifyBillingData.php

index b9709d7..a92bbb0 100644 (file)
@@ -326,13 +326,13 @@ foreach ( $members as $member ) {
         } else {
 
             // Else update account.
-            // $this->wpdb->update(
-            //     GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts',
-            //     $accountData,
-            //     array( 'id' => $accountId ),
-            //     $accountDataFormat,
-            //     array( '%d' )
-            // );
+            $this->wpdb->update(
+                GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts',
+                $accountData,
+                array( 'id' => $accountId ),
+                $accountDataFormat,
+                array( '%d' )
+            );
 
         }
 
index 82cbf1f..e7a9e38 100644 (file)
@@ -44,6 +44,8 @@ $prepareSql    = "
 SELECT balance
   FROM members.billing
  WHERE member_id = :member_id
+   AND transaction_time >= '01/01/2018'
+   AND member_id IN ( SELECT member_id FROM members.member )
 ORDER BY transaction_time DESC
 LIMIT 1
 OFFSET 0";
@@ -54,10 +56,11 @@ foreach ( $results as $key => &$row ) {
     $balanceDue = $BillingSupport->getBalanceDueByAccount( $row['account_id'] );
     $results[$key]['balanceDue'] = (float)$balanceDue;
     $getBalanceDue->bindParam( ':member_id', $row['old_member_id'] );
-    $getBalanceDue->execute();
-    $results[$key]['original_balance_due'] = (float)$getBalanceDue->fetchColumn();
-    if ( $results[$key]['original_balance_due'] != $results[$key]['balanceDue'] ) {
-        $badAccounts[] = $results[$key];
+    if ( $getBalanceDue->execute() ) {
+        $results[$key]['original_balance_due'] = (float)$getBalanceDue->fetchColumn();
+        if ( $results[$key]['original_balance_due'] != $results[$key]['balanceDue'] ) {
+            $badAccounts[] = $results[$key];
+        }
     }
 }