From ea4795e5c861616064c9ceae521aefedd60769c2 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 11 Feb 2024 09:53:09 +0000 Subject: [PATCH] Revert "Merge branch 'dillon/51-vue-polling-experimental-2' into 'master'" This reverts merge request !152 --- .../JobResourceNotFoundException.php | 11 - .../Abstracts/AbstractControllerLogic.php | 15 +- .../General/Eloquent/AbstractFetchRecord.php | 14 +- .../General/Eloquent/AbstractGetRecord.php | 26 +-- .../General/Eloquent/AbstractListRecord.php | 14 +- .../General/Eloquent/Filters/JobId.php | 20 -- .../Eloquent/Filters/OrderByIdDesc.php | 20 -- .../Eloquent/Filters/RequestSignature.php | 19 -- .../Eloquent/Filters/ResultNotNull.php | 18 -- app/Classes/General/Helper.php | 24 -- app/Classes/Jobs/ListBookingsJob.php | 52 ----- app/Classes/Jobs/ListDocumentsJob.php | 63 ------ app/Classes/Jobs/ListTransactionsJob.php | 52 ----- .../ControllersLogic/ListBookingJobLogic.php | 75 ------ .../Processors/ListBookingsJobProcessor.php | 46 ---- .../ControllersLogic/ListDocumentJobLogic.php | 75 ------ .../Processors/ListDocumentsJobProcessor.php | 47 ---- .../ControllersLogic/FetchJobResultLogic.php | 51 ----- .../ListGenericJobObject.php | 118 ---------- .../UpdateJobResultObject.php | 60 ----- .../Processors/FetchesJobResultProcessor.php | 47 ---- .../Processors/UpdateJobResultProcessor.php | 64 ------ .../Jobs/Services/CreatesJobResult.php | 26 --- .../Jobs/Services/FetchesJobResult.php | 33 --- .../Modules/Jobs/Services/ListsJobResult.php | 33 --- .../Jobs/Services/UpdatesJobResult.php | 28 --- .../ListTransactionsJobLogic.php | 74 ------ .../ListTransactionsJobProcessor.php | 45 ---- .../Bookings/ListBookingsJobController.php | 22 -- .../Documents/ListDocumentsJobController.php | 19 -- .../Jobs/FetchJobResultController.php | 19 -- .../ListTransactionsJobController.php | 21 -- app/Http/Resources/BookingResource.php | 2 + app/Http/Resources/CompanyResource.php | 1 + app/Http/Resources/DocumentResource.php | 3 + app/Http/Resources/JobResultResource.php | 22 -- app/Http/Resources/ListBookingJobResource.php | 81 ------- .../Resources/ListDocumentJobResource.php | 31 --- .../Resources/ListTransactionJobResource.php | 54 ----- app/Http/Resources/V2/BookingV2Resource.php | 82 ------- app/Http/Resources/V2/CompanyV2Resource.php | 100 -------- app/Models/JobResult.php | 13 -- ..._08_08_124848_create_job_results_table.php | 35 --- ...31_add_new_column_to_job_results_table.php | 36 --- ..._add_new_column_2_to_job_results_table.php | 34 --- .../AdminPaymentsBillingSectionComponent.vue | 136 ----------- ...PaymentsBillingSectionPollingComponent.vue | 136 ----------- .../SupplierPendingOrdersSectionComponent.vue | 10 +- .../general/elements/ListPollingComponent.vue | 213 ------------------ .../vue/general/mixins/aws/requestV2.js | 49 ---- .../assets/vue/general/mixins/tabHandler.js | 24 -- .../assets/vue/vuex/modules/crudRequestV2.js | 51 ----- resources/assets/vue/vuex/store.js | 4 +- resources/views/pages/billings.blade.php | 126 ++++++++++- .../views/pages/billings_experiment.blade.php | 9 - routes/api.php | 4 - routes/currency.php | 2 +- routes/document.php | 3 +- routes/job.php | 8 - routes/web.php | 12 +- 60 files changed, 152 insertions(+), 2380 deletions(-) delete mode 100644 app/Classes/Exceptions/JobResourceNotFoundException.php delete mode 100644 app/Classes/General/Eloquent/Filters/JobId.php delete mode 100644 app/Classes/General/Eloquent/Filters/OrderByIdDesc.php delete mode 100644 app/Classes/General/Eloquent/Filters/RequestSignature.php delete mode 100644 app/Classes/General/Eloquent/Filters/ResultNotNull.php delete mode 100644 app/Classes/Jobs/ListBookingsJob.php delete mode 100644 app/Classes/Jobs/ListDocumentsJob.php delete mode 100644 app/Classes/Jobs/ListTransactionsJob.php delete mode 100644 app/Classes/Modules/Bookings/ControllersLogic/ListBookingJobLogic.php delete mode 100644 app/Classes/Modules/Bookings/Processors/ListBookingsJobProcessor.php delete mode 100644 app/Classes/Modules/Documents/ControllersLogic/ListDocumentJobLogic.php delete mode 100644 app/Classes/Modules/Documents/Processors/ListDocumentsJobProcessor.php delete mode 100644 app/Classes/Modules/Jobs/ControllersLogic/FetchJobResultLogic.php delete mode 100644 app/Classes/Modules/Jobs/DataTransferObjects/ListGenericJobObject.php delete mode 100644 app/Classes/Modules/Jobs/DataTransferObjects/UpdateJobResultObject.php delete mode 100644 app/Classes/Modules/Jobs/Processors/FetchesJobResultProcessor.php delete mode 100644 app/Classes/Modules/Jobs/Processors/UpdateJobResultProcessor.php delete mode 100644 app/Classes/Modules/Jobs/Services/CreatesJobResult.php delete mode 100644 app/Classes/Modules/Jobs/Services/FetchesJobResult.php delete mode 100644 app/Classes/Modules/Jobs/Services/ListsJobResult.php delete mode 100644 app/Classes/Modules/Jobs/Services/UpdatesJobResult.php delete mode 100644 app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsJobLogic.php delete mode 100644 app/Classes/Modules/Transactions/Processors/ListTransactionsJobProcessor.php delete mode 100644 app/Http/Controllers/Bookings/ListBookingsJobController.php delete mode 100644 app/Http/Controllers/Documents/ListDocumentsJobController.php delete mode 100644 app/Http/Controllers/Jobs/FetchJobResultController.php delete mode 100644 app/Http/Controllers/Transactions/ListTransactionsJobController.php delete mode 100644 app/Http/Resources/JobResultResource.php delete mode 100644 app/Http/Resources/ListBookingJobResource.php delete mode 100644 app/Http/Resources/ListDocumentJobResource.php delete mode 100644 app/Http/Resources/ListTransactionJobResource.php delete mode 100644 app/Http/Resources/V2/BookingV2Resource.php delete mode 100644 app/Http/Resources/V2/CompanyV2Resource.php delete mode 100644 app/Models/JobResult.php delete mode 100644 database/migrations/2023_08_08_124848_create_job_results_table.php delete mode 100644 database/migrations/2023_08_29_063531_add_new_column_to_job_results_table.php delete mode 100644 database/migrations/2023_12_11_193200_add_new_column_2_to_job_results_table.php delete mode 100644 resources/assets/vue/components/bookings/sections/AdminPaymentsBillingSectionComponent.vue delete mode 100644 resources/assets/vue/components/bookings/sections/AdminPaymentsBillingSectionPollingComponent.vue delete mode 100644 resources/assets/vue/components/general/elements/ListPollingComponent.vue delete mode 100644 resources/assets/vue/general/mixins/aws/requestV2.js delete mode 100644 resources/assets/vue/general/mixins/tabHandler.js delete mode 100644 resources/assets/vue/vuex/modules/crudRequestV2.js delete mode 100644 resources/views/pages/billings_experiment.blade.php delete mode 100644 routes/job.php diff --git a/app/Classes/Exceptions/JobResourceNotFoundException.php b/app/Classes/Exceptions/JobResourceNotFoundException.php deleted file mode 100644 index a8ef358e..00000000 --- a/app/Classes/Exceptions/JobResourceNotFoundException.php +++ /dev/null @@ -1,11 +0,0 @@ -getMessage(), - $exception->getTrace()[0]['file'], - $exception->getTrace()[0]['line'] - )); - } - else{ - log::error($exception); - } - + log::error($exception); return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), $exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler(); diff --git a/app/Classes/General/Eloquent/AbstractFetchRecord.php b/app/Classes/General/Eloquent/AbstractFetchRecord.php index 503fb369..248deee7 100644 --- a/app/Classes/General/Eloquent/AbstractFetchRecord.php +++ b/app/Classes/General/Eloquent/AbstractFetchRecord.php @@ -4,11 +4,9 @@ namespace App\Classes\General\Eloquent; use App\Classes\Exceptions\ResourceNotFoundException; -use App\Classes\Exceptions\JobResourceNotFoundException; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Psy\Exception\ErrorException; -use Illuminate\Support\Facades\Log; abstract class AbstractFetchRecord extends AbstractGetRecord { @@ -29,18 +27,12 @@ abstract class AbstractFetchRecord extends AbstractGetRecord * @return Model * @throws ResourceNotFoundException */ - public function getResults(Builder $query, array $param = []): Model { + public function getResults(Builder $query): Model { if(!$query->exists()){ - $table = $query->getModel()->getTable(); - if($table ==='job_results'){ - throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided'); - } - else{ - throw new ResourceNotFoundException('Unable to find any record based on the criteria provided'); - } + throw new ResourceNotFoundException('Unable to find any record based on the criteria provided'); } return $query->first(); } -} +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/AbstractGetRecord.php b/app/Classes/General/Eloquent/AbstractGetRecord.php index 1a7eac3e..f927d818 100644 --- a/app/Classes/General/Eloquent/AbstractGetRecord.php +++ b/app/Classes/General/Eloquent/AbstractGetRecord.php @@ -30,25 +30,11 @@ abstract class AbstractGetRecord return $this->filters->only(self::DECORATION_FILTERS); } - // /** - // * @param null|string $json - // * @return array - // */ - // public function deserializeFilters(?string $json): array { - // return $json !== null ? collect(json_decode($json))->toArray() : []; - // } - /** - * @param null|string $param + * @param null|string $json * @return array */ - public function deserializeFilters($param): array { - if(gettype($param) == "array"){ - $json = implode(',', $param); - } - else{ - $json = $param; - } + public function deserializeFilters(?string $json): array { return $json !== null ? collect(json_decode($json))->toArray() : []; } @@ -64,9 +50,9 @@ abstract class AbstractGetRecord * @param array $filters * @return mixed */ - public function handler(array $filters, array $params = []){ + public function handler(array $filters){ $this->filters = collect($filters); - return $this->getResults($this->applyFiltersToQuery(), $params); + return $this->getResults($this->applyFiltersToQuery()); } @@ -79,6 +65,6 @@ abstract class AbstractGetRecord * @param Builder $query * @return mixed */ - abstract function getResults(Builder $query, array $params = []); + abstract function getResults(Builder $query); -} +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/AbstractListRecord.php b/app/Classes/General/Eloquent/AbstractListRecord.php index f898f108..7b7d0df9 100644 --- a/app/Classes/General/Eloquent/AbstractListRecord.php +++ b/app/Classes/General/Eloquent/AbstractListRecord.php @@ -17,11 +17,11 @@ abstract class AbstractListRecord extends AbstractGetRecord * @return mixed * @throws MalformedRequestException */ - public function execute(array $filters = [], array $param = []){ + public function execute(array $filters = []){ try{ - return $this->handler($filters, $param); + return $this->handler($filters); } catch (QueryException $exception){ log::error($exception); @@ -30,24 +30,18 @@ abstract class AbstractListRecord extends AbstractGetRecord } - /** * @param Builder $query * @return mixed */ - public function getResults(Builder $query, array $param = []) { + public function getResults(Builder $query) { $filters = $this->getDecorationFilters(); if($filters->has('order_by')){ $query = $query->orderBy($filters->get('order_by')->column, $filters->get('order_by')->DESC ? 'DESC': 'ASC'); } - if(!empty($param)){ - return $filters->has('per_page') ? $query->paginate($filters->get('per_page'), ['*'], 'page', $param['page']) : $query->get(); //page data from query parameters e.g ?page=1 - } - else{ - return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get(); - } + return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get(); } diff --git a/app/Classes/General/Eloquent/Filters/JobId.php b/app/Classes/General/Eloquent/Filters/JobId.php deleted file mode 100644 index 42ac51a4..00000000 --- a/app/Classes/General/Eloquent/Filters/JobId.php +++ /dev/null @@ -1,20 +0,0 @@ -where('job_id', $value); - } - -} diff --git a/app/Classes/General/Eloquent/Filters/OrderByIdDesc.php b/app/Classes/General/Eloquent/Filters/OrderByIdDesc.php deleted file mode 100644 index 547ec9bd..00000000 --- a/app/Classes/General/Eloquent/Filters/OrderByIdDesc.php +++ /dev/null @@ -1,20 +0,0 @@ -orderBy('id', 'desc'); - } - -} diff --git a/app/Classes/General/Eloquent/Filters/RequestSignature.php b/app/Classes/General/Eloquent/Filters/RequestSignature.php deleted file mode 100644 index 67dde0a3..00000000 --- a/app/Classes/General/Eloquent/Filters/RequestSignature.php +++ /dev/null @@ -1,19 +0,0 @@ -where('request_signature', $value); - } - -} diff --git a/app/Classes/General/Eloquent/Filters/ResultNotNull.php b/app/Classes/General/Eloquent/Filters/ResultNotNull.php deleted file mode 100644 index 3f6a0341..00000000 --- a/app/Classes/General/Eloquent/Filters/ResultNotNull.php +++ /dev/null @@ -1,18 +0,0 @@ -whereNotNull('result'); - } -} diff --git a/app/Classes/General/Helper.php b/app/Classes/General/Helper.php index 45c72f53..ac89540b 100644 --- a/app/Classes/General/Helper.php +++ b/app/Classes/General/Helper.php @@ -2,7 +2,6 @@ namespace App\Classes\General; -use Illuminate\Http\Resources\Json\ResourceCollection; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; @@ -43,27 +42,4 @@ class Helper } } } - - /** - * @param null|string $param - * @return array - */ - static function deserializeFilters($param): array { - if(gettype($param) == "array"){ - $json = implode(',', $param); - } - else{ - $json = $param; - } - return $json !== null ? collect(json_decode($json))->toArray() : []; - } - - /** - * @param ResourceCollection $collection - * @return array - */ - static function collectionResponse(ResourceCollection $collection){ - return json_decode($collection->response()->getContent(), true); - } - } diff --git a/app/Classes/Jobs/ListBookingsJob.php b/app/Classes/Jobs/ListBookingsJob.php deleted file mode 100644 index b021b71d..00000000 --- a/app/Classes/Jobs/ListBookingsJob.php +++ /dev/null @@ -1,52 +0,0 @@ -listGenericJobObject = $listGenericJobObject; - } - - public function handle() - { - $rawPayload = $this->job->payload(); - if(isset($rawPayload['data']['commandName'])){ - $this->listGenericJobObject->setJobCommandName($rawPayload['data']['commandName']); - } - - if(isset($rawPayload['data']['command'])){ - $this->listGenericJobObject->setJobCommand($rawPayload['data']['command']); - } - - $result = (App()->make(ListBookingsJobProcessor::class))->execute($this->listGenericJobObject); - } - - public function getJobId(){ - return $this->job->getJobId(); - } -} diff --git a/app/Classes/Jobs/ListDocumentsJob.php b/app/Classes/Jobs/ListDocumentsJob.php deleted file mode 100644 index 6e93062b..00000000 --- a/app/Classes/Jobs/ListDocumentsJob.php +++ /dev/null @@ -1,63 +0,0 @@ -listGenericJobObject = $listGenericJobObject; - } - - public function handle() - { - $rawPayload = $this->job->payload(); - if(isset($rawPayload['data']['commandName'])){ - $this->listGenericJobObject->setJobCommandName($rawPayload['data']['commandName']); - } - - if(isset($rawPayload['data']['command'])){ - $this->listGenericJobObject->setJobCommand($rawPayload['data']['command']); - } - - $result = (App()->make(ListDocumentsJobProcessor::class))->execute($this->listGenericJobObject); - - //cief todo: Insert into DB: job id, query result, timestamp - // Store the result in the job_results table - - //cief todo: why cannot save data in table like this - // $model = new JobResult(); - // $model->job_id = $this->job->getJobId(); - // $model->result = json_encode($result); - // $model->save(); - - // Log::error(json_encode($model->id)); - } - - public function getJobId(){ - return $this->job->getJobId(); - } -} diff --git a/app/Classes/Jobs/ListTransactionsJob.php b/app/Classes/Jobs/ListTransactionsJob.php deleted file mode 100644 index a2b28656..00000000 --- a/app/Classes/Jobs/ListTransactionsJob.php +++ /dev/null @@ -1,52 +0,0 @@ -listGenericJobObject = $listGenericJobObject; - } - - public function handle() - { - $rawPayload = $this->job->payload(); - if(isset($rawPayload['data']['commandName'])){ - $this->listGenericJobObject->setJobCommandName($rawPayload['data']['commandName']); - } - - if(isset($rawPayload['data']['command'])){ - $this->listGenericJobObject->setJobCommand($rawPayload['data']['command']); - } - - $result = (App()->make(ListTransactionsJobProcessor::class))->execute($this->listGenericJobObject); - } - - public function getJobId(){ - return $this->job->getJobId(); - } -} diff --git a/app/Classes/Modules/Bookings/ControllersLogic/ListBookingJobLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/ListBookingJobLogic.php deleted file mode 100644 index ef3570f7..00000000 --- a/app/Classes/Modules/Bookings/ControllersLogic/ListBookingJobLogic.php +++ /dev/null @@ -1,75 +0,0 @@ - 'List Booking Job', - 'message' => 'You have successfully submit a job to list bookings' - ]; - } - - /** @var CreatesJobResult */ - private $createsJobResult; - - /** - * ListPackingListsJobLogic constructor. - * @param CreatesJobResult $createsJobResult - */ - public function __construct(CreatesJobResult $createsJobResult) - { - $this->createsJobResult = $createsJobResult; - } - - - /** - * @param Request $request - * @return JsonResponse - */ - public function logic(Request $request) : JsonResponse - { - $jobId = uniqid(); - - $user = Auth::user(); - $userInfo = (object) [ - 'type' => $user->type, - ]; - - $userInfoJson = json_encode($userInfo); - $requestSignature = md5($userInfoJson . $request->fullUrl()); - - $listGenericJobObject = new ListGenericJobObject( - $request->fullUrl(), - $request->all(), - $requestSignature, - null, - $jobId, - $userInfo - ); - - ListBookingsJob::dispatch($listGenericJobObject); - - $result = []; - $result['job_id'] = $jobId; - - $this->createsJobResult->execute($listGenericJobObject); - - return $this->response(['data' => $result]); - } - -} diff --git a/app/Classes/Modules/Bookings/Processors/ListBookingsJobProcessor.php b/app/Classes/Modules/Bookings/Processors/ListBookingsJobProcessor.php deleted file mode 100644 index 2a09eb12..00000000 --- a/app/Classes/Modules/Bookings/Processors/ListBookingsJobProcessor.php +++ /dev/null @@ -1,46 +0,0 @@ -listsBookings = $listsBookings; - $this->updateJobResultProcessor = $updateJobResultProcessor; - } - - /** - * @param ListGenericJobObject $listGenericJobObject - * @return void - * @throws \App\Classes\Exceptions\MalformedRequestException - * @throws \App\Classes\Exceptions\JobResourceNotFoundException - */ - public function execute(ListGenericJobObject $listGenericJobObject) { - - $query = $this->listsBookings->execute($this->listsBookings->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]); - foreach ($query->items() as &$item) { - $item['userInfo'] = $listGenericJobObject->getUserInfo(); - } - $resultCurrent = Helper::collectionResponse(ListBookingJobResource::collection($query)); - $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent); - } -} diff --git a/app/Classes/Modules/Documents/ControllersLogic/ListDocumentJobLogic.php b/app/Classes/Modules/Documents/ControllersLogic/ListDocumentJobLogic.php deleted file mode 100644 index 5e895ad8..00000000 --- a/app/Classes/Modules/Documents/ControllersLogic/ListDocumentJobLogic.php +++ /dev/null @@ -1,75 +0,0 @@ - 'List Document Job', - 'message' => 'You have successfully submit a job to list documents' - ]; - } - - /** @var CreatesJobResult */ - private $createsJobResult; - - /** - * ListDocumentJobLogic constructor. - * @param CreatesJobResult $createsJobResult - */ - public function __construct(CreatesJobResult $createsJobResult) - { - $this->createsJobResult = $createsJobResult; - } - - - /** - * @param Request $request - * @return JsonResponse - */ - public function logic(Request $request) : JsonResponse - { - $jobId = uniqid(); - - $user = Auth::user(); - $userInfo = (object) [ - 'email' => $user->email, - 'type' => $user->type, - ]; - - $userInfoJson = json_encode($userInfo); - $requestSignature = md5($userInfoJson . $request->fullUrl()); - - $listGenericJobObject = new ListGenericJobObject( - $request->fullUrl(), - $request->all(), - $requestSignature, - null, - $jobId, - $userInfo - ); - - ListDocumentsJob::dispatch($listGenericJobObject); - - $result = []; - $result['job_id'] = $jobId; - - $this->createsJobResult->execute($listGenericJobObject); - - return $this->response(['data' => $result]); - } -} diff --git a/app/Classes/Modules/Documents/Processors/ListDocumentsJobProcessor.php b/app/Classes/Modules/Documents/Processors/ListDocumentsJobProcessor.php deleted file mode 100644 index 70777f0c..00000000 --- a/app/Classes/Modules/Documents/Processors/ListDocumentsJobProcessor.php +++ /dev/null @@ -1,47 +0,0 @@ -listsDocuments = $listsDocuments; - $this->updateJobResultProcessor = $updateJobResultProcessor; - } - - /** - * @param ListGenericJobObject $listGenericJobObject - * @return void - * @throws \App\Classes\Exceptions\MalformedRequestException - * @throws \App\Classes\Exceptions\JobResourceNotFoundException - */ - public function execute(ListGenericJobObject $listGenericJobObject) { - - $query = $this->listsDocuments->execute($this->listsDocuments->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]); - foreach ($query->items() as &$item) { - $item['userInfo'] = $listGenericJobObject->getUserInfo(); - } - $resultCurrent = Helper::collectionResponse(ListDocumentJobResource::collection($query)); - $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent); - } -} - diff --git a/app/Classes/Modules/Jobs/ControllersLogic/FetchJobResultLogic.php b/app/Classes/Modules/Jobs/ControllersLogic/FetchJobResultLogic.php deleted file mode 100644 index c4b72cf0..00000000 --- a/app/Classes/Modules/Jobs/ControllersLogic/FetchJobResultLogic.php +++ /dev/null @@ -1,51 +0,0 @@ - 'Retrieved Data', - 'message' => 'You have successfully retrieved data' - ]; - } - - /** @var FetchesJobResultProcessor */ - private $fetchesJobResultProcessor; - - /** - * FetchJobResultLogic constructor. - * @param FetchesJobResultProcessor $fetchesJobResultProcessor - */ - public function __construct(FetchesJobResultProcessor $fetchesJobResultProcessor) - { - $this->fetchesJobResultProcessor = $fetchesJobResultProcessor; - } - - - /** - * @param Request $request - * @return JsonResponse - * @throws \App\Classes\Exceptions\AccessForbiddenException - * @throws \App\Classes\Exceptions\MalformedRequestException - * @throws \App\Classes\Exceptions\RequestValidationException - */ - public function logic(Request $request) : JsonResponse - { - $query = $this->fetchesJobResultProcessor->execute($request); - return $this->resourceResponse(new JobResultResource($query)); - } - -} diff --git a/app/Classes/Modules/Jobs/DataTransferObjects/ListGenericJobObject.php b/app/Classes/Modules/Jobs/DataTransferObjects/ListGenericJobObject.php deleted file mode 100644 index 953d77d7..00000000 --- a/app/Classes/Modules/Jobs/DataTransferObjects/ListGenericJobObject.php +++ /dev/null @@ -1,118 +0,0 @@ -name = $name; - $this->payload = $payload; - $this->jobId = $jobId; - $this->requestSignature = $requestSignature; - $this->resultSignature = $resultSignature; - $this->userInfo = $userInfo; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return array - */ - public function getPayload(): array - { - return $this->payload; - } - - /** - * @return string - */ - public function getJobId(): string - { - return $this->jobId; - } - - /** - * @return string - */ - public function getRequestSignature(): string - { - return $this->requestSignature; - } - - /** - * @return string - */ - public function getResultSignature(): ?string - { - return $this->resultSignature; - } - - /** - * @return object - */ - public function getUserInfo(): object - { - return $this->userInfo; - } - - /** - * @return string - */ - public function getJobCommandName(): string - { - return $this->jobCommandName; - } - - /** - * @return string - */ - public function getJobCommand(): string - { - return $this->jobCommand; - } - - - public function setJobCommandName(string $jobCommandName) - { - $this->jobCommandName = $jobCommandName; - } - - public function setJobCommand(string $jobCommand) - { - $this->jobCommand = $jobCommand; - } - -} diff --git a/app/Classes/Modules/Jobs/DataTransferObjects/UpdateJobResultObject.php b/app/Classes/Modules/Jobs/DataTransferObjects/UpdateJobResultObject.php deleted file mode 100644 index 636c56b0..00000000 --- a/app/Classes/Modules/Jobs/DataTransferObjects/UpdateJobResultObject.php +++ /dev/null @@ -1,60 +0,0 @@ -result = $result; - $this->resultSignature = $resultSignature; - $this->jobCommandName = $jobCommandName; - $this->jobCommand = $jobCommand; - } - - /** - * @return string - */ - public function getResult(): string - { - return $this->result; - } - - /** - * @return array - */ - public function getResultSignature(): string - { - return $this->resultSignature; - } - - /** - * @return string - */ - public function getJobCommandName(): string - { - return $this->jobCommandName; - } - - /** - * @return string - */ - public function getJobCommand(): string - { - return $this->jobCommand; - } -} diff --git a/app/Classes/Modules/Jobs/Processors/FetchesJobResultProcessor.php b/app/Classes/Modules/Jobs/Processors/FetchesJobResultProcessor.php deleted file mode 100644 index 89783fe8..00000000 --- a/app/Classes/Modules/Jobs/Processors/FetchesJobResultProcessor.php +++ /dev/null @@ -1,47 +0,0 @@ -fetchesJobResult = $fetchesJobResult; - } - - - /** - * @param Request $request - * @return Model - * @throws \App\Classes\Exceptions\MalformedRequestException - * @throws \App\Classes\Exceptions\JobResourceNotFoundException - * @throws \App\Classes\Exceptions\ResourceNotFoundException - */ - public function execute(Request $request){ - - $res1 = $this->fetchesJobResult->execute(['job_id' => $request->route('job_id')]); - if($request->route('is_last')){ - $res2 = $this->fetchesJobResult->execute(['request_signature' => $res1->request_signature, 'result_not_null' => true, 'order_by_id_desc' => true]); - return $res2; - } - - if(!$res1->result){ - throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided'); - } - - return $res1; - } -} diff --git a/app/Classes/Modules/Jobs/Processors/UpdateJobResultProcessor.php b/app/Classes/Modules/Jobs/Processors/UpdateJobResultProcessor.php deleted file mode 100644 index 0106417d..00000000 --- a/app/Classes/Modules/Jobs/Processors/UpdateJobResultProcessor.php +++ /dev/null @@ -1,64 +0,0 @@ -fetchesJobResult = $fetchesJobResult; - $this->updatesJobResult = $updatesJobResult; - } - - /** - * @param ListGenericJobObject $listGenericJobObject - * @param array $resultCurrent - * @return void - * @throws \App\Classes\Exceptions\MalformedRequestException - * @throws \App\Classes\Exceptions\JobResourceNotFoundException - */ - public function execute(ListGenericJobObject $listGenericJobObject, $resultCurrent) { - $jobResultCurrent = $this->fetchesJobResult->execute(['job_id' => $listGenericJobObject->getJobId()]); - $resultCurrentJson = json_encode($resultCurrent); - $resultSignatureCurrent = md5($resultCurrentJson); - - try{ - $jobResultExisting = $this->fetchesJobResult->execute(['request_signature' => $jobResultCurrent->request_signature, 'result_not_null' => true, 'order_by_id_desc' => true]); - $resultSignatureExisting = $jobResultExisting->result_signature; - //if($resultSignatureExisting != $resultSignatureCurrent){ - $this->updateJobResult($jobResultCurrent, $resultCurrentJson, $resultSignatureCurrent, $listGenericJobObject->getJobCommandName(), $listGenericJobObject->getJobCommand()); - //} - } catch (JobResourceNotFoundException $exception){ - $this->updateJobResult($jobResultCurrent, $resultCurrentJson, $resultSignatureCurrent, $listGenericJobObject->getJobCommandName(), $listGenericJobObject->getJobCommand()); - } - } - - private function updateJobResult($jobResultCurrent, $resultCurrentJson, $resultSignatureCurrent, $jobCommandName, $jobCommand){ - $updateJobResultObject = new UpdateJobResultObject( - $resultCurrentJson, - $resultSignatureCurrent, - $jobCommandName, - $jobCommand - ); - $create = $this->updatesJobResult->execute($jobResultCurrent, $updateJobResultObject); - } -} diff --git a/app/Classes/Modules/Jobs/Services/CreatesJobResult.php b/app/Classes/Modules/Jobs/Services/CreatesJobResult.php deleted file mode 100644 index e70e0e6a..00000000 --- a/app/Classes/Modules/Jobs/Services/CreatesJobResult.php +++ /dev/null @@ -1,26 +0,0 @@ -job_id = $listGenericJobObject->getJobId(); - $model->request_signature = $listGenericJobObject->getRequestSignature(); - $model->result_signature = $listGenericJobObject->getResultSignature(); - $model->url = $listGenericJobObject->getName(); - - return $this->handler($model); - } -} diff --git a/app/Classes/Modules/Jobs/Services/FetchesJobResult.php b/app/Classes/Modules/Jobs/Services/FetchesJobResult.php deleted file mode 100644 index 1cc99cb6..00000000 --- a/app/Classes/Modules/Jobs/Services/FetchesJobResult.php +++ /dev/null @@ -1,33 +0,0 @@ -repository = $repository; - } - - - /** - * @return Builder - */ - public function getRepository(): Builder - { - return $this->repository->newQuery(); - } -} diff --git a/app/Classes/Modules/Jobs/Services/ListsJobResult.php b/app/Classes/Modules/Jobs/Services/ListsJobResult.php deleted file mode 100644 index 55f3b267..00000000 --- a/app/Classes/Modules/Jobs/Services/ListsJobResult.php +++ /dev/null @@ -1,33 +0,0 @@ -repository = $repository; - } - - - /** - * @return Builder - */ - function getRepository(): Builder - { - return $this->repository->newQuery(); - } -} diff --git a/app/Classes/Modules/Jobs/Services/UpdatesJobResult.php b/app/Classes/Modules/Jobs/Services/UpdatesJobResult.php deleted file mode 100644 index ab3d9385..00000000 --- a/app/Classes/Modules/Jobs/Services/UpdatesJobResult.php +++ /dev/null @@ -1,28 +0,0 @@ -result = $updateJobResultObject->getResult(); - $model->result_signature = $updateJobResultObject->getResultSignature(); - $model->job_command_name = $updateJobResultObject->getJobCommandName(); - $model->job_command = $updateJobResultObject->getJobCommand(); - - return $this->handler($model); - - } -} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsJobLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsJobLogic.php deleted file mode 100644 index 654a360f..00000000 --- a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsJobLogic.php +++ /dev/null @@ -1,74 +0,0 @@ - 'List Transaction Job', - 'message' => 'You have successfully submit a job to list transactions' - ]; - } - - /** @var CreatesJobResult */ - private $createsJobResult; - - /** - * ListTransactionsJobLogic constructor. - * @param CreatesJobResult $createsJobResult - */ - public function __construct(CreatesJobResult $createsJobResult) - { - $this->createsJobResult = $createsJobResult; - } - - - /** - * @param Request $request - * @return JsonResponse - */ - public function logic(Request $request) : JsonResponse - { - $jobId = uniqid(); - - $user = Auth::user(); - $userInfo = (object) [ - 'type' => $user->type, - ]; - - $userInfoJson = json_encode($userInfo); - $requestSignature = md5($userInfoJson . $request->fullUrl()); - - $listGenericJobObject = new ListGenericJobObject( - $request->fullUrl(), - $request->all(), - $requestSignature, - null, - $jobId, - $userInfo - ); - - ListTransactionsJob::dispatch($listGenericJobObject); - - $result = []; - $result['job_id'] = $jobId; - - $this->createsJobResult->execute($listGenericJobObject); - - return $this->response(['data' => $result]); - } - -} diff --git a/app/Classes/Modules/Transactions/Processors/ListTransactionsJobProcessor.php b/app/Classes/Modules/Transactions/Processors/ListTransactionsJobProcessor.php deleted file mode 100644 index 475d4715..00000000 --- a/app/Classes/Modules/Transactions/Processors/ListTransactionsJobProcessor.php +++ /dev/null @@ -1,45 +0,0 @@ -listsTransactions = $listsTransactions; - $this->updateJobResultProcessor = $updateJobResultProcessor; - } - - /** - * @param ListGenericJobObject $listGenericJobObject - * @return void - * @throws \App\Classes\Exceptions\MalformedRequestException - * @throws \App\Classes\Exceptions\JobResourceNotFoundException - */ - public function execute(ListGenericJobObject $listGenericJobObject) { - - $query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]); - - $resultCurrent = Helper::collectionResponse(ListTransactionJobResource::collection($query)); - $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent); - } -} - diff --git a/app/Http/Controllers/Bookings/ListBookingsJobController.php b/app/Http/Controllers/Bookings/ListBookingsJobController.php deleted file mode 100644 index 9b32fc77..00000000 --- a/app/Http/Controllers/Bookings/ListBookingsJobController.php +++ /dev/null @@ -1,22 +0,0 @@ -execute($request); - } -} diff --git a/app/Http/Controllers/Documents/ListDocumentsJobController.php b/app/Http/Controllers/Documents/ListDocumentsJobController.php deleted file mode 100644 index 8b763085..00000000 --- a/app/Http/Controllers/Documents/ListDocumentsJobController.php +++ /dev/null @@ -1,19 +0,0 @@ -execute($request); - } -} diff --git a/app/Http/Controllers/Jobs/FetchJobResultController.php b/app/Http/Controllers/Jobs/FetchJobResultController.php deleted file mode 100644 index cfef2f5c..00000000 --- a/app/Http/Controllers/Jobs/FetchJobResultController.php +++ /dev/null @@ -1,19 +0,0 @@ -execute($request); - } -} diff --git a/app/Http/Controllers/Transactions/ListTransactionsJobController.php b/app/Http/Controllers/Transactions/ListTransactionsJobController.php deleted file mode 100644 index fb341d5d..00000000 --- a/app/Http/Controllers/Transactions/ListTransactionsJobController.php +++ /dev/null @@ -1,21 +0,0 @@ -execute($request); - } -} diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index 70fbc95c..f3a7881d 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -11,9 +11,11 @@ use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\DocumentType; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; +use Illuminate\Support\Facades\Log; class BookingResource extends JsonResource { + /** * Transform the resource into an array. * diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index eff2bd1b..85ecee16 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -15,6 +15,7 @@ use App\Models\SegmentConstant; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Log; class CompanyResource extends JsonResource { diff --git a/app/Http/Resources/DocumentResource.php b/app/Http/Resources/DocumentResource.php index c0f801bb..59933a67 100644 --- a/app/Http/Resources/DocumentResource.php +++ b/app/Http/Resources/DocumentResource.php @@ -3,7 +3,10 @@ namespace App\Http\Resources; use App\Models\Booking; +use App\Models\Company; +use App\Models\Document; use Carbon\Carbon; +use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Resources\Json\JsonResource; class DocumentResource extends JsonResource diff --git a/app/Http/Resources/JobResultResource.php b/app/Http/Resources/JobResultResource.php deleted file mode 100644 index 51bc1898..00000000 --- a/app/Http/Resources/JobResultResource.php +++ /dev/null @@ -1,22 +0,0 @@ - $this->job_id, - 'result' => $this->result, - ]; - } -} diff --git a/app/Http/Resources/ListBookingJobResource.php b/app/Http/Resources/ListBookingJobResource.php deleted file mode 100644 index 06f8c38d..00000000 --- a/app/Http/Resources/ListBookingJobResource.php +++ /dev/null @@ -1,81 +0,0 @@ -userInfo = $userInfo ?? ($resource->userInfo ?? null); - } - - /** - * Transform the resource into an array. - * - * @param \Illuminate\Http\Request $request - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException - */ - public function toArray($request) - { - return [ - 'id' => $this->id, - 'company' => new CompanyResource($this->company, $this->userInfo), - 'bank' => new BankResource($this->bank), - 'service' => new ServiceTypeResource($this->service), - 'marking' => $this->marking, - 'amount' => $this->fix_amount, - 'floating_amount' => floatval((App()->make(CalculatesBookingFloatingAmount::class))->execute($this->resource, $this->fix_currency_id)), - 'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), - 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), - 'fixed_currency' => new CurrencyResource($this->fixedCurrency), - 'convertible_currency' => new CurrencyResource($this->convertibleCurrency), - 'conversion_currency' => new CurrencyResource($this->conversionCurrency), - 'documents' => [ - 'purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()), - 'delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), - 'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()), - 'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), - 'proforma_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->orderByDesc('id')->first()), - 'ecommerce_purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first()), - ], - 'status' => $this->status, - 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), - 'created_at_with_time' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'), - $this->mergeWhen($this->relationLoaded('transactions'), [ - 'purchase_order' => new TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()), - 'payment_attempts' => TransactionResource::collection( - $this->transactions() - ->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION) - ->whereDate('expires_on', '>=', Carbon::now()) - ->get() - ), - 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()), - 'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){ - $query->where(function($query){ - $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]); - })->orWhere(function($query){ - $query->where(function($query){ - $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]); - })->orWhere(function($query){ - $query->where('type', TransactionType::CREDIT_NOTE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - }); - }); - })->latest()->get()) - ]) - ]; - } -} diff --git a/app/Http/Resources/ListDocumentJobResource.php b/app/Http/Resources/ListDocumentJobResource.php deleted file mode 100644 index edf549ef..00000000 --- a/app/Http/Resources/ListDocumentJobResource.php +++ /dev/null @@ -1,31 +0,0 @@ - $this->id, - 'reference' => $this->reference, - 'status' => (int) $this->status, - 'document_type' => $this->document_type, - 'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingV2Resource($this->owner, $this->userInfo) : new CompanyV2Resource($this->owner, $this->userInfo)) : null, - 'files' => FileResource::collection($this->files), - 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A') - ]; - } -} diff --git a/app/Http/Resources/ListTransactionJobResource.php b/app/Http/Resources/ListTransactionJobResource.php deleted file mode 100644 index 6c4c0ece..00000000 --- a/app/Http/Resources/ListTransactionJobResource.php +++ /dev/null @@ -1,54 +0,0 @@ -type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; - $days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); - - return [ - 'id' => $this->id, - 'booking' => new BookingResource($booking), - 'type' => (int) $this->type, - 'bill_no' => $this->bill_no, - 'payment_reference' => $this->payment_reference, - 'payment_method' => (float) $this->payment_method, - 'recipient_bank_account' => new BankResource($booking->bank), - 'issuer_name' => $this->issuerCompany->name, - 'issuer_id' => $this->issuerCompany->id, - 'amount' => (double) $this->amount, - 'original_amount' => (double) $this->original_amount, - 'currency' => new CurrencyResource($this->currency), - 'original_currency' => new CurrencyResource($this->original_currency), - 'service_charge' => (double) $this->service_charge, - 'tax' => (double) $this->tax, - 'currency_rate' => (double) $this->currency_rate, - 'status' => (int) $this->status, - 'details' => TransactionDetailResource::collection($this->transactionDetails), - 'documents' => new DocumentResource($this->documents()->first()), - 'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())), - 'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())), - 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'), - 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), - 'interval' => [ - 'value' => $days->gt(Carbon::now()) ? '+' : '-', - 'duration' => $days->diff(Carbon::now())->format('%d'), - ], - 'redemption' => new VoucherRedemptionResource($this->voucherRedemption) - ]; - } -} diff --git a/app/Http/Resources/V2/BookingV2Resource.php b/app/Http/Resources/V2/BookingV2Resource.php deleted file mode 100644 index ee17181e..00000000 --- a/app/Http/Resources/V2/BookingV2Resource.php +++ /dev/null @@ -1,82 +0,0 @@ -userInfo = $userInfo ?? ($resource->userInfo ?? null); - } - - /** - * Transform the resource into an array. - * - * @param \Illuminate\Http\Request $request - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException - */ - public function toArray($request) - { - return [ - 'id' => $this->id, - 'company' => new CompanyV2Resource($this->company, $this->userInfo), - 'bank' => new V1\BankResource($this->bank), - 'service' => new V1\ServiceTypeResource($this->service), - 'marking' => $this->marking, - 'amount' => $this->fix_amount, - 'floating_amount' => floatval((App()->make(CalculatesBookingFloatingAmount::class))->execute($this->resource, $this->fix_currency_id)), - 'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), - 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), - 'fixed_currency' => new V1\CurrencyResource($this->fixedCurrency), - 'convertible_currency' => new V1\CurrencyResource($this->convertibleCurrency), - 'conversion_currency' => new V1\CurrencyResource($this->conversionCurrency), - 'documents' => [ - 'purchase_order' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()), - 'delivery_order' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), - 'invoice' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()), - 'supplier_delivery_order' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), - 'proforma_invoice' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->orderByDesc('id')->first()), - 'ecommerce_purchase_order' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first()), - ], - 'status' => $this->status, - 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), - 'created_at_with_time' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'), - $this->mergeWhen($this->relationLoaded('transactions'), [ - 'purchase_order' => new V1\TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()), - 'payment_attempts' => V1\TransactionResource::collection( - $this->transactions() - ->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION) - ->whereDate('expires_on', '>=', Carbon::now()) - ->get() - ), - 'expired_payment_attempts' => V1\TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()), - 'payment_history' => V1\TransactionResource::collection($this->transactions()->where(function($query){ - $query->where(function($query){ - $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]); - })->orWhere(function($query){ - $query->where(function($query){ - $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]); - })->orWhere(function($query){ - $query->where('type', TransactionType::CREDIT_NOTE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - }); - }); - })->latest()->get()) - ]) - ]; - } -} diff --git a/app/Http/Resources/V2/CompanyV2Resource.php b/app/Http/Resources/V2/CompanyV2Resource.php deleted file mode 100644 index 64fca7c7..00000000 --- a/app/Http/Resources/V2/CompanyV2Resource.php +++ /dev/null @@ -1,100 +0,0 @@ -userInfo = $userInfo; - } - - /** - * Transform the resource into an array. - * - * @param \Illuminate\Http\Request $request - * @return array - */ - public function toArray($request) - { - $lastPayment = $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->first(); - $totalPayments = $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount'); - - $segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $this->id)->first(); - $serviceCharge = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $this->id)->first(); - - $userResource = null; - - $userInfoEmail = $this->userInfo && isset($this->userInfo->email) ? $this->userInfo->email : null; - $userInfoType = $this->userInfo && isset($this->userInfo->type) ? $this->userInfo->type : null; - - if(!$userInfoEmail && Auth::user()){ - $userInfoEmail = Auth::user()->email; - } - if(!$userInfoType && Auth::user()){ - $userInfoType = Auth::user()->type; - } - - if(!is_null($userInfoEmail) && !is_null($userInfoType)){ - $userResource = new V1\UserResource($userInfoType === RoleTypes::USER ? $this->employees()->where('email', '=', $userInfoEmail)->first() : $this->employees()->orderBy('id', 'DESC')->first()); - } - - return [ - 'id' => $this->id, - 'name' => $this->name, - 'reference' => $this->reference, - 'debtor' => $this->debtor, - 'type' => (int) $this->type, - 'business_type' => (int) $this->business_type, - 'status' => (int) $this->status, - 'contact' => new V1\ContactResource ($this->when($this->has('contacts'), $this->contacts->first())), - 'address' => new V1\AddressResource($this->when($this->has('addresses'), $this->addresses->where('billing', true)->first())), - 'employee' => $userResource, - 'identification' => new V1\DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->first()), - 'bookings' => $this->whenLoaded('bookings', $this->bookings()->orderBy('id', 'DESC')->get(), []), - 'confirmed_bookings' => $this->bookings()->whereHas('transactions', function ($query){ - $query->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - })->count(), - 'total_payments' => (float) $totalPayments, - 'average_spending_per_day' => (float) $totalPayments / ($this->created_at->diff(Carbon::now())->days === 0 ? 1 : $this->created_at->diff(Carbon::now())->days), - 'average_spending_per_booking' => (float) $totalPayments > 0 ? $totalPayments / $this->bookings()->whereHas('transactions', function ($query){ - $query->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - })->count() : $totalPayments, - 'last_payment' => $lastPayment ? $lastPayment->created_at->diffForHumans() : 'No Payments', - 'personal_banks' => V1\BankResource::collection($this->banks->where('type', BankAccountType::PERSONAL)), - 'recipient_banks' => [ - 'accounts' => V1\BankResource::collection($this->banks->where('type', BankAccountType::EXTERNAL)), - 'default' => new V1\BankResource($this->banks->where('type', BankAccountType::EXTERNAL)->where('default', true)->first()) - ], - 'segments' => V1\SegmentResource::collection($this->segments), - 'seasonalSegment' => $this->whenLoaded('seasonalSegments', V1\SeasonalSegmentResource::collection($this->seasonalSegments)), - 'services' => (new FetchesCompanyServices())->getServices($this->servicesConfigurations()), - 'wallet' => $this->whenLoaded('wallets', new V1\WalletResource($this->wallets()->with('transactions')->first()), new V1\WalletResource($this->wallets()->first())), - 'created_at' => $this->created_at->format('d-m-Y'), - $this->mergeWhen($this->business_type === BusinessType::CURRENCY_VENDOR, [ - 'currencies' => $segment ? V1\CurrencyResource::collection(Currency::whereIn('id', $segment->detail->currencies)->get()) : [], - 'service_charge' => $serviceCharge - ]) - - ]; - } -} diff --git a/app/Models/JobResult.php b/app/Models/JobResult.php deleted file mode 100644 index f30b5076..00000000 --- a/app/Models/JobResult.php +++ /dev/null @@ -1,13 +0,0 @@ -id(); - $table->string('job_id', 50); - $table->longText('result')->nullable(); - $table->timestamps(); - - // $table->foreign('job_id')->references('id')->on('jobs')->onDelete('cascade'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('job_results'); - } -} diff --git a/database/migrations/2023_08_29_063531_add_new_column_to_job_results_table.php b/database/migrations/2023_08_29_063531_add_new_column_to_job_results_table.php deleted file mode 100644 index 8e6b8342..00000000 --- a/database/migrations/2023_08_29_063531_add_new_column_to_job_results_table.php +++ /dev/null @@ -1,36 +0,0 @@ -longText('url')->after('result')->nullable(); - $table->string('job_command_name')->after('url')->nullable(); - $table->longText('job_command')->after('job_command_name')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('job_results', function (Blueprint $table) { - $table->dropColumn('url'); - $table->dropColumn('job_command_name'); - $table->dropColumn('job_command'); - }); - } -} diff --git a/database/migrations/2023_12_11_193200_add_new_column_2_to_job_results_table.php b/database/migrations/2023_12_11_193200_add_new_column_2_to_job_results_table.php deleted file mode 100644 index 12c6d57f..00000000 --- a/database/migrations/2023_12_11_193200_add_new_column_2_to_job_results_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('request_signature')->after('job_id')->nullable(); - $table->string('result_signature')->after('request_signature')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('job_results', function (Blueprint $table) { - $table->dropColumn('request_signature'); - $table->dropColumn('result_signature'); - }); - } -} diff --git a/resources/assets/vue/components/bookings/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/bookings/sections/AdminPaymentsBillingSectionComponent.vue deleted file mode 100644 index 966ccbbc..00000000 --- a/resources/assets/vue/components/bookings/sections/AdminPaymentsBillingSectionComponent.vue +++ /dev/null @@ -1,136 +0,0 @@ - - diff --git a/resources/assets/vue/components/bookings/sections/AdminPaymentsBillingSectionPollingComponent.vue b/resources/assets/vue/components/bookings/sections/AdminPaymentsBillingSectionPollingComponent.vue deleted file mode 100644 index 47d14857..00000000 --- a/resources/assets/vue/components/bookings/sections/AdminPaymentsBillingSectionPollingComponent.vue +++ /dev/null @@ -1,136 +0,0 @@ - - diff --git a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue index d2b69080..7df9c125 100644 --- a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue @@ -117,17 +117,11 @@
- -
@@ -171,7 +165,7 @@ } }, created(){ - this.submit(route('api.company.list') + '?filters=' + JSON.stringify({'business_type': 3, 'status_in': [1, 2, 0]}), 'get', 'pendingOrdersSection', false, false); //cief todo: Uncaught (in promise) null + this.submit(route('api.company.list') + '?filters=' + JSON.stringify({'business_type': 3, 'status_in': [1, 2, 0]}), 'get', 'pendingOrdersSection', false, false) }, methods: { successHandler(response){ @@ -216,4 +210,4 @@ } - + \ No newline at end of file diff --git a/resources/assets/vue/components/general/elements/ListPollingComponent.vue b/resources/assets/vue/components/general/elements/ListPollingComponent.vue deleted file mode 100644 index fcd3b8b8..00000000 --- a/resources/assets/vue/components/general/elements/ListPollingComponent.vue +++ /dev/null @@ -1,213 +0,0 @@ - - - diff --git a/resources/assets/vue/general/mixins/aws/requestV2.js b/resources/assets/vue/general/mixins/aws/requestV2.js deleted file mode 100644 index 12b27542..00000000 --- a/resources/assets/vue/general/mixins/aws/requestV2.js +++ /dev/null @@ -1,49 +0,0 @@ -export default { - methods: { - poll(url, method, section, successNotification = true, errorNotification = true){ - if(!this.validate()){ return; } - if (section) { - this.$store.dispatch('toggleLoading', {name: section, status: true}) - } - this.$store.dispatch('crudRequestV2', { - endpoint: url, - method: method, - parameters: this.parameters - }).then(response => { - let statusCode = response.status, - success = response.ok; - - response.json().then(response => { - - if(!success){ - this.openModal(); - errorNotification ? this.$store.dispatch('createNotification', {title: response.title, message: response.message, type: 'error'}): null; - this.errorHandler(response, statusCode); return; - } - - successNotification ? this.$store.dispatch('createNotification', {title: response.title, message: response.message, type: 'success'}): null; - this.successHandler(response) - - - }); - }).catch((error) => { - this.$store.dispatch('createNotification', {title: 'Unexpected Error', message: 'An unexpected error has occurred. Try again!', type: 'error'}); - }).then(() => { - if (section) { - this.$store.dispatch('toggleLoading', {name: section, status: false}) - } - }) - - }, - validate() { - if(this.$v){ - this.$v.$touch(); - return !this.$v.$invalid; - } - return true; - }, - successHandler(response){}, - errorHandler(response){} - } - -} diff --git a/resources/assets/vue/general/mixins/tabHandler.js b/resources/assets/vue/general/mixins/tabHandler.js deleted file mode 100644 index 81790ed0..00000000 --- a/resources/assets/vue/general/mixins/tabHandler.js +++ /dev/null @@ -1,24 +0,0 @@ -export default { - data() { - return { - activeTab: null, - displayedTabs: [], - }; - }, - methods: { - setActiveTab(event) { - const tabName = event.currentTarget.getAttribute('tab-name'); - // console.log(`Tab "${tabName}" clicked`); - this.activeTab = tabName; - if (!this.displayedTabs.includes(tabName)) { - this.displayedTabs.push(tabName); - } - }, - isActiveTab(tabName) { - return this.activeTab === tabName; - }, - showTabContent(tabName) { - return this.displayedTabs.includes(tabName); - }, - }, -} diff --git a/resources/assets/vue/vuex/modules/crudRequestV2.js b/resources/assets/vue/vuex/modules/crudRequestV2.js deleted file mode 100644 index 355b1edb..00000000 --- a/resources/assets/vue/vuex/modules/crudRequestV2.js +++ /dev/null @@ -1,51 +0,0 @@ -export default { - actions: { - crudRequestV2({getters, dispatch}, {endpoint, method, parameters}){ - return dispatch('ensureReCaptchaIsSet').then(function () { - const queryDomain = endpoint.split('?')[0]; - let encodedParams = endpoint.split('?')[1]; - let decodedParams = fullyDecodeURI(encodedParams); - const queryParams = encodeURIComponent(decodedParams); - encodedParams = queryParams.toString(); - let filteredEncodedParams = encodedParams.replace(/%3D/g,'='); - filteredEncodedParams = filteredEncodedParams.replace(/%26/g,'&'); - let combinedAbsoluteUrl = queryDomain; - if(filteredEncodedParams !== undefined && filteredEncodedParams !== 'undefined'){ - combinedAbsoluteUrl = queryDomain + '?' + filteredEncodedParams; - } - - // return fetch(endpoint, { - return fetch(combinedAbsoluteUrl, { - method: method, - responseType: 'json', - body: parameters ? JSON.stringify(parameters):null, - headers: { - 'content-type': 'application/json', - 'Authorization': 'Bearer '+getters.getAccessToken, - 'captcha-token': getters.getReCaptcha - } - }).then(response => { - - if(response.status === 401 && window.location.href !== route('login')){ - dispatch('userAuthentication', {access_token: '', redirect_url: '/'}); - } - - return response; - - }) - }); - } - } -} - -function isEncoded(uri) { - uri = uri || ''; - return uri !== decodeURIComponent(uri); -} - -function fullyDecodeURI(uri){ - while (isEncoded(uri)){ - uri = decodeURIComponent(uri); - } - return uri; -} diff --git a/resources/assets/vue/vuex/store.js b/resources/assets/vue/vuex/store.js index ff10c673..2c3d911b 100644 --- a/resources/assets/vue/vuex/store.js +++ b/resources/assets/vue/vuex/store.js @@ -4,7 +4,6 @@ import toggleSection from './modules/toggleSection' import toggleLoading from './modules/toggleLoading' import createNotification from './modules/createNotification' import crudRequest from './modules/crudRequest' -import crudRequestV2 from './modules/crudRequestV2' import authentication from './modules/authentication' import loadRequestQueue from './modules/loadRequestQueue' @@ -17,7 +16,6 @@ export default new Vuex.Store({ loadRequestQueue, createNotification, crudRequest, - crudRequestV2, authentication } -}) +}) \ No newline at end of file diff --git a/resources/views/pages/billings.blade.php b/resources/views/pages/billings.blade.php index da84f8b9..4bc012d5 100644 --- a/resources/views/pages/billings.blade.php +++ b/resources/views/pages/billings.blade.php @@ -3,7 +3,129 @@
- + +
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Invoice
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Purchase Order
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Delivery Order
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Supplier Delivery Order
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+
-@endsection +@endsection \ No newline at end of file diff --git a/resources/views/pages/billings_experiment.blade.php b/resources/views/pages/billings_experiment.blade.php deleted file mode 100644 index d1caee2d..00000000 --- a/resources/views/pages/billings_experiment.blade.php +++ /dev/null @@ -1,9 +0,0 @@ -@extends('layouts.base_portal') -@section('inner_content') -
-
- - -
-
-@endsection diff --git a/routes/api.php b/routes/api.php index 460bd772..8b4bada0 100644 --- a/routes/api.php +++ b/routes/api.php @@ -67,10 +67,6 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/milestone.php'; - // require __DIR__ . '/accounting.php'; //cief todo: To check if this is needed - - require __DIR__ . '/job.php'; - // require __DIR__ . '/rate.php'; // require __DIR__ . '/receipt.php'; diff --git a/routes/currency.php b/routes/currency.php index ba55c9a2..b621aad6 100644 --- a/routes/currency.php +++ b/routes/currency.php @@ -1,4 +1,4 @@ - 'document', 'as' => 'document.', 'namespace' => 'Documents'], function () { Route::get('/list', 'ListDocumentsController@list')->name('list'); - Route::get('/list/job', 'ListDocumentsJobController@list')->name('list.job'); Route::delete('/{id}/delete', 'DeleteDocumentController@delete')->name('delete'); Route::put('/{id}/approve', 'ApproveDocumentController@approve')->name('status.approve'); Route::put('/{id}/reject', 'RejectDocumentController@reject')->name('status.reject'); Route::put('/{id}/reference/update', 'UpdateDocumentReferenceController@update')->name('reference.update'); -}); +}); \ No newline at end of file diff --git a/routes/job.php b/routes/job.php deleted file mode 100644 index 028e9468..00000000 --- a/routes/job.php +++ /dev/null @@ -1,8 +0,0 @@ - 'job', 'as' => 'job.', 'namespace' => 'Jobs'], function () { - Route::get('/fetch/{job_id}', 'FetchJobResultController@fetch')->name('fetch'); - Route::get('/fetch/{job_id}/{is_last}', 'FetchJobResultController@fetch')->name('fetch.last.attempt'); -}); diff --git a/routes/web.php b/routes/web.php index a6590c17..bf2892bb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -92,12 +92,6 @@ Route::get('/billings', function () { return view('pages.billings'); })->name('billings'); -/* Vue Polling Experiment - Starts */ -Route::get('/billings-experiment', function () { - return view('pages.billings_experiment'); -})->name('billings.experiment'); -/* Vue Polling Experiment - Ends */ - Route::get('/currency_orders', function () { return view('pages.currency_orders'); })->name('currency_orders'); @@ -836,13 +830,13 @@ Route::get('/invoice/{marking}/{started_at}/{ended_at}/fix', function($marking, ->withTrashed() ->orderBy('created_at', 'asc') ->first(); - + // get the first bill_no $firstBillNo = $firstInvoice->bill_no; if (strpos($firstBillNo, '-deleted') !== false) { $firstBillNo = substr($firstBillNo, 0, strpos($firstBillNo, '-deleted')); } - + // update currentInvoice bill_no to '-deleted-' $currentInvoice = $booking->transactions()->where('type', TransactionType::INVOICE)->first(); $currentInvoice->bill_no = $currentInvoice->bill_no ."-deleted-" . Str::random(10); @@ -865,4 +859,4 @@ Route::get('/invoice/{marking}/{started_at}/{ended_at}/fix', function($marking, } } ); -})->name('invoice.fix.byCustomerMarking'); +})->name('invoice.fix.byCustomerMarking'); \ No newline at end of file