1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 06:32:40 +01:00

Fix for including ALL relations on the refresh route if updated_at is provided

This commit is contained in:
David Bomba 2020-07-21 21:19:21 +10:00
parent 4bee89263a
commit 0d8d793a4c
4 changed files with 32 additions and 25 deletions

View File

@ -137,36 +137,39 @@ class BaseController extends Controller
$transformer = new $this->entity_transformer(Input::get('serializer')); $transformer = new $this->entity_transformer(Input::get('serializer'));
$includes = $transformer->getDefaultIncludes(); $includes = $transformer->getDefaultIncludes();
$includes = $this->getRequestIncludes($includes); $includes = $this->getRequestIncludes($includes);
info(print_r($includes,1));
$updated_at = request()->has('updated_at') ? request()->input('updated_at') : 0; $updated_at = request()->has('updated_at') ? request()->input('updated_at') : 0;
$updated_at = date('Y-m-d H:i:s', $updated_at); $updated_at = date('Y-m-d H:i:s', $updated_at);
//info($updated_at);
$query->with( $query->with(
[ [
'company' => function ($query) use($updated_at){$query->where('updated_at', '>=', 0);}, 'company' => function ($query) use($updated_at){$query->where('updated_at', '>=', 0);},
'company.activities' => function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);}, 'company.activities' => function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.clients' =>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.clients' =>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.tax_rates'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.tax_rates'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.groups'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.groups'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.company_gateways'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.company_gateways'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.clients.contacts'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.clients.contacts'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.products'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.products'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.invoices.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.invoices.invitations.contact'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.invoices.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.invoices.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.invoices.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.invoices.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.payments.paymentables'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.payments.paymentables'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.quotes.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.quotes.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.quotes.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.quotes.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.credits.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.credits.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.credits'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.credits'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.payment_terms'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.payment_terms'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.vendors'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.vendors'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.expenses'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.expenses'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.tasks'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.tasks'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.projects'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.projects'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.designs'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);}, 'company.designs'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
] ]
); );
@ -311,6 +314,7 @@ class BaseController extends Controller
'company.quotes.invitations.contact', 'company.quotes.invitations.contact',
'company.quotes.invitations.company', 'company.quotes.invitations.company',
'company.quotes.documents', 'company.quotes.documents',
'company.credits.invitations.contact',
'company.credits.invitations.company', 'company.credits.invitations.company',
'company.credits.documents', 'company.credits.documents',
'company.payment_terms.company', 'company.payment_terms.company',
@ -340,7 +344,7 @@ class BaseController extends Controller
* Thresholds for displaying large account on first load * Thresholds for displaying large account on first load
*/ */
if (request()->has('first_load') && request()->input('first_load') == 'true') { if (request()->has('first_load') && request()->input('first_load') == 'true') {
if (auth()->user()->getCompany()->is_large) { if (auth()->user()->getCompany()->is_large && request()->missing('updated_at')) {
$data = $mini_load; $data = $mini_load;
} else { } else {
$data = $first_load; $data = $first_load;

View File

@ -51,7 +51,7 @@ class QueryLogging
// Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); // Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time);
//if($count > 10) //if($count > 10)
// Log::info($queries); Log::info($queries);
} }
} }

View File

@ -39,6 +39,8 @@ class StorePaymentRequest extends Request
{ {
$input = $this->all(); $input = $this->all();
info(print_r($input,1));
$invoices_total = 0; $invoices_total = 0;
$credits_total = 0; $credits_total = 0;

View File

@ -78,10 +78,11 @@ class ValidCreditsRules implements Rule
} }
if(count($this->input['credits']) >=1 && count($this->input['invoices']) == 0) if(count($this->input['credits']) >=1 && count($this->input['invoices']) == 0){
$this->error_msg = "You must have an invoice set when using a credit"; $this->error_msg = "You must have an invoice set when using a credit";
return false; return false;
}
return true; return true;
} }