Merge branch 'task/EXC-338' into 'master'

Inbound custom cleared

See merge request CIEFWorldwideSdnBhd/shipping-portal!64
This commit is contained in:
omair saleh
2021-09-27 09:04:39 +00:00
5 changed files with 241 additions and 1 deletions
@@ -79,6 +79,7 @@ class CreateOrderRolesProcessor
$roleObject = new OrderRoleObject($order, $destinationWarehouse, OrderRoleTypes::DESTINATION_WAREHOUSE);
$this->createsOrderRole->execute($roleObject);
$roleObject = new OrderRoleObject($order, $freightForwarder, OrderRoleTypes::LAST_MILE_DELIVERY_DRIVER);
$this->createsOrderRole->execute($roleObject);
@@ -0,0 +1,66 @@
<?php
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
use App\Http\Resources\ContainerResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class InboundCustomClearedLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Containers',
'message' => 'You have successfully retrieved a list of Containers'
];
}
/** @var CanListContainers */
private $canListContainers;
/** @var ListsContainers */
private $listsContainers;
private $fetchInboundCustomCleared;
/**
* ListContainersLogic constructor.
* @param CanListContainers $canListContainers
* @param ListsContainers $listsContainers
*/
public function __construct(CanListContainers $canListContainers, ListsContainers $listsContainers, FetchInboundCustomClearedProcessor $fetchInboundCustomCleared)
{
$this->canListContainers = $canListContainers;
$this->listsContainers = $listsContainers;
$this->fetchInboundCustomCleared = $fetchInboundCustomCleared;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
//$this->canListOrders->passes();
//$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true]));
$d = $this->fetchInboundCustomCleared->execute();
return response()->json($d);
}
}
@@ -0,0 +1,105 @@
<?php
namespace App\Classes\Modules\PackingLists\Processors;
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
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\PackingListType;
use App\Classes\ValueObjects\Constants\TransportType;
use App\Models\PackingList;
use App\Models\Transport;
use App\Models\Container;
use Carbon\Carbon;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Facades\Log;
class FetchInboundCustomClearedProcessor
{
/** @var FetchesDataFromVTPortal */
private $fetchesDataFRomVTPortal;
/** @var CreatesTransport */
private $createsTransport;
/** @var CreatesSchedule */
private $createsSchedule;
/** @var UpdatesContractObligation */
private $updatesContractObligations;
/**
* FetchDeliveryListFromVTPortalProcessor constructor.
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
* @param CreatesTransport $createsTransport
* @param CreatesSchedule $createsSchedule
* @param UpdatesContractObligation $updatesContractObligations
*/
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, UpdatesContractObligation $updatesContractObligations)
{
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
$this->createsTransport = $createsTransport;
$this->createsSchedule = $createsSchedule;
$this->updatesContractObligations = $updatesContractObligations;
}
/**
* @return array
*/
public function execute(){
$packingLists = PackingList::query()->with(['steps' => function ($query) {
$query->where('steps.status', '<>', 3);
}])->first();
dd($packingLists);
/*
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::SUSPENDED])->get();
foreach($packingLists as $packingList){
try {
$filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]';
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
$shippingPackingList = $shippingPackingLists->Rows[0];
if(!$shippingPackingList[9] && !$shippingPackingList[10]) {
continue;
}
$packingList->status = ApprovalStatus::COMPLETED;
$packingList->save();
$deliveryDate = Carbon::parse($shippingPackingList[9] ? $shippingPackingList[9]:$shippingPackingList[10]);
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
$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]);
} catch (GuzzleException $exception) {
continue;
}
}*/
return [];
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\PackingLists\Containers;
use App\Classes\Modules\PackingLists\ControllersLogic\Containers\InboundCustomClearedLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class InboundCustomClearedController
{
/**
* @param Request $request
* @param InboundCustomClearedLogic $logic
* @return JsonResponse
*/
public function list(Request $request, InboundCustomClearedLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
+49 -1
View File
@@ -107,6 +107,54 @@
}
}
},
"/packing_list/container/inbound-custom-cleared": {
"get": {
"tags": [
"Packing"
],
"produces": [
"application/json"
],
"operationId": "listPackingIn",
"summary": "List packing",
"description": "",
"parameters": [
{
"name": "filter",
"in": "query",
"description": "Filters",
"required": false,
"type": "array",
"items": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Expires-After": {
"type": "string",
"format": "date-time",
"description": "date in UTC when token expires"
},
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"description": "calls per hour allowed by the user"
}
},
"schema": {
"type": "string"
}
},
"422": {
"description": "Invalid input supplied"
}
}
}
},
"/packing_list/list": {
"get": {
"tags": [
@@ -2982,7 +3030,7 @@
}
}
},
"/account/registration/registration": {
"/account/registration": {
"post": {
"tags": [
"Account",