From 4799b2e86c11cc6a933750e9e894a1405186f409 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 27 Jan 2016 12:56:24 +1100 Subject: [PATCH] Added ability to convert a quote to an invoice through the API --- app/Http/Controllers/InvoiceApiController.php | 9 +++++++++ app/Http/routes.php | 1 + 2 files changed, 10 insertions(+) diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index a168870dedfc..84ca80529d56 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 4bd84629f0c6..27ca4a21afc2 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -329,6 +329,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);