close #782 Enhancement: Schedule Time configuration change

This commit is contained in:
cuneytsenturk 2019-03-07 16:41:14 +03:00
parent 8b0a1a5034
commit 46decc1250
7 changed files with 56 additions and 10 deletions

View File

@ -6,6 +6,7 @@ APP_KEY=
APP_DEBUG=true APP_DEBUG=true
APP_LOG_LEVEL=debug APP_LOG_LEVEL=debug
APP_URL= APP_URL=
APP_SCHEDULE_TIME="09:00"
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=localhost DB_HOST=localhost

View File

@ -6,6 +6,7 @@ APP_KEY=base64:xBC+BxlC7sXhYAtpTZv8TYAHqoPgsJaXL0S5Id6BbBc=
APP_DEBUG=true APP_DEBUG=true
APP_LOG_LEVEL=debug APP_LOG_LEVEL=debug
APP_URL=http://akaunting.test APP_URL=http://akaunting.test
APP_SCHEDULE_TIME="09:00"
DB_CONNECTION=sqlite DB_CONNECTION=sqlite
DB_DATABASE=:memory: DB_DATABASE=:memory:

View File

@ -37,9 +37,11 @@ class Kernel extends ConsoleKernel
return; return;
} }
$schedule->command('reminder:invoice')->dailyAt(setting('general.schedule_time', '09:00')); $schedule_time = env('APP_SCHEDULE_TIME', '09:00');
$schedule->command('reminder:bill')->dailyAt(setting('general.schedule_time', '09:00'));
$schedule->command('recurring:check')->dailyAt(setting('general.schedule_time', '09:00')); $schedule->command('reminder:invoice')->dailyAt($schedule_time);
$schedule->command('reminder:bill')->dailyAt($schedule_time);
$schedule->command('recurring:check')->dailyAt($schedule_time);
} }
/** /**

View File

@ -188,6 +188,9 @@ class Settings extends Controller
case 'session_handler': case 'session_handler':
Installer::updateEnv(['SESSION_DRIVER' => $value]); Installer::updateEnv(['SESSION_DRIVER' => $value]);
break; break;
case 'schedule_time':
Installer::updateEnv(['APP_SCHEDULE_TIME' => '"' . $value . '"']);
break;
} }
} }
} }

View File

@ -5,7 +5,7 @@ namespace App\Listeners\Updates\V11;
use App\Events\UpdateFinished; use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener; use App\Listeners\Updates\Listener;
use App\Models\Common\Company; use App\Models\Common\Company;
use DotenvEditor; use App\Utilities\Installer;
class Version112 extends Listener class Version112 extends Listener
{ {
@ -34,11 +34,6 @@ class Version112 extends Listener
} }
// Set default locale // Set default locale
DotenvEditor::setKeys([ Installer::updateEnv(['APP_LOCALE' => $locale]);
[
'key' => 'APP_LOCALE',
'value' => $locale,
],
])->save();
} }
} }

View File

@ -0,0 +1,43 @@
<?php
namespace App\Listeners\Updates\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Models\Common\Company;
use App\Utilities\Installer;
use Artisan;
class Version1313 extends Listener
{
const ALIAS = 'core';
const VERSION = '1.3.13';
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
{
// Check if should listen
if (!$this->check($event)) {
return;
}
$schedule_time = '09:00';
// Get default locale if only 1 company
if (Company::all()->count() == 1) {
$schedule_time = setting('general.schedule_time', '09:00');
}
// Set default locale
Installer::updateEnv(['APP_SCHEDULE_TIME' => '"' . $schedule_time . '"']);
// Update database
Artisan::call('migrate', ['--force' => true]);
}
}

View File

@ -34,6 +34,7 @@ class EventServiceProvider extends ServiceProvider
'App\Listeners\Updates\V13\Version138', 'App\Listeners\Updates\V13\Version138',
'App\Listeners\Updates\V13\Version139', 'App\Listeners\Updates\V13\Version139',
'App\Listeners\Updates\V13\Version1311', 'App\Listeners\Updates\V13\Version1311',
'App\Listeners\Updates\V13\Version1313',
], ],
'Illuminate\Auth\Events\Login' => [ 'Illuminate\Auth\Events\Login' => [
'App\Listeners\Auth\Login', 'App\Listeners\Auth\Login',