From 7d268604b788bf439c045d01b5c63d353edc9ddc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 9 Feb 2021 07:59:40 +1100 Subject: [PATCH] Fixes for quote status --- app/Traits/GenerateMigrationResources.php | 30 ++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 0c82f23a3daa..b1dfadaecf89 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -749,6 +749,34 @@ info("get company"); } + private function transformQuoteStatusId($quote) + { + if(!$quote->is_public) + return 1; + + if($quote->quote_invoice_id) + return 4; + + switch ($quote->invoice_status_id) { + case 1: + return 1; + break; + case 2: + return 2; + break; + case 3: + return 2; + break; + case 4: + return 3; + break; + + default: + return 2; + break; + } + } + /* define('INVOICE_STATUS_DRAFT', 1); define('INVOICE_STATUS_SENT', 2); @@ -918,7 +946,7 @@ info("get company"); 'client_id' => $quote->client_id, 'user_id' => $quote->user_id, 'company_id' => $quote->account_id, - 'status_id' => $quote->invoice_status_id, + 'status_id' => $this->transformQuoteStatusId($quote), 'design_id' => $this->getDesignId($quote->invoice_design_id), 'number' => $quote->invoice_number, 'discount' => $quote->discount,