mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 04:24:00 +00:00
Merge branch 'invoice-backend' into 'master'
Invoice backend See merge request CIEFWorldwideSdnBhd/izyim!36
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ControllersLogic\FreightForwarder;
|
||||
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\FreightForwarder\Services\DeletesServiceFees;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class DeleteServiceFeesLogic
|
||||
{
|
||||
/** @var DeletesServiceFees */
|
||||
private $deletesServiceFees;
|
||||
|
||||
/**
|
||||
* DeleteServiceFeesLogic constructor.
|
||||
* @param DeletesServiceFees $deletesServiceFees
|
||||
*/
|
||||
public function __construct(DeletesServiceFees $deletesServiceFees)
|
||||
{
|
||||
$this->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()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ControllersLogic\FreightForwarder;
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\FreightForwarder\DataTransferObjects\CustomerRelationObject;
|
||||
use App\Classes\Modules\FreightForwarder\Services\UpdatesCustomerRelation;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCustomerRelationLogic
|
||||
{
|
||||
/** @var UpdatesCustomerRelation */
|
||||
private $updatesCustomerRelation;
|
||||
|
||||
/**
|
||||
* UpdateCustomerRelationLogic constructor.
|
||||
* @param UpdatesCustomerRelation $updatesCustomerRelation
|
||||
*/
|
||||
public function __construct(UpdatesCustomerRelation $updatesCustomerRelation)
|
||||
{
|
||||
$this->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()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ControllersLogic\FreightForwarder;
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\FreightForwarder\DataTransferObjects\FreightForwarderObject;
|
||||
use App\Classes\Modules\FreightForwarder\Services\UpdatesFreightForwarder;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateFreightForwarderLogic
|
||||
{
|
||||
/** @var UpdatesFreightForwarder */
|
||||
private $updatesFreightForwarder;
|
||||
|
||||
/**
|
||||
* UpdateFreightForwarderLogic constructor.
|
||||
* @param UpdatesFreightForwarder $updatesFreightForwarder
|
||||
*/
|
||||
public function __construct(UpdatesFreightForwarder $updatesFreightForwarder)
|
||||
{
|
||||
$this->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'), $request->input('minimum_cbm'));
|
||||
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()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: mhmj
|
||||
* Date: 18/07/2019
|
||||
* Time: 4:45 PM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\ControllersLogic\FreightForwarder;
|
||||
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\FreightForwarder\DataTransferObjects\ServiceObject;
|
||||
use App\Classes\Modules\FreightForwarder\Services\UpdatesServiceFees;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateServiceFeesLogic
|
||||
{
|
||||
/** @var UpdatesServiceFees */
|
||||
private $updatesServiceFees;
|
||||
|
||||
/**
|
||||
* UpdateServiceFeesLogic constructor.
|
||||
* @param UpdatesServiceFees $updatesServiceFees
|
||||
*/
|
||||
public function __construct(UpdatesServiceFees $updatesServiceFees)
|
||||
{
|
||||
$this->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()}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\FreightForwarder\DataTransferObjects;
|
||||
|
||||
|
||||
class CustomerRelationObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $forwarderId;
|
||||
|
||||
/** @var int|null */
|
||||
private $companyId;
|
||||
|
||||
/** @var float|null */
|
||||
private $customer_rate;
|
||||
|
||||
/** @var boolean|null */
|
||||
private $wave;
|
||||
|
||||
/**
|
||||
* CustomerRelationObject constructor.
|
||||
* @param int|null $forwarderId
|
||||
* @param int|null $companyId
|
||||
* @param float|null $customer_rate
|
||||
* @param bool|null $wave
|
||||
*/
|
||||
public function __construct(?int $forwarderId = null, ?int $companyId = null, ?float $customer_rate = null, ?bool $wave = null)
|
||||
{
|
||||
$this->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 bool|null
|
||||
*/
|
||||
public function getWave(): ?bool
|
||||
{
|
||||
return $this->wave;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\FreightForwarder\DataTransferObjects;
|
||||
|
||||
class FreightForwarderObject
|
||||
{
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/** @var string|null */
|
||||
private $email;
|
||||
|
||||
/** @var string|null */
|
||||
private $street_one;
|
||||
|
||||
/** @var string|null */
|
||||
private $street_two;
|
||||
|
||||
/** @var string|null */
|
||||
private $city;
|
||||
|
||||
/** @var string|null */
|
||||
private $state;
|
||||
|
||||
/** @var string|null */
|
||||
private $post_code;
|
||||
|
||||
/** @var string|null */
|
||||
private $country;
|
||||
|
||||
/** @var float|null */
|
||||
private $shipping_rate;
|
||||
|
||||
/** @var int|null */
|
||||
private $overdue_days;
|
||||
|
||||
/** @var float|null */
|
||||
private $markup_percentage;
|
||||
|
||||
/** @var float|null */
|
||||
private $minimum_cbm;
|
||||
|
||||
/**
|
||||
* FreightForwarderObject constructor.
|
||||
* @param null|string $name
|
||||
* @param null|string $email
|
||||
* @param null|string $street_one
|
||||
* @param null|string $street_two
|
||||
* @param null|string $city
|
||||
* @param null|string $state
|
||||
* @param null|string $post_code
|
||||
* @param null|string $country
|
||||
* @param float|null $shipping_rate
|
||||
* @param int|null $overdue_days
|
||||
* @param float|null $markup_percentage
|
||||
* @param float|null $minimum_cbm
|
||||
*/
|
||||
public function __construct(?string $name = null, ?string $email = null, ?string $street_one = null, ?string $street_two = null, ?string $city = null, ?string $state = null, ?string $post_code = null, ?string $country = null, ?float $shipping_rate = null, ?int $overdue_days = null, ?float $markup_percentage = null, ?float $minimum_cbm = null)
|
||||
{
|
||||
$this->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;
|
||||
$this->minimum_cbm = $minimum_cbm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float|null
|
||||
*/
|
||||
public function getMinimumCbm(): ?float
|
||||
{
|
||||
return $this->minimum_cbm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: mhmj
|
||||
* Date: 18/07/2019
|
||||
* Time: 12:19 PM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\FreightForwarder\DataTransferObjects;
|
||||
|
||||
|
||||
class ServiceObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $type;
|
||||
|
||||
/** @var int|null */
|
||||
private $forwarderId;
|
||||
|
||||
/** @var String|null */
|
||||
private $name;
|
||||
|
||||
/** @var String|null */
|
||||
private $description;
|
||||
|
||||
/** @var float|null */
|
||||
private $cost;
|
||||
|
||||
/**
|
||||
* ServiceObject constructor.
|
||||
* @param null|int $type
|
||||
* @param int|null $forwarderId
|
||||
* @param null|String $name
|
||||
* @param null|String $description
|
||||
* @param float|null $cost
|
||||
*/
|
||||
public function __construct(?int $type = null, ?int $forwarderId = null, ?string $name = null, ?string $description = null, ?float $cost = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->forwarderId = $forwarderId;
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
$this->cost = $cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getType(): ?int
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\FreightForwarder\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Models\ServiceFees;
|
||||
|
||||
class DeletesServiceFees
|
||||
{
|
||||
/** @var ServiceFees */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* DeletesServiceFees constructor.
|
||||
* @param ServiceFees $repository
|
||||
*/
|
||||
public function __construct(ServiceFees $repository)
|
||||
{
|
||||
$this->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()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\FreightForwarder\Services;
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\FreightForwarder\DataTransferObjects\CustomerRelationObject;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Models\CustomerRelation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class UpdatesCustomerRelation
|
||||
{
|
||||
/** @var CustomerRelation */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* UpdatesCustomerRelation constructor.
|
||||
* @param CustomerRelation $repository
|
||||
*/
|
||||
public function __construct(CustomerRelation $repository)
|
||||
{
|
||||
$this->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()}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\FreightForwarder\Services;
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\FreightForwarder\DataTransferObjects\FreightForwarderObject;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Models\Forwarder;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class UpdatesFreightForwarder
|
||||
{
|
||||
/** @var Forwarder */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* UpdatesFreightForwarder constructor.
|
||||
* @param Forwarder $repository
|
||||
*/
|
||||
public function __construct(Forwarder $repository)
|
||||
{
|
||||
$this->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->minimum_cbm = $forwarderObject->getMinimumCbm();
|
||||
$repository->save();
|
||||
return new JsonResponse([],HttpStatus::OK);
|
||||
|
||||
}catch(\Exception $exception){
|
||||
throw new InternalServerErrorException("Failed to update Freight Forwarder because {$exception->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: mhmj
|
||||
* Date: 18/07/2019
|
||||
* Time: 4:46 PM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\FreightForwarder\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\FreightForwarder\DataTransferObjects\ServiceObject;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Models\ServiceFees;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class UpdatesServiceFees
|
||||
{
|
||||
/** @var ServiceFees */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* UpdatesServiceFees constructor.
|
||||
* @param ServiceFees $repository
|
||||
*/
|
||||
public function __construct(ServiceFees $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
public function execute(?String $serviceId = null, 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()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user