mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
update packinglists from vt portal
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithParcels implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->with('parcels');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface ContainerOwner
|
||||
{
|
||||
|
||||
public function containers(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Packable
|
||||
{
|
||||
|
||||
public function packingLists(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Steppable
|
||||
{
|
||||
|
||||
public function steps(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Transportable
|
||||
{
|
||||
|
||||
public function transports(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Processors;
|
||||
|
||||
use App\Classes\General\Interfaces\Addressable;
|
||||
use App\Classes\Modules\Addresses\Services\CleansOldAddress;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Models\OldAddress;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CreateAddressFromOldAddressProcessor
|
||||
{
|
||||
|
||||
/** @var CleansOldAddress */
|
||||
private $cleansOldAddress;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
|
||||
/**
|
||||
* CreateAddressFromOldAddressProcessor constructor.
|
||||
* @param CleansOldAddress $cleansOldAddress
|
||||
* @param CreatesAddress $createsAddress
|
||||
*/
|
||||
public function __construct(CleansOldAddress $cleansOldAddress, CreatesAddress $createsAddress)
|
||||
{
|
||||
$this->cleansOldAddress = $cleansOldAddress;
|
||||
$this->createsAddress = $createsAddress;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param OldAddress $address
|
||||
* @param Addressable $addressable
|
||||
* @return Model|null
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(OldAddress $address, Addressable $addressable): ?Model {
|
||||
|
||||
if(!$object = $this->cleansOldAddress->execute($address)){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if($address = $addressable->addresses()->where('street_one', $object->getStreetOne())->first()){
|
||||
return $address;
|
||||
}
|
||||
|
||||
return $this->createsAddress->execute($addressable, $object);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Omair Saleh
|
||||
* Date: 20/8/2021
|
||||
* Time: 1:05 AM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Models\District;
|
||||
use App\Models\OldAddress;
|
||||
|
||||
class CleansOldAddress
|
||||
{
|
||||
|
||||
public function execute(OldAddress $address){
|
||||
if($address->street_one === '' && $address->street_two === ''){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!$address->post_code){
|
||||
return null;
|
||||
}
|
||||
|
||||
$district = District::where('postcode', 'like', '%'. $address->post_code .'%')->first();
|
||||
|
||||
if(!$district) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new AddressObject($this->cleanAddress($address->street_one, $district, $address->post_code), $this->cleanAddress($address->street_two, $district, $address->post_code), $district->country_id, $district->state_id, $district->id, $address->post_code, 'Delivery Address');
|
||||
|
||||
}
|
||||
|
||||
private function cleanAddress($address, $district, $postcode){
|
||||
$address = str_replace('Malaysia', '', str_replace('malaysia', '', $address));
|
||||
$address = str_replace($district->state->name, '',str_replace($district->name, '', $address));
|
||||
$address = str_replace($postcode, '', $address);
|
||||
$address = str_replace(', ,', ',', str_replace(', ,', ',', str_replace(', ,', ',', $address)));
|
||||
$address = str_replace(',', ', ', $address);
|
||||
$address = preg_replace('!\s+!', ' ', $address);
|
||||
$address = preg_replace("/,+/", ",", $address);
|
||||
return rtrim(rtrim(rtrim($address), ','));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,11 @@
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -11,13 +15,6 @@ use Illuminate\Http\JsonResponse;
|
||||
class CreateOrderLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
private $createOrderProcessor;
|
||||
|
||||
public function __construct( CreateOrderProcessor $createsOrderProcessor)
|
||||
{
|
||||
$this->createOrderProcessor = $createsOrderProcessor;
|
||||
}
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order',
|
||||
@@ -25,9 +22,48 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var fetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var CreateOrderProcessor */
|
||||
private $createOrderProcessor;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/**
|
||||
* CreateOrderLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param CreateOrderProcessor $createOrderProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse {
|
||||
|
||||
$order = $this->createOrderProcessor->execute($request);
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('address_id')]);
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class FetchOrderLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canFetchOrder->passes();
|
||||
|
||||
$query = $this->fetchesOrder->execute(['reference' => $request->route('id')]);
|
||||
$query = $this->fetchesOrder->execute(['reference' => $request->route('id'), 'with_parcels' => true]);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($query));
|
||||
|
||||
|
||||
@@ -13,83 +13,69 @@ use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Models\Address;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateOrderProcessor
|
||||
{
|
||||
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var CanCreateOrder */
|
||||
private $canCreateOrder;
|
||||
|
||||
/** @var CreatesOrder */
|
||||
private $createsOrder;
|
||||
|
||||
/** @var fetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createAddress;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreateOrderRolesProcessor */
|
||||
private $createOrderRolesProcessor;
|
||||
|
||||
/**
|
||||
* CreateOrderProcessor constructor.
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param CanCreateOrder $canCreateOrder
|
||||
* @param CreatesOrder $createsOrder
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param CreatesAddress $createAddress
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreateOrderRolesProcessor $createOrderRolesProcessor
|
||||
*/
|
||||
public function __construct(GeneratesOrderNumber $generatesOrderNumber, CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, FetchesAddress $fetchesAddress, CreatesAddress $createAddress, FetchesCompany $fetchesCompany, CreateOrderRolesProcessor $createOrderRolesProcessor)
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreatesAddress $createAddress, CreateOrderRolesProcessor $createOrderRolesProcessor)
|
||||
{
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->canCreateOrder = $canCreateOrder;
|
||||
$this->createsOrder = $createsOrder;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createAddress = $createAddress;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createOrderRolesProcessor = $createOrderRolesProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Company $company
|
||||
* @param CompanyModule $originWarehouse
|
||||
* @param Address $address
|
||||
* @param int|null $orderNumber
|
||||
* @return Addressable
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request){
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->get('company_id')]);
|
||||
public function execute(Company $company, CompanyModule $originWarehouse, Address $address, int $orderNumber){
|
||||
|
||||
/** @var CompanyModule $importer */
|
||||
$importer = $this->fetchesCompany->execute(['id' => $request->get('company_id')])->companyModules()->importers()->first();
|
||||
$importer = $company->companyModules()->importers()->first();
|
||||
|
||||
$orderObject = new OrderObject($this->generatesOrderNumber->execute(), OrderType::SHARED_CONTAINER, $company->status === ApprovalStatus::APPROVED ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION);
|
||||
$orderObject = new OrderObject($orderNumber, OrderType::SHARED_CONTAINER, $company->status === ApprovalStatus::APPROVED ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
$this->canCreateOrder->passes($orderObject);
|
||||
|
||||
/** @var Order $order */
|
||||
$order = $this->createsOrder->execute($importer, $orderObject);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->get('address_id')]);
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode,$address->reference);
|
||||
|
||||
$this->createAddress->execute($order, $addressObject);
|
||||
|
||||
$this->createOrderRolesProcessor->execute($request, $order);
|
||||
$this->createOrderRolesProcessor->execute($originWarehouse, $order);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Classes\Modules\Orders\Services\CreatesOrder;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder;
|
||||
use App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor;
|
||||
use App\Classes\Modules\OrderSteps\Processors\CreateOrderStepsProcessor;
|
||||
use App\Classes\Modules\Steps\Processors\CreateStepsProcessor;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||
use App\Classes\ValueObjects\Constants\OrderStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderSteps;
|
||||
@@ -33,8 +34,8 @@ class CreateOrderProcessorOld
|
||||
/** @var ConfirmOrderProcessor */
|
||||
private $confirmOrderProcessor;
|
||||
|
||||
/** @var CreateOrderStepsProcessor */
|
||||
private $createOrderStepsProcessor;
|
||||
/** @var CreateStepsProcessor */
|
||||
private $createStepsProcessor;
|
||||
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
@@ -58,11 +59,11 @@ class CreateOrderProcessorOld
|
||||
private $fetchesAddress;
|
||||
|
||||
/**
|
||||
* CreateOrderProcessor constructor.
|
||||
* CreateOrderProcessorOld constructor.
|
||||
* @param CanCreateOrder $canCreateOrder
|
||||
* @param CreatesOrder $createsOrder
|
||||
* @param \App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor $confirmOrderProcessor
|
||||
* @param CreateOrderStepsProcessor $createOrderStepsProcessor
|
||||
* @param CreateStepsProcessor $createStepsProcessor
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
@@ -71,12 +72,12 @@ class CreateOrderProcessorOld
|
||||
* @param CreatesAddress $createAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
*/
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, \App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor $confirmOrderProcessor, CreateOrderStepsProcessor $createOrderStepsProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, ActivateContractProcessor $unityActivateContract, \App\Classes\Modules\Orders\Processors\CreateOrderRolesProcessor $createOrderRoleProcessor, CreatesAddress $createAddress, FetchesAddress $fetchesAddress)
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, \App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor $confirmOrderProcessor, CreateStepsProcessor $createStepsProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, ActivateContractProcessor $unityActivateContract, \App\Classes\Modules\Orders\Processors\CreateOrderRolesProcessor $createOrderRoleProcessor, CreatesAddress $createAddress, FetchesAddress $fetchesAddress)
|
||||
{
|
||||
$this->canCreateOrder = $canCreateOrder;
|
||||
$this->createsOrder = $createsOrder;
|
||||
$this->confirmOrderProcessor = $confirmOrderProcessor;
|
||||
$this->createOrderStepsProcessor = $createOrderStepsProcessor;
|
||||
$this->createStepsProcessor = $createStepsProcessor;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
@@ -120,7 +121,7 @@ class CreateOrderProcessorOld
|
||||
|
||||
//Add processing to order step
|
||||
//Note: For processing apointee_id is CIEF Freight Forward , id is 1, reserved in company table
|
||||
$this->createOrderStepsProcessor->execute($order, OrderSteps::PROCESSING, 1);
|
||||
$this->createStepsProcessor->execute($order, OrderSteps::PROCESSING, 1);
|
||||
|
||||
//Pre-approved order, no need Admin to process it
|
||||
//This processor then calls Generate Order Steps
|
||||
|
||||
@@ -40,17 +40,20 @@ class CreateOrderRolesProcessor
|
||||
}
|
||||
|
||||
|
||||
public function execute(Request $request, Order $order){
|
||||
/**
|
||||
* @param CompanyModule $originWarehouse
|
||||
* @param Order $order
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $originWarehouse, Order $order){
|
||||
|
||||
$address = $order->addresses()->first();
|
||||
|
||||
$importer = $order->companyModule;
|
||||
|
||||
/** @var CompanyModule $originWarehouse */
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->get('warehouse_id')]);
|
||||
|
||||
/** @var CompanyModule $destinationWarehouse */
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => $address->state_id = 13 ? WarehouseReferences::SABAH : ($address->state_id === 14 ? WarehouseReferences::SARAWAK : WarehouseReferences::KLANG)]);
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::DESTINATION_WAREHOUSE[$address->state_id ]]);
|
||||
|
||||
/** @var CompanyModule $freightForwarder */
|
||||
$freightForwarder = $originWarehouse->company->companyModules()->freightForwarders()->first();
|
||||
@@ -80,5 +83,28 @@ class CreateOrderRolesProcessor
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
return true;
|
||||
|
||||
$companies = $this->fetchesCompany->getRepository()->whereIn('id',[1, $request->get('warehouse_id')])->get();
|
||||
|
||||
$cief_company = $companies[0]->id == 1 ? $companies[0] : $companies[1];
|
||||
$warehouse_company = $companies[0]->id != 1 ? $companies[0] : $companies[1];
|
||||
|
||||
$cief_company_module = $cief_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$cief_company_module->unity_hash_id]);
|
||||
$contractEntities[0]->{"company_module_id"} = $cief_company_module->id;
|
||||
|
||||
$warehouse_company_module = $warehouse_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$warehouse_company_module->unity_hash_id]);
|
||||
$contractEntities[1]->{"company_module_id"} = $warehouse_company_module->id;
|
||||
|
||||
foreach($contractEntities as $entity){
|
||||
$order_role_object = new OrderRoleObject($orderId, $entity->company_module_id, $entity->hash_id, $entity->entity_signature_hash_id);
|
||||
|
||||
$this->canCreateOrderRole->passes($order_role_object);
|
||||
|
||||
$this->createsOrderRole->execute($order_role_object);
|
||||
}
|
||||
|
||||
return $contractEntities;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class FetchesDataFromVTPortal
|
||||
{
|
||||
|
||||
/** @var string|null */
|
||||
private $cookies;
|
||||
|
||||
/**
|
||||
* @param string $cookies
|
||||
*/
|
||||
public function setCookies(string $cookies): void
|
||||
{
|
||||
$this->cookies = $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCookies(): ?string
|
||||
{
|
||||
return $this->cookies;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param $body
|
||||
* @param string $cookie
|
||||
* @param bool $requiresAuthentication
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function clientRequest(string $url, string $method, $body, string $cookie, $requiresAuthentication = true){
|
||||
|
||||
if($requiresAuthentication) {
|
||||
if(!$this->getCookies()){
|
||||
$this->remoteLogin();
|
||||
}
|
||||
}
|
||||
|
||||
$client = new \GuzzleHttp\Client(
|
||||
[
|
||||
'cookies' => true,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $this->getCookies() ? $this->getCookies() : $cookie
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$request = $client->request($method, $url, [\GuzzleHttp\RequestOptions::JSON => $body]);
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
private function remoteLogin(){
|
||||
|
||||
$latest_cookie = [];
|
||||
$cookieRequest = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$cookieRequest->get('https://portalvt.azurewebsites.net');
|
||||
foreach ($cookieRequest->getConfig('cookies')->toArray() as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
}
|
||||
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
|
||||
|
||||
/** @var $loginRequest */
|
||||
$loginRequest = $this->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login', 'POST', [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
], $latest_cookie, false);
|
||||
|
||||
$this->setCookies($latest_cookie.';AppVTCC='.$this->getResponseBody($loginRequest)->AccessToken);
|
||||
|
||||
}
|
||||
|
||||
public function getResponseBody(ResponseInterface $request){
|
||||
return json_decode($request->getBody()->getContents())->d;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-4
@@ -5,7 +5,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanCreateContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanCreateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
@@ -52,9 +52,7 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||
|
||||
$object = new ContainerObject( $packingList->id , $request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
$object = new ContainerObject($request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
|
||||
$this->canCreateContainer->passes($object);
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\DeletesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanDeleteContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanDeleteContainer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanFetchContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ 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\Containers\Rules\CanListContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
||||
@@ -9,16 +13,14 @@ use App\Classes\Modules\PackingLists\Services\CreatesPackingListPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingListPackage;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListPackageObject;
|
||||
use App\Classes\Modules\Packages\Services\FetchesPackage;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -29,62 +31,28 @@ class CreatePackingListLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreatePackingList */
|
||||
private $canCreatePackingList;
|
||||
|
||||
private $canCreatePackingListPackage;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesPackage;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsPackingList;
|
||||
|
||||
private $createsPackingListPackage;
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* @param CanCreatePackingList $canCreatePackingList
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesPackingList $createsPackingList
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
*/
|
||||
public function __construct(CanCreatePackingList $canCreatePackingList, CanCreatePackingListPackage $canCreatePackingListPackage, FetchesPackage $fetchesPackage, CreatesPackingList $createsPackingList, CreatesPackingListPackage $createsPackingListPackage)
|
||||
public function __construct(CreatePackingListProcessor $createPackingListProcessor)
|
||||
{
|
||||
$this->canCreatePackingList = $canCreatePackingList;
|
||||
$this->canCreatePackingListPackage = $canCreatePackingListPackage;
|
||||
$this->fetchesPackage = $fetchesPackage;
|
||||
$this->createsPackingList = $createsPackingList;
|
||||
$this->createsPackingListPackage = $createsPackingListPackage;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$package = $this->fetchesPackage->execute(['id'=>$request->input('package_id')]);
|
||||
|
||||
$reference_no = rand(1000000, 9999999);
|
||||
|
||||
|
||||
$object = new PackingListObject($reference_no, ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
$this->canCreatePackingList->passes($object);
|
||||
|
||||
$packageList = $this->createsPackingList->execute( $object);
|
||||
|
||||
|
||||
$object = new PackingListPackageObject($packageList->id, $package->id);
|
||||
|
||||
$this->canCreatePackingListPackage->passes($object);
|
||||
|
||||
$query = $this->createsPackingListPackage->execute($object);
|
||||
$object = new PackingListObject($request->input('reference_number'), ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
$query = $this->createPackingListProcessor->execute($object);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($query));
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ class CreatePackageLogic extends AbstractControllerLogic
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->input('order_id')]);
|
||||
|
||||
$object = new PackageObject(
|
||||
$order->id,
|
||||
null,
|
||||
$request->input('type'),
|
||||
$request->input('description'),
|
||||
@@ -74,7 +73,7 @@ class CreatePackageLogic extends AbstractControllerLogic
|
||||
$request->input('length'),
|
||||
$request->input('weight'),
|
||||
$request->input('quantity'),
|
||||
ApprovalStatus::PENDING_SUBMISSION);
|
||||
ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
$this->canCreatePackage->passes($object);
|
||||
|
||||
|
||||
@@ -7,39 +7,76 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
class ContainerObject implements DataTransferObject
|
||||
{
|
||||
|
||||
private $packingListId;
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
private $containerReference;
|
||||
/** @var string */
|
||||
private $containerNumber;
|
||||
|
||||
/** @var string */
|
||||
private $sealNumber;
|
||||
|
||||
/** @var int */
|
||||
private $containerType;
|
||||
|
||||
private $sealReference;
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
public function __construct(int $packingListId, ?string $containerReference, int $containerType, ?String $sealReference)
|
||||
/**
|
||||
* ContainerObject constructor.
|
||||
* @param string $reference
|
||||
* @param string $containerNumber
|
||||
* @param string $sealNumber
|
||||
* @param int $containerType
|
||||
* @param int $status
|
||||
*/
|
||||
public function __construct(string $reference, string $containerNumber, string $sealNumber, int $containerType, int $status)
|
||||
{
|
||||
$this->packingListId = $packingListId;
|
||||
$this->containerReference = $containerReference;
|
||||
$this->reference = $reference;
|
||||
$this->containerNumber = $containerNumber;
|
||||
$this->sealNumber = $sealNumber;
|
||||
$this->containerType = $containerType;
|
||||
$this->sealReference = $sealReference;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getPackingListId(): int
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): string
|
||||
{
|
||||
return $this->packingListId;
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
public function getContainerReference(): ?string
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContainerNumber(): string
|
||||
{
|
||||
return $this->containerReference;
|
||||
return $this->containerNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSealNumber(): string
|
||||
{
|
||||
return $this->sealNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getContainerType(): int
|
||||
{
|
||||
return $this->containerType;
|
||||
}
|
||||
|
||||
public function getSealReference(): ?string
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->sealReference;
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,30 +7,47 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
class PackageObject implements DataTransferObject
|
||||
{
|
||||
|
||||
private $orderId;
|
||||
|
||||
private $claimantId;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var null|string */
|
||||
private $description;
|
||||
|
||||
/** @var float */
|
||||
private $width;
|
||||
|
||||
/** @var float */
|
||||
private $height;
|
||||
|
||||
/** @var float */
|
||||
private $length;
|
||||
|
||||
/** @var float */
|
||||
private $weight;
|
||||
|
||||
/** @var int */
|
||||
private $quantity;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
public function __construct(int $orderId, ?int $claimantId, int $type, ?string $description, float $width, float $height, float $length, float $weight, int $quantity, int $status)
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/**
|
||||
* PackageObject constructor.
|
||||
* @param int $type
|
||||
* @param null|string $description
|
||||
* @param float $width
|
||||
* @param float $height
|
||||
* @param float $length
|
||||
* @param float $weight
|
||||
* @param int $quantity
|
||||
* @param int $status
|
||||
* @param null|string $reference
|
||||
*/
|
||||
public function __construct(int $type, ?string $description, float $width, float $height, float $length, float $weight, int $quantity, int $status, ?string $reference=null)
|
||||
{
|
||||
$this->orderId = $orderId;
|
||||
$this->claimantId = $claimantId;
|
||||
$this->type = $type;
|
||||
$this->description = $description;
|
||||
$this->width = $width;
|
||||
@@ -39,55 +56,80 @@ class PackageObject implements DataTransferObject
|
||||
$this->weight = $weight;
|
||||
$this->quantity = $quantity;
|
||||
$this->status = $status;
|
||||
$this->reference = $reference;
|
||||
}
|
||||
|
||||
public function getOrderId(): int
|
||||
{
|
||||
return $this->orderId;
|
||||
}
|
||||
|
||||
public function getClaimantId(): ?int
|
||||
{
|
||||
return $this->claimantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth(): float
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight(): float
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getLength(): float
|
||||
{
|
||||
return $this->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getWeight(): float
|
||||
{
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getQuantity(): int
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,31 +7,62 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
class PackingListObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var null|string */
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $claimantId;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
/** @var string|null */
|
||||
private $contractReference;
|
||||
|
||||
/**
|
||||
* PackingListObject constructor.
|
||||
* @param null|string $reference
|
||||
* @param string $reference
|
||||
* @param int $claimantId
|
||||
* @param int $type
|
||||
* @param int $status
|
||||
* @param null|string $contractReference
|
||||
*/
|
||||
public function __construct(?string $reference, int $status)
|
||||
public function __construct(string $reference, int $claimantId, int $type, int $status, ?string $contractReference = null)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
$this->claimantId = $claimantId;
|
||||
$this->type = $type;
|
||||
$this->status = $status;
|
||||
$this->contractReference = $contractReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
public function getReference(): string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getClaimantId(): int
|
||||
{
|
||||
return $this->claimantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@@ -40,5 +71,13 @@ class PackingListObject implements DataTransferObject
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getContractReference(): ?string
|
||||
{
|
||||
return $this->contractReference;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\ContainerOwner;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanCreateContainer;
|
||||
|
||||
class CreateContainerProcessor
|
||||
{
|
||||
/** @var CanCreateContainer */
|
||||
private $canCreateContainer;
|
||||
|
||||
/** @var CreatesContainer */
|
||||
private $createsContainer;
|
||||
|
||||
/**
|
||||
* CreateContainerProcessor constructor.
|
||||
* @param CanCreateContainer $canCreateContainer
|
||||
* @param CreatesContainer $createsContainer
|
||||
*/
|
||||
public function __construct(CanCreateContainer $canCreateContainer, CreatesContainer $createsContainer)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
$this->createsContainer = $createsContainer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ContainerObject $object
|
||||
* @param ContainerOwner $owner
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(ContainerObject $object, ContainerOwner $owner){
|
||||
|
||||
$this->canCreateContainer->passes($object);
|
||||
return $this->createsContainer->execute($object, $owner);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\CreatesPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanCreatePackage;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatePackageProcessor
|
||||
{
|
||||
|
||||
|
||||
/** @var CanCreatePackage */
|
||||
private $canCreatePackage;
|
||||
|
||||
/** @var CreatesPackage */
|
||||
private $createsPackage;
|
||||
|
||||
/**
|
||||
* CreatePackageProcessor constructor.
|
||||
* @param CanCreatePackage $canCreatePackage
|
||||
* @param CreatesPackage $createsPackage
|
||||
*/
|
||||
public function __construct(CanCreatePackage $canCreatePackage, CreatesPackage $createsPackage)
|
||||
{
|
||||
$this->canCreatePackage = $canCreatePackage;
|
||||
$this->createsPackage = $createsPackage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PackageObject $object
|
||||
* @param PackingList $packingList
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(PackageObject $object, PackingList $packingList){
|
||||
|
||||
$this->canCreatePackage->passes($object);
|
||||
|
||||
return $this->createsPackage->execute($object, $packingList);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
|
||||
class CreatePackingListProcessor
|
||||
{
|
||||
|
||||
|
||||
/** @var CanCreatePackingList */
|
||||
private $canCreatePackingList;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsPackingList;
|
||||
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* @param CanCreatePackingList $canCreatePackingList
|
||||
* @param CreatesPackingList $createsPackingList
|
||||
*/
|
||||
public function __construct(CanCreatePackingList $canCreatePackingList, CreatesPackingList $createsPackingList)
|
||||
{
|
||||
$this->canCreatePackingList = $canCreatePackingList;
|
||||
$this->createsPackingList = $createsPackingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param Packable $packable
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(PackingListObject $object, Packable $packable){
|
||||
|
||||
$this->canCreatePackingList->passes($object);
|
||||
return $this->createsPackingList->execute($object, $packable);
|
||||
}
|
||||
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
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\PackingLists\Services\ListsPackingLists;
|
||||
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\ContainerTypes;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class FetchContainersStatusUpdateFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/**
|
||||
* FetchContainersStatusUpdateFromVTPortalProcessor 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
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
$containers = Container::where('status', '=', ApprovalStatus::PENDING_VERIFICATION)->get();
|
||||
|
||||
/** @var Container $container */
|
||||
foreach($containers as $container){
|
||||
try {
|
||||
$filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]';
|
||||
|
||||
$containerDetailsRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containerDetails = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailsRequest);
|
||||
|
||||
$containerDetails = $containerDetails->Rows[0];
|
||||
|
||||
if(!$eta = $containerDetails[3]){
|
||||
continue;
|
||||
}
|
||||
|
||||
$eta = Carbon::parse($eta);
|
||||
|
||||
$delayDate = $containerDetails[6];
|
||||
|
||||
$containerStatus = $containerDetails[9];
|
||||
|
||||
$unstuffingDate = $containerDetails[7];
|
||||
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport){
|
||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $eta, null, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($eta->subDays(5), $eta, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
if($delayDate){
|
||||
$delayDate = Carbon::parse($delayDate);
|
||||
$transport = $container->transports()->first();
|
||||
if(!$transport->schedules()->where('eta', '=', $delayDate)){
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
}
|
||||
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($delayDate->subDays(5), $delayDate, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
if($containerStatus === 'Unstuffing'){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => Carbon::parse($unstuffingDate)->subDay(), 'status' => ApprovalStatus::COMPLETED]);
|
||||
$container->packingLists()->update(['status' => ApprovalStatus::APPROVED]);
|
||||
/** @var PackingList $packingList */
|
||||
foreach($container->packingLists as $packingList){
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
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\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
class FetchDeliveryListFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @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
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->where('status', '=', ApprovalStatus::APPROVED)->get();
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
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":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
|
||||
foreach($shippingPackingLists->Rows as $shippingPackingList){
|
||||
if(!$shippingPackingList[9]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$deliveryDate = Carbon::parse($shippingPackingList[9]);
|
||||
$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));
|
||||
|
||||
$deliveryStep = $packingList->steps()->where('reference', '=', '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 [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
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\PackingList\Processors\GenerateShippingOrderStepsProcessor;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
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\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
||||
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\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class FetchLoadedContainersFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreateContainerProcessor */
|
||||
private $createContainerProcessor;
|
||||
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
|
||||
/** @var AssignContractEntityProcessor */
|
||||
private $unityAssignContractEntity;
|
||||
|
||||
/** @var CreateContractEntityProcessor */
|
||||
private $unityCreateContractEntity;
|
||||
|
||||
/** @var CreatesStep */
|
||||
private $createsStep;
|
||||
|
||||
/** @var ActivateContractProcessor */
|
||||
private $unityActivateContract;
|
||||
|
||||
/**
|
||||
* FetchLoadedContainersFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreateContainerProcessor $createContainerProcessor
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
* @param CreatesStep $createsStep
|
||||
* @param ActivateContractProcessor $unityActivateContract
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, FetchesOrder $fetchesOrder, CreatePackingListProcessor $createPackingListProcessor, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreateContainerProcessor $createContainerProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, CreatesStep $createsStep, ActivateContractProcessor $unityActivateContract)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createContainerProcessor = $createContainerProcessor;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
$this->createsStep = $createsStep;
|
||||
$this->unityActivateContract = $unityActivateContract;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null){
|
||||
|
||||
DB::beginTransaction();
|
||||
$start = $start ? $start : Carbon::now()->subMonth();
|
||||
$end = $end ? $end : Carbon::now();
|
||||
$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('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containers = $this->fetchesDataFRomVTPortal->getResponseBody($containersRequest);
|
||||
|
||||
foreach ($containers->Rows as $container){
|
||||
|
||||
$filter = '["ContainerID:=%js%'.$container[11].'"]';
|
||||
$containerDetailRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containerDetail = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailRequest);
|
||||
|
||||
$containerObject = new ContainerObject($container[0], str_replace(' ', '', $container[24]), str_replace(' ', '', $container[15]), ContainerTypes::FORTY_FEET_DRY_CONTAINER, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerObject->getReference()]);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
$warehouseId = $container[12];
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]);
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
}
|
||||
|
||||
foreach($containerDetail->Rows as $packingList){
|
||||
$marking = explode('/', explode('CIEF/', $packingList[13])[1]);
|
||||
|
||||
if(!array_key_exists(1, $marking)){
|
||||
continue;
|
||||
}
|
||||
|
||||
$orderNumber = $marking[1];
|
||||
|
||||
if(!$packingList[22]){
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var Order $order */
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
continue;
|
||||
}
|
||||
|
||||
$packingListReference = $packingList[16];
|
||||
|
||||
try{
|
||||
$this->fetchesPackingList->execute(['reference' => $packingListReference]);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
$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);
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::PENDING_VERIFICATION, $contractReference);
|
||||
|
||||
/** @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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\PackingList;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
class FetchPackingListFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var ListsPackingLists */
|
||||
private $listsPackingLists;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/**
|
||||
* FetchPackingListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param ListsPackingLists $listsPackingLists
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, ListsPackingLists $listsPackingLists, CreatePackageProcessor $createPackageProcessor)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->listsPackingLists = $listsPackingLists;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->where('status', '=', ApprovalStatus::PENDING_VERIFICATION)->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":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
|
||||
$packingList->packages()->delete();
|
||||
|
||||
foreach($shippingPackingLists->Rows as $shippingPackingList){
|
||||
if(!$shippingPackingList[22]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $shippingPackingList[43] ? $shippingPackingList[43] : $shippingPackingList[19], $shippingPackingList[31], $shippingPackingList[30], $shippingPackingList[29], 0, $shippingPackingList[22], ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
|
||||
}
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+169
-226
@@ -2,275 +2,218 @@
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\General\Services\GeneratesInitials;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Addresses\Processors\CreateAddressFromOldAddressProcessor;
|
||||
use App\Classes\Modules\Addresses\Services\CleansOldAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\CreatePackageLogic;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
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\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Models\Company;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\District;
|
||||
use App\Models\OldAddress;
|
||||
use App\Models\OldCompany;
|
||||
use App\Models\OldOrders;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var CreateUserProcessor */
|
||||
private $createUserProcessor;
|
||||
|
||||
/** @var CreateCompanyProcessor */
|
||||
private $createCompanyProcessor;
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var UpdatesCompanyStatus*/
|
||||
private $updatesCompanyStatus;
|
||||
/** @var CleansOldAddress */
|
||||
private $cleansOldAddress;
|
||||
|
||||
/** @var CreateCompanyModuleProcessor */
|
||||
private $createCompanyModuleProcessor;
|
||||
/** @var CreateAddressFromOldAddressProcessor */
|
||||
private $createAddressFromOldAddressProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesCompanyConnection */
|
||||
private $createsCompanyConnection;
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var ApprovesCompanyConnection */
|
||||
private $approvesCompanyConnection;
|
||||
/** @var CreateOrderProcessor */
|
||||
private $createOrderProcessor;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageLogic */
|
||||
private $createPackage;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/**
|
||||
* FetchWarehouseReceiveListFromVTPortalProcessor constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param CleansOldAddress $cleansOldAddress
|
||||
* @param CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param CreateOrderProcessor $createOrderProcessor
|
||||
* @param FetchesPackingList $fetchesPakcingList
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageLogic $createPackage
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, UpdatesCompanyStatus $updatesCompanyStatus, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, CreatesAddress $createsAddress)
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CleansOldAddress $cleansOldAddress, CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor, FetchesCompanyModule $fetchesCompanyModule, FetchesOrder $fetchesOrder, CreateOrderProcessor $createOrderProcessor, FetchesPackingList $fetchesPakcingList, CreatePackingListProcessor $createPackingListProcessor, CreatePackageLogic $createPackage, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->cleansOldAddress = $cleansOldAddress;
|
||||
$this->createAddressFromOldAddressProcessor = $createAddressFromOldAddressProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesPackingList = $fetchesPakcingList;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackage = $createPackage;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(){
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null){
|
||||
|
||||
// $addresses = OldAddress::whereIn('id', [2, 3, 4, 9, 11, 12, 17, 18, 19, 22, 23, 27, 28, 30, 31, 33, 36, 38, 40, 42, 45, 50, 51, 52, 53, 54, 58, 59, 61, 67, 68, 70, 72, 78, 80, 82, 83, 85, 86, 89, 93, 94, 97, 100, 102, 103, 104, 106, 107, 111, 115, 120, 125, 126, 128, 130, 131, 132, 133, 134, 135, 136, 137, 140, 142, 144, 145, 155, 156, 159, 170, 172, 173, 175, 177, 178, 180, 181, 182, 183, 185, 186, 187, 190, 199, 200, 202, 204, 207, 210, 213, 214, 215, 217, 218, 220, 222, 228, 231, 232, 234, 237, 242, 244, 245, 251, 252, 255, 258, 259, 261, 262, 266, 268, 273, 274, 275, 278, 281, 282, 285, 287, 292, 294, 295, 296, 297, 299, 303, 306, 307, 308, 311, 315, 316, 317, 319, 320, 321, 328, 329, 330, 332, 333, 334, 336, 339, 341]);
|
||||
$companies = OldCompany::has('orders')->get();
|
||||
DB::beginTransaction();
|
||||
$start = $start ? $start : Carbon::now()->subMonth();
|
||||
$end = $end ? $end : Carbon::now();
|
||||
$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"]';
|
||||
|
||||
foreach($companies as $company){
|
||||
|
||||
$marking = explode("CIEF/", $company->marking);
|
||||
if(count($marking) < 2){
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @var Company $newCompany */
|
||||
$newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
$this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED);
|
||||
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking[1]);
|
||||
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
|
||||
$i = 0;
|
||||
foreach($company->addresses as $address){
|
||||
if($address->street_one === '' && $address->street_two === ''){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$address->post_code){
|
||||
continue;
|
||||
}
|
||||
|
||||
$district = District::where('postcode', 'like', '%'. $address->post_code .'%')->first();
|
||||
|
||||
if(!$district) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$street_one = str_replace($district->name, '',str_replace($district->state->name, '', $address->street_one));
|
||||
$street_two = str_replace($district->name, '',str_replace($district->state->name, '', $address->street_two));
|
||||
|
||||
$object = new AddressObject($street_one, $street_two, $district->country_id, $district->state_id, $district->id, $address->post_code, 'Business Address');
|
||||
$this->createsAddress->execute($companyModule, $object);
|
||||
|
||||
if($address->contact){
|
||||
$i++;
|
||||
if($i === 1) {
|
||||
$contactObject = new ContactObject('', $address->contact, $company->email, '',);
|
||||
$this->createContactProcessor->execute($contactObject, $newCompany);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
dd('done');
|
||||
|
||||
return '';
|
||||
Cache::forget('VT_COOKIE_CACHE');
|
||||
$loginRequest = $this->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC"}}'), '');
|
||||
$response = $this->getResponseBody($loginRequest);
|
||||
$orders = [];
|
||||
$unknown = 0;
|
||||
$warehouseListRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest);
|
||||
|
||||
foreach ($response->Rows as $parcel){
|
||||
$marking = explode('/', explode('CIEF/', $parcel[5])[1]);
|
||||
$customerMarking = $marking[0];
|
||||
if($customerMarking === '2752CHG'){
|
||||
if(!array_key_exists(1, $marking)){
|
||||
$unknown++;
|
||||
echo "found and order without order number";
|
||||
continue;
|
||||
}
|
||||
$orderNumber = $marking[1];
|
||||
$ctn = $parcel[9];
|
||||
if(!array_key_exists($customerMarking, $orders)){
|
||||
$orders[$customerMarking] = [
|
||||
$orderNumber => [
|
||||
'ctn' => $ctn,
|
||||
'cbm' => $parcel[10],
|
||||
]
|
||||
];
|
||||
continue;
|
||||
}
|
||||
//
|
||||
|
||||
if(!array_key_exists($orderNumber, $orders[$customerMarking])){
|
||||
$orders[$customerMarking][$orderNumber]['ctn'] = 0;
|
||||
$orders[$customerMarking][$orderNumber]['cbm'] = 0;
|
||||
}
|
||||
|
||||
$orders[$customerMarking][$orderNumber]['ctn'] += $ctn;
|
||||
$orders[$customerMarking][$orderNumber]['cbm'] += $parcel[10];
|
||||
if(!array_key_exists(1, $marking)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// $orders[$customerMarking][$orderNumber]['cbm'] += $parcel[10];
|
||||
// $orders[$customerMarking][$orderNumber]['ctn'] += $ctn;
|
||||
// if(!$orders->contains($customerMarking)){
|
||||
// $orders->push(collect([
|
||||
// $customerMarking => collect()
|
||||
// ]));
|
||||
// }
|
||||
// dd($orders);
|
||||
//
|
||||
// if(!$orders[$customerMarking]->contains($orderNumber)){
|
||||
// $orders[$customerMarking]->push(collect([
|
||||
// $orderNumber => [
|
||||
// 'ctn' => $ctn,
|
||||
// 'cbm' => $parcel[10]
|
||||
// ]
|
||||
// ]));
|
||||
// } else {
|
||||
// $orders[$customerMarking][$orderNumber]['ctn'] += $ctn;
|
||||
// $orders[$customerMarking][$orderNumber]['cbm'] += $parcel[10];
|
||||
// }
|
||||
}
|
||||
dd($orders, $unknown);
|
||||
$orderNumber = $marking[1];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private function remoteLogin(){
|
||||
|
||||
$latest_cookie = [];
|
||||
$cookieRequest = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$cookieRequest->get('https://portalvt.azurewebsites.net');
|
||||
foreach ($cookieRequest->getConfig('cookies')->toArray() as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
}
|
||||
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
|
||||
|
||||
/** @var $loginRequest */
|
||||
$loginRequest = $this->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login', 'POST', [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
], $latest_cookie, false);
|
||||
|
||||
Cache::store('file')->put('VT_COOKIE_CACHE', $latest_cookie.';AppVTCC='.$this->getResponseBody($loginRequest)->AccessToken, 3000);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param $body
|
||||
* @param string $cookie
|
||||
* @param bool $requiresAuthentication
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private function clientRequest(string $url, string $method, $body, string $cookie, $requiresAuthentication = true){
|
||||
|
||||
if($requiresAuthentication) {
|
||||
if(!Cache::has('VT_COOKIE_CACHE')){
|
||||
$this->remoteLogin();
|
||||
if(!$parcel[9]){
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
$oldOrder = OldOrders::where('marking', '=', $orderNumber)->first();
|
||||
|
||||
if(!$oldOrder){
|
||||
continue;
|
||||
}
|
||||
|
||||
$customerMarking = str_replace(' ', '', str_replace('/', '', str_replace('CIEF/', '', $oldOrder->company->marking)));
|
||||
|
||||
$companyModule = CompanyModule::whereHas('inviters', function($query) use ($customerMarking) {
|
||||
return $query->where('invitee_reference', '=', $customerMarking);
|
||||
})->first();
|
||||
|
||||
if(!$companyModule) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$oldOrder->address) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @var Address $address */
|
||||
$address = $this->createAddressFromOldAddressProcessor->execute($oldOrder->address, $companyModule);
|
||||
|
||||
if(!$address){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$warehouseId = $parcel[0];
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]);
|
||||
|
||||
$order = $this->createOrderProcessor->execute($companyModule->company, $originWarehouse, $address, $orderNumber);
|
||||
}
|
||||
|
||||
|
||||
$packingListReference = $parcel[17];
|
||||
$quantity = $parcel[9];
|
||||
$measurement = round(($parcel[10]/$quantity) ** (1/3) * 100, 2);
|
||||
$description = $parcel[7];
|
||||
$tracking = $parcel[6];
|
||||
$receiveDate = $parcel[1];
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::APPROVED);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $order->packingLists()->where('reference', '=', $packingListReference)->first();
|
||||
|
||||
if(!$packingList) {
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $tracking, Carbon::parse($receiveDate), Carbon::parse($receiveDate), ApprovalStatus::APPROVED);
|
||||
|
||||
|
||||
$this->createsTransport->execute($transportObject, $packingList);
|
||||
}
|
||||
|
||||
/** @var Transport $transport */
|
||||
$transport = $packingList->transports()->first();
|
||||
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject(Carbon::parse($receiveDate), Carbon::parse($receiveDate), ApprovalStatus::APPROVED));
|
||||
|
||||
$packingList->packages()->delete();
|
||||
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $description, $measurement, $measurement, $measurement, 0, $quantity, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
|
||||
}
|
||||
|
||||
$client = new \GuzzleHttp\Client(
|
||||
[
|
||||
'cookies' => true,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => Cache::has('VT_COOKIE_CACHE') ? Cache::get('VT_COOKIE_CACHE'):$cookie
|
||||
]
|
||||
]
|
||||
);
|
||||
DB::commit();
|
||||
return [];
|
||||
|
||||
$request = $client->request($method, $url, [\GuzzleHttp\RequestOptions::JSON => $body]);
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
private function getResponseBody(ResponseInterface $request){
|
||||
return json_decode($request->getBody()->getContents())->d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingList\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use App\Classes\Modules\Orders\Processors\UpdatesOrderCurrentStepProcessor;
|
||||
use App\Classes\Modules\Steps\Processors\UpdateStepsProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Steps\Services\FetchesSteps;
|
||||
use App\Classes\Modules\Orders\Services\UpdatesCurrentStep;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanUpdateCurrentStep;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesManySteps;
|
||||
use App\Classes\ValueObjects\Constants\OrderStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderSteps;
|
||||
use App\Classes\ValueObjects\Constants\Steps;
|
||||
use App\Classes\Modules\Unity\Processors\GetContractObligationsProcessor;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Order;
|
||||
use App\Models\Step;
|
||||
use App\Classes\Jobs\UnityLogin;
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
|
||||
class GenerateShippingOrderStepsProcessor
|
||||
{
|
||||
/** @var CreatesManySteps */
|
||||
private $createsManyStep;
|
||||
|
||||
/** @var UpdateStepsProcessor */
|
||||
private $updateStepProcessors;
|
||||
|
||||
/**
|
||||
* GenerateShippingOrderStepsProcessor constructor.
|
||||
* @param CreatesManySteps $createsManyStep
|
||||
* @param UpdateStepsProcessor $updateStepProcessors
|
||||
*/
|
||||
public function __construct(CreatesManySteps $createsManyStep, UpdateStepsProcessor $updateStepProcessors)
|
||||
{
|
||||
$this->createsManyStep = $createsManyStep;
|
||||
$this->updateStepProcessors = $updateStepProcessors;
|
||||
}
|
||||
|
||||
|
||||
public function execute(Steppable $owner, CompanyModule $appointee, array $contract_obligation_list = []){
|
||||
|
||||
$obligations = $contract_obligation_list;
|
||||
|
||||
$this->createsManyStep->execute($owner, array_map(function($obligation) use ($appointee) {
|
||||
return new StepsObject($appointee->id, $obligation->name,true, $step->sequence??0, 0,0, null,0, $step->hash_id);
|
||||
}, $obligations));
|
||||
|
||||
$this->updateStepProcessors->execute(OrderSteps::PROCESSING);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,26 +2,29 @@
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services\Containers;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\ContainerOwner;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Models\Container;
|
||||
|
||||
class CreatesContainer extends AbstractUpdateRecord
|
||||
class CreatesContainer extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param ContainerObject $object
|
||||
* @param ContainerOwner $owner
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(ContainerObject $object) {
|
||||
public function execute(ContainerObject $object, ContainerOwner $owner) {
|
||||
$model = new Container();
|
||||
|
||||
$model->packing_list_id = $object->getPackingListId();
|
||||
$model->container_reference = $object->getContainerReference();
|
||||
$model->reference = $object->getReference();
|
||||
$model->container_number = $object->getContainerNumber();
|
||||
$model->container_type = $object->getContainerType();
|
||||
$model->seal_reference = $object->getSealReference();
|
||||
$model->seal_reference = $object->getSealNumber();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
return $this->handler($owner->containers(), $model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,27 @@
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatesPackingList extends AbstractUpdateRecord
|
||||
class CreatesPackingList extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
public function execute(PackingListObject $object) {
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param Packable $packable
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingListObject $object, Packable $packable) {
|
||||
$model = new PackingList();
|
||||
|
||||
$model->reference = $object->getReference();
|
||||
$model->claimant_id = $object->getClaimantId();
|
||||
$model->type = $object->getType();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
return $this->handler($packable->packingLists(), $model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
namespace App\Classes\Modules\PackingLists\Services\Packages;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Models\Package;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatesPackage extends AbstractUpdateRecord
|
||||
class CreatesPackage extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
public function execute(PackageObject $object) {
|
||||
public function execute(PackageObject $object, PackingList $packingList) {
|
||||
$model = new Package();
|
||||
$model->order_id = $object->getOrderId();
|
||||
$model->claimant_id = $object->getClaimantId();
|
||||
$model->type = $object->getType();
|
||||
$model->description = $object->getDescription();
|
||||
$model->width = $object->getWidth();
|
||||
@@ -21,7 +21,7 @@ class CreatesPackage extends AbstractUpdateRecord
|
||||
$model->quantity = $object->getQuantity();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
return $this->handler($packingList->packages(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
@@ -10,16 +10,16 @@ use App\Classes\Modules\PackingLists\Standards\Validators\ContainerValidation;
|
||||
class CanCreateContainer extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var PackingListValidation */
|
||||
private $containerPackingListValidation;
|
||||
/** @var ContainerValidation */
|
||||
private $containerValidation;
|
||||
|
||||
/**
|
||||
* CanCreatePackingList constructor.
|
||||
* @param PackingListValidation $PackingListValidation
|
||||
* CanCreateContainer constructor.
|
||||
* @param ContainerValidation $containerValidation
|
||||
*/
|
||||
public function __construct(ContainerValidation $containerPackingListValidation)
|
||||
public function __construct(ContainerValidation $containerValidation)
|
||||
{
|
||||
$this->containerPackingListValidation = $containerPackingListValidation;
|
||||
$this->containerValidation = $containerValidation;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,19 +34,19 @@ class CanCreateContainer extends AbstractRule
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param ContainerObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->containerPackingListValidation->validate($object);
|
||||
return $this->containerValidation->validate($object);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param ContainerObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
@@ -15,10 +15,7 @@ class ContainerValidation extends AbstractValidation
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'packing_list_id' => $object->getPackingListId(),
|
||||
'container_reference' => $object->getContainerReference(),
|
||||
'container_type' => $object->getContainerType(),
|
||||
'seal_reference' => $object->getSealReference(),
|
||||
'reference' => $object->getReference()
|
||||
];
|
||||
}
|
||||
|
||||
@@ -27,8 +24,7 @@ class ContainerValidation extends AbstractValidation
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'packing_list_id' => 'required',
|
||||
'container_reference' => 'required',
|
||||
'reference' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ class PackageValidation extends AbstractValidation
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'order_id' => $object->getOrderId(),
|
||||
'type' => $object->getType(),
|
||||
'width' => $object->getWidth(),
|
||||
'height' => $object->getHeight(),
|
||||
@@ -31,7 +30,6 @@ class PackageValidation extends AbstractValidation
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'order_id' => 'required',
|
||||
'type' => 'required',
|
||||
'width' => 'required',
|
||||
'height' => 'required',
|
||||
|
||||
@@ -8,54 +8,42 @@ use Carbon\Carbon;
|
||||
class ScheduleObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var Carbonn date */
|
||||
/** @var Carbon */
|
||||
private $etd;
|
||||
|
||||
/** @var Carbon date */
|
||||
/** @var Carbon */
|
||||
private $eta;
|
||||
|
||||
/** @var int */
|
||||
private $transport_id;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* ScheduleObject constructor
|
||||
* @param int $etd
|
||||
* @param int $eta
|
||||
* @param int $transport_id
|
||||
* ScheduleObject constructor.
|
||||
* @param Carbon $etd
|
||||
* @param Carbon $eta
|
||||
* @param int $status
|
||||
*/
|
||||
public function __construct(string $etd, string $eta, int $transport_id, int $status)
|
||||
public function __construct(Carbon $etd, Carbon $eta, int $status)
|
||||
{
|
||||
$this->etd = $etd;
|
||||
$this->eta = $eta;
|
||||
$this->transport_id = $transport_id;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getETD(): Carbon
|
||||
public function getEtd(): Carbon
|
||||
{
|
||||
return Carbon::parse($this->etd);
|
||||
return $this->etd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getETA(): Carbon
|
||||
public function getEta(): Carbon
|
||||
{
|
||||
return Carbon::parse($this->eta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTransportId(): int
|
||||
{
|
||||
return $this->transport_id;
|
||||
return $this->eta;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,4 +53,6 @@ class ScheduleObject implements DataTransferObject
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class CreatesSchedule extends AbstractUpdateRelationshipRecord
|
||||
|
||||
$model->etd = $object->getETD();
|
||||
$model->eta = $object->getETA();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($transport->schedules(), $model);
|
||||
|
||||
|
||||
@@ -7,81 +7,64 @@ use Carbon\Carbon;
|
||||
|
||||
class StepsObject implements DataTransferObject
|
||||
{
|
||||
private $id;
|
||||
|
||||
private $appointee_id;
|
||||
/** @var int */
|
||||
private $appointeeId;
|
||||
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
private $primary;
|
||||
|
||||
/** @var float */
|
||||
private $sequence;
|
||||
|
||||
private $status;
|
||||
/** @var string */
|
||||
private $obligationId;
|
||||
|
||||
private $contract_status;
|
||||
|
||||
private $completed_date;
|
||||
|
||||
private $hash_id;
|
||||
|
||||
public function __construct(int $appointee_id, string $reference, bool $primary, float $sequence, int $status, int $contract_status, ?string $completed_date, int $id=0, ?string $hash_id)
|
||||
/**
|
||||
* StepsObject constructor.
|
||||
* @param int $appointeeId
|
||||
* @param string $reference
|
||||
* @param float $sequence
|
||||
* @param string $obligationId
|
||||
*/
|
||||
public function __construct(int $appointeeId, string $reference, float $sequence, string $obligationId)
|
||||
{
|
||||
$this->appointee_id = $appointee_id;
|
||||
$this->appointeeId = $appointeeId;
|
||||
$this->reference = $reference;
|
||||
$this->primary = $primary;
|
||||
|
||||
$this->sequence = $sequence;
|
||||
$this->status = $status;
|
||||
$this->contract_status = $contract_status;
|
||||
$this->completed_date = $completed_date;
|
||||
|
||||
$this->id = $id;
|
||||
$this->hash_id = $hash_id;
|
||||
$this->obligationId = $obligationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAppointeeId(): int
|
||||
{
|
||||
return $this->appointee_id;
|
||||
return $this->appointeeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
public function getPrimary(): bool
|
||||
{
|
||||
return $this->primary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getSequence(): float
|
||||
{
|
||||
return $this->sequence;
|
||||
}
|
||||
|
||||
public function getStatus(): int
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getObligationId(): string
|
||||
{
|
||||
return $this->status;
|
||||
return $this->obligationId;
|
||||
}
|
||||
|
||||
public function getContractStatus(): int
|
||||
{
|
||||
return $this->contract_status;
|
||||
}
|
||||
|
||||
public function getCompletedDate(): Carbon
|
||||
{
|
||||
return $this->completed_date ? Carbon::parse($this->completed_date) : Carbon::now();
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getHashId(): ?string
|
||||
{
|
||||
return $this->hash_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,20 @@ class CreateStepsProcessor
|
||||
$this->fetchesSteps = $fetchesSteps;
|
||||
}
|
||||
|
||||
public function execute(Model $order, string $currentStep, $appointee_id){
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param string $currentStep
|
||||
* @param $appointee_id
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Order $order, string $currentStep, $appointee_id){
|
||||
|
||||
$order_steps_object = new StepsObject( $appointee_id, $currentStep, true, 0, OrderStatus::PROCESSING, 0, null, 0, null);
|
||||
$stepObject = new StepsObject( $appointee_id, $currentStep, true, 0, OrderStatus::PROCESSING, 0, null, 0, null);
|
||||
|
||||
$this->canCreateStep->passes($order_steps_object);
|
||||
$this->canCreateStep->passes($stepObject);
|
||||
|
||||
return $this->createsSteps->execute($order, $order_steps_object);
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Models\Step;
|
||||
use App\Models\Order;
|
||||
|
||||
class CreatesManySteps extends AbstractUpdateRecord
|
||||
class CreatesManySteps extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
public function execute(Order $order, array $orderSteps) {
|
||||
public function execute(Steppable $owner, array $orderSteps) {
|
||||
|
||||
$orderStepsModel=[];
|
||||
foreach($orderSteps as $step){
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Steps\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\Steppable;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Models\Step;
|
||||
use App\Models\Order;
|
||||
|
||||
class CreatesStep extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Steppable $owner
|
||||
* @param StepsObject $orderSteps
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Steppable $owner, StepsObject $orderSteps) {
|
||||
|
||||
$model = new Step();
|
||||
|
||||
$model->appointee_id = $orderSteps->getAppointeeId();
|
||||
$model->reference = $orderSteps->getReference();
|
||||
$model->sequence = $orderSteps->getSequence();
|
||||
$model->obligation_hash_id = $orderSteps->getObligationId();
|
||||
|
||||
return $this->handler($owner->steps(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Steps\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Models\Step;
|
||||
use App\Models\Order;
|
||||
|
||||
class CreatesSteps extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param StepsObject $orderSteps
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Order $order, StepsObject $orderSteps) {
|
||||
|
||||
$orderStepsModel = new Step();
|
||||
|
||||
$orderStepsModel->appointee_id = $orderSteps->getAppointeeId();
|
||||
$orderStepsModel->reference = $orderSteps->getReference();
|
||||
$orderStepsModel->primary = $orderSteps->getPrimary();
|
||||
$orderStepsModel->sequence = $orderSteps->getSequence();
|
||||
$orderStepsModel->status = 0;
|
||||
$orderStepsModel->contract_status = 0;
|
||||
$orderStepsModel->complete_date = null;
|
||||
|
||||
return $this->handler($order->orderSteps(), $orderStepsModel);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,44 +11,44 @@ class TransportObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $type;
|
||||
|
||||
/** @var string|null */
|
||||
/** @var null|string */
|
||||
private $courier;
|
||||
|
||||
/** @var int */
|
||||
private $tracking_number;
|
||||
/** @var null|string */
|
||||
private $trackingNumber;
|
||||
|
||||
/** @var int */
|
||||
private $dispacth_date;
|
||||
/** @var Carbon|null */
|
||||
private $dispatchDate;
|
||||
|
||||
/** @var int */
|
||||
private $drop_date;
|
||||
/** @var Carbon|null */
|
||||
private $dropDate;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* TransportObject constructor.
|
||||
* @param int $type
|
||||
* @param string $type
|
||||
* @param null|string $courier
|
||||
* @param string $tracking_number
|
||||
* @param int $dispatch_date
|
||||
* @param int $drop_date
|
||||
* @param null|string $trackingNumber
|
||||
* @param Carbon|null $dispatchDate
|
||||
* @param Carbon|null $dropDate
|
||||
* @param int $status
|
||||
*/
|
||||
public function __construct(int $type, string $courier, string $tracking_number, ?string $dispatch_date, ?string $drop_date, int $status)
|
||||
public function __construct(string $type, ?string $courier, ?string $trackingNumber, ?Carbon $dispatchDate, ?Carbon $dropDate, int $status)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->courier = $courier;
|
||||
$this->tracking_number = $tracking_number;
|
||||
$this->dispatch_date = $dispatch_date;
|
||||
$this->drop_date = $drop_date;
|
||||
$this->trackingNumber = $trackingNumber;
|
||||
$this->dispatchDate = $dispatchDate;
|
||||
$this->dropDate = $dropDate;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): int
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
@@ -62,27 +62,27 @@ class TransportObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return null|string
|
||||
*/
|
||||
public function getTrackingNumber(): string
|
||||
public function getTrackingNumber(): ?string
|
||||
{
|
||||
return $this->tracking_number;
|
||||
return $this->trackingNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function getDispatchDate(): ?Carbon
|
||||
{
|
||||
return $this->dispatch_date ? Carbon::parse($this->dispatch_date) : null;
|
||||
return $this->dispatchDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function getDropDate(): ?Carbon
|
||||
{
|
||||
return $this->drop_date ? Carbon::parse($this->drop_date) : null;
|
||||
return $this->dropDate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Transports\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\Transportable;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Models\Transport;
|
||||
use App\Models\Container;
|
||||
@@ -12,12 +13,12 @@ class CreatesTransport extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Container $containerPackingList
|
||||
* @param TransportObject $object
|
||||
* @param Transportable $transportable
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Container $containerPackingList, TransportObject $object) {
|
||||
public function execute(TransportObject $object, Transportable $transportable) {
|
||||
$model = new Transport();
|
||||
|
||||
$model->type = $object->getType();
|
||||
@@ -27,7 +28,7 @@ class CreatesTransport extends AbstractUpdateRelationshipRecord
|
||||
$model->drop_date = $object->getDropDate();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($containerPackingList->transports(), $model);
|
||||
return $this->handler($transportable->transports(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,12 @@ class AssignContractEntityProcessor
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
public function execute(Request $request, array $contractEntities, array $obligations){
|
||||
public function execute(string $contractEntities, array $obligations){
|
||||
|
||||
$responses = [];
|
||||
|
||||
//CIEF Contract Entity Hash ID
|
||||
$contract_entity_hash_id = $contractEntities[0]->hash_id;
|
||||
|
||||
foreach($obligations as $obligation){
|
||||
$responses[] = $this->updatesContractEntity->execute($obligation->hash_id, [$contract_entity_hash_id]);
|
||||
$responses[] = $this->updatesContractEntity->execute($obligation->hash_id, [$contractEntities]);
|
||||
}
|
||||
|
||||
return $responses;
|
||||
|
||||
@@ -20,7 +20,7 @@ class CreateContractEntityProcessor
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
public function execute(string $new_contract_id, array $entity_hash_ids){
|
||||
public function execute(string $new_contract_id, string $entity_hash_ids){
|
||||
return $this->createsContractEntity->execute($new_contract_id, $entity_hash_ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,10 @@ class CreatesContractEntity
|
||||
$this->contract_hash_id = Config::get('unity.contract_template_hash_id');
|
||||
}
|
||||
|
||||
public function execute(string $new_contract_id, array $entity_hash_ids){
|
||||
public function execute(string $new_contract_id, string $entity_hash_ids){
|
||||
|
||||
$accesToken=$this->getAccessToken->execute();
|
||||
|
||||
$response = Http::withToken($accesToken)->post($this->createContractEntityEndpoint,['contract_id'=>[$new_contract_id],'entity_id'=>$entity_hash_ids])->object();
|
||||
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PackageType {
|
||||
|
||||
public const CARTON = 0;
|
||||
|
||||
public const PALLET = 1;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PackingListType {
|
||||
|
||||
public const SUPPLIER_PACKING_LIST = 0;
|
||||
|
||||
public const WAREHOUSE_RECEIVE_LIST = 1;
|
||||
|
||||
public const SHIPPING_PACKING_LIST = 2;
|
||||
|
||||
public const TRANSPORT_PACKING_LIST = 3;
|
||||
|
||||
public const DELIVERY_PACKING_LIST = 4;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class TransportType {
|
||||
|
||||
public const AIR = 0;
|
||||
|
||||
public const SEA = 1;
|
||||
|
||||
public const LAND = 2;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -14,5 +14,24 @@ final class WarehouseReferences {
|
||||
|
||||
public const SARAWAK = 'SRW-V01';
|
||||
|
||||
public const DESTINATION_WAREHOUSE = [
|
||||
1 => self::KLANG,
|
||||
2 => self::KLANG,
|
||||
3 => self::KLANG,
|
||||
4 => self::KLANG,
|
||||
5 => self::SABAH,
|
||||
6 => self::KLANG,
|
||||
7 => self::KLANG,
|
||||
8 => self::KLANG,
|
||||
9 => self::KLANG,
|
||||
10 => self::KLANG,
|
||||
11 => self::KLANG,
|
||||
12 => self::KLANG,
|
||||
13 => self::SABAH,
|
||||
14 => self::KLANG,
|
||||
15 => self::KLANG,
|
||||
16 => self::KLANG,
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ class ContainerResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'container_reference' => $this->container_reference,
|
||||
'container_reference' => $this->reference,
|
||||
'container_type' => $this->container_type,
|
||||
'container_number' => $this->container_number,
|
||||
'seal_reference' => $this->seal_reference,
|
||||
'packing_list' => PackingListResource::collection($this->packingLists),
|
||||
'transport' => TransportResource::collection($this->transports),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
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 Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderResource extends JsonResource
|
||||
@@ -24,6 +28,55 @@ class OrderResource extends JsonResource
|
||||
'company_module' => new CompanyModuleResource($this->companyModule),
|
||||
'warehouse' => new CompanyModuleResource($this->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee),
|
||||
'address' => new AddressResource($this->addresses()->first()),
|
||||
$this->mergeWhen($this->relationLoaded('parcels'), [
|
||||
'origin_warehouse_packages' => PackageResource::collection($this->parcels()->whereHas('packingList', function($query){
|
||||
return $query->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('containers', function($query) {
|
||||
return $query->whereHas('transports', function($query){
|
||||
return $query->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
});
|
||||
})->get()),
|
||||
'in_transit_packages' => PackageResource::collection($this->parcels()->whereHas('packingList', function($query){
|
||||
return $query->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereHas('containers', function($query) {
|
||||
return $query->whereHas('transports', function($query){
|
||||
return $query->where('status', '=', ApprovalStatus::APPROVED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
});
|
||||
})->get()),
|
||||
'destination_warehouse_packages' => PackageResource::collection($this->parcels()->whereHas('packingList', function($query){
|
||||
return $query->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereHas('containers', function($query) {
|
||||
return $query->whereHas('transports', function($query){
|
||||
return $query->where('type', '=', TransportType::SEA)->where('status', '=', ApprovalStatus::COMPLETED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
})->whereDoesntHave('transports', function($query){
|
||||
return $query->where('type', '=', TransportType::LAND)->where('status', '=', ApprovalStatus::APPROVED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
})->get()),
|
||||
'delivered_packages' => PackageResource::collection($this->parcels()->whereHas('packingList', function($query){
|
||||
return $query->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereHas('containers', function($query) {
|
||||
return $query->whereHas('transports', function($query){
|
||||
return $query->where('type', '=', TransportType::SEA)->where('status', '=', ApprovalStatus::COMPLETED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
})->whereHas('transports', function($query){
|
||||
return $query->where('type', '=', TransportType::LAND)->where('status', '=', ApprovalStatus::APPROVED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
})->get()),
|
||||
'parcels' => PackageResource::collection($this->parcels()->whereHas('packingList', function($query){
|
||||
return $query->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST);
|
||||
})->get()),
|
||||
]),
|
||||
'created_at' => $this->created_at->format('d-m-Y')
|
||||
];
|
||||
}
|
||||
|
||||
@@ -16,15 +16,18 @@ class PackageResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'packing_list_id' => $this->packing_list_id,
|
||||
'type' => $this->type,
|
||||
'description' => $this->description,
|
||||
'width' => $this->width,
|
||||
'height' => $this->height,
|
||||
'length' => $this->length,
|
||||
'width' => floatval($this->width),
|
||||
'height' => floatval($this->height),
|
||||
'length' => floatval($this->length),
|
||||
'weight' => $this->weight,
|
||||
'quantity' => $this->quantity,
|
||||
'cbm' => (($this->width / 100) * ($this->width / 100) * ($this->width / 100)) * $this->quantity,
|
||||
'status' => $this->status,
|
||||
'order' => new OrderResource($this->packingList->owner),
|
||||
'container' => new ContainerResource($this->packingList->containers()->first()),
|
||||
'transport' => new TransportResource($this->packingList->transports()->first())
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ class PackingListResource extends JsonResource
|
||||
'claimant_id' => $this->claimant_id,
|
||||
'reference' => $this->reference,
|
||||
'status' => $this->status,
|
||||
'transport' => new TransportResource($this->transports()->first()),
|
||||
'packages' => PackageResource::collection($this->packages),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ class ScheduleResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'etd' => $this->etd,
|
||||
'eta' => $this->eta,
|
||||
'etd' => $this->etd->format('d-m-Y'),
|
||||
'eta' => $this->eta->format('d-m-Y'),
|
||||
'status' => $this->status,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TransportResource extends JsonResource
|
||||
@@ -19,9 +20,11 @@ class TransportResource extends JsonResource
|
||||
'type' => $this->type,
|
||||
'courier' => $this->courier,
|
||||
'tracking_number' => $this->tracking_number,
|
||||
'dispatch_date' => $this->dispatch_date,
|
||||
'drop_date' => $this->drop_date,
|
||||
'dispatch_date' => $this->dispatch_date ? $this->dispatch_date->format('d-m-Y') : $this->dispatch_date,
|
||||
'drop_date' => $this->drop_date ? $this->drop_date->format('d-m-Y') : $this->drop_date,
|
||||
'status' => $this->status,
|
||||
'current_schedule' => new ScheduleResource($this->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()),
|
||||
'schedule_history' => ScheduleResource::collection($this->schedules()->where('status', '!=', ApprovalStatus::APPROVED)->get())
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
* Class Address
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\Company company_id
|
||||
* @property \App\Models\State state_id
|
||||
* @property \App\Models\District district_id
|
||||
* @property int country_id
|
||||
* @property int company_id
|
||||
* @property int state_id
|
||||
* @property int district_id
|
||||
* @property string postcode
|
||||
* @property string street_one
|
||||
* @property string street_two
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Addressable;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\General\Interfaces\ContainerOwner;
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
@@ -27,7 +28,7 @@ use PhpParser\Node\Expr\AssignOp\Mod;
|
||||
* @property integer type
|
||||
* @property integer status
|
||||
*/
|
||||
class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable
|
||||
class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable, ContainerOwner
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
@@ -120,6 +121,14 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
|
||||
return $this->HasMany(Bank::class, 'company_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function containers(): morphMany
|
||||
{
|
||||
return $this->morphMany(Container::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @return Builder
|
||||
@@ -147,4 +156,6 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
|
||||
return $query->where('type', '=', BusinessType::WAREHOUSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,19 +2,22 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Transportable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class Container extends AbstractModel
|
||||
class Container extends AbstractModel implements Transportable
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'containers';
|
||||
|
||||
protected $fillable = ['status'];
|
||||
|
||||
public function packingLists(): belongsToMany
|
||||
{
|
||||
return $this->belongsToMany(PackingList::class, Container::class, 'container_id', 'packing_list_id');
|
||||
return $this->belongsToMany(PackingList::class, ContainerPackingList::class, 'container_id', 'packing_list_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class Container extends AbstractModel
|
||||
class ContainerPackingList extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@@ -15,4 +15,20 @@ class OldOrders extends Model
|
||||
|
||||
protected $table = 'orders';
|
||||
|
||||
/**
|
||||
* @return hasOne
|
||||
*/
|
||||
public function address(): hasOne
|
||||
{
|
||||
return $this->hasOne(OldAddress::class, 'reference_id', 'address_id')->where('type', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return belongsTo
|
||||
*/
|
||||
public function company(): belongsTo
|
||||
{
|
||||
return $this->belongsTo(oldCompany::class, 'company_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-1
@@ -3,14 +3,17 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Addressable;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Scopes\CustomerOrdersScope;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class Order extends AbstractModel implements Addressable
|
||||
class Order extends AbstractModel implements Addressable, Packable
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
@@ -43,6 +46,22 @@ class Order extends AbstractModel implements Addressable
|
||||
return $this->morphMany(Address::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function packingLists(): morphMany
|
||||
{
|
||||
return $this->morphMany(PackingList::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasManyThrough
|
||||
*/
|
||||
public function parcels(): HasManyThrough
|
||||
{
|
||||
return $this->HasManyThrough(Package::class, PackingList::class, 'owner_id', 'packing_list_id')->where('owner_type', Order::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
@@ -51,6 +70,7 @@ class Order extends AbstractModel implements Addressable
|
||||
return $this->HasMany(OrderRole::class, 'order_id');
|
||||
}
|
||||
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
// if (auth()->user()->type === RoleTypes::USER) {
|
||||
|
||||
@@ -10,6 +10,8 @@ class OrderRole extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['entity_hash_id', 'entity_signature'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -12,14 +13,12 @@ class Package extends AbstractModel
|
||||
|
||||
protected $table = 'packages';
|
||||
|
||||
public function order(): BelongsTo
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function packingList(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Order::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function owner(): morphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
return $this->belongsTo(PackingList::class, 'packing_list_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,17 +2,58 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Steppable;
|
||||
use App\Classes\General\Interfaces\Transportable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PackingList extends AbstractModel
|
||||
class PackingList extends AbstractModel implements Transportable, Steppable
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'packing_lists';
|
||||
|
||||
public function orderSteps(): morphMany
|
||||
protected $fillable = ['status'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
public function owner(): morphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function containers(): BelongsToMany
|
||||
{
|
||||
return $this->BelongsToMany(Container::class, ContainerPackingList::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function steps(): morphMany
|
||||
{
|
||||
return $this->morphMany(Step::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function packages(): hasMany
|
||||
{
|
||||
return $this->hasMany(Package::class, 'packing_list_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return morphMany
|
||||
*/
|
||||
public function transports(): morphMany
|
||||
{
|
||||
return $this->morphMany(Transport::class, 'owner');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ class Schedule extends AbstractModel
|
||||
|
||||
protected $table = 'schedules';
|
||||
|
||||
protected $dates = ['etd', 'eta'];
|
||||
|
||||
public function owner(): morphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
+3
-13
@@ -10,22 +10,12 @@ class Step extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'order_steps';
|
||||
protected $table = 'steps';
|
||||
|
||||
protected $fillable = ['status'];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = ['order_id','appointee_id','reference','primary','sequence','status','contract_status','complete_date','unity_hash_id'];
|
||||
|
||||
public function companyModule(): belongsTo
|
||||
{
|
||||
return $this->belongsTo(CompanyModule::class, 'appointee_id', 'id');
|
||||
}
|
||||
|
||||
public function orderRole(): belongsTo
|
||||
{
|
||||
return $this->belongsTo(OrderRole::class, 'appointee_id', 'company_module_id');
|
||||
}
|
||||
|
||||
public function owner(): morphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
@@ -13,6 +13,10 @@ class Transport extends AbstractModel
|
||||
|
||||
protected $table = 'transport_arrangements';
|
||||
|
||||
protected $fillable = ['status', 'drop_date'];
|
||||
|
||||
protected $dates = ['dispatch_date', 'drop_date'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
|
||||
+1
-7
@@ -41,9 +41,7 @@ return [
|
||||
|
||||
'on_error_email' => env('UNITY_ON_ERROR_EMAIL','dev@shipping.com,dev@unity.com'),
|
||||
|
||||
'contract_template_id' => env('UNITY_CONTRACT_TEMPLATE_ID', 105),
|
||||
|
||||
'contract_template_hash_id' => env('UNITY_CONTRACT_TEMPLATE_HASH_ID', 'zDMkNBK3dpej1Zpg7yv9'),
|
||||
'contract_template_hash_id' => env('UNITY_CONTRACT_TEMPLATE_HASH_ID', 'Kp3qzMV82m5R2PZg6eX0'),
|
||||
|
||||
'contract_template_cache' => env('UNITY_CONTRACT_TEMPLATE_CACHE','60'),
|
||||
|
||||
@@ -51,8 +49,4 @@ return [
|
||||
'PACKING' => Constant\OrderSteps::PACKING,
|
||||
],
|
||||
|
||||
'step_processors' => [
|
||||
Constant\OrderSteps::PACKING => Step\Packing::class,
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -19,9 +20,9 @@ class CreateStepsTable extends Migration
|
||||
$table->bigInteger('appointee_id')->unsigned()->index();
|
||||
$table->string('obligation_hash_id',200)->nullable();
|
||||
$table->string('reference');
|
||||
$table->integer('primary')->default(0);
|
||||
$table->integer('primary')->default(false);
|
||||
$table->decimal('sequence', 4, 2);
|
||||
$table->integer('status')->default(0);
|
||||
$table->integer('status')->default(ApprovalStatus::PENDING_SUBMISSION);
|
||||
$table->date('complete_date')->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
@@ -16,7 +16,8 @@ class CreatePackingListsTable extends Migration
|
||||
Schema::create('packing_lists', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('owner');
|
||||
$table->bigInteger('claimant_id')->unsigned()->index()->nullable(true);
|
||||
$table->bigInteger('claimant_id')->unsigned()->index()->nullable();
|
||||
$table->string('reference_contract')->nullable();
|
||||
$table->string('reference',200);
|
||||
$table->integer('type')->default(0);
|
||||
$table->integer('status')->default(0);
|
||||
|
||||
@@ -17,10 +17,11 @@ class CreateContainersTable extends Migration
|
||||
{
|
||||
Schema::create('containers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('reference',45);
|
||||
$table->string('container_number',45);
|
||||
$table->morphs('owner');
|
||||
$table->string('reference');
|
||||
$table->string('container_number')->nullable();
|
||||
$table->integer('container_type')->default(ContainerTypes::FORTY_FEET_DRY_CONTAINER);
|
||||
$table->string('seal_reference',45);
|
||||
$table->string('seal_reference')->nullable();
|
||||
$table->integer('status')->default(ApprovalStatus::PENDING_SUBMISSION);
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -16,15 +18,15 @@ class CreateTransportArrangementsTable extends Migration
|
||||
Schema::create('transport_arrangements', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('owner');
|
||||
$table->integer('type')->default(0);
|
||||
$table->integer('type')->default(TransportType::SEA);
|
||||
|
||||
$table->string('courier',45);
|
||||
$table->string('tracking_number',45);
|
||||
$table->string('courier')->nullable();
|
||||
$table->string('tracking_number')->nullable();
|
||||
|
||||
$table->timestamp('dispatch_date')->nullable();
|
||||
$table->timestamp('drop_date')->nullable();
|
||||
|
||||
$table->integer('status')->default(0);
|
||||
$table->integer('status')->default(ApprovalStatus::PENDING_VERIFICATION);
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Processors\CreateAddressFromOldAddressProcessor;
|
||||
use App\Classes\Modules\Addresses\Services\CleansOldAddress;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
@@ -48,6 +50,9 @@ class CompaniesTableSeeder extends Seeder
|
||||
/** @var ApprovesCompanyConnection */
|
||||
private $approvesCompanyConnection;
|
||||
|
||||
/** @var CreateAddressFromOldAddressProcessor */
|
||||
private $createAddressFromOldAddressProcessor;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
@@ -65,11 +70,12 @@ class CompaniesTableSeeder extends Seeder
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
||||
* @param CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param CreatesCompany $createsCompany
|
||||
* @param CreatesContact $createsContact
|
||||
*/
|
||||
public function __construct(CreateCompanyProcessor $createCompanyProcessor, UpdatesCompanyStatus $updatesCompanyStatus, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, CreatesAddress $createsAddress, CreatesCompany $createsCompany, CreatesContact $createsContact)
|
||||
public function __construct(CreateCompanyProcessor $createCompanyProcessor, UpdatesCompanyStatus $updatesCompanyStatus, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor, CreatesAddress $createsAddress, CreatesCompany $createsCompany, CreatesContact $createsContact)
|
||||
{
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
@@ -77,6 +83,7 @@ class CompaniesTableSeeder extends Seeder
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
||||
$this->createAddressFromOldAddressProcessor = $createAddressFromOldAddressProcessor;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->createsCompany = $createsCompany;
|
||||
$this->createsContact = $createsContact;
|
||||
@@ -168,16 +175,20 @@ class CompaniesTableSeeder extends Seeder
|
||||
|
||||
}
|
||||
|
||||
if(App::environment(['production'])){
|
||||
if(true){
|
||||
$companies = OldCompany::all();
|
||||
|
||||
foreach($companies as $company){
|
||||
|
||||
$marking = explode("CIEF/", $company->marking);
|
||||
|
||||
if(count($marking) < 2){
|
||||
continue;
|
||||
}
|
||||
|
||||
$marking = str_replace(' ', '', str_replace('/', '', $marking[1]));
|
||||
|
||||
|
||||
/** @var Company $newCompany */
|
||||
$newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
@@ -186,33 +197,14 @@ class CompaniesTableSeeder extends Seeder
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking[1]);
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking);
|
||||
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
|
||||
$i = 0;
|
||||
foreach($company->addresses as $address){
|
||||
if($address->street_one === '' && $address->street_two === ''){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$address->post_code){
|
||||
continue;
|
||||
}
|
||||
|
||||
$district = District::where('postcode', 'like', '%'. $address->post_code .'%')->first();
|
||||
|
||||
if(!$district) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$street_one = str_replace($district->state->name, '',str_replace($district->name, '', $address->street_one));
|
||||
$street_two = str_replace($district->state->name, '',str_replace($district->name, '', $address->street_two));
|
||||
|
||||
$object = new AddressObject(str_replace(', ,', ',', str_replace(', ,', ',', $street_one)), str_replace(', ,', ',', str_replace(', ,', ',', $street_two)), $district->country_id, $district->state_id, $district->id, $address->post_code, 'Business Address');
|
||||
$this->createsAddress->execute($companyModule, $object);
|
||||
|
||||
$this->createAddressFromOldAddressProcessor->execute($address, $companyModule);
|
||||
$contact = preg_replace("/[^0-9.]/", "", $address->contact);
|
||||
if($contact){
|
||||
$i++;
|
||||
@@ -224,20 +216,10 @@ class CompaniesTableSeeder extends Seeder
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function cleanAddress($address){
|
||||
$address = str_replace('Malaysia', '', str_replace('malaysia', '', $address));
|
||||
$address = str_replace(', ,', ',', str_replace(', ,', ',', str_replace(', ,', ',', $address)));
|
||||
$address = str_replace(' ', ' ', str_replace(' ', ' ', str_replace(' ', ' ', $address)));
|
||||
return str_replace(', ,', ',', str_replace(', ,', ',', $address));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<template>
|
||||
<div v-if="validator.$error" class="text-danger">
|
||||
<small class="bold" v-for="(object, param) in validator.$params">
|
||||
<span v-if="object.type === 'minLength'">{{object.min}} characters</span>
|
||||
<span v-if="object.type === 'minValue'">{{object.min}}</span>
|
||||
<span v-if="object.type === 'sameAs'">{{object.eq}} field</span>
|
||||
<span v-if="object.type === 'numeric'">this field only accepts numbers</span>
|
||||
</small>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
validator: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
errorMessages:{
|
||||
required: 'this field is required',
|
||||
email: 'enter a valid email address',
|
||||
minLength: 'this field must have at least',
|
||||
sameAs: 'this field must match the',
|
||||
minValue: 'this field must at least be',
|
||||
numeric: 'this field only accepts numbers',
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
Validation(){
|
||||
return this.validator;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="dropzone no-border no-padding text-center" style="min-height: auto;">
|
||||
<div class="no-border no-padding text-center" style="min-height: auto;">
|
||||
<div class="dz-message hide"></div>
|
||||
<div class="dragzone row m-l-0 m-r-0 bg-master-lightest" :class="[{'m-b-15': hasFile}]" style="border-width: 1px;">
|
||||
<div class="col">
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
{{errorMessages[param]}}
|
||||
<span v-if="object.type === 'minLength'">{{object.min}} characters</span>
|
||||
<span v-if="object.type === 'sameAs'">{{object.eq}} field</span>
|
||||
<span v-if="object.type === 'minValue'">{{object.min}}</span>
|
||||
</small>
|
||||
</div>
|
||||
</template>
|
||||
@@ -21,7 +22,9 @@
|
||||
required: 'this field is required',
|
||||
email: 'enter a valid email address',
|
||||
minLength: 'this field must have at least',
|
||||
sameAs: 'this field must match the'
|
||||
minValue: 'this field must at least be',
|
||||
sameAs: 'this field must match the',
|
||||
numeric: 'this field can only contain numbers'
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<div class="row bg-white no-margin">
|
||||
<div class="col">
|
||||
<div class="row m-b-15">
|
||||
<div class="col b-t b-primary" style="border-top-width: 5px;"></div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-b-10 align-items-center">
|
||||
<div class="col-auto">
|
||||
<p class="no-margin all-caps fs-10 lh-10 light">QTY</p>
|
||||
<h5 class="no-margin text-primary bold">{{item.quantity}}</h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin all-caps fs-10 lh-18 light">Description</p>
|
||||
<p class="bold m-b-5 fs-12">{{item.description}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-t b-b b-grey m-b-15">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-auto b-r b-grey p-t-10 p-b-10">
|
||||
<p class="no-margin text-info bold">{{item.width}} <sup>CM</sup></p>
|
||||
<p class="no-margin all-caps fs-10 light">Width</p>
|
||||
</div>
|
||||
<div class="col-auto b-r b-grey p-t-10 p-b-10">
|
||||
<p class="no-margin text-info bold">{{item.quantity}} <sup>CM</sup></p>
|
||||
<p class="no-margin all-caps fs-10 light">Height</p>
|
||||
</div>
|
||||
<div class="col-auto b-r b-grey p-t-10 p-b-10">
|
||||
<p class="no-margin text-info bold">{{item.length}} <sup>CM</sup></p>
|
||||
<p class="no-margin all-caps fs-10 light">Length</p>
|
||||
</div>
|
||||
<div class="col text-right p-t-10 p-b-10">
|
||||
<p class="no-margin all-caps fs-10 lh-15 light">Total CBM</p>
|
||||
<h5 class="no-margin text-primary bold">{{parseFloat((item.cbm * 100) / 100).toFixed(3)}}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-b b-grey p-b-20 align-items-center">
|
||||
<div class="col">
|
||||
<div class="row m-b-5">
|
||||
<div class="col-auto">
|
||||
<small class="fs-10 all-caps muted">Order Number</small>
|
||||
<p class="no-margin bold">{{item.order.reference}}</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<small class="fs-10 all-caps muted">Status</small>
|
||||
<p class="no-margin bold">{{status}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-auto">
|
||||
<small class="fs-10 all-caps muted">Warehouse</small>
|
||||
<h6 class="no-margin small">{{item.order.warehouse.id === 3 ? 'Guang Zhou' : 'Yiwu'}}</h6>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<small class="fs-10 all-caps muted">Delivery Address</small>
|
||||
<h6 class="no-margin small">{{item.order.address.reference}} <i class="fa fa-info-circle m-l-5" v-tooltip:right="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" ></i></h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row p-t-10 p-b-10">
|
||||
<div class="col-auto p-r-0">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto">
|
||||
<i class="fa fa-check fs-15 p-t-15" :class="{'text-primary': status !== 'Ready To Ship', 'muted': status === 'Ready To Ship'}"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto">
|
||||
<div class="b-l b-dashed " style="height: 40px;" :class="{'b-primary': status === 'Preparing Delivery' || status === 'Delivered', 'b-grey': status !== 'Preparing Delivery' || status !== 'Delivered'}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto">
|
||||
<i class="fa fa-check fs-15" :class="{'text-primary': item.transport, 'muted': !item.transport}"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-0">
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<div class="col-auto">
|
||||
<small class="fs-10 all-caps muted">Shipping Date</small>
|
||||
<h6 class="no-margin small">{{item.container ? item.container.transport[0].current_schedule.etd : 'n/a'}}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="col-auto">
|
||||
<small class="fs-10 all-caps muted">Delivery Date</small>
|
||||
<h6 class="no-margin small">{{item.transport ? item.transport.current_schedule.eta : 'n/a'}}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-25">
|
||||
<div class="col"></div>
|
||||
<div class="col b-t b-primary" style="border-top-width: 5px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
export default {
|
||||
props: {
|
||||
status: {
|
||||
required: true,
|
||||
type: String
|
||||
}
|
||||
},
|
||||
created(){
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
expanded: false
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
File diff suppressed because one or more lines are too long
@@ -95,7 +95,7 @@
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="originWarehouse">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="inTransit">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
@@ -124,7 +124,7 @@
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="originWarehouse">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="destinationWarehouse">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
@@ -153,7 +153,7 @@
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="originWarehouse">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="delivery">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
@@ -176,23 +176,150 @@
|
||||
<div class="row no-margin">
|
||||
<div class="col bg-master-lightest padding-30">
|
||||
<div class="row tabsContainer tabContent active" tab-name="originWarehouse">
|
||||
<div class="col-4">
|
||||
<div class="row">
|
||||
<div class="col bg-complete-lighter p-b-10">
|
||||
<div class="row align-item-center p-t-10 p-b-10">
|
||||
<div class="col">
|
||||
<h6 class="bold no-margin">Received Parcels</h6>
|
||||
<p class="no-margin ">Parcels received at our warehouse</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="40" height="40"
|
||||
viewBox="0 0 172 172"
|
||||
style=" fill:#000000;"><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g fill="#000000"><path d="M8.6,23.65c-2.37676,0 -4.3,1.92324 -4.3,4.3c0,2.37676 1.92324,4.3 4.3,4.3c2.37676,0 4.3,-1.92324 4.3,-4.3c4.77031,0 8.6,3.82969 8.6,8.6v85.10137c0,8.28926 6.76074,15.05 15.05,15.05h0.50391c0.99941,2.98145 3.72051,5.19863 7.02109,5.19863h4.43438c-0.74746,1.26816 -1.20938,2.72949 -1.20938,4.3c0,4.72832 3.87168,8.6 8.6,8.6c4.72832,0 8.6,-3.87168 8.6,-8.6c0,-1.57051 -0.46191,-3.03184 -1.20938,-4.3h66.91875c-0.74746,1.26816 -1.20937,2.72949 -1.20937,4.3c0,4.72832 3.87168,8.6 8.6,8.6c4.72832,0 8.6,-3.87168 8.6,-8.6c0,-1.57051 -0.46191,-3.03184 -1.20937,-4.3h4.43437c3.36777,0 6.13926,-2.30117 7.08828,-5.375h0.43672v-2.15c0,-3.90527 -3.04863,-7.12188 -6.87832,-7.45781c0.26035,-0.69707 0.42832,-1.43613 0.42832,-2.21719v-40.85c0,-1.67129 -0.73066,-3.14941 -1.78887,-4.3c1.0582,-1.15059 1.78887,-2.62871 1.78887,-4.3v-43c0,-3.53574 -2.91426,-6.45 -6.45,-6.45h-94.6c-3.53574,0 -6.45,2.91426 -6.45,6.45v43c0,1.67129 0.73066,3.14941 1.78887,4.3c-1.0582,1.15059 -1.78887,2.62871 -1.78887,4.3v40.85c0,0.78105 0.16797,1.52012 0.42832,2.21719c-3.15781,0.27715 -5.75293,2.51953 -6.57598,5.48418h-0.30234c-5.96289,0 -10.75,-4.78711 -10.75,-10.75v-85.10137c0,-7.09668 -5.80332,-12.9 -12.9,-12.9zM49.45,30.1h94.6c1.21777,0 2.15,0.93223 2.15,2.15v43c0,1.21777 -0.93223,2.15 -2.15,2.15c-1.17578,0.0168 -2.11641,0.97422 -2.11641,2.15c0,1.17578 0.94062,2.1332 2.11641,2.15c1.21777,0 2.15,0.93223 2.15,2.15v40.85c0,1.21777 -0.93223,2.15 -2.15,2.15h-94.6c-1.21777,0 -2.15,-0.93223 -2.15,-2.15v-40.85c0,-1.21777 0.93223,-2.15 2.15,-2.15c1.17578,-0.0168 2.11641,-0.97422 2.11641,-2.15c0,-1.17578 -0.94063,-2.1332 -2.11641,-2.15c-1.21777,0 -2.15,-0.93223 -2.15,-2.15v-43c0,-1.21777 0.93223,-2.15 2.15,-2.15zM88.15,38.7c-0.77266,-0.0084 -1.49492,0.39473 -1.88965,1.0666c-0.38633,0.67188 -0.38633,1.49492 0,2.1668c0.39473,0.67188 1.11699,1.075 1.88965,1.0666h17.2c0.77266,0.0084 1.49492,-0.39473 1.88965,-1.0666c0.38633,-0.67187 0.38633,-1.49492 0,-2.1668c-0.39472,-0.67187 -1.11699,-1.075 -1.88965,-1.0666zM58.05,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM66.65,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM75.25,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM83.85,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM92.45,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM101.05,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM109.65,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM118.25,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM126.85,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM135.45,77.4c-1.18418,0 -2.15,0.96582 -2.15,2.15c0,1.18418 0.96582,2.15 2.15,2.15c1.18418,0 2.15,-0.96582 2.15,-2.15c0,-1.18418 -0.96582,-2.15 -2.15,-2.15zM88.15,90.3c-0.77266,-0.0084 -1.49492,0.39473 -1.88965,1.0666c-0.38633,0.67188 -0.38633,1.49492 0,2.1668c0.39473,0.67188 1.11699,1.075 1.88965,1.0666h17.2c0.77266,0.0084 1.49492,-0.39473 1.88965,-1.0666c0.38633,-0.67187 0.38633,-1.49492 0,-2.1668c-0.39472,-0.67187 -1.11699,-1.075 -1.88965,-1.0666zM44.075,131.15h105.35c1.80566,0 3.225,1.41934 3.225,3.225c0,1.80566 -1.41934,3.225 -3.225,3.225h-105.35c-1.80566,0 -3.225,-1.41934 -3.225,-3.225c0,-1.80566 1.41934,-3.225 3.225,-3.225zM55.9,141.9c2.40195,0 4.3,1.89805 4.3,4.3c0,2.40195 -1.89805,4.3 -4.3,4.3c-2.40195,0 -4.3,-1.89805 -4.3,-4.3c0,-2.40195 1.89805,-4.3 4.3,-4.3zM137.6,141.9c2.40195,0 4.3,1.89805 4.3,4.3c0,2.40195 -1.89805,4.3 -4.3,4.3c-2.40195,0 -4.3,-1.89805 -4.3,-4.3c0,-2.40195 1.89805,-4.3 4.3,-4.3z"></path></g></g></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<parcel-component v-for="parcel in order.parcels" :data="parcel" :key="parcel.id"></parcel-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="row" v-if="order.origin_warehouse_packages.length">
|
||||
<div class="col">
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50" >
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="row" v-for="group in Math.ceil(order.origin_warehouse_packages.length / 2)">
|
||||
<div class="col-12 p-r-0" :class="'col-md-'+(12/2)" v-for="item in order.origin_warehouse_packages.slice((group - 1) * 2, group * 2)" v-bind:key="item.id" :data="item">
|
||||
<package-component :data="item" status="Ready To Ship"></package-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-if="!order.origin_warehouse_packages.length">
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here Yet!</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here Yet!</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="inTransit">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row" v-if="order.in_transit_packages.length">
|
||||
<div class="col">
|
||||
<div class="row" v-for="group in Math.ceil(order.in_transit_packages.length / 3)">
|
||||
<div class="col-12" :class="'col-md-'+(12/3)" v-for="item in order.in_transit_packages.slice((group - 1) * 3, group * 3)" v-bind:key="item.id" :data="item">
|
||||
<package-component :data="item" status="Shipping"></package-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-if="!order.in_transit_packages.length">
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here Yet!</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="destinationWarehouse">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row" v-if="order.destination_warehouse_packages.length">
|
||||
<div class="col">
|
||||
<div class="row" v-for="group in Math.ceil(order.destination_warehouse_packages.length / 3)">
|
||||
<div class="col-12" :class="'col-md-'+(12/3)" v-for="item in order.destination_warehouse_packages.slice((group - 1) * 3, group * 3)" v-bind:key="item.id" :data="item">
|
||||
<package-component :data="item" status="Preparing Delivery"></package-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-if="!order.destination_warehouse_packages.length">
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here Yet!</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="delivery">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row" v-if="order.delivered_packages.length">
|
||||
<div class="col">
|
||||
<div class="row" v-for="group in Math.ceil(order.delivered_packages.length / 3)">
|
||||
<div class="col-12" :class="'col-md-'+(12/3)" v-for="item in order.delivered_packages.slice((group - 1) * 3, group * 3)" v-bind:key="item.id" :data="item">
|
||||
<package-component :data="item" status="Delivered"></package-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-if="!order.delivered_packages.length">
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here Yet!</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user