mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 22:04:35 -04:00
Improve eager loading - first load
This commit is contained in:
parent
1aed5b1850
commit
708db5a991
@ -303,7 +303,7 @@ class CheckData extends Command
|
|||||||
|
|
||||||
if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) {
|
if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) {
|
||||||
$wrong_balances++;
|
$wrong_balances++;
|
||||||
$this->logMessage($client->present()->name.' - '.$client->id." - balances do not match Invoice Balance = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}");
|
$this->logMessage($client->present()->name.' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
}
|
}
|
||||||
@ -352,11 +352,12 @@ class CheckData extends Command
|
|||||||
$total_credit = $invoice->credits->sum('amount');
|
$total_credit = $invoice->credits->sum('amount');
|
||||||
|
|
||||||
$total_paid = $total_amount - $total_refund;
|
$total_paid = $total_amount - $total_refund;
|
||||||
|
$calculated_paid_amount = $invoice->amount - $invoice->balance - $total_credit;
|
||||||
|
|
||||||
if ($total_paid != ($invoice->amount - $invoice->balance - $total_credit)) {
|
if ((string)$total_paid != (string)($invoice->amount - $invoice->balance - $total_credit)) {
|
||||||
$wrong_balances++;
|
$wrong_balances++;
|
||||||
|
|
||||||
$this->logMessage($client->present()->name.' - '.$client->id." - balances do not match Invoice Amount = {$invoice->amount} - Invoice Balance = {$invoice->balance} Total paid = {$total_paid}");
|
$this->logMessage($client->present()->name.' - '.$client->id." - Total Amount = {$total_amount} != Calculated Total = {$calculated_paid_amount} - Total Refund = {$total_refund} Total credit = {$total_credit}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ class BaseController extends Controller
|
|||||||
private $first_load = [
|
private $first_load = [
|
||||||
'account',
|
'account',
|
||||||
'user.company_user',
|
'user.company_user',
|
||||||
'token',
|
'token.company_user',
|
||||||
'company.activities',
|
'company.activities',
|
||||||
'company.users.company_user',
|
'company.users.company_user',
|
||||||
'company.tax_rates',
|
'company.tax_rates',
|
||||||
@ -81,6 +81,7 @@ class BaseController extends Controller
|
|||||||
'company.recurring_invoices.invitations.company',
|
'company.recurring_invoices.invitations.company',
|
||||||
'company.recurring_invoices.documents',
|
'company.recurring_invoices.documents',
|
||||||
'company.payments.paymentables',
|
'company.payments.paymentables',
|
||||||
|
'company.payments.documents',
|
||||||
'company.quotes.invitations.contact',
|
'company.quotes.invitations.contact',
|
||||||
'company.quotes.invitations.company',
|
'company.quotes.invitations.company',
|
||||||
'company.quotes.documents',
|
'company.quotes.documents',
|
||||||
@ -89,10 +90,10 @@ class BaseController extends Controller
|
|||||||
'company.credits.documents',
|
'company.credits.documents',
|
||||||
'company.payment_terms.company',
|
'company.payment_terms.company',
|
||||||
'company.vendors.contacts',
|
'company.vendors.contacts',
|
||||||
'company.expenses',
|
'company.expenses.documents',
|
||||||
'company.tasks',
|
'company.tasks.documents',
|
||||||
'company.projects',
|
'company.projects.documents',
|
||||||
'company.designs',
|
'company.designs.company',
|
||||||
'company.documents',
|
'company.documents',
|
||||||
'company.webhooks',
|
'company.webhooks',
|
||||||
'company.tokens_hashed',
|
'company.tokens_hashed',
|
||||||
@ -255,7 +256,7 @@ class BaseController extends Controller
|
|||||||
$query->where('updated_at', '>=', $updated_at);
|
$query->where('updated_at', '>=', $updated_at);
|
||||||
},
|
},
|
||||||
'company.designs'=> function ($query) use ($updated_at) {
|
'company.designs'=> function ($query) use ($updated_at) {
|
||||||
$query->where('updated_at', '>=', $updated_at);
|
$query->where('updated_at', '>=', $updated_at)->with('company');
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -52,7 +52,7 @@ class QueryLogging
|
|||||||
|
|
||||||
Log::info($request->method().' - '.$request->url().": $count queries - ".$time);
|
Log::info($request->method().' - '.$request->url().": $count queries - ".$time);
|
||||||
|
|
||||||
// if($count > 50)
|
// if($count > 50)
|
||||||
// Log::info($queries);
|
// Log::info($queries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,11 +105,10 @@ class Import implements ShouldQueue
|
|||||||
'invoices',
|
'invoices',
|
||||||
'recurring_invoices',
|
'recurring_invoices',
|
||||||
'quotes',
|
'quotes',
|
||||||
'payments',
|
|
||||||
'credits',
|
'credits',
|
||||||
|
'payments',
|
||||||
'company_gateways',
|
'company_gateways',
|
||||||
'client_gateway_tokens',
|
'client_gateway_tokens',
|
||||||
|
|
||||||
// //'documents',
|
// //'documents',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -722,7 +721,12 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
if (isset($modified['invoices'])) {
|
if (isset($modified['invoices'])) {
|
||||||
foreach ($modified['invoices'] as $key => $invoice) {
|
foreach ($modified['invoices'] as $key => $invoice) {
|
||||||
$modified['invoices'][$key]['invoice_id'] = $this->transformId('invoices', $invoice['invoice_id']);
|
|
||||||
|
if($modified['amount'] >= 0)
|
||||||
|
$modified['invoices'][$key]['invoice_id'] = $this->transformId('invoices', $invoice['invoice_id']);
|
||||||
|
else
|
||||||
|
$modified['credits'][$key]['credit_id'] = $this->transformId('credits', $invoice['invoice_id']);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ class PaymentMigrationRepository extends BaseRepository
|
|||||||
|
|
||||||
$invoice_totals = 0;
|
$invoice_totals = 0;
|
||||||
$credit_totals = 0;
|
$credit_totals = 0;
|
||||||
|
$invoices = false;
|
||||||
|
|
||||||
/*Iterate through invoices and apply payments*/
|
/*Iterate through invoices and apply payments*/
|
||||||
if (array_key_exists('invoices', $data) && is_array($data['invoices']) && count($data['invoices']) > 0) {
|
if (array_key_exists('invoices', $data) && is_array($data['invoices']) && count($data['invoices']) > 0) {
|
||||||
@ -129,7 +130,7 @@ class PaymentMigrationRepository extends BaseRepository
|
|||||||
$this->activity_repo->save($fields, $invoice, Ninja::eventVars());
|
$this->activity_repo->save($fields, $invoice, Ninja::eventVars());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($invoices) == 0) {
|
if ($invoices && count($invoices) == 0) {
|
||||||
$this->activity_repo->save($fields, $payment, Ninja::eventVars());
|
$this->activity_repo->save($fields, $payment, Ninja::eventVars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user