diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index fb7fa77b3ec1..47ceee908af3 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -48,46 +48,46 @@ class Kernel extends ConsoleKernel $schedule->job(new VersionCheck)->daily(); /* Checks and cleans redundant files */ - $schedule->job(new DiskCleanup)->dailyAt('02:10')->withoutOverlapping(); + $schedule->job(new DiskCleanup)->dailyAt('02:10')->withoutOverlapping()->name('disk-cleanup-job')->onOneServer(); /* Send reminders */ - $schedule->job(new ReminderJob)->hourly()->withoutOverlapping(); + $schedule->job(new ReminderJob)->hourly()->withoutOverlapping()->name('reminder-job')->onOneServer(); /* Returns the number of jobs in the queue */ $schedule->job(new QueueSize)->everyFiveMinutes()->withoutOverlapping(); /* Checks for large companies and marked them as is_large */ - $schedule->job(new CompanySizeCheck)->dailyAt('23:20')->withoutOverlapping(); + $schedule->job(new CompanySizeCheck)->dailyAt('23:20')->withoutOverlapping()->name('company-size-job')->onOneServer(); /* Pulls in the latest exchange rates */ $schedule->job(new UpdateExchangeRates)->dailyAt('23:30')->withoutOverlapping(); /* Runs cleanup code for subscriptions */ - $schedule->job(new SubscriptionCron)->dailyAt('00:01')->withoutOverlapping(); + $schedule->job(new SubscriptionCron)->dailyAt('00:01')->withoutOverlapping()->name('subscription-job')->onOneServer(); /* Sends recurring invoices*/ - $schedule->job(new RecurringInvoicesCron)->hourly()->withoutOverlapping(); + $schedule->job(new RecurringInvoicesCron)->hourly()->withoutOverlapping()->name('recurring-invoice-job')->onOneServer(); /* Sends recurring invoices*/ - $schedule->job(new RecurringExpensesCron)->dailyAt('00:10')->withoutOverlapping(); + $schedule->job(new RecurringExpensesCron)->dailyAt('00:10')->withoutOverlapping()->name('recurring-expense-job')->onOneServer(); /* Fires notifications for expired Quotes */ - $schedule->job(new QuoteCheckExpired)->dailyAt('05:10')->withoutOverlapping(); + $schedule->job(new QuoteCheckExpired)->dailyAt('05:10')->withoutOverlapping()->name('quote-expired-job')->onOneServer(); /* Performs auto billing */ - $schedule->job(new AutoBillCron)->dailyAt('06:20')->withoutOverlapping(); + $schedule->job(new AutoBillCron)->dailyAt('06:20')->withoutOverlapping()->name('auto-bill-job')->onOneServer(); /* Checks the status of the scheduler */ $schedule->job(new SchedulerCheck)->dailyAt('01:10')->withoutOverlapping(); /* Checks for scheduled tasks */ - $schedule->job(new TaskScheduler())->dailyAt('06:50')->withoutOverlapping(); + $schedule->job(new TaskScheduler())->dailyAt('06:50')->withoutOverlapping()->name('task-scheduler-job')->onOneServer(); /* Performs system maintenance such as pruning the backup table */ - $schedule->job(new SystemMaintenance)->weekly()->withoutOverlapping(); + $schedule->job(new SystemMaintenance)->sundays()->at('02:30')->withoutOverlapping()->name('system-maintenance-job')->onOneServer(); /* Pulls in bank transactions from third party services */ - $schedule->job(new BankTransactionSync)->dailyAt('04:10')->withoutOverlapping(); + $schedule->job(new BankTransactionSync)->dailyAt('04:10')->withoutOverlapping()->name('bank-trans-sync-job')->onOneServer(); if (Ninja::isSelfHost()) { diff --git a/app/Http/Requests/Report/GenericReportRequest.php b/app/Http/Requests/Report/GenericReportRequest.php index 2e963adeacef..9cfddf60f433 100644 --- a/app/Http/Requests/Report/GenericReportRequest.php +++ b/app/Http/Requests/Report/GenericReportRequest.php @@ -32,8 +32,6 @@ class GenericReportRequest extends Request return [ 'date_range' => 'bail|required|string', - // 'start_date' => [Rule::requiredIf($this->date_range === 'custom')], - // 'end_date' => [Rule::requiredIf($this->date_range === 'custom')], 'end_date' => 'bail|required_if:date_range,custom|nullable|date', 'start_date' => 'bail|required_if:date_range,custom|nullable|date', 'report_keys' => 'present|array', @@ -57,6 +55,12 @@ class GenericReportRequest extends Request $input['send_email'] = true; } + if (array_key_exists('date_range', $input) && $input['date_range'] != 'custom') { + $input['start_date'] = null; + $input['end_date'] = null; + } + + $this->replace($input); } } diff --git a/app/Http/Requests/Twilio/ConfirmSmsRequest.php b/app/Http/Requests/Twilio/ConfirmSmsRequest.php index 537dcbab7da4..f8e98bb9ddc7 100644 --- a/app/Http/Requests/Twilio/ConfirmSmsRequest.php +++ b/app/Http/Requests/Twilio/ConfirmSmsRequest.php @@ -24,7 +24,7 @@ class ConfirmSmsRequest extends Request */ public function authorize() : bool { - return auth()->user()->isAdmin(); + return true; } public function rules() diff --git a/app/Http/Requests/Twilio/GenerateSmsRequest.php b/app/Http/Requests/Twilio/GenerateSmsRequest.php index 9c25ec18ef3f..ccf20040b15e 100644 --- a/app/Http/Requests/Twilio/GenerateSmsRequest.php +++ b/app/Http/Requests/Twilio/GenerateSmsRequest.php @@ -24,7 +24,7 @@ class GenerateSmsRequest extends Request */ public function authorize() : bool { - return auth()->user(); + return true; } diff --git a/app/Jobs/Ninja/SystemMaintenance.php b/app/Jobs/Ninja/SystemMaintenance.php index de3571304c08..01219ce4b9cc 100644 --- a/app/Jobs/Ninja/SystemMaintenance.php +++ b/app/Jobs/Ninja/SystemMaintenance.php @@ -49,10 +49,6 @@ class SystemMaintenance implements ShouldQueue nlog('Starting System Maintenance'); - if (Ninja::isHosted()) { - return; - } - $delete_pdf_days = config('ninja.maintenance.delete_pdfs'); nlog("Number of days to keep PDFs {$delete_pdf_days}"); diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 64e6faf13cef..f5c64f38fcb9 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -87,7 +87,8 @@ class ReminderJob implements ShouldQueue $query->where('is_disabled', 0); }) ->with('invitations')->cursor()->each(function ($invoice) { - if ($invoice->isPayable()) { + // if ($invoice->refresh() && $invoice->isPayable()) { + if ($invoice->isPayable()) { //Attempts to prevent duplicates from sending if($invoice->reminder_last_sent && Carbon::parse($invoice->reminder_last_sent)->startOfDay()->eq(now()->startOfDay())){ @@ -97,9 +98,8 @@ class ReminderJob implements ShouldQueue $reminder_template = $invoice->calculateTemplate('invoice'); nlog("reminder template = {$reminder_template}"); - $invoice = $this->calcLateFee($invoice, $reminder_template); $invoice->service()->touchReminder($reminder_template)->save(); - $invoice->service()->touchPdf(true); + $invoice = $this->calcLateFee($invoice, $reminder_template); //20-04-2022 fixes for endless reminders - generic template naming was wrong $enabled_reminder = 'enable_'.$reminder_template; @@ -220,16 +220,18 @@ class ReminderJob implements ShouldQueue $invoice->client->service()->updateBalance($invoice->balance - $temp_invoice_balance); $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}"); - $transaction = [ - 'invoice' => $invoice->transaction_event(), - 'payment' => [], - 'client' => $invoice->client->transaction_event(), - 'credit' => [], - 'metadata' => ['setLateFee'], - ]; + // $transaction = [ + // 'invoice' => $invoice->transaction_event(), + // 'payment' => [], + // 'client' => $invoice->client->transaction_event(), + // 'credit' => [], + // 'metadata' => ['setLateFee'], + // ]; // TransactionLog::dispatch(TransactionEvent::CLIENT_STATUS, $transaction, $invoice->company->db); + $invoice->service()->touchPdf(true); + return $invoice; } } diff --git a/app/Jobs/Util/VersionCheck.php b/app/Jobs/Util/VersionCheck.php index cdb2a280a89c..7ee5a047d358 100644 --- a/app/Jobs/Util/VersionCheck.php +++ b/app/Jobs/Util/VersionCheck.php @@ -37,13 +37,14 @@ class VersionCheck implements ShouldQueue { $version_file = trim(@file_get_contents(config('ninja.version_url'))); - nlog("latest version = {$version_file}"); - if (Ninja::isSelfHost() && $version_file) { Account::whereNotNull('id')->update(['latest_version' => $version_file]); } if (Ninja::isSelfHost()) { + + nlog("latest version = {$version_file}"); + $account = Account::first(); if (! $account) {