diff --git a/app/Classes/External/Supplier.php b/app/Classes/External/Supplier.php index 8719d81..f6620fb 100644 --- a/app/Classes/External/Supplier.php +++ b/app/Classes/External/Supplier.php @@ -40,7 +40,7 @@ abstract class Supplier 'query'=>[ $this->login_user_field=>$this->o->stats_username, $this->login_pass_field=>$this->o->stats_password, - $this->date_field=>$this->o->stats_lastupdate, + $this->date_field=>$this->o->stats_lastupdate->format('Y-m-d'), ], /* 'headers' => [ @@ -52,7 +52,7 @@ abstract class Supplier $api_remain = Arr::get($result->getHeader('X-RateLimit-Remaining'),0); $api_reset = Arr::get($result->getHeader('X-RateLimit-Reset'),0); - if ($api_remain == 0) { + if ($api_remain === 0 AND $api_reset) { Log::error('API Throttle.',['m'=>__METHOD__]); Cache::put('api_throttle',$api_reset,now()->addSeconds($api_reset)); } @@ -86,7 +86,7 @@ abstract class Supplier $this->_columns = $expect; if ($this->_columns->diff($fields)->count()) { - abort('500','Missing columns in data: '.join('|',$this->_columns->diff($fields)->toArray())); + abort('500','Missing columns in data: '.join('|',$this->_columns->diff($fields)->toArray()).' got: '.join('|',$fields)); } return $fields->intersect($this->_columns); diff --git a/app/Console/Commands/InvoiceGenerate.php b/app/Console/Commands/InvoiceGenerate.php index 406f937..12b0f7b 100644 --- a/app/Console/Commands/InvoiceGenerate.php +++ b/app/Console/Commands/InvoiceGenerate.php @@ -47,6 +47,7 @@ class InvoiceGenerate extends Command foreach ($accounts as $o) { $io = new Invoice; + $io->account_id = $o->id; foreach ($o->services(TRUE)->get() as $so) { foreach ($so->next_invoice_items(FALSE) as $ooo) @@ -54,7 +55,7 @@ class InvoiceGenerate extends Command } // If there are no items, no reason to do anything - if (! $io->items->count()) + if (! $io->items->count() OR $io->total < 0) continue; $io->account_id = $o->id; diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2899d22..0d08c8d 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -5,6 +5,7 @@ namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; +use App\Models\AdslSupplier; use App\Jobs\BroadbandTraffic; class Kernel extends ConsoleKernel @@ -26,7 +27,9 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->job(new BroadbandTraffic())->dailyAt('10:00'); + // @todo This needs to be more generic and dynamic + // Exetel Traffic + $schedule->job(new BroadbandTraffic(AdslSupplier::find(1)))->timezone('Australia/Melbourne')->dailyAt('10:00'); } /** diff --git a/app/Models/Service.php b/app/Models/Service.php index 10e302f..ffe34b4 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -1231,7 +1231,7 @@ class Service extends Model } // Add additional charges - if (($future == TRUE OR ($future == FALSE AND ($this->invoice_to < Carbon::now()->addDays(30)))) + if (($future == TRUE OR ($future == FALSE AND ($this->invoice_to >= Carbon::now()->addDays(30)))) AND ! $this->invoice_items->filter(function($item) { return $item->module_id == 30 AND ! $item->exists; })->count()) { foreach ($this->charges->filter(function($item) { return ! $item->processed; }) as $oo) { diff --git a/composer.json b/composer.json index afb4075..3209e22 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "doctrine/dbal": "^2.10", "eduardokum/laravel-mail-auto-embed": "^1.0", "fideloper/proxy": "^4.0", + "hmazter/laravel-schedule-list": "^2.1", "intervention/image": "^2.5", "laravel/framework": "^6.4", "laravel/passport": "^8.2", diff --git a/composer.lock b/composer.lock index b48b25b..3f6e3c7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "224d038b28e5caca797e510d07cacf32", + "content-hash": "9c2cec462a61ee2fc9803db52e3a407b", "packages": [ { "name": "barryvdh/laravel-snappy", @@ -1421,6 +1421,61 @@ ], "time": "2019-07-01T23:21:34+00:00" }, + { + "name": "hmazter/laravel-schedule-list", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/hmazter/laravel-schedule-list.git", + "reference": "57112ad287c4d5a0bcb68206557012b4191b1363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hmazter/laravel-schedule-list/zipball/57112ad287c4d5a0bcb68206557012b4191b1363", + "reference": "57112ad287c4d5a0bcb68206557012b4191b1363", + "shasum": "" + }, + "require": { + "dragonmantank/cron-expression": "^2.0", + "illuminate/console": "5.6.*|5.7.*|5.8.*|^6.0|^7.0", + "illuminate/support": "5.6.*|5.7.*|5.8.*|^6.0|^7.0", + "php": "^7.2" + }, + "require-dev": { + "orchestra/testbench": "~3.6", + "phpunit/phpunit": "^8.3" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Hmazter\\LaravelScheduleList\\ScheduleListServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Hmazter\\LaravelScheduleList\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kristoffer Högberg", + "email": "krihog@gmail.com" + } + ], + "description": "Laravel package to add command to list all scheduled artisan commands", + "keywords": [ + "artisan", + "console", + "laravel5" + ], + "time": "2020-01-16T11:29:32+00:00" + }, { "name": "igaster/laravel-theme", "version": "v2.0.15",