diff --git a/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php index e05f9462..78f86e2d 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::today()->subDays(2); + $start = $start ? $start : Carbon::today()->subMonth(); $startLimit = Carbon::parse('11-08-2021'); @@ -131,9 +131,9 @@ class FetchWarehouseReceiveListFromVTPortalProcessor $warehouseListRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"Parcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ParcelDate asc","Filter":'.$filter.'}}'), ''); $response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest); -dd($response); - foreach ($response->Rows as $parcel){ + foreach ($response->Rows as $parcel){ + $allow_contract = true; $marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $parcel[11])); $orderNumber = $marking[array_key_last($marking)]; @@ -143,48 +143,12 @@ dd($response); } 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[43]; - $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]; @@ -193,7 +157,7 @@ dd($response); $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(); diff --git a/resources/assets/vue/components/orders/elements/ParcelComponent.vue b/resources/assets/vue/components/orders/elements/ParcelComponent.vue index 01299ad1..84ccbe82 100644 --- a/resources/assets/vue/components/orders/elements/ParcelComponent.vue +++ b/resources/assets/vue/components/orders/elements/ParcelComponent.vue @@ -32,7 +32,7 @@
Warehouse
-{{item.order.warehouse.reference}}
+{{item.order ? item.order.warehouse.reference : 'Unclaimed'}}