diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index ce5eaa1d72d6..6eb6df367e71 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -1,6 +1,7 @@ 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); diff --git a/app/Http/routes.php b/app/Http/routes.php index 768c9c3d3d4c..bfeed103a99a 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -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');