diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f67dc4af685b..9beb55d2b94f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -97,6 +97,9 @@ class Kernel extends ConsoleKernel /* Fires webhooks for overdue Invoice */ $schedule->job(new InvoiceCheckLateWebhook)->dailyAt('07:00')->withoutOverlapping()->name('invoice-overdue-job')->onOneServer(); + /* Pulls in bank transactions from third party services */ + $schedule->job(new BankTransactionSync)->everyFourHours()->withoutOverlapping()->name('bank-trans-sync-job')->onOneServer(); + if (Ninja::isSelfHost()) { $schedule->call(function () { Account::whereNotNull('id')->update(['is_scheduler_running' => true]); @@ -107,9 +110,6 @@ class Kernel extends ConsoleKernel if (Ninja::isHosted()) { $schedule->job(new AdjustEmailQuota)->dailyAt('23:30')->withoutOverlapping(); - /* Pulls in bank transactions from third party services */ - $schedule->job(new BankTransactionSync)->everyFourHours()->withoutOverlapping()->name('bank-trans-sync-job')->onOneServer(); - /* Checks ACH verification status and updates state to authorize when verified */ $schedule->job(new CheckACHStatus)->everySixHours()->withoutOverlapping()->name('ach-status-job')->onOneServer(); @@ -120,7 +120,7 @@ class Kernel extends ConsoleKernel $schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping()->name('s3-cleanup-job')->onOneServer(); } - if (config('queue.default') == 'database' && Ninja::isSelfHost() && config('ninja.internal_queue_enabled') && ! config('ninja.is_docker')) { + if (config('queue.default') == 'database' && Ninja::isSelfHost() && config('ninja.internal_queue_enabled') && !config('ninja.is_docker')) { $schedule->command('queue:work database --stop-when-empty --memory=256')->everyMinute()->withoutOverlapping(); $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping(); @@ -134,7 +134,7 @@ class Kernel extends ConsoleKernel */ protected function commands() { - $this->load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } diff --git a/app/Jobs/Ninja/BankTransactionSync.php b/app/Jobs/Ninja/BankTransactionSync.php index 978abbab1e80..1a68e643a44b 100644 --- a/app/Jobs/Ninja/BankTransactionSync.php +++ b/app/Jobs/Ninja/BankTransactionSync.php @@ -49,17 +49,19 @@ class BankTransactionSync implements ShouldQueue foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); - nlog("syncing transactions - yodlee"); + if (Ninja::isSelfHost()) { // @turbo124 @todo I migrated the schedule for the job within the kernel to execute on all platforms and use the same expression here to determine if yodlee can run or not. Please chek/verify + nlog("syncing transactions - yodlee"); - $a = Account::with('bank_integrations')->whereNotNull('bank_integration_yodlee_account_id')->cursor()->each(function ($account) { - // $queue = Ninja::isHosted() ? 'bank' : 'default'; + $a = Account::with('bank_integrations')->whereNotNull('bank_integration_yodlee_account_id')->cursor()->each(function ($account) { + // $queue = Ninja::isHosted() ? 'bank' : 'default'; - if ($account->isPaid() && $account->plan == 'enterprise') { - $account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->andWhere('auto_sync', true)->cursor()->each(function ($bank_integration) use ($account) { - (new ProcessBankTransactionsYodlee($account, $bank_integration))->handle(); - }); - } - }); + if ($account->isPaid() && $account->plan == 'enterprise') { + $account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->andWhere('auto_sync', true)->cursor()->each(function ($bank_integration) use ($account) { + (new ProcessBankTransactionsYodlee($account, $bank_integration))->handle(); + }); + } + }); + } nlog("syncing transactions - nordigen");