1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fix for cloning invoices from API

This commit is contained in:
David Bomba 2016-05-02 19:40:54 +10:00
parent afae9e8289
commit 7cac31e7a6
2 changed files with 11 additions and 0 deletions

View File

@ -1,6 +1,7 @@
<?php namespace App\Http\Controllers;
use Auth;
use Guzzle\Tests\Common\Cache\NullCacheAdapterTest;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Request;
use Utils;
@ -357,7 +358,16 @@ class InvoiceApiController extends BaseAPIController
return $this->response($data);
}
else if ($request->action == ACTION_CLONE) {
$invoice = Invoice::scope($publicId)->firstOrFail();
$clonedInvoice = $this->invoiceRepo->cloneInvoice($invoice, null);
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($clonedInvoice, $transformer, 'invoice');
return $this->response($data);
}
$data = $request->input();
$data['public_id'] = $publicId;
$this->invoiceService->save($data);

View File

@ -380,6 +380,7 @@ if (!defined('CONTACT_EMAIL')) {
define('ACTION_RESTORE', 'restore');
define('ACTION_ARCHIVE', 'archive');
define('ACTION_CLONE', 'clone');
define('ACTION_CONVERT', 'convert');
define('ACTION_DELETE', 'delete');