diff --git a/app/Classes/Modules/Exports/Services/ExportsPendingArrangementDeliveryList.php b/app/Classes/Modules/Exports/Services/ExportsPendingArrangementDeliveryList.php index 65908390..d7a33554 100644 --- a/app/Classes/Modules/Exports/Services/ExportsPendingArrangementDeliveryList.php +++ b/app/Classes/Modules/Exports/Services/ExportsPendingArrangementDeliveryList.php @@ -57,7 +57,8 @@ class ExportsPendingArrangementDeliveryList implements FromQuery, WithHeadings, $container = $packingList->containers()->first(); $ContainerTransport = $container->transports()->first(); $order = $packingList->owner; - $marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; + $inviter = $order->companyModule ? $order->companyModule->inviters()->withPivot('invitee_reference')->first() : null; + $marking = $inviter ? $inviter->pivot->invitee_reference : 'Unclaimed'; $address = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first(); $contacts = $address->contacts->first() ? $address->contacts->first(): ''; $originalPackingList = $packingList->owner instanceof PackingList ? $packingList->owner : $packingList; diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListLogic.php index 850f196b..09f6453f 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListLogic.php @@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\PackingLists\Services\DeletesPackingList; use App\Classes\Modules\PackingLists\Services\FetchesPackingList; use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList; +use App\Classes\ValueObjects\Constants\PackingListType; use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -58,9 +59,11 @@ class DeletePackingListLogic extends AbstractControllerLogic $this->canDeletePackingList->passes(); - $query = $this->fetchesPackingList->execute(['id' => $request->route('id')]); + $warehouseList = $this->fetchesPackingList->execute(['id' => $request->route('id')]); + $packingList = $this->fetchesPackingList->execute(['reference' => $warehouseList->reference, 'type' => PackingListType::SHIPPING_PACKING_LIST]); - $this->deletesPackingList->execute($query); + $this->deletesPackingList->execute($warehouseList); + $this->deletesPackingList->execute($packingList); return $this->response([]); diff --git a/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php index 520e64ec..c6239da5 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php @@ -91,7 +91,6 @@ class FetchDeliveryListFromVTPortalProcessor $deliveryStep->update(['status' => ApprovalStatus::COMPLETED]); } catch (GuzzleException $exception) { - dd($exception); continue; } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php index f8b915a8..b29dc77b 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php @@ -7,12 +7,15 @@ use App\Classes\Modules\Companies\Services\FetchesCompanyModule; use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal; use App\Classes\Modules\Orders\Services\FetchesOrder; use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject; +use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject; use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject; use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer; use App\Classes\Modules\PackingLists\Services\FetchesPackingList; +use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject; use App\Classes\Modules\Schedules\Services\CreatesSchedule; use App\Classes\Modules\Steps\DataTransferObjects\StepsObject; use App\Classes\Modules\Steps\Services\CreatesStep; +use App\Classes\Modules\Transports\DataTransferObjects\TransportObject; use App\Classes\Modules\Transports\Services\CreatesTransport; use App\Classes\Modules\Unity\Processors\ActivateContractProcessor; use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor; @@ -21,10 +24,13 @@ 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\PackageType; use App\Classes\ValueObjects\Constants\RoleTypes; use App\Classes\ValueObjects\Constants\PackingListType; +use App\Classes\ValueObjects\Constants\TransportType; use App\Models\Order; use App\Models\PackingList; +use App\Models\Transport; use Carbon\Carbon; use GuzzleHttp\Exception\GuzzleException; use Illuminate\Support\Facades\DB; @@ -124,9 +130,8 @@ class FetchLoadedContainersFromVTPortalProcessor */ public function execute(?Carbon $start = null, ?Carbon $end = null){ - DB::beginTransaction(); try { - $start = $start ? $start : Carbon::now()->subDays(30); + $start = $start ? $start : Carbon::today()->subDays(5); $startLimit = Carbon::parse('11-08-2021'); @@ -134,7 +139,7 @@ class FetchLoadedContainersFromVTPortalProcessor $start = $startLimit; } - $end = $end ? $end : Carbon::now(); + $end = $end ? $end : Carbon::today()->addDay(); $filter = '["LoadedTime:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]'; $containersRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"LoadedTime asc","Filter":'.$filter.'}}'), ''); @@ -148,6 +153,8 @@ class FetchLoadedContainersFromVTPortalProcessor $containerDetail = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailRequest); $containerObject = new ContainerObject($container[0], str_replace(' ', '', $container[24]), str_replace(' ', '', $container[16]), ContainerTypes::FORTY_FEET_DRY_CONTAINER, Carbon::parse($container[6]), ApprovalStatus::PENDING_VERIFICATION); + $containerInfo = $container; + try { $container = $this->fetchesContainer->execute(['reference' => $containerObject->getReference()]); @@ -156,6 +163,52 @@ class FetchLoadedContainersFromVTPortalProcessor $originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]); $container = $this->createContainerProcessor->execute($containerObject, $originWarehouse); } + $eta = Carbon::parse($containerInfo[4]); + + $etd = Carbon::parse($eta)->subDays(5); + + $delayDate = $containerInfo[7]; + + $containerStatus = $containerInfo[10]; + + $unstuffingDate = $containerInfo[8]; + + $transport = $container->transports()->first(); + + if(!$transport){ + $transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED); + /** @var Transport $transport */ + $transport = $this->createsTransport->execute($transportObject, $container); + $this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED)); + } + + if($delayDate){ + + $delayDate = Carbon::parse($delayDate); + $transport = $container->transports()->first(); + + if(!$transport->schedules()->where('eta', '=', $delayDate)->first()) { + $etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd; + $transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]); + $this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED)); + } + + } + + if($containerStatus === 'Unstuffing'){ + $container->update(['status' => ApprovalStatus::COMPLETED]); + $container->transports()->first()->update(['drop_date' => Carbon::parse($unstuffingDate)->subDay(), 'status' => ApprovalStatus::COMPLETED]); + + /** @var PackingList $packingList */ + foreach($container->packingLists as $packingList){ + + if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){ + $packingList->status = ApprovalStatus::APPROVED; + $packingList->save(); + } + + } + } foreach($containerDetail->Rows as $packingList){ $marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $packingList[39])); @@ -166,48 +219,76 @@ class FetchLoadedContainersFromVTPortalProcessor continue; } + $allow_contract = true; + try { - /** @var Order $order */ $order = $this->fetchesOrder->execute(['reference' => $orderNumber]); - } catch (ResourceNotFoundException $exception){ - continue; + } catch (ResourceNotFoundException $exception) { + try { + $order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]); + } catch (ResourceNotFoundException $exception) { + $order = $this->fetchesCompanyModule->execute(['id' => 1]); + $allow_contract = false; + } + } - $packingListReference = $packingList[6]; + $packingListReference = $packingList[3]; + $package = $packingList; + $deliveryDate = $package[1] ? Carbon::parse($package[1]) : null; - try{ - $this->fetchesPackingList->execute(['reference' => $packingListReference]); + try { + $packingList = $this->fetchesPackingList->execute(['reference' => $packingListReference, 'type' => PackingListType::SHIPPING_PACKING_LIST]); } catch (ResourceNotFoundException $exception){ - $contract = $this->unityCreateContract->execute(); - $contractReference = $contract->hash_id; - $contractObligations = $contract->contract_obligation_list; + if ($allow_contract) { + $appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id; +// $contract = $this->unityCreateContract->execute(); +// $contractReference = $contract->hash_id; +// $contractObligations = $contract->contract_obligation_list; +// +// $this->unityActivateContract->execute($contractReference); +// +// $supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id; +// +// $supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId); +// $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]); +// +// $this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations); + } else { + $appointee_id = 2037; + } - $this->unityActivateContract->execute($contractReference); - - $supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id; - - $supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId); - $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]); - - $this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations); - - $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, ApprovalStatus::SUSPENDED, $contractReference); + $packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, null); /** @var PackingList $packingList */ $packingList = $this->createPackingListProcessor->execute($packingListObject, $order); - $container->packingLists()->attach($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); + $container->packingLists()->detach($packingList); + $container->packingLists()->attach($packingList); + $packingList->packages()->delete(); + + $replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first(); + if($replica) $replica->packages()->delete(); + + $packageObject = new PackageObject(PackageType::CARTON, $package[8], $package[21], $package[22], $package[20], 0, $package[11], ApprovalStatus::APPROVED); + $this->createPackageProcessor->execute($packageObject, $packingList); + if($containerStatus === 'Unstuffing'){ + $packingList->transports()->delete(); + + if($deliveryDate) { +// && !$packingList->transports()->exists() + $packingList->status = ApprovalStatus::COMPLETED; + $packingList->save(); + + $transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED); + /** @var Transport $transport */ + $transport = $this->createsTransport->execute($transportObject, $packingList); + $this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED)); } - } } @@ -217,8 +298,6 @@ class FetchLoadedContainersFromVTPortalProcessor Log::error($exception); } - - DB::commit(); return []; } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php index 40eb347a..99ebf9c1 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php @@ -136,7 +136,7 @@ class FetchOrderListsFromYdPortalProcessor public function execute(?Carbon $start = null, ?Carbon $end = null) { try { - $start = $start ? $start : Carbon::now()->subMonths(3); + $start = $start ? $start : Carbon::today()->subMonths(1); $startLimit = Carbon::parse('01-12-2021'); @@ -144,7 +144,7 @@ class FetchOrderListsFromYdPortalProcessor $start = $startLimit; } - $end = $end ? $end : Carbon::now(); + $end = $end ? $end : Carbon::today()->addDay(); $orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [ 'begintime' => $start->timestamp, @@ -154,6 +154,7 @@ class FetchOrderListsFromYdPortalProcessor $rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest); foreach($rows->data as $row){ + $containerReference = null; $loadingDate = null; $unstuffingDate = null; @@ -244,8 +245,6 @@ class FetchOrderListsFromYdPortalProcessor } - DB::beginTransaction(); - $packingListReference = $row->expressno; try{ @@ -398,11 +397,14 @@ class FetchOrderListsFromYdPortalProcessor $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); - $step->update(['status' => ApprovalStatus::COMPLETED]); + if ($allow_contract) { + $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); + $step->update(['status' => ApprovalStatus::COMPLETED]); + } } + } } } @@ -417,17 +419,21 @@ class FetchOrderListsFromYdPortalProcessor $transport = $this->createsTransport->execute($transportObject, $packingList); $this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED)); - $deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first(); - $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; - $this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id); - $deliveryStep->update(['status' => ApprovalStatus::COMPLETED]); + + if ($allow_contract) { + $deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first(); + $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; + $this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id); + $deliveryStep->update(['status' => ApprovalStatus::COMPLETED]); + } + } - DB::commit(); echo 'successful'; } } catch (\Exception $exception) { + dump($exception); Log::debug($exception); } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php index 2cfd94dd..cebd8101 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php @@ -46,42 +46,32 @@ class FetchPackingListFromVTPortalProcessor */ public function execute(){ - $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->whereDoesntHave('containers', function($query){ + $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->where('reference', 'not like', '%PO%')->whereIn('claimant_id', [2])->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->whereDoesntHave('containers', function($query){ $query->where('status', '=', ApprovalStatus::COMPLETED); - })->get(); + })->limit(10)->get(); - DB::beginTransaction(); foreach($packingLists as $packingList){ try { + $filter = '["PoID:=%js%'.$packingList->reference.'"]'; - $filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]'; - - $shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), ''); + $shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"Po","view":"grid1","request":{"PageIndex":-1,"PageSize":1000,"Filter":'.$filter.'}}'), ''); $shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest); + if(count($shippingPackingLists->Rows)) { - $packingList->packages()->delete(); - $replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first(); - if($replica) $replica->packages()->delete(); - - foreach($shippingPackingLists->Rows as $shippingPackingList){ - if(!$shippingPackingList[22]) { - continue; - } - - $packageObject = new PackageObject(PackageType::CARTON, $shippingPackingList[19], $shippingPackingList[31], $shippingPackingList[30], $shippingPackingList[29], 0, $shippingPackingList[22], ApprovalStatus::APPROVED); - $this->createPackageProcessor->execute($packageObject, $packingList); - } + } else { + dump($packingList->reference); } } catch (GuzzleException $exception) { + dd($exception); + Log::error($exception); continue; } } - DB::commit(); return []; diff --git a/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php index 8ba2957e..4709b2e1 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php @@ -116,7 +116,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor try { - $start = $start ? $start : Carbon::now()->subMonth(); + $start = $start ? $start : Carbon::today()->subDays(5); $startLimit = Carbon::parse('11-08-2021'); @@ -124,7 +124,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor $start = $startLimit; } - $end = $end ? $end : Carbon::now(); + $end = $end ? $end : Carbon::today()->addDay(); $filter = '["ParcelDate:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]'; @@ -133,66 +133,31 @@ class FetchWarehouseReceiveListFromVTPortalProcessor $response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest); foreach ($response->Rows as $parcel){ - - $marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $parcel[29])); + $allow_contract = true; + $marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $parcel[11])); $orderNumber = $marking[array_key_last($marking)]; - if(!$parcel[3]){ + $quantity = $parcel[16]; + if(!$quantity){ continue; } + try { $order = $this->fetchesOrder->execute(['reference' => $orderNumber]); + $appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id; } catch (ResourceNotFoundException $exception) { - - $oldOrder = OldOrders::where('marking', '=', $orderNumber)->first(); - - if(!$oldOrder){ - continue; - } - - - $customerMarking = str_replace('/', '', str_replace(' ', '', explode('CIEF/', $oldOrder->company->marking)[1])); - - $companyModule = CompanyModule::whereHas('inviters', function($query) use ($customerMarking) { - return $query->where('invitee_reference', '=', $customerMarking); - })->first(); - - - if(!$companyModule){ - log::error('unknown customer: '.$customerMarking); - continue; - } - - if(!$oldOrder->address) { - continue; - } - - /** @var Address $address */ - $address = $this->createAddressFromOldAddressProcessor->execute($oldOrder->address, $companyModule); - - if(!$address){ - continue; - } - - - $warehouseId = $parcel[44]; - $originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]); - - $order = $this->createOrderProcessor->execute($companyModule->company, $originWarehouse, $address, $orderNumber); - - $order->created_at = Carbon::parse($parcel[1]); - $order->save(); - + $allow_contract = false; + $order = $this->fetchesCompanyModule->execute(['id' => 1]); + $appointee_id = 2037; } $packingListReference = $parcel[0]; - $quantity = $parcel[3]; // $measurement = round(($parcel[10]/$quantity) ** (1/3) * 100, 2); - $description = $parcel[31]; - $tracking = $parcel[38]; + $description = $parcel[13]; + $tracking = $parcel[37]; $receiveDate = $parcel[1]; - $packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::APPROVED); + $packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED); /** @var PackingList $packingList */ $packingList = $order->packingLists()->where('reference', '=', $packingListReference)->first(); @@ -215,7 +180,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor $packingList->packages()->delete(); if($replica) $replica->packages()->delete(); - $packageObject = new PackageObject(PackageType::CARTON, $description, $parcel[10], $parcel[9], $parcel[8], 0, $quantity, ApprovalStatus::APPROVED); + $packageObject = new PackageObject(PackageType::CARTON, $description, $parcel[23], $parcel[22], $parcel[21], 0, $quantity, ApprovalStatus::APPROVED); $this->createPackageProcessor->execute($packageObject, $packingList); } } catch (\Exception $exception){ diff --git a/app/Console/Commands/CurlVTCommand.php b/app/Console/Commands/CurlVTCommand.php index 2fa093e4..c0fc5b5d 100644 --- a/app/Console/Commands/CurlVTCommand.php +++ b/app/Console/Commands/CurlVTCommand.php @@ -49,9 +49,6 @@ class CurlVTCommand extends Command { return FetchWarehouseReceiveListFromVTPortalJob::withChain([ new FetchLoadedContainersFromVTPortalJob, - new FetchPackingListFromVTPortalJob, - new FetchContainersStatusUpdateFromVTPortalJob, - new FetchDeliveryListFromVTPortalJob ])->dispatch(); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 885b78cc..5fc88d3c 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -28,10 +28,10 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule) { -// $schedule->command('command:curlVTCommand') -// ->cron('0 9-18/3 * * *') -// ->withoutOverlapping() -// ->appendOutputTo (storage_path().'/logs/curlvt.log'); + $schedule->command('command:curlVTCommand') + ->cron('0 8 * * *') + ->withoutOverlapping() + ->appendOutputTo (storage_path().'/logs/curlvt.log'); $schedule->command('command:curlYdOrderListCommand') ->cron('30 9-18/3 * * *') diff --git a/app/Http/Resources/ContainerResource.php b/app/Http/Resources/ContainerResource.php index 42cc5fbb..49a33232 100644 --- a/app/Http/Resources/ContainerResource.php +++ b/app/Http/Resources/ContainerResource.php @@ -30,7 +30,7 @@ class ContainerResource extends JsonResource 'remarks' => RemarkResource::collection($this->remarks), 'status' => $this->status, 'packing_lists' => $this->whenLoaded('packingLists', PackingListResource::collection($this->whenLoaded('packingLists', function(){ - return $this->packingLists()->whereHas('packages')->get()->sortBy(function ($packingList) { + return $this->packingLists()->get()->sortBy(function ($packingList) { return $packingList->owner->company_module_id; }); }))) diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index 225a1651..ef59df63 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -57,8 +57,8 @@
- - + + diff --git a/resources/assets/vue/components/containers/elements/PackingListComponent.vue b/resources/assets/vue/components/containers/elements/PackingListComponent.vue index 18756ed8..6aaa5a3b 100644 --- a/resources/assets/vue/components/containers/elements/PackingListComponent.vue +++ b/resources/assets/vue/components/containers/elements/PackingListComponent.vue @@ -13,18 +13,18 @@
{{ (parseFloat(cbm) + parseFloat(overweight)).toFixed(3)}}
{{item.transport ? 'Delivery' : item.status === 5 ? 'On Hold' : 'Release'}}
-
+
{{item.order.address.contact ? item.order.address.contact.reference+' '+item.order.address.contact.phone : ''}}
{{item.order.address.street_one+' '+(item.order.address.street_two ? item.order.address.street_two : '')+', '+ item.order.address.district.name+', '+item.order.address.post_code+' '+item.order.address.state.name+', '+item.order.address.country.name}}
{{item.order.address.remark ? item.order.address.remark.content: ''}} -
Define Location
+
Define Location
- +

{{ item.transport.current_schedule.eta }}

-

{{ item.packages[0].container.transport ? item.packages[0].container.transport.dropped_days+' Days': 'n/a'}}

+

{{ item.packages.length ? item.packages[0].container.transport ? item.packages[0].container.transport.dropped_days+' Days': 'n/a' : 'n/a'}}

Reschedule Transport
@@ -40,23 +40,6 @@
Unclaimed
-
-
-
-
Generate Invoice
-
-
-
- - - -
- -
-
-
@@ -88,9 +71,6 @@ this.parameters.packing_list_id = this.data.id; }, methods: { - generateInvoice() { - this.submit(this.route('api.transaction.supplier.create'), 'post', this.section, true, true); - }, updateStatus(status){ this.submit(this.route('api.packing_list.status.update', this.item.id, status), 'put', '', true, true) }, diff --git a/resources/assets/vue/components/orders/elements/ParcelComponent.vue b/resources/assets/vue/components/orders/elements/ParcelComponent.vue index 01299ad1..9386f121 100644 --- a/resources/assets/vue/components/orders/elements/ParcelComponent.vue +++ b/resources/assets/vue/components/orders/elements/ParcelComponent.vue @@ -32,7 +32,8 @@

Warehouse

-

{{item.order.warehouse.reference}}

+

{{item.order.warehouse.reference}}

+ Unclaimed
diff --git a/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue b/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue index b33dd4b5..107dc3f1 100644 --- a/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue +++ b/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue @@ -1,26 +1,18 @@