mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b485e8480 | |||
| 7d47ac14d0 | |||
| 5083ee83ad | |||
| 8363b8ca10 | |||
| 0a89451889 | |||
| 59730e21d2 | |||
| 3887512721 | |||
| e11cc64f89 | |||
| 5ca3a927c1 | |||
| 4246795e14 | |||
| d0a9f1aa9f | |||
| e8a7812583 | |||
| c651b6ca09 | |||
| d9f3ad74ca | |||
| 278145e211 | |||
| 7f0236d8d5 | |||
| 414a042199 | |||
| a85aeb00d7 | |||
| a31d7b7b8b | |||
| aa210c0b6f | |||
| bf0d61c862 | |||
| fae47f4a75 | |||
| 53575cf59a | |||
| 06db3ddf7b | |||
| 15650f53ad | |||
| 514364bb08 | |||
| 46bfe78b77 | |||
| 64ab158991 | |||
| 0255b39f4b | |||
| 94cf4dee1b | |||
| 0a32af0dab | |||
| 3f48d85e31 | |||
| 5e44386b24 | |||
| 11572a5627 | |||
| 30224f9114 | |||
| bf99141304 | |||
| 5b8bfa32d3 | |||
| dd4ecbe743 | |||
| 52cae7f877 | |||
| 5355b31bcb | |||
| c71727c9c0 | |||
| c6e621c4ab | |||
| 7279779377 | |||
| f90f5f7370 | |||
| d353a8629f | |||
| 9c62a792b7 | |||
| 32d3523190 | |||
| b5e2f47b31 | |||
| 82162026b3 | |||
| 3582654861 | |||
| 0772173dd9 | |||
| 61c11aef26 | |||
| 66c3b532cb | |||
| eac5c6d104 | |||
| 46b5d19331 | |||
| bea3836df8 | |||
| c07bcb6334 | |||
| c79443eb62 | |||
| 572cb4ac1d | |||
| 25c95f0843 | |||
| a3cdae6815 | |||
| 276e12679d | |||
| d24fea2910 |
@@ -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;
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CurlWarehouseListJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private $page;
|
||||
|
||||
public function __construct($page = -2)
|
||||
{
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$cookies = $this->getCookie();
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $cookies,
|
||||
];
|
||||
|
||||
$yesterday = Carbon::now()->subDays(1)->format('Y-m-d');
|
||||
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', [\GuzzleHttp\RequestOptions::JSON => json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":' . $this->page . ',"PageSize":100,"PageOffset":0,"SortExpression":"ParcelDate DESC,FullMarking DESC","GroupExpression":"","Filter":["ParcelDate:=%js%\"' . $yesterday . 'T00:00:00.000\"\u0000"],"ContextKey":"view1","FilterIsExternal":false,"LookupContextFieldName":null,"LookupContextController":null,"LookupContextView":null,"LookupContext":null,"Inserting":false,"LastCommandName":null,"ExternalFilter":[],"DoesNotRequireData":false,"LastView":"grid1","Tag":null,"RequiresFirstLetters":false,"ViewType":"Grid","SupportsCaching":true,"SystemFilter":null,"RequiresRowCount":true,"QuickFindHint":null,"RequiresPivot":false,"PivotDefinitions":null,"RequiresMetaData":true}}')]);
|
||||
|
||||
$data = json_decode($res->getBody()->getContents());
|
||||
|
||||
if (!empty($data->d->Row)) {
|
||||
// insert data here
|
||||
|
||||
// next page
|
||||
$this->page = $this->page > 0 ? $this->page + 1 : 1;
|
||||
CurlWarehouseListJob::dispatch($this->page + 1)
|
||||
->delay(Carbon::now()->addSeconds(10));
|
||||
}
|
||||
}
|
||||
|
||||
public function getCookie()
|
||||
{
|
||||
// get latest cookies
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$r = $client->request('GET', 'https://portalvt.azurewebsites.net');
|
||||
$call_cookie = $client->getConfig('cookies');
|
||||
$call_cookie = $call_cookie->toArray();
|
||||
$latest_cookie = [];
|
||||
|
||||
foreach ($call_cookie as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
}
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
|
||||
// get access token
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $latest_cookie,
|
||||
];
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login', [\GuzzleHttp\RequestOptions::JSON => [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
]]);
|
||||
|
||||
$token = json_decode($res->getBody()->getContents());
|
||||
$token = $token->d->AccessToken;
|
||||
|
||||
$latest_cookie = $latest_cookie . ';AppVTCC=' . $token;
|
||||
return $latest_cookie;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersStatusUpdateFromVTPortalProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchContainersStatusUpdateFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchContainersStatusUpdateFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryListFromVTPortalProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchDeliveryListFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
(App()->make(FetchDeliveryListFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchLoadedContainersFromVTPortalProcessor;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchLoadedContainersFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchLoadedContainersFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListFromVTPortalProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchPackingListFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 1800;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchPackingListFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchWarehouseReceiveListFromVTPortalProcessor;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchWarehouseReceiveListFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchWarehouseReceiveListFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
$this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
}
|
||||
|
||||
@@ -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,52 @@
|
||||
<?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');
|
||||
|
||||
}
|
||||
|
||||
public function cleanAddress($address, $district, $postcode){
|
||||
$address = str_replace('Malaysia', '', str_replace('malaysia', '', str_replace('MALAYSIA', '', $address)));
|
||||
$address = str_replace($district->state->name, '',str_replace($district->name, '', $address));
|
||||
$address = str_replace(strtolower($district->state->name), '',str_replace(strtolower($district->name), '', $address));
|
||||
$address = str_replace(strtoupper($district->state->name), '',str_replace(strtoupper($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(rtrim($address, '.')), ','));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,10 +53,6 @@ class ListCompaniesLogic extends AbstractControllerLogic
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
logger("llogic");
|
||||
|
||||
logger($request->input('filters'));
|
||||
|
||||
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
||||
return $this->collectionResponse(CompanyResource::collection($query));
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class ListOrdersLogic extends AbstractControllerLogic
|
||||
{
|
||||
$this->canListOrders->passes();
|
||||
|
||||
$query = $this->listsOrders->execute($this->listsOrders->deserializeFilters($request->input('filters')));
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true]));
|
||||
|
||||
return $this->collectionResponse(OrderResource::collection($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,94 @@
|
||||
<?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->requestAsync($method, $url, [\GuzzleHttp\RequestOptions::JSON => $body, 'timeout' => 1200]);
|
||||
|
||||
return $request->wait();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
<?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;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
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(){
|
||||
|
||||
try {
|
||||
$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();
|
||||
$schedule = $transport->schedules()->where('eta', '=', $delayDate)->first();
|
||||
$etd = $delayDate->subDays(5);
|
||||
if(!$schedule){
|
||||
$etd = $schedule->etd;
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
}
|
||||
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
if($containerStatus === 'Unstuffing'){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => Carbon::parse($unstuffingDate)->subDay(), 'status' => ApprovalStatus::COMPLETED]);
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
<?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;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
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
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
try {
|
||||
$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] && !$shippingPackingList[10]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$deliveryDate = Carbon::parse($shippingPackingList[9] ? $shippingPackingList[9]:$shippingPackingList[10]);
|
||||
$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', '=', 'LAST_MILE_DELIVERY')->first();
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
<?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;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
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
|
||||
*/
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null){
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$start = $start ? $start : Carbon::now()->subMonth();
|
||||
|
||||
$startLimit = Carbon::parse('11-08-2021');
|
||||
|
||||
if($start->isBefore($startLimit)){
|
||||
$start = $startLimit;
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?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;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
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 {
|
||||
DB::beginTransaction();
|
||||
|
||||
$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[19], $shippingPackingList[31], $shippingPackingList[30], $shippingPackingList[29], 0, $shippingPackingList[22], ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+173
-218
@@ -2,275 +2,230 @@
|
||||
|
||||
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;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
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();
|
||||
|
||||
foreach($companies as $company){
|
||||
try {
|
||||
|
||||
$marking = explode("CIEF/", $company->marking);
|
||||
if(count($marking) < 2){
|
||||
continue;
|
||||
$start = $start ? $start : Carbon::now()->subMonth();
|
||||
|
||||
$startLimit = Carbon::parse('11-08-2021');
|
||||
|
||||
if($start->isBefore($startLimit)){
|
||||
$start = $startLimit;
|
||||
}
|
||||
|
||||
/** @var Company $newCompany */
|
||||
$newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION);
|
||||
$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"]';
|
||||
|
||||
$this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED);
|
||||
$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.'}}'), '');
|
||||
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER);
|
||||
$response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking[1]);
|
||||
foreach ($response->Rows as $parcel){
|
||||
$marking = explode('/', explode('CIEF/', $parcel[5])[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;
|
||||
|
||||
|
||||
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],
|
||||
]
|
||||
];
|
||||
|
||||
if(!$parcel[9]){
|
||||
continue;
|
||||
}
|
||||
//
|
||||
|
||||
if(!array_key_exists($orderNumber, $orders[$customerMarking])){
|
||||
$orders[$customerMarking][$orderNumber]['ctn'] = 0;
|
||||
$orders[$customerMarking][$orderNumber]['cbm'] = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
$orders[$customerMarking][$orderNumber]['ctn'] += $ctn;
|
||||
$orders[$customerMarking][$orderNumber]['cbm'] += $parcel[10];
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
// $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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @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'];
|
||||
return [];
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception->getMessage());
|
||||
}
|
||||
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
DB::commit();
|
||||
|
||||
|
||||
/** @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();
|
||||
}
|
||||
}
|
||||
|
||||
$client = new \GuzzleHttp\Client(
|
||||
[
|
||||
'cookies' => true,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => Cache::has('VT_COOKIE_CACHE') ? Cache::get('VT_COOKIE_CACHE'):$cookie
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$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,
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
+10
-1
@@ -2,6 +2,11 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Classes\Jobs\FetchContainersStatusUpdateFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchDeliveryListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchLoadedContainersFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchPackingListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -24,7 +29,11 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
$schedule->job(FetchWarehouseReceiveListFromVTPortalJob::class)->dailyAt('21:00');
|
||||
$schedule->job(FetchLoadedContainersFromVTPortalJob::class)->dailyAt('21:15');
|
||||
$schedule->job(FetchPackingListFromVTPortalJob::class)->dailyAt('21:30');
|
||||
$schedule->job(FetchContainersStatusUpdateFromVTPortalJob::class)->dailyAt('21:45');
|
||||
$schedule->job(FetchDeliveryListFromVTPortalJob::class)->dailyAt('22:00');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@ class ContactResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
//'country_code' => $this->country->phone_code,
|
||||
// 'country_code' => $this->country->phone_code,
|
||||
'reference' => $this->reference,
|
||||
'phone' => $this->phone,
|
||||
'email' => $this->email,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -2,12 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class OldAddress extends Model
|
||||
{
|
||||
|
||||
@@ -2,21 +2,9 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceConfigurationsObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
class OldCompany extends Model
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class OldOrders extends Model
|
||||
{
|
||||
@@ -15,4 +12,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
|
||||
*/
|
||||
|
||||
+5
-5
@@ -65,12 +65,12 @@ return [
|
||||
|
||||
'old_izyim_db' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DATABASE_URL_IZYIM'),
|
||||
'host' => env('DB_HOST_IZYIM', '127.0.0.1'),
|
||||
'port' => env('DB_PORT_IZYIM', '3306'),
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE_IZYIM', 'forge'),
|
||||
'username' => env('DB_USERNAME_IZYIM', 'forge'),
|
||||
'password' => env('DB_PASSWORD_IZYIM', ''),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET_IZYIM', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ return [
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'retry_after' => 3600,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
|
||||
+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);
|
||||
|
||||
@@ -20,7 +20,7 @@ class CreatePackagesTable extends Migration
|
||||
$table->integer('type')->default(0);
|
||||
$table->string('reference')->nullable();
|
||||
|
||||
$table->string('description',45)->nullable();
|
||||
$table->string('description')->nullable();
|
||||
|
||||
$table->decimal('width', 8, 2);
|
||||
$table->decimal('height', 8, 2);
|
||||
|
||||
@@ -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,7 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Processors\CreateAddressFromOldAddressProcessor;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
@@ -20,12 +21,10 @@ use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\District;
|
||||
use App\Models\OldCompany;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
use App\Models\Company;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class CompaniesTableSeeder extends Seeder
|
||||
{
|
||||
@@ -48,6 +47,9 @@ class CompaniesTableSeeder extends Seeder
|
||||
/** @var ApprovesCompanyConnection */
|
||||
private $approvesCompanyConnection;
|
||||
|
||||
/** @var CreateAddressFromOldAddressProcessor */
|
||||
private $createAddressFromOldAddressProcessor;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
@@ -65,11 +67,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 +80,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 +172,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 +194,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 +213,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));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,5 +24,6 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call(CurrenciesTableSeeder::class);
|
||||
|
||||
$this->call(CompaniesTableSeeder::class);
|
||||
$this->call(OrdersTableSeeder::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Classes\Jobs\FetchContainersStatusUpdateFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchDeliveryListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchLoadedContainersFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchPackingListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersStatusUpdateFromVTPortalProcessor;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OrdersTableSeeder extends Seeder
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
FetchWarehouseReceiveListFromVTPortalJob::withChain([
|
||||
new FetchLoadedContainersFromVTPortalJob,
|
||||
new FetchPackingListFromVTPortalJob,
|
||||
new FetchContainersStatusUpdateFromVTPortalJob,
|
||||
new FetchDeliveryListFromVTPortalJob
|
||||
])->dispatch();
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user