diff --git a/app/Classes/Modules/ControllersLogic/FreightForwarder/DeleteServiceFeesLogic.php b/app/Classes/Modules/ControllersLogic/FreightForwarder/DeleteServiceFeesLogic.php new file mode 100644 index 0000000..21a4c2b --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/FreightForwarder/DeleteServiceFeesLogic.php @@ -0,0 +1,36 @@ +deletesServiceFees = $deletesServiceFees; + } + + public function execute(String $serviceId){ + + try{ + return $this->deletesServiceFees->execute($serviceId); + return new JsonResponse([],HttpStatus::REQUEST_ACCEPTED); + + }catch(\Exception $exception){ + + throw new InternalServerErrorException("Failed to delete Customer Relation because{$exception->getMessage()}"); + } + } +} \ No newline at end of file diff --git a/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateCustomerRelationLogic.php b/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateCustomerRelationLogic.php new file mode 100644 index 0000000..c2d417a --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateCustomerRelationLogic.php @@ -0,0 +1,38 @@ +updatesCustomerRelation = $updatesCustomerRelation; + } + + public function execute(Request $request){ + + try{ + + $object = new CustomerRelationObject($request->input('forwarder_id'), $request->input('company_id'), $request->input('customer_rate'), $request->input('wave')); + return $this->updatesCustomerRelation->execute($object); + return new JsonResponse([], HttpStatus::REQUEST_ACCEPTED); + + }catch(\Exception $exception){ + throw new InternalServerErrorException("Failed to update Customer Relation because{$exception->getMessage()}"); + } + } +} \ No newline at end of file diff --git a/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateFreightForwarderLogic.php b/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateFreightForwarderLogic.php new file mode 100644 index 0000000..2df4f86 --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateFreightForwarderLogic.php @@ -0,0 +1,39 @@ +updatesFreightForwarder = $updatesFreightForwarder; + } + + + public function execute(String $forwarderId, Request $request){ + + try{ + $object = new FreightForwarderObject(null, null, null, null, null, null,null, null, $request->input('shipping_rate'), $request->input('overdue_days'), $request->input('markup_percentage')); + return $this->updatesFreightForwarder->execute($forwarderId, $object); + return new JsonResponse([],HttpStatus::REQUEST_ACCEPTED); + + }catch(\Exception $exception){ + + throw new InternalServerErrorException("Failed to update Freight Forwarder because{$exception->getMessage()}"); + } + } +} \ No newline at end of file diff --git a/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateServiceFeesLogic.php b/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateServiceFeesLogic.php new file mode 100644 index 0000000..08d9bd9 --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/FreightForwarder/UpdateServiceFeesLogic.php @@ -0,0 +1,45 @@ +updatesServiceFees = $updatesServiceFees; + } + + + public function execute(Request $request){ + try{ + $object = new ServiceObject($request->input('type'), $request->input('forwarder_id'), $request->input('name'), $request->input('description'), $request->input('cost')); + return $this->updatesServiceFees->execute($request->input('id'), $object); + return new JsonResponse([],HttpStatus::REQUEST_ACCEPTED); + + }catch (\Exception $exception){ + throw new InternalServerErrorException("Failed to update Service Fees because{$exception->getMessage()}"); + } + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/FreightForwarder/DataTransferObjects/CustomerRelationObject.php b/app/Classes/Modules/FreightForwarder/DataTransferObjects/CustomerRelationObject.php new file mode 100644 index 0000000..1e33e59 --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/DataTransferObjects/CustomerRelationObject.php @@ -0,0 +1,70 @@ +forwarderId = $forwarderId; + $this->companyId = $companyId; + $this->customer_rate = $customer_rate; + $this->wave = $wave; + } + + /** + * @return int|null + */ + public function getForwarderId(): ?int + { + return $this->forwarderId; + } + + /** + * @return int|null + */ + public function getCompanyId(): ?int + { + return $this->companyId; + } + + /** + * @return float|null + */ + public function getCustomerRate(): ?float + { + return $this->customer_rate; + } + + /** + * @return float|null + */ + public function getWave(): ?float + { + return $this->wave; + } + + + + +} \ No newline at end of file diff --git a/app/Classes/Modules/FreightForwarder/DataTransferObjects/FreightForwarderObject.php b/app/Classes/Modules/FreightForwarder/DataTransferObjects/FreightForwarderObject.php new file mode 100644 index 0000000..0c7b6b5 --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/DataTransferObjects/FreightForwarderObject.php @@ -0,0 +1,157 @@ +name = $name; + $this->email = $email; + $this->street_one = $street_one; + $this->street_two = $street_two; + $this->city = $city; + $this->state = $state; + $this->post_code = $post_code; + $this->country = $country; + $this->shipping_rate = $shipping_rate; + $this->overdue_days = $overdue_days; + $this->markup_percentage = $markup_percentage; + } + + /** + * @return null|string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @return null|string + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @return null|string + */ + public function getStreetOne(): ?string + { + return $this->street_one; + } + + /** + * @return null|string + */ + public function getStreetTwo(): ?string + { + return $this->street_two; + } + + /** + * @return null|string + */ + public function getCity(): ?string + { + return $this->city; + } + + /** + * @return null|string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @return null|string + */ + public function getPostCode(): ?string + { + return $this->post_code; + } + + /** + * @return null|string + */ + public function getCountry(): ?string + { + return $this->country; + } + + /** + * @return float|null + */ + public function getShippingRate(): ?float + { + return $this->shipping_rate; + } + + /** + * @return int|null + */ + public function getOverdueDays(): ?int + { + return $this->overdue_days; + } + + /** + * @return float|null + */ + public function getMarkupPercentage(): ?float + { + return $this->markup_percentage; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/FreightForwarder/DataTransferObjects/ServiceObject.php b/app/Classes/Modules/FreightForwarder/DataTransferObjects/ServiceObject.php new file mode 100644 index 0000000..58e0217 --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/DataTransferObjects/ServiceObject.php @@ -0,0 +1,86 @@ +type = $type; + $this->forwarderId = $forwarderId; + $this->name = $name; + $this->description = $description; + $this->cost = $cost; + } + + /** + * @return null|String + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @return int|null + */ + public function getForwarderId(): ?int + { + return $this->forwarderId; + } + + /** + * @return null|String + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @return null|String + */ + public function getDescription(): ?string + { + return $this->description; + } + + /** + * @return float|null + */ + public function getCost(): ?float + { + return $this->cost; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/FreightForwarder/Services/DeletesServiceFees.php b/app/Classes/Modules/FreightForwarder/Services/DeletesServiceFees.php new file mode 100644 index 0000000..b65c40f --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/Services/DeletesServiceFees.php @@ -0,0 +1,33 @@ +repository = $repository; + } + + public function execute(String $serviceId){ + try{ + + $repository = $this->repository->findOrFail($serviceId); + $repository->delete(); + + }catch(\Exception $exception){ + throw new InternalServerErrorException("Failed to delete Customer Relation because{$exception->getMessage()}"); + } + } +} \ No newline at end of file diff --git a/app/Classes/Modules/FreightForwarder/Services/UpdatesCustomerRelation.php b/app/Classes/Modules/FreightForwarder/Services/UpdatesCustomerRelation.php new file mode 100644 index 0000000..5de1e5b --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/Services/UpdatesCustomerRelation.php @@ -0,0 +1,45 @@ +repository = $repository; + } + + public function execute(CustomerRelationObject $customerRelationObject){ + + try{ + $this->repository->updateOrCreate( + [ + 'forwarder_id' => $customerRelationObject->getForwarderId(), + 'company_id' => $customerRelationObject->getCompanyId(), + ], + [ + 'customer_rate' => $customerRelationObject->getCustomerRate(), + 'wave' => $customerRelationObject->getWave(), + ]); + + return new JsonResponse([],HttpStatus::OK); + + }catch(\Exception $exception){ + throw new InternalServerErrorException("Failed to update Customer Relation because {$exception->getMessage()}"); + } + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/FreightForwarder/Services/UpdatesFreightForwarder.php b/app/Classes/Modules/FreightForwarder/Services/UpdatesFreightForwarder.php new file mode 100644 index 0000000..29296b9 --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/Services/UpdatesFreightForwarder.php @@ -0,0 +1,41 @@ +repository = $repository; + } + + + public function execute(String $forwarderId, FreightForwarderObject $forwarderObject){ + + try{ + $repository = $this->repository->findOrFail($forwarderId); + $repository->shipping_rate = $forwarderObject->getShippingRate(); + $repository->overdue_days = $forwarderObject->getOverdueDays(); + $repository->markup_percentage = $forwarderObject->getMarkupPercentage(); + $repository->save(); + return new JsonResponse([],HttpStatus::OK); + + }catch(\Exception $exception){ + throw new InternalServerErrorException("Failed to update Freight Forwarder because {$exception->getMessage()}"); + } + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/FreightForwarder/Services/UpdatesServiceFees.php b/app/Classes/Modules/FreightForwarder/Services/UpdatesServiceFees.php new file mode 100644 index 0000000..976b1b9 --- /dev/null +++ b/app/Classes/Modules/FreightForwarder/Services/UpdatesServiceFees.php @@ -0,0 +1,54 @@ +repository = $repository; + } + + + public function execute(String $serviceId, ServiceObject $serviceObject){ + try{ + $this->repository->updateOrCreate( + [ + 'id' => $serviceId, + ], + [ + 'name' => $serviceObject->getName(), + 'type' => $serviceObject->getType(), + 'description' => $serviceObject->getDescription(), + 'cost' => $serviceObject->getCost(), + 'forwarder_id' => $serviceObject->getForwarderId(), + ]); + + return new JsonResponse([],HttpStatus::OK); + + }catch(\Exception $exception){ + + throw new InternalServerErrorException("Failed to update Service Fees because {$exception->getMessage()}"); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/FreightForwarder/DeleteServiceFeesController.php b/app/Http/Controllers/FreightForwarder/DeleteServiceFeesController.php new file mode 100644 index 0000000..6584407 --- /dev/null +++ b/app/Http/Controllers/FreightForwarder/DeleteServiceFeesController.php @@ -0,0 +1,13 @@ +execute($serviceId); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/FreightForwarder/UpdateCustomerRelationController.php b/app/Http/Controllers/FreightForwarder/UpdateCustomerRelationController.php new file mode 100644 index 0000000..40426fe --- /dev/null +++ b/app/Http/Controllers/FreightForwarder/UpdateCustomerRelationController.php @@ -0,0 +1,13 @@ +execute($request); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/FreightForwarder/UpdateFreightForwarderController.php b/app/Http/Controllers/FreightForwarder/UpdateFreightForwarderController.php new file mode 100644 index 0000000..78511e1 --- /dev/null +++ b/app/Http/Controllers/FreightForwarder/UpdateFreightForwarderController.php @@ -0,0 +1,14 @@ +execute($forwarderId, $request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/FreightForwarder/UpdateServiceFeesController.php b/app/Http/Controllers/FreightForwarder/UpdateServiceFeesController.php new file mode 100644 index 0000000..9bc6940 --- /dev/null +++ b/app/Http/Controllers/FreightForwarder/UpdateServiceFeesController.php @@ -0,0 +1,21 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Models/CustomerRelation.php b/app/Models/CustomerRelation.php index 6a13371..0365401 100644 --- a/app/Models/CustomerRelation.php +++ b/app/Models/CustomerRelation.php @@ -7,7 +7,7 @@ class CustomerRelation extends AbstractModel protected $table = 'customer_relation'; protected $fillable = [ - 'forwarder_id', 'company_id', 'customer_rate' + 'forwarder_id', 'company_id', 'customer_rate', 'wave' ]; public function forwarder() diff --git a/app/Models/Forwarder.php b/app/Models/Forwarder.php index 922e80c..d168034 100644 --- a/app/Models/Forwarder.php +++ b/app/Models/Forwarder.php @@ -7,7 +7,7 @@ class Forwarder extends AbstractModel protected $table = 'forwarder'; protected $fillable = [ - 'name', 'email', 'street_one', 'street_two', 'city', 'state', 'post_code', 'country', 'shipping_rate' + 'name', 'email', 'street_one', 'street_two', 'city', 'state', 'post_code', 'country', 'shipping_rate','overdue_days','markup_percentage' ]; public function customerRelation() diff --git a/database/migrations/2019_07_12_155143_create_customer_relation_table.php b/database/migrations/2019_07_12_155143_create_customer_relation_table.php index 09e21a3..aa258c2 100644 --- a/database/migrations/2019_07_12_155143_create_customer_relation_table.php +++ b/database/migrations/2019_07_12_155143_create_customer_relation_table.php @@ -17,7 +17,7 @@ class CreateCustomerRelationTable extends Migration $table->increments('id'); $table->integer('forwarder_id')->unsigned()->nullable(); $table->integer('company_id')->unsigned()->nullable(); - $table->string('customer_rate')->nullable(); + $table->float('customer_rate')->nullable(); $table->float('wave')->nullable(); $table->timestamps(); }); diff --git a/routes/api.php b/routes/api.php index bbb7047..d987c9d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -160,4 +160,15 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function Route::get('/order/status', 'OrdersStatusReportController@index')->name('order.status'); }); + // Freight Forwarder Routes + Route::group(['prefix' => 'forwarder', 'as' => 'forwarder.', 'namespace' => 'FreightForwarder'], function () { + + // Update Freight Forwarder Settings + Route::put('/{forwarderId}/update', 'UpdateFreightForwarderController@update')->name('update.freight.forwarder'); + Route::put('/update/customer-relation', 'UpdateCustomerRelationController@update')->name('update.customer.relation'); + Route::put('/update/services', 'UpdateServiceFeesController@update')->name('update.service.fees'); + Route::delete('/{serviceId}/delete/services', 'DeleteServiceFeesController@delete')->name('delete.service.fees'); + + }); + }); \ No newline at end of file