mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
8b9104e9f1
@ -132,52 +132,90 @@ class BaseController extends Controller
|
|||||||
|
|
||||||
protected function refreshResponse($query)
|
protected function refreshResponse($query)
|
||||||
{
|
{
|
||||||
$this->buildManager();
|
|
||||||
|
// $this->manager->parseIncludes($includes);
|
||||||
|
|
||||||
|
$this->serializer = request()->input('serializer') ?: EntityTransformer::API_SERIALIZER_ARRAY;
|
||||||
|
|
||||||
|
if ($this->serializer === EntityTransformer::API_SERIALIZER_JSON) {
|
||||||
|
$this->manager->setSerializer(new JsonApiSerializer());
|
||||||
|
} else {
|
||||||
|
$this->manager->setSerializer(new ArraySerializer());
|
||||||
|
}
|
||||||
|
|
||||||
$transformer = new $this->entity_transformer(Input::get('serializer'));
|
$transformer = new $this->entity_transformer(Input::get('serializer'));
|
||||||
|
|
||||||
$includes = $transformer->getDefaultIncludes();
|
|
||||||
$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->whereNotNull('updated_at');},
|
'company' => function ($query) use($updated_at){
|
||||||
'company.clients' =>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
$query->whereNotNull('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.clients'=>function ($query) use($updated_at){
|
||||||
'company.company_gateways'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
$query->where('clients.updated_at', '>=', $updated_at)->with('contacts');
|
||||||
'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.tax_rates'=>function ($query) use($updated_at){
|
||||||
'company.invoices'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $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.groups'=>function ($query) use($updated_at){
|
||||||
'company.invoices.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
$query->where('updated_at', '>=', $updated_at);
|
||||||
'company.payments'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
},
|
||||||
'company.quotes.invitations.contact'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
'company.company_gateways'=>function ($query) use($updated_at){
|
||||||
'company.quotes.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
$query->where('updated_at', '>=', $updated_at)->with('gateway');
|
||||||
'company.quotes.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
},
|
||||||
'company.credits.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
'company.products'=>function ($query) use($updated_at){
|
||||||
'company.credits.invitations.contact'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
$query->where('updated_at', '>=', $updated_at);
|
||||||
'company.credits.invitations'=>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.invoices'=>function ($query) use($updated_at){
|
||||||
'company.vendors.contacts'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
$query->where('updated_at', '>=', $updated_at)->with('invitations','documents');
|
||||||
'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.payments'=>function ($query) use($updated_at){
|
||||||
'company.projects'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
$query->where('updated_at', '>=', $updated_at)->with('paymentables');
|
||||||
'company.designs'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
},
|
||||||
|
'company.quotes'=>function ($query) use($updated_at){
|
||||||
|
$query->where('updated_at', '>=', $updated_at)->with('invitations','documents');
|
||||||
|
},
|
||||||
|
'company.credits'=>function ($query) use($updated_at){
|
||||||
|
$query->where('updated_at', '>=', $updated_at)->with('invitations','documents');
|
||||||
|
},
|
||||||
|
'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)->with('contacts');
|
||||||
|
},
|
||||||
|
'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.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);
|
||||||
|
},
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = $this->createCollection($query, $transformer, $this->entity_type);
|
|
||||||
|
|
||||||
return $this->response($data);
|
if (is_a($query, "Illuminate\Database\Eloquent\Builder")) {
|
||||||
|
$limit = Input::get('per_page', 20);
|
||||||
|
|
||||||
|
$paginator = $query->paginate($limit);
|
||||||
|
$query = $paginator->getCollection();
|
||||||
|
$resource = new Collection($query, $transformer, $this->entity_type);
|
||||||
|
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||||
|
} else {
|
||||||
|
$resource = new Collection($query, $transformer, $this->entity_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response($this->manager->createData($resource)->toArray());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function listResponse($query)
|
protected function listResponse($query)
|
||||||
|
@ -50,7 +50,7 @@ class QueryLogging
|
|||||||
|
|
||||||
Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time);
|
Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time);
|
||||||
|
|
||||||
// if($count > 100)
|
// if($count > 700)
|
||||||
// Log::info($queries);
|
// Log::info($queries);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,6 @@ class BaseRepository
|
|||||||
$tmp_data = $data;
|
$tmp_data = $data;
|
||||||
|
|
||||||
/* We need to unset some variable as we sometimes unguard the model */
|
/* We need to unset some variable as we sometimes unguard the model */
|
||||||
|
|
||||||
if (isset($tmp_data['invitations'])) {
|
if (isset($tmp_data['invitations'])) {
|
||||||
unset($tmp_data['invitations']);
|
unset($tmp_data['invitations']);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ class CreateInvitations extends AbstractService
|
|||||||
$invitation = InvoiceInvitation::whereCompanyId($this->invoice->company_id)
|
$invitation = InvoiceInvitation::whereCompanyId($this->invoice->company_id)
|
||||||
->whereClientContactId($contact->id)
|
->whereClientContactId($contact->id)
|
||||||
->whereInvoiceId($this->invoice->id)
|
->whereInvoiceId($this->invoice->id)
|
||||||
|
->withTrashed()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$invitation && $contact->send_email) {
|
if (!$invitation && $contact->send_email) {
|
||||||
|
@ -10,7 +10,7 @@ return [
|
|||||||
'app_name' => env('APP_NAME'),
|
'app_name' => env('APP_NAME'),
|
||||||
'app_env' => env('APP_ENV', 'selfhosted'),
|
'app_env' => env('APP_ENV', 'selfhosted'),
|
||||||
'require_https' => env('REQUIRE_HTTPS', true),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => env('APP_URL', ''),
|
'app_url' => rtrim(env('APP_URL', ''), '/') . '/',
|
||||||
'app_domain' => env('APP_DOMAIN', ''),
|
'app_domain' => env('APP_DOMAIN', ''),
|
||||||
'app_version' => '5.0.12',
|
'app_version' => '5.0.12',
|
||||||
'minimum_client_version' => '5.0.12',
|
'minimum_client_version' => '5.0.12',
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
<script>
|
<script>
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
window.addEventListener('load', function () {
|
window.addEventListener('load', function () {
|
||||||
navigator.serviceWorker.register('/flutter_service_worker.js?v={{sha1(time())}}');
|
navigator.serviceWorker.register('/flutter_service_worker.js?v={{ md5(public_path('flutter_service_worker.js')) }}');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +125,15 @@ class InvoiceTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->post('/api/v1/invoices/', $invoice)
|
])->post('/api/v1/invoices/', $invoice)
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
|
|
||||||
|
//test that the same request should produce a validation error due
|
||||||
|
//to duplicate number being used.
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/invoices/', $invoice)
|
||||||
|
->assertStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteInvoice()
|
public function testDeleteInvoice()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user