From b4afd1419edcdceec530ed44e03596e7a8ff6bd1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 17 Apr 2021 16:51:24 +1000 Subject: [PATCH 1/5] Update API definitions --- app/Http/Controllers/TaskController.php | 51 +++++++++++++++++++++---- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index 642e1822f966..0447b2f63868 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -582,12 +582,47 @@ class TaskController extends BaseController } + + /** + * Store a newly created resource in storage. + * + * @param StoreTaskRequest $request + * @return Response + * + * + * + * @OA\Post( + * path="/api/v1/tasks/stort", + * operationId="sortTasks", + * tags={"tasks"}, + * summary="Sort tasks on KanBan", + * description="Sorts tasks after drag and drop on the KanBan.", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Response( + * response=200, + * description="Returns an Ok, 200 HTTP status", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + */ public function sort(SortTaskRequest $request) { - // : {"status_ids": - // ["VolejYWdjN","wMvbmqpbYA","OpnelRlbKB","Wpmbk2xazJ"], - // "task_ids":{"VolejYWdjN": - // ["xYRdG7dDzO","q9wdLwbjPX","4w9aAOdvMR","mxkazYeJ0P","WJxbojagwO","oBDbDxbl2E"],"wMvbmqpbYA":["4openRe7Az","1YQdJ2dOGp"],"OpnelRlbKB":["X46dBXa79j"],"Wpmbk2xazJ":["k8mep2bMyJ","JX7ax9byv4"]}} $task_statuses = $request->input('status_ids'); $tasks = $request->input('task_ids'); @@ -608,17 +643,19 @@ class TaskController extends BaseController $sort_status_id = $this->decodePrimaryKey($key); - nlog($task_list); + // nlog($task_list); foreach ($task_list as $key => $task) { - nlog($task); + // nlog($task); + $task_record = Task::where('id', $this->decodePrimaryKey($task)) ->where('company_id', auth()->user()->company()->id) ->first(); - nlog($task_record->id); + // nlog($task_record->id); + $task_record->status_order = $key; $task_record->status_id = $sort_status_id; $task_record->save(); From d47a0e1392052aa219c66d80c064d92a7e443f0c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 18 Apr 2021 07:06:12 +1000 Subject: [PATCH 2/5] Small fixes --- app/Console/Kernel.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2cf0371b23e4..ff73d173352f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -68,6 +68,11 @@ class Kernel extends ConsoleKernel } + if(config('queue.default') && Ninja::isSelfHost()) { + $schedule->command('queue:work')->everyMinute()->withoutOverlapping(); + $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping(); + } + } /** From 6eaff79544104b771c19f66992b7c29546052164 Mon Sep 17 00:00:00 2001 From: = Date: Sun, 18 Apr 2021 09:04:40 +1000 Subject: [PATCH 3/5] Remove taxes from demo data set --- app/Console/Commands/DemoMode.php | 120 +++++++++++++++--------------- app/Factory/TaskStatusFactory.php | 1 + 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index a029056be74a..5796512f4be2 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -388,20 +388,20 @@ class DemoMode extends Command $invoice->line_items = $this->buildLineItems(rand(1, 10)); $invoice->uses_inclusive_taxes = false; - if (rand(0, 1)) { - $invoice->tax_name1 = 'GST'; - $invoice->tax_rate1 = 10.00; - } + // if (rand(0, 1)) { + // $invoice->tax_name1 = 'GST'; + // $invoice->tax_rate1 = 10.00; + // } - if (rand(0, 1)) { - $invoice->tax_name2 = 'VAT'; - $invoice->tax_rate2 = 17.50; - } + // if (rand(0, 1)) { + // $invoice->tax_name2 = 'VAT'; + // $invoice->tax_rate2 = 17.50; + // } - if (rand(0, 1)) { - $invoice->tax_name3 = 'CA Sales Tax'; - $invoice->tax_rate3 = 5; - } + // if (rand(0, 1)) { + // $invoice->tax_name3 = 'CA Sales Tax'; + // $invoice->tax_rate3 = 5; + // } // $invoice->custom_value1 = $faker->date; // $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no'; @@ -455,20 +455,20 @@ class DemoMode extends Command $invoice->line_items = $this->buildLineItems(rand(1, 10)); $invoice->uses_inclusive_taxes = false; - if (rand(0, 1)) { - $invoice->tax_name1 = 'GST'; - $invoice->tax_rate1 = 10.00; - } + // if (rand(0, 1)) { + // $invoice->tax_name1 = 'GST'; + // $invoice->tax_rate1 = 10.00; + // } - if (rand(0, 1)) { - $invoice->tax_name2 = 'VAT'; - $invoice->tax_rate2 = 17.50; - } + // if (rand(0, 1)) { + // $invoice->tax_name2 = 'VAT'; + // $invoice->tax_rate2 = 17.50; + // } - if (rand(0, 1)) { - $invoice->tax_name3 = 'CA Sales Tax'; - $invoice->tax_rate3 = 5; - } + // if (rand(0, 1)) { + // $invoice->tax_name3 = 'CA Sales Tax'; + // $invoice->tax_rate3 = 5; + // } // $invoice->custom_value1 = $faker->date; // $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no'; @@ -504,20 +504,20 @@ class DemoMode extends Command $credit->line_items = $this->buildLineItems(rand(1, 10)); $credit->uses_inclusive_taxes = false; - if (rand(0, 1)) { - $credit->tax_name1 = 'GST'; - $credit->tax_rate1 = 10.00; - } + // if (rand(0, 1)) { + // $credit->tax_name1 = 'GST'; + // $credit->tax_rate1 = 10.00; + // } - if (rand(0, 1)) { - $credit->tax_name2 = 'VAT'; - $credit->tax_rate2 = 17.50; - } + // if (rand(0, 1)) { + // $credit->tax_name2 = 'VAT'; + // $credit->tax_rate2 = 17.50; + // } - if (rand(0, 1)) { - $credit->tax_name3 = 'CA Sales Tax'; - $credit->tax_rate3 = 5; - } + // if (rand(0, 1)) { + // $credit->tax_name3 = 'CA Sales Tax'; + // $credit->tax_rate3 = 5; + // } $credit->save(); @@ -559,20 +559,20 @@ class DemoMode extends Command $quote->line_items = $this->buildLineItems(rand(1, 10)); $quote->uses_inclusive_taxes = false; - if (rand(0, 1)) { - $quote->tax_name1 = 'GST'; - $quote->tax_rate1 = 10.00; - } + // if (rand(0, 1)) { + // $quote->tax_name1 = 'GST'; + // $quote->tax_rate1 = 10.00; + // } - if (rand(0, 1)) { - $quote->tax_name2 = 'VAT'; - $quote->tax_rate2 = 17.50; - } + // if (rand(0, 1)) { + // $quote->tax_name2 = 'VAT'; + // $quote->tax_rate2 = 17.50; + // } - if (rand(0, 1)) { - $quote->tax_name3 = 'CA Sales Tax'; - $quote->tax_rate3 = 5; - } + // if (rand(0, 1)) { + // $quote->tax_name3 = 'CA Sales Tax'; + // $quote->tax_rate3 = 5; + // } $quote->save(); @@ -600,20 +600,20 @@ class DemoMode extends Command $item->quantity = 1; //$item->cost = 10; - if (rand(0, 1)) { - $item->tax_name1 = 'GST'; - $item->tax_rate1 = 10.00; - } + // if (rand(0, 1)) { + // $item->tax_name1 = 'GST'; + // $item->tax_rate1 = 10.00; + // } - if (rand(0, 1)) { - $item->tax_name1 = 'VAT'; - $item->tax_rate1 = 17.50; - } + // if (rand(0, 1)) { + // $item->tax_name1 = 'VAT'; + // $item->tax_rate1 = 17.50; + // } - if (rand(0, 1)) { - $item->tax_name1 = 'Sales Tax'; - $item->tax_rate1 = 5; - } + // if (rand(0, 1)) { + // $item->tax_name1 = 'Sales Tax'; + // $item->tax_rate1 = 5; + // } $product = Product::all()->random(); diff --git a/app/Factory/TaskStatusFactory.php b/app/Factory/TaskStatusFactory.php index ffcff72af0dd..a9bd6ab7b404 100644 --- a/app/Factory/TaskStatusFactory.php +++ b/app/Factory/TaskStatusFactory.php @@ -22,6 +22,7 @@ class TaskStatusFactory $task_status->company_id = $company_id; $task_status->name = ''; $task_status->color = '#fff'; + $task_status->status_order = 9999; return $task_status; } From 3cfabd88d75aa289b58663b9011a47bc2f0a90ad Mon Sep 17 00:00:00 2001 From: = Date: Sun, 18 Apr 2021 19:50:06 +1000 Subject: [PATCH 4/5] Reset task statuses on delete/archive --- app/Console/Kernel.php | 2 +- app/Http/Controllers/TaskStatusController.php | 4 ++- app/Repositories/TaskStatusRepository.php | 30 +++++++++++++++++++ tests/Feature/TaskStatusApiTest.php | 17 +++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ff73d173352f..23a38601787b 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -68,7 +68,7 @@ class Kernel extends ConsoleKernel } - if(config('queue.default') && Ninja::isSelfHost()) { + if(config('queue.default') == 'database' && Ninja::isSelfHost()) { $schedule->command('queue:work')->everyMinute()->withoutOverlapping(); $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping(); } diff --git a/app/Http/Controllers/TaskStatusController.php b/app/Http/Controllers/TaskStatusController.php index 4934e0b5fa90..4751ee9d0d5a 100644 --- a/app/Http/Controllers/TaskStatusController.php +++ b/app/Http/Controllers/TaskStatusController.php @@ -8,6 +8,7 @@ use App\Http\Requests\TaskStatus\DestroyTaskStatusRequest; use App\Http\Requests\TaskStatus\ShowTaskStatusRequest; use App\Http\Requests\TaskStatus\StoreTaskStatusRequest; use App\Http\Requests\TaskStatus\UpdateTaskStatusRequest; +use App\Models\Task; use App\Models\TaskStatus; use App\Repositories\TaskStatusRepository; use App\Transformers\TaskStatusTransformer; @@ -398,8 +399,9 @@ class TaskStatusController extends BaseController */ public function destroy(DestroyTaskStatusRequest $request, TaskStatus $task_status) { - $task_status->delete(); + $this->task_status_repo->delete($task_status); + return $this->itemResponse($task_status->fresh()); } diff --git a/app/Repositories/TaskStatusRepository.php b/app/Repositories/TaskStatusRepository.php index 4ba2c6d63ff6..6448bac5c31b 100644 --- a/app/Repositories/TaskStatusRepository.php +++ b/app/Repositories/TaskStatusRepository.php @@ -11,9 +11,39 @@ namespace App\Repositories; +use App\Models\Task; + /** * Class for task status repository. */ class TaskStatusRepository extends BaseRepository { + + public function delete($task_status) + { + + Task::where('status_id', $task_status->id) + ->where('company_id', $task_status->company_id) + ->update(['status_id' => null]); + + + parent::delete($task_status); + + return $task_status; + + } + + public function archive($task_status) + { + + Task::where('status_id', $task_status->id) + ->where('company_id', $task_status->company_id) + ->update(['status_id' => null]); + + + parent::archive($task_status); + + return $task_status; + + } } diff --git a/tests/Feature/TaskStatusApiTest.php b/tests/Feature/TaskStatusApiTest.php index 7e37c2c61f55..c93b28d7e346 100644 --- a/tests/Feature/TaskStatusApiTest.php +++ b/tests/Feature/TaskStatusApiTest.php @@ -122,6 +122,23 @@ class TaskStatusApiTest extends TestCase $this->assertEquals(0, $arr['data'][0]['archived_at']); } + + public function testTaskStatusDeletedFromDELETEROute() + { + $data = [ + 'ids' => [$this->encodePrimaryKey($this->task_status->id)], + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->delete('/api/v1/task_statuses/'.$this->encodePrimaryKey($this->task_status->id)); + + $arr = $response->json(); + + $this->assertTrue($arr['data']['is_deleted']); + } + public function testTaskStatusDeleted() { $data = [ From 9b77789c8ad7811f572838e53e560944b14851e0 Mon Sep 17 00:00:00 2001 From: = Date: Sun, 18 Apr 2021 21:16:32 +1000 Subject: [PATCH 5/5] v5.1.47 --- VERSION.txt | 2 +- app/Services/Quote/ConvertQuote.php | 4 ++-- config/ninja.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index b3084435fbea..cfbc6d1a7105 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.1.46 \ No newline at end of file +5.1.47 \ No newline at end of file diff --git a/app/Services/Quote/ConvertQuote.php b/app/Services/Quote/ConvertQuote.php index b3b947ee40de..750597a314f3 100644 --- a/app/Services/Quote/ConvertQuote.php +++ b/app/Services/Quote/ConvertQuote.php @@ -34,9 +34,9 @@ class ConvertQuote public function run($quote) { $invoice = CloneQuoteToInvoiceFactory::create($quote, $quote->user_id); - + $invoice->design_id = $this->client->getSetting('invoice_design_id'); $invoice = $this->invoice_repo->save([], $invoice); - + $invoice->fresh(); $invoice->service() diff --git a/config/ninja.php b/config/ninja.php index bda3d8bb4114..36d401e99903 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', ''), - 'app_version' => '5.1.46', - 'app_tag' => '5.1.46-release', + 'app_version' => '5.1.47', + 'app_tag' => '5.1.47-release', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false),