mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Merge branch 'debug_api' into 'master'
Debug api See merge request CIEFWorldwideSdnBhd/shipping-portal!49
This commit is contained in:
+16
-4
@@ -4,10 +4,12 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainer;
|
||||
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;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -32,13 +34,17 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsContainer;
|
||||
|
||||
public function __construct(CanCreateContainer $canCreateContainer, FetchesPackingList $fetchesPackingList, CreatesContainer $createsContainer)
|
||||
public function __construct(CanCreateContainer $canCreateContainer, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreatesContainer $createsContainer)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsContainer = $createsContainer;
|
||||
}
|
||||
|
||||
@@ -51,15 +57,21 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
$request->input('status')
|
||||
);
|
||||
|
||||
$object = new ContainerObject($request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
$company = $this->fetchesCompanyModule->execute(['id' => 2]);
|
||||
|
||||
$this->canCreateContainer->passes($object);
|
||||
|
||||
$query = $this->createsContainer->execute($object);
|
||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-2
@@ -58,8 +58,14 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new ContainerObject( $container->packing_list_id , $request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
$request->input('seal_reference'),
|
||||
$container->status,
|
||||
);
|
||||
|
||||
$this->canUpdateContainer->passes($object);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class CreatePackageLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->input('order_id')]);
|
||||
|
||||
$object = new PackageObject(
|
||||
|
||||
@@ -14,7 +14,7 @@ class ContainerObject implements DataTransferObject
|
||||
private $containerNumber;
|
||||
|
||||
/** @var string */
|
||||
private $sealNumber;
|
||||
private $sealReference;
|
||||
|
||||
/** @var int */
|
||||
private $containerType;
|
||||
@@ -26,15 +26,15 @@ class ContainerObject implements DataTransferObject
|
||||
* ContainerObject constructor.
|
||||
* @param string $reference
|
||||
* @param string $containerNumber
|
||||
* @param string $sealNumber
|
||||
* @param string $sealReference
|
||||
* @param int $containerType
|
||||
* @param int $status
|
||||
*/
|
||||
public function __construct(string $reference, string $containerNumber, string $sealNumber, int $containerType, int $status)
|
||||
public function __construct(string $reference, string $containerNumber, string $sealReference, int $containerType, int $status)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
$this->containerNumber = $containerNumber;
|
||||
$this->sealNumber = $sealNumber;
|
||||
$this->sealReference = $sealReference;
|
||||
$this->containerType = $containerType;
|
||||
$this->status = $status;
|
||||
}
|
||||
@@ -58,9 +58,9 @@ class ContainerObject implements DataTransferObject
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSealNumber(): string
|
||||
public function getSealReference(): string
|
||||
{
|
||||
return $this->sealNumber;
|
||||
return $this->sealReference;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ class CreatesContainer extends AbstractUpdateRelationshipRecord
|
||||
$model->reference = $object->getReference();
|
||||
$model->container_number = $object->getContainerNumber();
|
||||
$model->container_type = $object->getContainerType();
|
||||
$model->seal_reference = $object->getSealNumber();
|
||||
$model->seal_reference = $object->getSealReference();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($owner->containers(), $model);
|
||||
|
||||
@@ -17,7 +17,7 @@ class UpdatesContainer extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Container $model, ContainerObject $object) {
|
||||
|
||||
$model->container_reference = $object->getContainerReference();
|
||||
$model->reference = $object->getReference();
|
||||
$model->container_type = $object->getContainerType();
|
||||
$model->seal_reference = $object->getSealReference();
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class CreateScheduleLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new ScheduleObject($request->input('etd'), $request->input('eta'), $request->input('transport_id'), ApprovalStatus::PENDING_SUBMISSION);
|
||||
$object = new ScheduleObject($request->input('etd'), $request->input('eta'), ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
$this->canCreateSchedule->passes($object);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ class ScheduleValidation extends AbstractValidation
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'transport_id' => $object->getTransportId(),
|
||||
'etd' => $object->getETD(),
|
||||
'eta' => $object->getETA(),
|
||||
'status' => $object->getStatus(),
|
||||
@@ -28,7 +27,6 @@ class ScheduleValidation extends AbstractValidation
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'transport_id' => 'required',
|
||||
'etd' => 'required',
|
||||
'eta' => 'required',
|
||||
];
|
||||
|
||||
@@ -7,7 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Transports\Standards\Rules\CanCreateTransport;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\TransportResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -29,8 +29,8 @@ class CreateTransportLogic extends AbstractControllerLogic
|
||||
/** @var CanCreateTransport */
|
||||
private $canCreateTransport;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
@@ -38,13 +38,13 @@ class CreateTransportLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* CreateTransportLogic constructor.
|
||||
* @param CanCreateTransport $canCreateTransport
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param CreatesTransport $createsTransport
|
||||
*/
|
||||
public function __construct(CanCreateTransport $canCreateTransport, FetchesContainer $fetchesContainer, CreatesTransport $createsTransport)
|
||||
public function __construct(CanCreateTransport $canCreateTransport, FetchesPackingList $fetchesPackingList, CreatesTransport $createsTransport)
|
||||
{
|
||||
$this->canCreateTransport = $canCreateTransport;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->createsTransport = $createsTransport;
|
||||
}
|
||||
|
||||
@@ -58,11 +58,18 @@ class CreateTransportLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$object = new TransportObject($request->input('type'), $request->input('courier'), $request->input('tracking_number'), null, null, ApprovalStatus::PENDING_SUBMISSION);
|
||||
$object = new TransportObject(
|
||||
$request->input('type'),
|
||||
$request->input('courier'),
|
||||
$request->input('tracking_number'),
|
||||
null,
|
||||
null,
|
||||
pprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
$this->canCreateTransport->passes($object);
|
||||
|
||||
$query = $this->createsTransport->execute($this->fetchesContainer->execute(['id' => $request->input('container_id')]), $object);
|
||||
$query = $this->createsTransport->execute($object, $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]));
|
||||
|
||||
return $this->resourceResponse(new TransportResource($query));
|
||||
|
||||
|
||||
@@ -58,7 +58,14 @@ class UpdateTransportLogic extends AbstractControllerLogic
|
||||
{
|
||||
$query = $this->fetchesTransport->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new TransportObject($request->input('type'), $request->input('courier'), $request->input('tracking_number'), $request->input('dispatch_date'), $request->input('drop_date'), $request->input('status'));
|
||||
$object = new TransportObject(
|
||||
$request->input('type'),
|
||||
$request->input('courier'),
|
||||
$request->input('tracking_number'),
|
||||
$request->input('dispatch_date'),
|
||||
$request->input('drop_date'),
|
||||
$request->input('status')
|
||||
);
|
||||
|
||||
$this->canUpdateTransport->passes($object);
|
||||
|
||||
|
||||
@@ -172,49 +172,49 @@ class CompaniesTableSeeder extends Seeder
|
||||
|
||||
}
|
||||
|
||||
if(true){
|
||||
$companies = OldCompany::all();
|
||||
// if(true){
|
||||
// $companies = OldCompany::all();
|
||||
|
||||
foreach($companies as $company){
|
||||
// foreach($companies as $company){
|
||||
|
||||
$marking = explode("CIEF/", $company->marking);
|
||||
// $marking = explode("CIEF/", $company->marking);
|
||||
|
||||
if(count($marking) < 2){
|
||||
continue;
|
||||
}
|
||||
// if(count($marking) < 2){
|
||||
// continue;
|
||||
// }
|
||||
|
||||
$marking = str_replace(' ', '', str_replace('/', '', $marking[1]));
|
||||
// $marking = str_replace(' ', '', str_replace('/', '', $marking[1]));
|
||||
|
||||
|
||||
/** @var Company $newCompany */
|
||||
$newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION);
|
||||
// /** @var Company $newCompany */
|
||||
// $newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
$this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED);
|
||||
// $this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED);
|
||||
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER);
|
||||
// /** @var CompanyModule $companyModule */
|
||||
// $companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking);
|
||||
// $connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking);
|
||||
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
// $connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
// $this->approvesCompanyConnection->execute($connection);
|
||||
|
||||
$i = 0;
|
||||
foreach($company->addresses as $address){
|
||||
$this->createAddressFromOldAddressProcessor->execute($address, $companyModule);
|
||||
$contact = preg_replace("/[^0-9.]/", "", $address->contact);
|
||||
if($contact){
|
||||
$i++;
|
||||
if($i === 1) {
|
||||
$contactObject = new ContactObject('', $contact, $company->email, '',);
|
||||
$this->createContactProcessor->execute($contactObject, $newCompany);
|
||||
}
|
||||
}
|
||||
// $i = 0;
|
||||
// foreach($company->addresses as $address){
|
||||
// $this->createAddressFromOldAddressProcessor->execute($address, $companyModule);
|
||||
// $contact = preg_replace("/[^0-9.]/", "", $address->contact);
|
||||
// if($contact){
|
||||
// $i++;
|
||||
// if($i === 1) {
|
||||
// $contactObject = new ContactObject('', $contact, $company->email, '',);
|
||||
// $this->createContactProcessor->execute($contactObject, $newCompany);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user