diff --git a/app/Console/Commands/SendRecurringInvoices.php b/app/Console/Commands/SendRecurringInvoices.php index 55815f327710..11a8e0cd939f 100644 --- a/app/Console/Commands/SendRecurringInvoices.php +++ b/app/Console/Commands/SendRecurringInvoices.php @@ -70,7 +70,9 @@ class SendRecurringInvoices extends Command ->get(); foreach ($accounts as $account) { - $account->checkCounterReset(); + + if(!$account->is_disabled) + $account->checkCounterReset(); } } @@ -94,6 +96,11 @@ class SendRecurringInvoices extends Command $this->info(date('r') . ' Processing Invoice: '. $recurInvoice->id); $account = $recurInvoice->account; + + if($account->is_disabled){ + continue; + } + $account->loadLocalizationSettings($recurInvoice->client); Auth::loginUsingId($recurInvoice->activeUser()->id); @@ -127,7 +134,7 @@ class SendRecurringInvoices extends Command foreach ($expenses as $expense) { $shouldSendToday = $expense->shouldSendToday(); - if (! $shouldSendToday) { + if (! $shouldSendToday || $expense->account->is_disabled) { continue; } diff --git a/app/Console/Commands/SendReminders.php b/app/Console/Commands/SendReminders.php index d2ee903762b3..29591e99865b 100644 --- a/app/Console/Commands/SendReminders.php +++ b/app/Console/Commands/SendReminders.php @@ -109,7 +109,7 @@ class SendReminders extends Command /** @var Invoice $invoice */ foreach ($delayedAutoBillInvoices as $invoice) { - if ($invoice->isPaid()) { + if ($invoice->isPaid() || $invoice->account->is_deleted) { continue; } @@ -128,7 +128,7 @@ class SendReminders extends Command $this->info(date('r ') . $accounts->count() . ' accounts found with fees enabled'); foreach ($accounts as $account) { - if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) { + if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS) || $account->is_disabled) { continue; } @@ -155,7 +155,7 @@ class SendReminders extends Command $this->info(date('r ') . count($accounts) . ' accounts found with reminders enabled'); foreach ($accounts as $account) { - if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) { + if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS) || $account->is_disabled) { continue; } @@ -201,7 +201,7 @@ class SendReminders extends Command $account = $scheduledReport->account; $account->loadLocalizationSettings(); - if (! $account->hasFeature(FEATURE_REPORTS)) { + if (! $account->hasFeature(FEATURE_REPORTS) || $account->is_disabled) { continue; } diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php index d8c15ea434a2..4bb11aac9c7a 100644 --- a/app/Http/Controllers/ClientPortalController.php +++ b/app/Http/Controllers/ClientPortalController.php @@ -67,6 +67,17 @@ class ClientPortalController extends BaseController $client = $invoice->client; $account = $invoice->account; + /* Forward requests from V4 to V5 if the domain is set */ + if(strlen($account->forward_url_for_v5) >1){ + + if ($invoice->isType(INVOICE_TYPE_QUOTE)) + $entity = 'quote'; + else + $entity = 'invoice'; + + return redirect($account->forward_url_for_v5."/client/".$entity."/".$invitationKey); + } + if (request()->silent) { session(['silent:' . $client->id => true]); return redirect(request()->url() . (request()->borderless ? '?borderless=true' : '')); diff --git a/app/Http/Controllers/Migration/StepsController.php b/app/Http/Controllers/Migration/StepsController.php index c659ff58f911..1ab40663cc7e 100644 --- a/app/Http/Controllers/Migration/StepsController.php +++ b/app/Http/Controllers/Migration/StepsController.php @@ -102,6 +102,14 @@ class StepsController extends BaseController } $account = \Auth::user()->account; + + if(strlen($request->input('url')) == 0) { + $account->is_disabled = false; + } + else { + $account->is_disabled = true; + } + $account->forward_url_for_v5 = rtrim($request->input('url'),'/'); $account->save(); @@ -201,22 +209,28 @@ class StepsController extends BaseController ); } + $completeService = (new CompleteService(session('MIGRATION_ACCOUNT_TOKEN'))); + try { $migrationData = $this->generateMigrationData($request->all()); - $completeService = (new CompleteService(session('MIGRATION_ACCOUNT_TOKEN'))) - ->data($migrationData) + + $completeService->data($migrationData) ->endpoint(session('MIGRATION_ENDPOINT')) ->start(); } - finally { + catch(\Exception $e){ + info($e->getMessage()); + return view('migration.completed', ['customMessage' => $e->getMessage()]); + } + if ($completeService->isSuccessful()) { return view('migration.completed'); } return view('migration.completed', ['customMessage' => $completeService->getErrors()[0]]); - } + } public function completed() diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index e958afdc904b..a3d823d20222 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -171,7 +171,7 @@ info("get company"); 'all_pages_footer' => $this->account->all_pages_footer ? (bool) $this->account->all_pages_footer : true, 'all_pages_header' => $this->account->all_pages_header ? (bool) $this->account->all_pages_header : true, 'show_currency_code' => $this->account->show_currency_code ? (bool) $this->account->show_currency_code : false, - 'enable_client_portal_password' => $this->account->enable_portal_password ? (bool) $this->account->enable_portal_password : true, + 'enable_client_portal_password' => $this->account->enable_portal_password ? (bool) $this->account->enable_portal_password : false, 'send_portal_password' => $this->account->send_portal_password ? (bool) $this->account->send_portal_password : false, 'recurring_number_prefix' => $this->account->recurring_invoice_number_prefix ? $this->account->recurring_invoice_number_prefix : 'R', 'enable_client_portal' => $this->account->enable_client_portal ? (bool) $this->account->enable_client_portal : false, diff --git a/database/migrations/2021_06_22_234707_add_forward_url_for_v5.php b/database/migrations/2021_06_22_234707_add_forward_url_for_v5.php index 718c7e31d067..7b033cb6ad94 100644 --- a/database/migrations/2021_06_22_234707_add_forward_url_for_v5.php +++ b/database/migrations/2021_06_22_234707_add_forward_url_for_v5.php @@ -15,6 +15,7 @@ class AddForwardUrlForV5 extends Migration { Schema::table('accounts', function ($table) { $table->text('forward_url_for_v5')->default(''); + $table->boolean('is_disabled')->default(false); }); } diff --git a/resources/views/accounts/management.blade.php b/resources/views/accounts/management.blade.php index a72f4ccf8681..9acb3c80d7f1 100644 --- a/resources/views/accounts/management.blade.php +++ b/resources/views/accounts/management.blade.php @@ -277,7 +277,8 @@