From e12e5a460ee6098edff5db694b365acaaac76735 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Sat, 24 Jul 2021 16:21:11 +0800 Subject: [PATCH] WIP - Order steps & remaining APIs --- .../CreateContainerPackingListLogic.php | 4 +- .../FetchContainerPackingListLogic 2.php | 66 ------------- .../UpdateContainerPackingListLogic.php | 26 ++--- .../ContainerPackingListObject.php | 2 +- .../ContainerPackingListPackageValidation.php | 41 -------- .../ContainerPackingListValidation 2.php | 41 -------- .../ContainerPackingListValidation.php | 17 ++-- .../CreatePackageItemLogic.php | 4 +- .../UpdatePackageItemLogic.php | 36 +++---- .../ControllersLogic/CreatePackageLogic.php | 8 +- .../ControllersLogic/UpdatePackageLogic.php | 37 +++---- .../CreatePackingListLogic.php | 1 - .../UpdatePackingListLogic.php | 29 ++---- .../Services/UpdatesPackingList.php | 11 +-- .../ControllersLogic/UpdateRemarkLogic.php | 1 - .../ControllersLogic/UpdateScheduleLogic.php | 1 - .../ControllersLogic/CreateTransportLogic.php | 1 - .../DataTransferObjects/TransportObject.php | 12 +-- .../ContainerPackingListResource.php | 25 +++++ resources/views/swagger/json.blade.php | 97 +++++++++++++------ 20 files changed, 158 insertions(+), 302 deletions(-) delete mode 100644 app/Classes/Modules/ContainerPackingLists/ControllersLogic/FetchContainerPackingListLogic 2.php delete mode 100644 app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListPackageValidation.php delete mode 100644 app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListValidation 2.php create mode 100644 app/Http/Resources/ContainerPackingListResource.php diff --git a/app/Classes/Modules/ContainerPackingLists/ControllersLogic/CreateContainerPackingListLogic.php b/app/Classes/Modules/ContainerPackingLists/ControllersLogic/CreateContainerPackingListLogic.php index 842338a1..383b5f6f 100644 --- a/app/Classes/Modules/ContainerPackingLists/ControllersLogic/CreateContainerPackingListLogic.php +++ b/app/Classes/Modules/ContainerPackingLists/ControllersLogic/CreateContainerPackingListLogic.php @@ -8,7 +8,7 @@ use App\Classes\Modules\ContainerPackingLists\Services\CreatesContainerPackingLi use App\Classes\Modules\ContainerPackingLists\Standards\Rules\CanCreateContainerPackingList; use App\Classes\Modules\ContainerPackingLists\DataTransferObjects\ContainerPackingListObject; use App\Classes\Modules\PackingLists\Services\FetchesPackingList; -use App\Http\Resources\PackingListResource; +use App\Http\Resources\ContainerPackingListResource; use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -60,7 +60,7 @@ class CreateContainerPackingListLogic extends AbstractControllerLogic $query = $this->createsContainerPackingList->execute($object); - return $this->resourceResponse(new PackingListResource($packingList)); + return $this->resourceResponse(new ContainerPackingListResource($query)); } diff --git a/app/Classes/Modules/ContainerPackingLists/ControllersLogic/FetchContainerPackingListLogic 2.php b/app/Classes/Modules/ContainerPackingLists/ControllersLogic/FetchContainerPackingListLogic 2.php deleted file mode 100644 index 74d4b418..00000000 --- a/app/Classes/Modules/ContainerPackingLists/ControllersLogic/FetchContainerPackingListLogic 2.php +++ /dev/null @@ -1,66 +0,0 @@ - 'Retrieved ContainerPackingList', - 'message' => 'You have successfully retrieved a ContainerPackingList' - ]; - } - - /** @var CanFetchContainerPackingList */ - private $canFetchContainerPackingList; - - /** @var FetchesContainerPackingList */ - private $fetchesContainerPackingList; - - /** - * FetchContainerPackingListControllersLogic constructor. - * @param CanFetchContainerPackingList $canFetchContainerPackingList - * @param FetchesContainerPackingList $fetchesContainerPackingList - */ - public function __construct(CanFetchContainerPackingList $canFetchContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList) - { - $this->canFetchContainerPackingList = $canFetchContainerPackingList; - $this->fetchesContainerPackingList = $fetchesContainerPackingList; - } - - - /** - * @param Request $request - * @return JsonResponse - * @throws ErrorException - */ - public function logic(Request $request) : JsonResponse - { - try { - - $this->canFetchContainerPackingList->passes(); - - $query = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]); - - return $this->resourceResponse(new ContainerPackingListResource($query)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } - - } - -} diff --git a/app/Classes/Modules/ContainerPackingLists/ControllersLogic/UpdateContainerPackingListLogic.php b/app/Classes/Modules/ContainerPackingLists/ControllersLogic/UpdateContainerPackingListLogic.php index a614c230..8ae97336 100644 --- a/app/Classes/Modules/ContainerPackingLists/ControllersLogic/UpdateContainerPackingListLogic.php +++ b/app/Classes/Modules/ContainerPackingLists/ControllersLogic/UpdateContainerPackingListLogic.php @@ -6,7 +6,6 @@ namespace App\Classes\Modules\ContainerPackingLists\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\ContainerPackingLists\Services\UpdatesContainerPackingList; use App\Classes\Modules\ContainerPackingLists\Services\FetchesContainerPackingList; -use App\Classes\Modules\ContainerPackingLists\Services\FetchesDistrict; use App\Classes\Modules\ContainerPackingLists\Standards\Rules\CanUpdateContainerPackingList; use App\Classes\Modules\ContainerPackingLists\DataTransferObjects\ContainerPackingListObject; use App\Http\Resources\ContainerPackingListResource; @@ -36,22 +35,17 @@ class UpdateContainerPackingListLogic extends AbstractControllerLogic /** @var FetchesContainerPackingList */ private $fetchesContainerPackingList; - /** @var FetchesDistrict */ - private $fetchesDistrict; - /** * UpdateContainerPackingListLogic constructor. * @param CanUpdateContainerPackingList $canUpdateContainerPackingList * @param UpdatesContainerPackingList $updatesContainerPackingList * @param FetchesContainerPackingList $fetchesContainerPackingList - * @param FetchesDistrict $fetchesDistrict */ - public function __construct(CanUpdateContainerPackingList $canUpdateContainerPackingList, UpdatesContainerPackingList $updatesContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList, FetchesDistrict $fetchesDistrict) + public function __construct(CanUpdateContainerPackingList $canUpdateContainerPackingList, UpdatesContainerPackingList $updatesContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList) { $this->canUpdateContainerPackingList = $canUpdateContainerPackingList; $this->updatesContainerPackingList = $updatesContainerPackingList; $this->fetchesContainerPackingList = $fetchesContainerPackingList; - $this->fetchesDistrict = $fetchesDistrict; } @@ -62,24 +56,16 @@ class UpdateContainerPackingListLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - try { - $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); - $object = new ContainerPackingListObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); - //$object = new ContainerPackingListObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing')); + $container = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]); - $this->canUpdateContainerPackingList->passes($object); + $object = new ContainerPackingListObject( $container->packing_list_id , $request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference')); - $query = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]); + $this->canUpdateContainerPackingList->passes($object); - $query = $this->updatesContainerPackingList->execute($query, $object); + $query = $this->updatesContainerPackingList->execute($container, $object); - return $this->resourceResponse(new ContainerPackingListResource($query)); - - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + return $this->resourceResponse(new ContainerPackingListResource($query)); } diff --git a/app/Classes/Modules/ContainerPackingLists/DataTransferObjects/ContainerPackingListObject.php b/app/Classes/Modules/ContainerPackingLists/DataTransferObjects/ContainerPackingListObject.php index 97ceae5c..067033ff 100644 --- a/app/Classes/Modules/ContainerPackingLists/DataTransferObjects/ContainerPackingListObject.php +++ b/app/Classes/Modules/ContainerPackingLists/DataTransferObjects/ContainerPackingListObject.php @@ -38,7 +38,7 @@ class ContainerPackingListObject implements DataTransferObject return $this->containerType; } - public function getSealReference(): int + public function getSealReference(): ?string { return $this->sealReference; } diff --git a/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListPackageValidation.php b/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListPackageValidation.php deleted file mode 100644 index ad87e77e..00000000 --- a/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListPackageValidation.php +++ /dev/null @@ -1,41 +0,0 @@ - $object->getPackingListId(), - 'package_id' => $object->getPackageId() - ]; - } - - /** - * @return array - */ - protected function rules(): array { - return [ - 'packing_list_id' => 'required', - 'package_id' => 'required', - ]; - } - - /** - * @return array - */ - protected function messages(): array { - return []; - } - -} diff --git a/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListValidation 2.php b/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListValidation 2.php deleted file mode 100644 index 65dd3380..00000000 --- a/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListValidation 2.php +++ /dev/null @@ -1,41 +0,0 @@ - $object->getStatus(), - 'reference' => $object->getReference() - ]; - } - - /** - * @return array - */ - protected function rules(): array { - return [ - 'status' => 'required', - 'reference' => 'required', - ]; - } - - /** - * @return array - */ - protected function messages(): array { - return []; - } - -} diff --git a/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListValidation.php b/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListValidation.php index 0ff94dc7..d8ed3fa9 100644 --- a/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListValidation.php +++ b/app/Classes/Modules/ContainerPackingLists/Standards/Validators/ContainerPackingListValidation.php @@ -1,23 +1,22 @@ $object->getPackingListId(), - 'reference' => $object->getContainerReference(), + 'packing_list_id' => $object->getPackingListId(), + 'container_reference' => $object->getContainerReference(), 'container_type' => $object->getContainerType(), 'seal_reference' => $object->getSealReference(), ]; @@ -28,10 +27,8 @@ class ContainerPackingListValidation extends AbstractValidation */ protected function rules(): array { return [ - 'status' => 'required', - 'reference' => 'required', - 'container_type' => 'required', - 'seal_reference' => 'required', + 'packing_list_id' => 'required', + 'container_reference' => 'required', ]; } diff --git a/app/Classes/Modules/PackageItems/ControllersLogic/CreatePackageItemLogic.php b/app/Classes/Modules/PackageItems/ControllersLogic/CreatePackageItemLogic.php index f935f7c5..9c3ba7b5 100644 --- a/app/Classes/Modules/PackageItems/ControllersLogic/CreatePackageItemLogic.php +++ b/app/Classes/Modules/PackageItems/ControllersLogic/CreatePackageItemLogic.php @@ -2,7 +2,7 @@ namespace App\Classes\Modules\PackageItems\ControllersLogic; - +use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\PackageItems\Services\CreatesPackageItem; use App\Classes\Modules\Orders\Services\FetchesOrder; @@ -73,7 +73,7 @@ class CreatePackageItemLogic extends AbstractControllerLogic $request->input('uom'), $request->input('price'), $request->input('total'), - 0); + ApprovalStatus::PENDING_SUBMISSION); $this->canCreatePackageItem->passes($object); diff --git a/app/Classes/Modules/PackageItems/ControllersLogic/UpdatePackageItemLogic.php b/app/Classes/Modules/PackageItems/ControllersLogic/UpdatePackageItemLogic.php index 5e61dc2e..698a464f 100644 --- a/app/Classes/Modules/PackageItems/ControllersLogic/UpdatePackageItemLogic.php +++ b/app/Classes/Modules/PackageItems/ControllersLogic/UpdatePackageItemLogic.php @@ -6,7 +6,6 @@ namespace App\Classes\Modules\PackageItems\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\PackageItems\Services\UpdatesPackageItem; use App\Classes\Modules\PackageItems\Services\FetchesPackageItem; -use App\Classes\Modules\PackageItems\Services\FetchesDistrict; use App\Classes\Modules\PackageItems\Standards\Rules\CanUpdatePackageItem; use App\Classes\Modules\PackageItems\DataTransferObjects\PackageItemObject; use App\Http\Resources\PackageItemResource; @@ -36,22 +35,17 @@ class UpdatePackageItemLogic extends AbstractControllerLogic /** @var FetchesPackageItem */ private $fetchesPackageItem; - /** @var FetchesDistrict */ - private $fetchesDistrict; - /** * UpdatePackageItemLogic constructor. * @param CanUpdatePackageItem $canUpdatePackageItem * @param UpdatesPackageItem $updatesPackageItem * @param FetchesPackageItem $fetchesPackageItem - * @param FetchesDistrict $fetchesDistrict */ - public function __construct(CanUpdatePackageItem $canUpdatePackageItem, UpdatesPackageItem $updatesPackageItem, FetchesPackageItem $fetchesPackageItem, FetchesDistrict $fetchesDistrict) + public function __construct(CanUpdatePackageItem $canUpdatePackageItem, UpdatesPackageItem $updatesPackageItem, FetchesPackageItem $fetchesPackageItem) { $this->canUpdatePackageItem = $canUpdatePackageItem; $this->updatesPackageItem = $updatesPackageItem; $this->fetchesPackageItem = $fetchesPackageItem; - $this->fetchesDistrict = $fetchesDistrict; } @@ -62,24 +56,24 @@ class UpdatePackageItemLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - try { + $packageItem = $this->fetchesPackageItem->execute(['id' => $request->route('id')]); - $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); - $object = new PackageItemObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); - //$object = new PackageItemObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing')); + $object = new PackageItemObject( + $packageItem->package_id, + $request->input('name'), + $packageItem->reference, + $request->input('description'), + $request->input('quantity'), + $request->input('uom'), + $request->input('price'), + $request->input('total'), + $request->input('status')); - $this->canUpdatePackageItem->passes($object); + $this->canUpdatePackageItem->passes($object); - $query = $this->fetchesPackageItem->execute(['id' => $request->route('id')]); + $query = $this->updatesPackageItem->execute($packageItem, $object); - $query = $this->updatesPackageItem->execute($query, $object); - - return $this->resourceResponse(new PackageItemResource($query)); - - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + return $this->resourceResponse(new PackageItemResource($query)); } diff --git a/app/Classes/Modules/Packages/ControllersLogic/CreatePackageLogic.php b/app/Classes/Modules/Packages/ControllersLogic/CreatePackageLogic.php index 4fcf1613..5c17b99f 100644 --- a/app/Classes/Modules/Packages/ControllersLogic/CreatePackageLogic.php +++ b/app/Classes/Modules/Packages/ControllersLogic/CreatePackageLogic.php @@ -2,7 +2,7 @@ namespace App\Classes\Modules\Packages\ControllersLogic; - +use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Packages\Services\CreatesPackage; use App\Classes\Modules\Orders\Services\FetchesOrder; @@ -30,7 +30,7 @@ class CreatePackageLogic extends AbstractControllerLogic /** @var CanCreatePackage */ private $canCreatePackage; - /** @var FetchesDistrict */ + /** @var FetchesOrder */ private $fetchesOrder; /** @var FetchesCompany */ @@ -42,7 +42,7 @@ class CreatePackageLogic extends AbstractControllerLogic /** * CreatePackageLogic constructor. * @param CanCreatePackage $canCreatePackage - * @param FetchesDistrict $fetchesDistrict + * @param FetchesOrder $fetchesOrder * @param FetchesCompany $fetchesCompany * @param CreatesPackage $createsPackage */ @@ -76,7 +76,7 @@ class CreatePackageLogic extends AbstractControllerLogic $request->input('length'), $request->input('weight'), $request->input('quantity'), - 0); + ApprovalStatus::PENDING_SUBMISSION); $this->canCreatePackage->passes($object); diff --git a/app/Classes/Modules/Packages/ControllersLogic/UpdatePackageLogic.php b/app/Classes/Modules/Packages/ControllersLogic/UpdatePackageLogic.php index 3a844486..baf6e2ca 100644 --- a/app/Classes/Modules/Packages/ControllersLogic/UpdatePackageLogic.php +++ b/app/Classes/Modules/Packages/ControllersLogic/UpdatePackageLogic.php @@ -6,7 +6,6 @@ namespace App\Classes\Modules\Packages\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Packages\Services\UpdatesPackage; use App\Classes\Modules\Packages\Services\FetchesPackage; -use App\Classes\Modules\Packages\Services\FetchesDistrict; use App\Classes\Modules\Packages\Standards\Rules\CanUpdatePackage; use App\Classes\Modules\Packages\DataTransferObjects\PackageObject; use App\Http\Resources\PackageResource; @@ -36,22 +35,18 @@ class UpdatePackageLogic extends AbstractControllerLogic /** @var FetchesPackage */ private $fetchesPackage; - /** @var FetchesDistrict */ - private $fetchesDistrict; /** * UpdatePackageLogic constructor. * @param CanUpdatePackage $canUpdatePackage * @param UpdatesPackage $updatesPackage * @param FetchesPackage $fetchesPackage - * @param FetchesDistrict $fetchesDistrict */ - public function __construct(CanUpdatePackage $canUpdatePackage, UpdatesPackage $updatesPackage, FetchesPackage $fetchesPackage, FetchesDistrict $fetchesDistrict) + public function __construct(CanUpdatePackage $canUpdatePackage, UpdatesPackage $updatesPackage, FetchesPackage $fetchesPackage) { $this->canUpdatePackage = $canUpdatePackage; $this->updatesPackage = $updatesPackage; $this->fetchesPackage = $fetchesPackage; - $this->fetchesDistrict = $fetchesDistrict; } @@ -62,25 +57,25 @@ class UpdatePackageLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - try { + $package = $this->fetchesPackage->execute(['id' => $request->route('id')]); - $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); - $object = new PackageObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); - //$object = new PackageObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing')); + $object = new PackageObject( + $package->order_id, + null, + $request->input('type'), + $request->input('description'), + $request->input('width'), + $request->input('height'), + $request->input('length'), + $request->input('weight'), + $request->input('quantity'), + $request->input('status')); - $this->canUpdatePackage->passes($object); + $this->canUpdatePackage->passes($object); - $query = $this->fetchesPackage->execute(['id' => $request->route('id')]); - - $query = $this->updatesPackage->execute($query, $object); - - return $this->resourceResponse(new PackageResource($query)); - - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + $query = $this->updatesPackage->execute($package, $object); + return $this->resourceResponse(new PackageResource($query)); } } diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/CreatePackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/CreatePackingListLogic.php index 561e177d..3774a025 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/CreatePackingListLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/CreatePackingListLogic.php @@ -45,7 +45,6 @@ class CreatePackingListLogic extends AbstractControllerLogic /** * CreatePackingListLogic constructor. * @param CanCreatePackingList $canCreatePackingList - * @param FetchesDistrict $fetchesDistrict * @param FetchesCompany $fetchesCompany * @param CreatesPackingList $createsPackingList */ diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/UpdatePackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/UpdatePackingListLogic.php index 399a55e5..926b9873 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/UpdatePackingListLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/UpdatePackingListLogic.php @@ -6,7 +6,6 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\PackingLists\Services\UpdatesPackingList; use App\Classes\Modules\PackingLists\Services\FetchesPackingList; -use App\Classes\Modules\PackingLists\Services\FetchesDistrict; use App\Classes\Modules\PackingLists\Standards\Rules\CanUpdatePackingList; use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject; use App\Http\Resources\PackingListResource; @@ -36,25 +35,19 @@ class UpdatePackingListLogic extends AbstractControllerLogic /** @var FetchesPackingList */ private $fetchesPackingList; - /** @var FetchesDistrict */ - private $fetchesDistrict; - /** * UpdatePackingListLogic constructor. * @param CanUpdatePackingList $canUpdatePackingList * @param UpdatesPackingList $updatesPackingList * @param FetchesPackingList $fetchesPackingList - * @param FetchesDistrict $fetchesDistrict */ - public function __construct(CanUpdatePackingList $canUpdatePackingList, UpdatesPackingList $updatesPackingList, FetchesPackingList $fetchesPackingList, FetchesDistrict $fetchesDistrict) + public function __construct(CanUpdatePackingList $canUpdatePackingList, UpdatesPackingList $updatesPackingList, FetchesPackingList $fetchesPackingList) { $this->canUpdatePackingList = $canUpdatePackingList; $this->updatesPackingList = $updatesPackingList; $this->fetchesPackingList = $fetchesPackingList; - $this->fetchesDistrict = $fetchesDistrict; } - /** * @param Request $request * @return JsonResponse @@ -62,25 +55,15 @@ class UpdatePackingListLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - try { + $packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]); - $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); - $object = new PackingListObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); - //$object = new PackingListObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing')); + $object = new PackingListObject($packingList->reference, $request->input('status')); - $this->canUpdatePackingList->passes($object); + $this->canUpdatePackingList->passes($object); - $query = $this->fetchesPackingList->execute(['id' => $request->route('id')]); - - $query = $this->updatesPackingList->execute($query, $object); - - return $this->resourceResponse(new PackingListResource($query)); - - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + $query = $this->updatesPackingList->execute($packingList, $object); + return $this->resourceResponse(new PackingListResource($query)); } } diff --git a/app/Classes/Modules/PackingLists/Services/UpdatesPackingList.php b/app/Classes/Modules/PackingLists/Services/UpdatesPackingList.php index 2a53408b..7f81ae22 100644 --- a/app/Classes/Modules/PackingLists/Services/UpdatesPackingList.php +++ b/app/Classes/Modules/PackingLists/Services/UpdatesPackingList.php @@ -17,15 +17,8 @@ class UpdatesPackingList extends AbstractUpdateRecord */ public function execute(PackingList $model, PackingListObject $object) { - //$model->company_id = $object->getCompanyId(); - $model->street_one = $object->getStreetOne(); - $model->street_two = $object->getStreetTwo(); - $model->district_id = $object->getDistrictId(); - $model->state_id = $object->getStateId(); - $model->postcode = $object->getPostCode(); - $model->country_id = $object->getCountryId(); - //$model->default = $object->getDefault(); - //$model->billing = $object->getBilling(); + $model->reference = $object->getReference(); + $model->status = $object->getStatus(); return $this->handler($model); diff --git a/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php b/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php index 3ddaebcd..e9c0738f 100644 --- a/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php +++ b/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php @@ -39,7 +39,6 @@ class UpdateRemarkLogic extends AbstractControllerLogic * @param CanUpdateRemark $canUpdateRemark * @param UpdatesRemark $updatesRemark * @param FetchesRemark $fetchesRemark - * @param FetchesDistrict $fetchesDistrict */ public function __construct(CanUpdateRemark $canUpdateRemark, UpdatesRemark $updatesRemark, FetchesRemark $fetchesRemark) { diff --git a/app/Classes/Modules/Schedules/ControllersLogic/UpdateScheduleLogic.php b/app/Classes/Modules/Schedules/ControllersLogic/UpdateScheduleLogic.php index 184b73f2..2805c927 100644 --- a/app/Classes/Modules/Schedules/ControllersLogic/UpdateScheduleLogic.php +++ b/app/Classes/Modules/Schedules/ControllersLogic/UpdateScheduleLogic.php @@ -41,7 +41,6 @@ class UpdateScheduleLogic extends AbstractControllerLogic * @param CanUpdateSchedule $canUpdateSchedule * @param UpdatesSchedule $updatesSchedule * @param FetchesSchedule $fetchesSchedule - * @param FetchesDistrict $fetchesDistrict */ public function __construct(CanUpdateSchedule $canUpdateSchedule, UpdatesSchedule $updatesSchedule, FetchesSchedule $fetchesSchedule) { diff --git a/app/Classes/Modules/Transports/ControllersLogic/CreateTransportLogic.php b/app/Classes/Modules/Transports/ControllersLogic/CreateTransportLogic.php index 1a0aa96b..73bdafac 100644 --- a/app/Classes/Modules/Transports/ControllersLogic/CreateTransportLogic.php +++ b/app/Classes/Modules/Transports/ControllersLogic/CreateTransportLogic.php @@ -5,7 +5,6 @@ namespace App\Classes\Modules\Transports\ControllersLogic; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Transports\Services\CreatesTransport; -use App\Classes\Modules\Transports\Services\FetchesDistrict; use App\Classes\Modules\Transports\Standards\Rules\CanCreateTransport; use App\Classes\Modules\Transports\DataTransferObjects\TransportObject; use App\Classes\Modules\ContainerPackingLists\Services\FetchesContainerPackingList; diff --git a/app/Classes/Modules/Transports/DataTransferObjects/TransportObject.php b/app/Classes/Modules/Transports/DataTransferObjects/TransportObject.php index bc493ca4..c391ac72 100644 --- a/app/Classes/Modules/Transports/DataTransferObjects/TransportObject.php +++ b/app/Classes/Modules/Transports/DataTransferObjects/TransportObject.php @@ -28,14 +28,14 @@ class TransportObject implements DataTransferObject /** * TransportObject constructor. - * @param string $type + * @param int $type * @param null|string $courier - * @param int $tracking_number + * @param string $tracking_number * @param int $dispatch_date * @param int $drop_date * @param int $status */ - public function __construct(string $type, string $courier, int $tracking_number, ?string $dispatch_date, ?string $drop_date, int $status) + public function __construct(int $type, string $courier, string $tracking_number, ?string $dispatch_date, ?string $drop_date, int $status) { $this->type = $type; $this->courier = $courier; @@ -46,9 +46,9 @@ class TransportObject implements DataTransferObject } /** - * @return string + * @return int */ - public function getType(): string + public function getType(): int { return $this->type; } @@ -64,7 +64,7 @@ class TransportObject implements DataTransferObject /** * @return int */ - public function getTrackingNumber(): int + public function getTrackingNumber(): string { return $this->tracking_number; } diff --git a/app/Http/Resources/ContainerPackingListResource.php b/app/Http/Resources/ContainerPackingListResource.php new file mode 100644 index 00000000..b98b5f00 --- /dev/null +++ b/app/Http/Resources/ContainerPackingListResource.php @@ -0,0 +1,25 @@ + $this->id, + 'packing_list_id' => $this->packing_list_id, + 'container_reference' => $this->container_reference, + 'container_type' => $this->container_type, + 'seal_reference' => $this->seal_reference, + ]; + } +} diff --git a/resources/views/swagger/json.blade.php b/resources/views/swagger/json.blade.php index 1d1f753b..2a23ab93 100644 --- a/resources/views/swagger/json.blade.php +++ b/resources/views/swagger/json.blade.php @@ -210,25 +210,18 @@ "parameters": [ { "name": "id", - "in": "query", - "description": "transport id", + "in": "path", + "description": "Packing list id", "required": true, "type": "integer" }, { - "name": "commenter_id", + "name": "status", "in": "query", - "description": "Commenter id", + "description": "Status", "required": true, "type": "integer" }, - { - "name": "content", - "in": "query", - "description": "Content", - "required": true, - "type": "string" - } ], "responses": { "200": { @@ -331,7 +324,7 @@ "in": "query", "description": "Container type", "required": true, - "type": "string" + "type": "integer" }, { "name": "seal_reference", @@ -422,7 +415,7 @@ "produces": [ "application/json" ], - "operationId": "showPacking", + "operationId": "showContainerPacking", "summary": "Show container packing list", "description": "", "parameters": [ @@ -467,7 +460,7 @@ "produces": [ "application/json" ], - "operationId": "updatePacking", + "operationId": "updateContainerPacking", "summary": "Update packing", "description": "", "parameters": [ @@ -497,7 +490,7 @@ "in": "query", "description": "Container type", "required": true, - "type": "string" + "type": "integer" }, { "name": "seal_reference", @@ -1088,6 +1081,13 @@ "required": true, "type": "integer" }, + { + "name": "status", + "in": "query", + "description": "Status", + "required": true, + "type": "integer" + }, ], "responses": { "200": { @@ -1181,7 +1181,7 @@ { "name": "name", "in": "query", - "description": "Courier Provider Name", + "description": "Name", "required": true, "type": "string" }, @@ -1359,19 +1359,54 @@ "type": "string" }, { - "name": "commenter_id", + "name": "name", "in": "query", - "description": "Commenter id", + "description": "Name", + "required": true, + "type": "string" + }, + { + "name": "description", + "in": "query", + "description": "Description", + "required": false, + "type": "string" + }, + { + "name": "quantity", + "in": "query", + "description": "Quantity", + "required": true, + "type": "number" + }, + { + "name": "uom", + "in": "query", + "description": "UOM", + "required": true, + "type": "string" + }, + { + "name": "price", + "in": "query", + "description": "Price", + "required": true, + "type": "number" + }, + { + "name": "total", + "in": "query", + "description": "Total", + "required": true, + "type": "number" + }, + { + "name": "status", + "in": "query", + "description": "Status", "required": true, "type": "integer" }, - { - "name": "comment", - "in": "query", - "description": "Comment", - "required": true, - "type": "string" - } ], "responses": { "200": { @@ -1661,7 +1696,7 @@ "in": "query", "description": "Status", "required": true, - "type": "string" + "type": "integer" }, ], "responses": { @@ -1756,14 +1791,14 @@ { "name": "etd", "in": "query", - "description": "Estimate time deliver", + "description": "Estimate time deliver (e.g. 2021-09-01)", "required": true, "type": "string" }, { "name": "eta", "in": "query", - "description": "Estimate time arrival", + "description": "Estimate time arrival (e.g. 2021-09-01)", "required": true, "type": "string" } @@ -1908,14 +1943,14 @@ { "name": "etd", "in": "query", - "description": "Estimate time deliver", + "description": "Estimate time deliver (e.g. 2021-09-01)", "required": true, "type": "string" }, { "name": "eta", "in": "query", - "description": "Estimate time arrival", + "description": "Estimate time arrival (e.g. 2021-09-01)", "required": true, "type": "string" }, @@ -1924,7 +1959,7 @@ "in": "query", "description": "Status", "required": true, - "type": "string" + "type": "integer" } ], "responses": {