mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 04:14:34 -04:00
Checks for same client prior to attempted merge
This commit is contained in:
parent
2dd1dd6da6
commit
0e5aa5e26e
@ -328,9 +328,12 @@ class ClientController extends BaseController
|
|||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$m_client) {
|
if (!$m_client) {
|
||||||
return response()->json(['message' => "Client not found"]);
|
return response()->json(['message' => "Client not found"], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($m_client->id == $client->id)
|
||||||
|
return response()->json(['message' => "Attempting to merge the same client is not possible."], 400);
|
||||||
|
|
||||||
$merged_client = $client->service()->merge($m_client)->save();
|
$merged_client = $client->service()->merge($m_client)->save();
|
||||||
|
|
||||||
return $this->itemResponse($merged_client);
|
return $this->itemResponse($merged_client);
|
||||||
|
@ -77,9 +77,6 @@ class ProjectTransformer extends EntityTransformer
|
|||||||
{
|
{
|
||||||
$transformer = new InvoiceTransformer($this->serializer);
|
$transformer = new InvoiceTransformer($this->serializer);
|
||||||
|
|
||||||
if(!$project->invoices)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return $this->includeCollection($project->invoices, $transformer, Invoice::class);
|
return $this->includeCollection($project->invoices, $transformer, Invoice::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +84,6 @@ class ProjectTransformer extends EntityTransformer
|
|||||||
{
|
{
|
||||||
$transformer = new ExpenseTransformer($this->serializer);
|
$transformer = new ExpenseTransformer($this->serializer);
|
||||||
|
|
||||||
if(!$project->expenses) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->includeCollection($project->expenses, $transformer, Expense::class);
|
return $this->includeCollection($project->expenses, $transformer, Expense::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,14 +91,9 @@ class ProjectTransformer extends EntityTransformer
|
|||||||
{
|
{
|
||||||
$transformer = new QuoteTransformer($this->serializer);
|
$transformer = new QuoteTransformer($this->serializer);
|
||||||
|
|
||||||
if(!$project->quotes) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->includeCollection($project->quotes, $transformer, Quote::class);
|
return $this->includeCollection($project->quotes, $transformer, Quote::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function transform(Project $project)
|
public function transform(Project $project)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -47,6 +47,24 @@ class ProjectApiTest extends TestCase
|
|||||||
Model::reguard();
|
Model::reguard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProjectIncludesZeroCount()
|
||||||
|
{
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->putJson("/api/v1/projects/{$this->project->hashed_id}?include=expenses,invoices,quotes");
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
|
|
||||||
|
$this->assertEquals(0, count($arr['data']['invoices']));
|
||||||
|
$this->assertEquals(0, count($arr['data']['expenses']));
|
||||||
|
$this->assertEquals(0, count($arr['data']['quotes']));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function testProjectIncludes()
|
public function testProjectIncludes()
|
||||||
{
|
{
|
||||||
$i = Invoice::factory()->create([
|
$i = Invoice::factory()->create([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user