From 7d7f05b5ee34b9157ceb456a61184f7a4b94d729 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 11 Jul 2022 09:11:59 +1000 Subject: [PATCH 1/5] Minor fixes for hosted --- app/Traits/GenerateMigrationResources.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index e17c34a1c9..0dc64825db 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -443,12 +443,17 @@ trait GenerateMigrationResources if(!Utils::isNinja()) return $transformed; - $ninja_client = Client::where('public_id', $this->account->id)->first(); + $db = DB_NINJA_1; + + if($this->account->id > 1000000) + $db = DB_NINJA_2; + + $ninja_client = Client::on($db)->where('public_id', $this->account->id)->first(); if(!$ninja_client) return $transformed; - $agts = AccountGatewayToken::where('client_id', $ninja_client->id)->get(); + $agts = AccountGatewayToken::on($db)->where('client_id', $ninja_client->id)->get(); $is_default = true; if(count($agts) == 0) { @@ -464,7 +469,7 @@ trait GenerateMigrationResources if(!$payment_method) continue; - $contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first(); + $contact = Contact::on($db)->where('id', $payment_method->contact_id)->withTrashed()->first(); $transformed[] = [ 'id' => $payment_method->id, From 7d1c236c27d53b00972bd04a0a0b97340d123159 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 12 Jul 2022 08:37:41 +1000 Subject: [PATCH 2/5] Fixes for wrong payment types --- app/Traits/GenerateMigrationResources.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 0dc64825db..49b8cebfbf 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -1437,7 +1437,7 @@ trait GenerateMigrationResources case PAYMENT_TYPE_BITCOIN: return 31; case 2: - return 4; + return 1; default: return $payment_type_id; From 9b74091119a1d9e138782b06eef7c6c1b6d754ae Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 16 Jul 2022 16:15:41 +1000 Subject: [PATCH 3/5] Fixes for ninja clients --- app/Traits/GenerateMigrationResources.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 49b8cebfbf..1061e94a52 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -444,11 +444,14 @@ trait GenerateMigrationResources return $transformed; $db = DB_NINJA_1; + $account_id = 20432; - if($this->account->id > 1000000) + if($this->account->id > 1000000){ $db = DB_NINJA_2; + $account_id = 1000002; + } - $ninja_client = Client::on($db)->where('public_id', $this->account->id)->first(); + $ninja_client = Client::on($db)->where('public_id', $this->account->id)->where('account_id', $account_id)->first(); if(!$ninja_client) return $transformed; @@ -458,7 +461,7 @@ trait GenerateMigrationResources if(count($agts) == 0) { $transformed[] = [ - 'client' => $ninja_client + 'client' => $ninja_client->toArray() ]; } @@ -481,7 +484,7 @@ trait GenerateMigrationResources 'gateway_type_id' => $payment_method->payment_type->gateway_type_id, 'is_default' => $is_default, 'meta' => $this->convertMeta($payment_method), - 'client' => $contact->client->toArray(), + 'client' => $ninja_client->toArray(), 'contacts' => $contact->client->contacts->toArray(), ]; } From 69c0b5e530eabc78b00b4ca71d5bf4c85fe1d249 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Nov 2022 11:31:06 +1100 Subject: [PATCH 4/5] Minor updates --- app/Http/Middleware/MigrationLookup.php | 2 +- app/Traits/GenerateMigrationResources.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Middleware/MigrationLookup.php b/app/Http/Middleware/MigrationLookup.php index 6fcce46d16..4f1d941ea7 100644 --- a/app/Http/Middleware/MigrationLookup.php +++ b/app/Http/Middleware/MigrationLookup.php @@ -19,7 +19,7 @@ class MigrationLookup private string $migration_notification = 'The Invoice Ninja v4 platform is now disabled for free users. Please Migrate Now to the new Invoice Ninja v5 platform to remain as a free account.

*Not ready for v5? Upgrade to Pro or Enterprise to remain on v4. *Please note that the v4 platform will be "sunset" in November 2022.'; - private string $silo = 'V4 is now disabled for your account. Please migrate. Migrate Now'; + private string $silo = 'V4 is now disabled for your account. Please migrate. Migrate Now Upgrade to v5 and take advantage of our Black friday promo'; public function handle(Request $request, Closure $next, $guard = 'user') { diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 1061e94a52..def63b4ac7 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -1441,6 +1441,8 @@ trait GenerateMigrationResources return 31; case 2: return 1; + case 3: + return 2; default: return $payment_type_id; From 59de0216ac8c4cb8610b40eab56916ccb8326c70 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 6 Dec 2022 17:45:28 +1100 Subject: [PATCH 5/5] improve query efficiency --- app/Http/Controllers/InvoiceController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index d21ae1c13f..53fec504fa 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -219,6 +219,9 @@ class InvoiceController extends BaseController $clients = $clients->where('clients.user_id', '=', Auth::user()->id); } + if($clientPublicId != 0) + $clients->where('public_id', $clientPublicId); + $data = [ 'clients' => $clients->get(), 'entityType' => $invoice->getEntityType(),