Update query for accounts needing invoices.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 20 Feb 2019 14:39:05 +0000 (09:39 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 20 Feb 2019 14:39:05 +0000 (09:39 -0500)
This is the list that comes up for invoicing when you choose create
invoices. This list will only be for accounts that do not have an
invoice created yet.

models/admin/billing/invoicing.php

index 4ea6c2d..e52c622 100644 (file)
@@ -156,6 +156,17 @@ class GlmMembersAdmin_billing_invoicing //extends GlmDataAccounts
         case 'createInvoices':
             $view = 'invoicing';
 
+            $currentInvoiceDateTS = $BillingSupport->getCurrentInvoiceDate();
+            $currentInvoiceDate   = date( 'Y-m-d', $currentInvoiceDateTS );
+            $nextInvoiceDateTS    = $BillingSupport->getNextInvoiceDate();
+            $nextInvoiceDate      = date( 'Y-m-d', $nextInvoiceDateTS );
+
+            $wParts[] = " T.id NOT IN (
+                SELECT account
+                  FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX  . "invoices
+                 WHERE due_date BETWEEN '$currentInvoiceDate' AND '$nextInvoiceDate'
+                ) ";
+
             if ( $option2 ) {
                 // $where used in all places.
                 $where    = implode( ' AND ', $wParts );
@@ -234,6 +245,7 @@ class GlmMembersAdmin_billing_invoicing //extends GlmDataAccounts
 
         // $where used in all places.
         $where = implode( ' AND ', $wParts );
+        // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
 
         // Check if Counties is enabled and fetch counties
         if ( isset( $this->config['settings']['enable_counties'] ) && $this->config['settings']['enable_counties'] ) {