From 8dab2a09ff5ec575cf6483460c3a2181c81f3cdd Mon Sep 17 00:00:00 2001 From: omair saleh Date: Thu, 9 Sep 2021 04:05:51 +0800 Subject: [PATCH] hold and release goods for delivery --- .../UpdatePackingListStatusLogic.php | 62 +++++++++++++++++++ ...inersStatusUpdateFromVTPortalProcessor.php | 9 ++- ...FetchDeliveryListFromVTPortalProcessor.php | 3 - ...hLoadedContainersFromVTPortalProcessor.php | 5 +- .../FetchPackingListFromVTPortalProcessor.php | 2 +- .../Services/UpdatesPackingListStatus.php | 24 +++++++ .../UpdatePackingListStatusController.php | 20 ++++++ .../elements/ContainerComponent.vue | 11 ++++ routes/packing_list.php | 1 + routes/web.php | 4 +- 10 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 app/Classes/Modules/PackingLists/ControllersLogic/UpdatePackingListStatusLogic.php create mode 100644 app/Classes/Modules/PackingLists/Services/UpdatesPackingListStatus.php create mode 100644 app/Http/Controllers/PackingLists/UpdatePackingListStatusController.php diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/UpdatePackingListStatusLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/UpdatePackingListStatusLogic.php new file mode 100644 index 00000000..67a1733c --- /dev/null +++ b/app/Classes/Modules/PackingLists/ControllersLogic/UpdatePackingListStatusLogic.php @@ -0,0 +1,62 @@ + 'Updated PackingList Status', + 'message' => 'You have successfully updated the PackingList status' + ]; + } + + + /** @var FetchesPackingList */ + private $fetchesPackingList; + + /** @var UpdatesPackingListStatus */ + private $updatesPackingListStatus; + + /** + * UpdatePackingListStatusLogic constructor. + * @param FetchesPackingList $fetchesPackingList + * @param UpdatesPackingListStatus $updatesPackingListStatus + */ + public function __construct(FetchesPackingList $fetchesPackingList, UpdatesPackingListStatus $updatesPackingListStatus) + { + $this->fetchesPackingList = $fetchesPackingList; + $this->updatesPackingListStatus = $updatesPackingListStatus; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]); + + $query = $this->updatesPackingListStatus->execute($packingList, $request->route('status')); + + return $this->resourceResponse(new PackingListResource($query)); + } + +} diff --git a/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php index cddc41ea..06d1add0 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php @@ -65,7 +65,6 @@ class FetchContainersStatusUpdateFromVTPortalProcessor /** * @return array - * @throws \App\Classes\Exceptions\MalformedRequestException */ public function execute(){ @@ -122,9 +121,15 @@ class FetchContainersStatusUpdateFromVTPortalProcessor if($containerStatus === 'Unstuffing'){ $container->update(['status' => ApprovalStatus::COMPLETED]); $container->transports()->first()->update(['drop_date' => Carbon::parse($unstuffingDate)->subDay(), 'status' => ApprovalStatus::COMPLETED]); - $container->packingLists()->update(['status' => ApprovalStatus::APPROVED]); + /** @var PackingList $packingList */ foreach($container->packingLists as $packingList){ + + if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){ + $packingList->status = ApprovalStatus::APPROVED; + $packingList->save(); + } + $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){ $this->updatesContractObligations->execute($signature, $step->obligation_hash_id); diff --git a/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php index 6714472b..c987cb29 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php @@ -3,8 +3,6 @@ namespace App\Classes\Modules\PackingLists\Processors; use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal; -use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject; -use App\Classes\Modules\PackingLists\Services\ListsPackingLists; use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject; use App\Classes\Modules\Schedules\Services\CreatesSchedule; use App\Classes\Modules\Transports\DataTransferObjects\TransportObject; @@ -12,7 +10,6 @@ use App\Classes\Modules\Transports\Services\CreatesTransport; use App\Classes\Modules\Unity\Services\UpdatesContractObligation; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\OrderRoleTypes; -use App\Classes\ValueObjects\Constants\PackageType; use App\Classes\ValueObjects\Constants\PackingListType; use App\Classes\ValueObjects\Constants\TransportType; use App\Models\PackingList; diff --git a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php index 2776124d..4ed1ff00 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php @@ -199,7 +199,10 @@ class FetchLoadedContainersFromVTPortalProcessor $this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations); - $packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::PENDING_VERIFICATION, $contractReference); + $connection = $order->companyModule->connections()->first(); + $marking = $connection->invitee_reference; + + $packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, (int) filter_var($marking, FILTER_SANITIZE_NUMBER_INT) <= 1000 ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::SUSPENDED, $contractReference); /** @var PackingList $packingList */ $packingList = $this->createPackingListProcessor->execute($packingListObject, $order); diff --git a/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php index 715c61ba..ed03c5d1 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php @@ -46,7 +46,7 @@ class FetchPackingListFromVTPortalProcessor */ public function execute(){ - $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->where('status', '=', ApprovalStatus::PENDING_VERIFICATION)->get(); + $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->get(); foreach($packingLists as $packingList){ diff --git a/app/Classes/Modules/PackingLists/Services/UpdatesPackingListStatus.php b/app/Classes/Modules/PackingLists/Services/UpdatesPackingListStatus.php new file mode 100644 index 00000000..e25b550f --- /dev/null +++ b/app/Classes/Modules/PackingLists/Services/UpdatesPackingListStatus.php @@ -0,0 +1,24 @@ +status = $status; + + return $this->handler($model); + + } +} diff --git a/app/Http/Controllers/PackingLists/UpdatePackingListStatusController.php b/app/Http/Controllers/PackingLists/UpdatePackingListStatusController.php new file mode 100644 index 00000000..5d653449 --- /dev/null +++ b/app/Http/Controllers/PackingLists/UpdatePackingListStatusController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index 78fd231a..d66b5517 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -43,6 +43,7 @@
Customer Marking
Quantity
CBM
+
status
Delivery Address
@@ -56,7 +57,12 @@
{{packingList.order.company_module.marking}}
{{packingList.packages.reduce((total, obj) => obj.quantity + total, 0)}}
{{(Math.round((packingList.packages.reduce((total, obj) => obj.cbm + total, 0)) * 10000) / 10000).toFixed(3)}}
+
{{packingList.status === 5 ? 'On Hold' : 'Release'}}
{{packingList.order.address.street_one+' '+(packingList.order.address.street_two ? packingList.order.address.street_two : '')+', '+ packingList.order.address.district.name+', '+packingList.order.address.post_code+' '+packingList.order.address.state.name+', '+packingList.order.address.country.name}}
+
+
Release
+
Hold
+
@@ -75,6 +81,11 @@ expanded: false } }, + methods: { + successHandler(){ + this.$store.dispatch('reloadList', {'name': 'containerListSection'}); + } + }, mixins: [componentHandler] } \ No newline at end of file diff --git a/routes/packing_list.php b/routes/packing_list.php index 06b11950..ea64c7e1 100644 --- a/routes/packing_list.php +++ b/routes/packing_list.php @@ -7,6 +7,7 @@ Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' = Route::get('/list', 'ListPackingListsController@list')->name('list'); Route::post('/create', 'CreatePackingListController@create')->name('create'); Route::put('/update/{id}', 'UpdatePackingListController@update')->name('update'); + Route::put('/status/{id}/update/{status}', 'UpdatePackingListStatusController@update')->name('status.update'); Route::delete('/delete/{id}', 'DeletePackingListController@delete')->name('delete'); Route::group(['namespace' => 'Containers', 'prefix' => 'container', 'as' => 'container.'], function () { diff --git a/routes/web.php b/routes/web.php index 2ebbe797..7548a1dd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -77,6 +77,7 @@ Route::get('/customer/{marking}', function ($marking) { })->name('customer.profile'); Route::get('/orders/refresh', function(){ + FetchWarehouseReceiveListFromVTPortalJob::withChain([ new FetchLoadedContainersFromVTPortalJob, new FetchPackingListFromVTPortalJob, @@ -84,7 +85,8 @@ Route::get('/orders/refresh', function(){ new FetchDeliveryListFromVTPortalJob ])->dispatch(); - return redirect('orders'); + return redirect()->back(); + })->name('orders.refresh'); Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download')->name('order.qr.download');