diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 629f41a3ba30..659612e4d831 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -51,7 +51,7 @@ class QueryLogging // Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); //if($count > 10) - Log::info($queries); + // Log::info($queries); } } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 578c8f8b4943..ee8f3baed3e6 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -44,8 +44,12 @@ class AutoBillInvoice extends AbstractService if($this->invoice->balance > 0) $gateway_token = $this->getGateway($this->invoice->balance); - else - return $this->invoice->service()->markPaid()->save(); + + // else + // return $this->invoice->service()->markPaid()->save(); + + if(!$gateway_token) + return $this->invoice; $fee = $gateway_token->gateway->calcGatewayFee($this->invoice->balance); @@ -60,13 +64,28 @@ class AutoBillInvoice extends AbstractService private function getGateway($amount) { - $gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC'); + // $gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC'); - return $gateway_tokens->filter(function ($token) use ($amount){ + // return $gateway_tokens->filter(function ($token) use ($amount){ - return $this->validGatewayLimits($token, $amount); + // return $this->validGatewayLimits($token, $amount); - })->all()->first(); + // })->all()->first(); + + + $gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC')->get(); + + foreach($gateway_tokens as $gateway_token) + { + if($this->validGatewayLimits($gateway_token, $amount)) + return $gateway_token; + } + + // return collect($gateway_tokens)->filter(function ($token) use ($amount){ + + // return $this->validGatewayLimits($token, $amount); + + // })->first(); }