From 3aec23525cf29e36757ce6acd528547bde41c4e2 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Mon, 13 Dec 2021 11:45:48 +0800 Subject: [PATCH] Duplicate packing list for admin CIEF reference --- .../FetchLoadedContainersFromVTPortalProcessor.php | 7 ++++++- app/Models/PackingList.php | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php index bb9986c0..32c17cd1 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php @@ -21,6 +21,7 @@ use App\Classes\Modules\Unity\Services\CreatesContract; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\ContainerTypes; use App\Classes\ValueObjects\Constants\OrderRoleTypes; +use App\Classes\ValueObjects\Constants\RoleTypes; use App\Classes\ValueObjects\Constants\PackingListType; use App\Models\Order; use App\Models\PackingList; @@ -194,7 +195,7 @@ class FetchLoadedContainersFromVTPortalProcessor $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]); $importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id); - $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]); + $order->orderRoles()->where('role_id', '=', RoleT::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]); $this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations); @@ -207,6 +208,10 @@ class FetchLoadedContainersFromVTPortalProcessor $packingList = $this->createPackingListProcessor->execute($packingListObject, $order); $container->packingLists()->attach($packingList); + //Duplicate a copy for internal reference + $packingListObject = new PackingListObject($packingListReference, RoleTypes::SUPER_ADMIN, PackingListType::SHIPPING_PACKING_LIST, (int) filter_var($marking, FILTER_SANITIZE_NUMBER_INT) <= 1000 ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::SUSPENDED, $contractReference); + $packingList = $this->createPackingListProcessor->execute($packingListObject, $packingList); + foreach($contractObligations as $obligation) { $stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id); $this->createsStep->execute($packingList, $stepObject); diff --git a/app/Models/PackingList.php b/app/Models/PackingList.php index fc775ba2..24565d9c 100644 --- a/app/Models/PackingList.php +++ b/app/Models/PackingList.php @@ -4,6 +4,7 @@ namespace App\Models; use App\Classes\General\Interfaces\Steppable; use App\Classes\General\Interfaces\Transportable; +use App\Classes\General\Interfaces\Packable; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -11,7 +12,7 @@ use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\SoftDeletes; -class PackingList extends AbstractModel implements Transportable, Steppable +class PackingList extends AbstractModel implements Transportable, Steppable, Packable { use SoftDeletes;