diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index a168870ded..84ca80529d 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -303,6 +303,15 @@ class InvoiceApiController extends BaseAPIController return $this->response($data); } + else if ($request->action == ACTION_CONVERT) { + $quote = Invoice::scope($publicId)->firstOrFail(); + $invoice = $this->invoiceRepo->cloneInvoice($quote, $quote->id); + + $transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer')); + $data = $this->createItem($invoice, $transformer, 'invoice'); + + return $this->response($data); + } $data = $request->input(); $data['public_id'] = $publicId; diff --git a/app/Http/routes.php b/app/Http/routes.php index f8f3c75266..e4fbfc7a93 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -333,6 +333,7 @@ if (!defined('CONTACT_EMAIL')) { define('ACTION_RESTORE', 'restore'); define('ACTION_ARCHIVE', 'archive'); + define('ACTION_CONVERT', 'convert'); define('ACTION_DELETE', 'delete'); define('ACTIVITY_TYPE_CREATE_CLIENT', 1);