Added schedule:list, fixed traffic import service, fixed invoice generation with charges and credit amounts

This commit is contained in:
Deon George 2020-05-29 14:10:10 +10:00
parent 7f1681f0b7
commit 121aa5b31c
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
6 changed files with 67 additions and 7 deletions

View File

@ -40,7 +40,7 @@ abstract class Supplier
'query'=>[ 'query'=>[
$this->login_user_field=>$this->o->stats_username, $this->login_user_field=>$this->o->stats_username,
$this->login_pass_field=>$this->o->stats_password, $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' => [ 'headers' => [
@ -52,7 +52,7 @@ abstract class Supplier
$api_remain = Arr::get($result->getHeader('X-RateLimit-Remaining'),0); $api_remain = Arr::get($result->getHeader('X-RateLimit-Remaining'),0);
$api_reset = Arr::get($result->getHeader('X-RateLimit-Reset'),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__]); Log::error('API Throttle.',['m'=>__METHOD__]);
Cache::put('api_throttle',$api_reset,now()->addSeconds($api_reset)); Cache::put('api_throttle',$api_reset,now()->addSeconds($api_reset));
} }
@ -86,7 +86,7 @@ abstract class Supplier
$this->_columns = $expect; $this->_columns = $expect;
if ($this->_columns->diff($fields)->count()) { 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); return $fields->intersect($this->_columns);

View File

@ -47,6 +47,7 @@ class InvoiceGenerate extends Command
foreach ($accounts as $o) { foreach ($accounts as $o) {
$io = new Invoice; $io = new Invoice;
$io->account_id = $o->id;
foreach ($o->services(TRUE)->get() as $so) { foreach ($o->services(TRUE)->get() as $so) {
foreach ($so->next_invoice_items(FALSE) as $ooo) 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 there are no items, no reason to do anything
if (! $io->items->count()) if (! $io->items->count() OR $io->total < 0)
continue; continue;
$io->account_id = $o->id; $io->account_id = $o->id;

View File

@ -5,6 +5,7 @@ namespace App\Console;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Models\AdslSupplier;
use App\Jobs\BroadbandTraffic; use App\Jobs\BroadbandTraffic;
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
@ -26,7 +27,9 @@ class Kernel extends ConsoleKernel
*/ */
protected function schedule(Schedule $schedule) 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');
} }
/** /**

View File

@ -1231,7 +1231,7 @@ class Service extends Model
} }
// Add additional charges // 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()) 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) { foreach ($this->charges->filter(function($item) { return ! $item->processed; }) as $oo) {

View File

@ -15,6 +15,7 @@
"doctrine/dbal": "^2.10", "doctrine/dbal": "^2.10",
"eduardokum/laravel-mail-auto-embed": "^1.0", "eduardokum/laravel-mail-auto-embed": "^1.0",
"fideloper/proxy": "^4.0", "fideloper/proxy": "^4.0",
"hmazter/laravel-schedule-list": "^2.1",
"intervention/image": "^2.5", "intervention/image": "^2.5",
"laravel/framework": "^6.4", "laravel/framework": "^6.4",
"laravel/passport": "^8.2", "laravel/passport": "^8.2",

57
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "224d038b28e5caca797e510d07cacf32", "content-hash": "9c2cec462a61ee2fc9803db52e3a407b",
"packages": [ "packages": [
{ {
"name": "barryvdh/laravel-snappy", "name": "barryvdh/laravel-snappy",
@ -1421,6 +1421,61 @@
], ],
"time": "2019-07-01T23:21:34+00:00" "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", "name": "igaster/laravel-theme",
"version": "v2.0.15", "version": "v2.0.15",