diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 0b8ad079ea92..6a68546d6e18 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -65,7 +65,7 @@ class CheckData extends Command /** * @var string */ - protected $name = 'ninja:check-data'; + protected $signature = 'ninja:check-data {--database=} {--fix=}'; /** * @var string diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 4edd36a1c3ec..f0ac9d77857f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -46,7 +46,7 @@ class Kernel extends ConsoleKernel $schedule->job(new VersionCheck)->daily(); - $schedule->command('ninja:check-data')->daily()->withoutOverlapping(); + $schedule->command('ninja:check-data --database=db-ninja-01')->daily()->withoutOverlapping(); $schedule->job(new ReminderJob)->daily()->withoutOverlapping(); @@ -65,6 +65,7 @@ class Kernel extends ConsoleKernel $schedule->job(new AdjustEmailQuota)->daily()->withoutOverlapping(); $schedule->job(new SendFailedEmails)->daily()->withoutOverlapping(); + $schedule->command('ninja:check-data --database=db-ninja-02')->daily()->withoutOverlapping(); } diff --git a/app/Observers/CompanyObserver.php b/app/Observers/CompanyObserver.php index 8ae111afa0e3..05a0ee3c3329 100644 --- a/app/Observers/CompanyObserver.php +++ b/app/Observers/CompanyObserver.php @@ -39,10 +39,6 @@ class CompanyObserver if(Ninja::isHosted() && $company->portal_mode == 'domain' && $company->isDirty('portal_domain')) { - nlog('company observer - updated'); - nlog($company->portal_domain); - nlog($company->getOriginal('portal_domain')); - //fire event to build new custom portal domain \Modules\Admin\Jobs\Domain\CustomDomain::dispatch($company->getOriginal('portal_domain'), $company)->onQueue('domain'); } diff --git a/app/Observers/InvoiceObserver.php b/app/Observers/InvoiceObserver.php index d3f425c3f577..b91436d2edcf 100644 --- a/app/Observers/InvoiceObserver.php +++ b/app/Observers/InvoiceObserver.php @@ -52,8 +52,8 @@ class InvoiceObserver WebhookHandler::dispatch(Webhook::EVENT_UPDATE_INVOICE, $invoice, $invoice->company); } - if($invoice->isDirty('date') || $invoice->isDirty('due_date')) - $invoice->service()->setReminder()->save(); + // if($invoice->isDirty('date') || $invoice->isDirty('due_date')) + // $invoice->service()->setReminder()->save(); // UnlinkFile::dispatchNow(config('filesystems.default'), $invoice->client->invoice_filepath() . $invoice->numberFormatter().'.pdf'); diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index b5062a061b40..bfe250ea26c8 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -169,10 +169,14 @@ class BaseRepository */ protected function alternativeSave($data, $model) { - - if (array_key_exists('client_id', $data)) //forces the client_id if it doesn't exist + //forces the client_id if it doesn't exist + if(array_key_exists('client_id', $data)) $model->client_id = $data['client_id']; + //pickup changes here to recalculate reminders + if($model instanceof Invoice && ($model->isDirty('date') || $model->isDirty('due_date'))) + $model->service()->setReminder()->save(); + $client = Client::where('id', $model->client_id)->withTrashed()->first(); $state = []; @@ -189,7 +193,7 @@ class BaseRepository $data = array_merge($company_defaults, $data); } - $tmp_data = $data; //preserves the $data arrayss + $tmp_data = $data; //preserves the $data array /* We need to unset some variable as we sometimes unguard the model */ if (isset($tmp_data['invitations'])) diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index f93d5a88db30..f0cf40cb6411 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -245,6 +245,13 @@ class InvoiceService return $this; } + + public function setReminder($settings = null) + { + $this->invoice = (new UpdateReminder($this->invoice, $settings))->run(); + + return $this; + } public function setStatus($status) { @@ -425,13 +432,6 @@ class InvoiceService return $this; } - - public function setReminder($settings = null) - { - $this->invoice = (new UpdateReminder($this->invoice, $settings))->run(); - - return $this; - } /** * Saves the invoice. diff --git a/app/Services/Invoice/UpdateReminder.php b/app/Services/Invoice/UpdateReminder.php index 60faac74f108..99a826ddfc22 100644 --- a/app/Services/Invoice/UpdateReminder.php +++ b/app/Services/Invoice/UpdateReminder.php @@ -21,7 +21,7 @@ class UpdateReminder extends AbstractService public $settings; - public function __construct($invoice, $settings = null) + public function __construct(Invoice $invoice, $settings = null) { $this->invoice = $invoice; $this->settings = $settings; diff --git a/resources/views/email/migration/failed.blade.php b/resources/views/email/migration/failed.blade.php index 41c6421e7c97..0b84e5af48dd 100644 --- a/resources/views/email/migration/failed.blade.php +++ b/resources/views/email/migration/failed.blade.php @@ -7,7 +7,11 @@

Looks like your migration failed. Here's the error message:

+    	@if(Ninja::isHosted())
+    		There was a problem with your migration, please send us an email contact@invoiceninja.com
+    	@else
         {!! $exception->getMessage() !!}
         {!! $content !!}
+        @endif
     
@endcomponent diff --git a/tests/Integration/CheckRemindersTest.php b/tests/Integration/CheckRemindersTest.php index 78c5ab89f483..31d1dd7f217d 100644 --- a/tests/Integration/CheckRemindersTest.php +++ b/tests/Integration/CheckRemindersTest.php @@ -19,7 +19,6 @@ use Tests\TestCase; /** * @test - * @covers App\Utils\Traits\MakesReminders */ class CheckRemindersTest extends TestCase { @@ -50,6 +49,8 @@ class CheckRemindersTest extends TestCase $settings->num_days_reminder3 = 1; $this->company->settings = $settings; + $this->company->save(); + $this->invoice->service()->markSent(); $this->invoice->service()->setReminder($settings)->save();