diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerLogic.php index cff8cbb6..40376b12 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerLogic.php @@ -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)); - } } diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/UpdateContainerLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/UpdateContainerLogic.php index 3d1516f0..72537db2 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/UpdateContainerLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/UpdateContainerLogic.php @@ -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); diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Packages/CreatePackageLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Packages/CreatePackageLogic.php index 28e43d02..80a5ee5d 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/Packages/CreatePackageLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Packages/CreatePackageLogic.php @@ -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( diff --git a/app/Classes/Modules/PackingLists/DataTransferObjects/ContainerObject.php b/app/Classes/Modules/PackingLists/DataTransferObjects/ContainerObject.php index 92b0effa..3924102c 100644 --- a/app/Classes/Modules/PackingLists/DataTransferObjects/ContainerObject.php +++ b/app/Classes/Modules/PackingLists/DataTransferObjects/ContainerObject.php @@ -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; } /** diff --git a/app/Classes/Modules/PackingLists/Services/Containers/CreatesContainer.php b/app/Classes/Modules/PackingLists/Services/Containers/CreatesContainer.php index d8d733b2..eb8ff4e0 100644 --- a/app/Classes/Modules/PackingLists/Services/Containers/CreatesContainer.php +++ b/app/Classes/Modules/PackingLists/Services/Containers/CreatesContainer.php @@ -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); diff --git a/app/Classes/Modules/PackingLists/Services/Containers/UpdatesContainer.php b/app/Classes/Modules/PackingLists/Services/Containers/UpdatesContainer.php index c3f6f1a4..d10102e1 100644 --- a/app/Classes/Modules/PackingLists/Services/Containers/UpdatesContainer.php +++ b/app/Classes/Modules/PackingLists/Services/Containers/UpdatesContainer.php @@ -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(); diff --git a/app/Classes/Modules/Schedules/ControllersLogic/CreateScheduleLogic.php b/app/Classes/Modules/Schedules/ControllersLogic/CreateScheduleLogic.php index 5bf9c7e9..aecff745 100644 --- a/app/Classes/Modules/Schedules/ControllersLogic/CreateScheduleLogic.php +++ b/app/Classes/Modules/Schedules/ControllersLogic/CreateScheduleLogic.php @@ -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); diff --git a/app/Classes/Modules/Schedules/Standards/Validators/ScheduleValidation.php b/app/Classes/Modules/Schedules/Standards/Validators/ScheduleValidation.php index 7d14a3f1..485dc833 100644 --- a/app/Classes/Modules/Schedules/Standards/Validators/ScheduleValidation.php +++ b/app/Classes/Modules/Schedules/Standards/Validators/ScheduleValidation.php @@ -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', ]; diff --git a/app/Classes/Modules/Transports/ControllersLogic/CreateTransportLogic.php b/app/Classes/Modules/Transports/ControllersLogic/CreateTransportLogic.php index af438830..edd5690f 100644 --- a/app/Classes/Modules/Transports/ControllersLogic/CreateTransportLogic.php +++ b/app/Classes/Modules/Transports/ControllersLogic/CreateTransportLogic.php @@ -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)); diff --git a/app/Classes/Modules/Transports/ControllersLogic/UpdateTransportLogic.php b/app/Classes/Modules/Transports/ControllersLogic/UpdateTransportLogic.php index cab03419..6f6cfd4c 100644 --- a/app/Classes/Modules/Transports/ControllersLogic/UpdateTransportLogic.php +++ b/app/Classes/Modules/Transports/ControllersLogic/UpdateTransportLogic.php @@ -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); diff --git a/database/seeders/CompaniesTableSeeder.php b/database/seeders/CompaniesTableSeeder.php index 01bb3801..c2ffdeb4 100644 --- a/database/seeders/CompaniesTableSeeder.php +++ b/database/seeders/CompaniesTableSeeder.php @@ -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); + // } + // } - } - } - } + // } + // } + // } }