mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #8040 from turbo124/master
Improve query efficiency for create invoice with client
This commit is contained in:
commit
1463544bdb
@ -219,6 +219,9 @@ class InvoiceController extends BaseController
|
|||||||
$clients = $clients->where('clients.user_id', '=', Auth::user()->id);
|
$clients = $clients->where('clients.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($clientPublicId != 0)
|
||||||
|
$clients->where('public_id', $clientPublicId);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'clients' => $clients->get(),
|
'clients' => $clients->get(),
|
||||||
'entityType' => $invoice->getEntityType(),
|
'entityType' => $invoice->getEntityType(),
|
||||||
|
@ -19,7 +19,7 @@ class MigrationLookup
|
|||||||
private string $migration_notification = 'The Invoice Ninja v4 platform is now disabled for free users. Please <a class="btn btn-primary btn-sm" href="/migration/start">Migrate Now</a> to the new Invoice Ninja v5 platform to remain as a free account.<br><br>
|
private string $migration_notification = 'The Invoice Ninja v4 platform is now disabled for free users. Please <a class="btn btn-primary btn-sm" href="/migration/start">Migrate Now</a> to the new Invoice Ninja v5 platform to remain as a free account.<br><br>
|
||||||
*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.';
|
*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. <a class="btn btn-primary btn-sm" href="/migration/start">Migrate Now</a>';
|
private string $silo = 'V4 is now disabled for your account. Please migrate. <a class="btn btn-primary btn-sm" href="/migration/start">Migrate Now</a> Upgrade to v5 and take advantage of our <a class="btn btn-danger btn-sm" href="https://invoicing.co/campaign/black_friday_2022">Black friday promo</a>';
|
||||||
|
|
||||||
public function handle(Request $request, Closure $next, $guard = 'user')
|
public function handle(Request $request, Closure $next, $guard = 'user')
|
||||||
{
|
{
|
||||||
|
@ -443,17 +443,25 @@ trait GenerateMigrationResources
|
|||||||
if(!Utils::isNinja())
|
if(!Utils::isNinja())
|
||||||
return $transformed;
|
return $transformed;
|
||||||
|
|
||||||
$ninja_client = Client::where('public_id', $this->account->id)->first();
|
$db = DB_NINJA_1;
|
||||||
|
$account_id = 20432;
|
||||||
|
|
||||||
|
if($this->account->id > 1000000){
|
||||||
|
$db = DB_NINJA_2;
|
||||||
|
$account_id = 1000002;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ninja_client = Client::on($db)->where('public_id', $this->account->id)->where('account_id', $account_id)->first();
|
||||||
|
|
||||||
if(!$ninja_client)
|
if(!$ninja_client)
|
||||||
return $transformed;
|
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;
|
$is_default = true;
|
||||||
|
|
||||||
if(count($agts) == 0) {
|
if(count($agts) == 0) {
|
||||||
$transformed[] = [
|
$transformed[] = [
|
||||||
'client' => $ninja_client
|
'client' => $ninja_client->toArray()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +472,7 @@ trait GenerateMigrationResources
|
|||||||
if(!$payment_method)
|
if(!$payment_method)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
|
$contact = Contact::on($db)->where('id', $payment_method->contact_id)->withTrashed()->first();
|
||||||
|
|
||||||
$transformed[] = [
|
$transformed[] = [
|
||||||
'id' => $payment_method->id,
|
'id' => $payment_method->id,
|
||||||
@ -476,7 +484,7 @@ trait GenerateMigrationResources
|
|||||||
'gateway_type_id' => $payment_method->payment_type->gateway_type_id,
|
'gateway_type_id' => $payment_method->payment_type->gateway_type_id,
|
||||||
'is_default' => $is_default,
|
'is_default' => $is_default,
|
||||||
'meta' => $this->convertMeta($payment_method),
|
'meta' => $this->convertMeta($payment_method),
|
||||||
'client' => $contact->client->toArray(),
|
'client' => $ninja_client->toArray(),
|
||||||
'contacts' => $contact->client->contacts->toArray(),
|
'contacts' => $contact->client->contacts->toArray(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -1432,7 +1440,9 @@ trait GenerateMigrationResources
|
|||||||
case PAYMENT_TYPE_BITCOIN:
|
case PAYMENT_TYPE_BITCOIN:
|
||||||
return 31;
|
return 31;
|
||||||
case 2:
|
case 2:
|
||||||
return 4;
|
return 1;
|
||||||
|
case 3:
|
||||||
|
return 2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $payment_type_id;
|
return $payment_type_id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user