invoice-backend

This commit is contained in:
mhmj
2019-07-18 22:25:16 +08:00
parent 6c55f95229
commit 6c532dd738
11 changed files with 46 additions and 23 deletions
@@ -27,7 +27,7 @@ class UpdateFreightForwarderLogic
public function execute(String $forwarderId, Request $request){ public function execute(String $forwarderId, Request $request){
try{ try{
$object = new FreightForwarderObject(null, null, null, null, null, null,null, null, $request->input('shipping_rate'), $request->input('overdue_days'), $request->input('markup_percentage')); $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 $this->updatesFreightForwarder->execute($forwarderId, $object);
return new JsonResponse([],HttpStatus::REQUEST_ACCEPTED); return new JsonResponse([],HttpStatus::REQUEST_ACCEPTED);
@@ -14,7 +14,7 @@ class CustomerRelationObject
/** @var float|null */ /** @var float|null */
private $customer_rate; private $customer_rate;
/** @var float|null */ /** @var boolean|null */
private $wave; private $wave;
/** /**
@@ -22,9 +22,9 @@ class CustomerRelationObject
* @param int|null $forwarderId * @param int|null $forwarderId
* @param int|null $companyId * @param int|null $companyId
* @param float|null $customer_rate * @param float|null $customer_rate
* @param float|null $wave * @param bool|null $wave
*/ */
public function __construct(?int $forwarderId = null, ?int $companyId = null, ?float $customer_rate = null, ?float $wave = null) public function __construct(?int $forwarderId = null, ?int $companyId = null, ?float $customer_rate = null, ?bool $wave = null)
{ {
$this->forwarderId = $forwarderId; $this->forwarderId = $forwarderId;
$this->companyId = $companyId; $this->companyId = $companyId;
@@ -57,9 +57,9 @@ class CustomerRelationObject
} }
/** /**
* @return float|null * @return bool|null
*/ */
public function getWave(): ?float public function getWave(): ?bool
{ {
return $this->wave; return $this->wave;
} }
@@ -37,6 +37,9 @@ class FreightForwarderObject
/** @var float|null */ /** @var float|null */
private $markup_percentage; private $markup_percentage;
/** @var float|null */
private $minimum_cbm;
/** /**
* FreightForwarderObject constructor. * FreightForwarderObject constructor.
* @param null|string $name * @param null|string $name
@@ -50,8 +53,9 @@ class FreightForwarderObject
* @param float|null $shipping_rate * @param float|null $shipping_rate
* @param int|null $overdue_days * @param int|null $overdue_days
* @param float|null $markup_percentage * @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) 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->name = $name;
$this->email = $email; $this->email = $email;
@@ -64,6 +68,7 @@ class FreightForwarderObject
$this->shipping_rate = $shipping_rate; $this->shipping_rate = $shipping_rate;
$this->overdue_days = $overdue_days; $this->overdue_days = $overdue_days;
$this->markup_percentage = $markup_percentage; $this->markup_percentage = $markup_percentage;
$this->minimum_cbm = $minimum_cbm;
} }
/** /**
@@ -154,4 +159,16 @@ class FreightForwarderObject
return $this->markup_percentage; return $this->markup_percentage;
} }
/**
* @return float|null
*/
public function getMinimumCbm(): ?float
{
return $this->minimum_cbm;
}
} }
@@ -11,7 +11,7 @@ namespace App\Classes\Modules\FreightForwarder\DataTransferObjects;
class ServiceObject class ServiceObject
{ {
/** @var String|null */ /** @var int|null */
private $type; private $type;
/** @var int|null */ /** @var int|null */
@@ -28,13 +28,13 @@ class ServiceObject
/** /**
* ServiceObject constructor. * ServiceObject constructor.
* @param null|String $type * @param null|int $type
* @param int|null $forwarderId * @param int|null $forwarderId
* @param null|String $name * @param null|String $name
* @param null|String $description * @param null|String $description
* @param float|null $cost * @param float|null $cost
*/ */
public function __construct(?string $type = null, ?int $forwarderId = null, ?string $name = null, ?string $description = null, ?float $cost = null) public function __construct(?int $type = null, ?int $forwarderId = null, ?string $name = null, ?string $description = null, ?float $cost = null)
{ {
$this->type = $type; $this->type = $type;
$this->forwarderId = $forwarderId; $this->forwarderId = $forwarderId;
@@ -44,9 +44,9 @@ class ServiceObject
} }
/** /**
* @return null|String * @return null|int
*/ */
public function getType(): ?string public function getType(): ?int
{ {
return $this->type; return $this->type;
} }
@@ -83,4 +83,7 @@ class ServiceObject
return $this->cost; return $this->cost;
} }
} }
@@ -30,6 +30,7 @@ class UpdatesFreightForwarder
$repository->shipping_rate = $forwarderObject->getShippingRate(); $repository->shipping_rate = $forwarderObject->getShippingRate();
$repository->overdue_days = $forwarderObject->getOverdueDays(); $repository->overdue_days = $forwarderObject->getOverdueDays();
$repository->markup_percentage = $forwarderObject->getMarkupPercentage(); $repository->markup_percentage = $forwarderObject->getMarkupPercentage();
$repository->minimum_cbm = $forwarderObject->getMinimumCbm();
$repository->save(); $repository->save();
return new JsonResponse([],HttpStatus::OK); return new JsonResponse([],HttpStatus::OK);
@@ -30,7 +30,7 @@ class UpdatesServiceFees
} }
public function execute(String $serviceId, ServiceObject $serviceObject){ public function execute(?String $serviceId = null, ServiceObject $serviceObject){
try{ try{
$this->repository->updateOrCreate( $this->repository->updateOrCreate(
[ [
+1 -1
View File
@@ -7,7 +7,7 @@ class Forwarder extends AbstractModel
protected $table = 'forwarder'; protected $table = 'forwarder';
protected $fillable = [ protected $fillable = [
'name', 'email', 'street_one', 'street_two', 'city', 'state', 'post_code', 'country', 'shipping_rate','overdue_days','markup_percentage' 'name', 'email', 'street_one', 'street_two', 'city', 'state', 'post_code', 'country', 'shipping_rate','overdue_days','markup_percentage','minimum_cbm'
]; ];
public function customerRelation() public function customerRelation()
@@ -24,9 +24,10 @@ class CreateForwarderTable extends Migration
$table->string('state', 50)->nullable(); $table->string('state', 50)->nullable();
$table->string('post_code', 10)->nullable(); $table->string('post_code', 10)->nullable();
$table->string('country')->nullable(); $table->string('country')->nullable();
$table->float('shipping_rate'); $table->decimal('shipping_rate', 7, 2)->default(0);
$table->integer('overdue_days')->nullable(); $table->integer('overdue_days')->default(0);
$table->float('markup_percentage')->nullable(); $table->decimal('markup_percentage', 7, 2)->default(0);
$table->decimal('minimum_cbm', 5, 2)->default(0);
$table->timestamps(); $table->timestamps();
}); });
DB::table('forwarder')->insert( DB::table('forwarder')->insert(
@@ -42,6 +43,7 @@ class CreateForwarderTable extends Migration
'shipping_rate' => '300', 'shipping_rate' => '300',
'overdue_days' => '0', 'overdue_days' => '0',
'markup_percentage' => '0', 'markup_percentage' => '0',
'minimum_cbm' =>'0.3',
'created_at' => \Carbon\Carbon::now(), 'created_at' => \Carbon\Carbon::now(),
'updated_at' => \Carbon\Carbon::now() 'updated_at' => \Carbon\Carbon::now()
] ]
@@ -17,8 +17,8 @@ class CreateLocationFeesTable extends Migration
$table->increments('id'); $table->increments('id');
$table->integer('forwarder_id')->unsigned()->nullable(); $table->integer('forwarder_id')->unsigned()->nullable();
$table->string('state')->nullable(); $table->string('state')->nullable();
$table->float('rate')->nullable(); $table->decimal('rate', 7, 2)->default(0);
$table->float('outstation_rate')->nullable(); $table->decimal('outstation_rate', 7, 2)->default(0);
$table->timestamps(); $table->timestamps();
}); });
} }
@@ -16,9 +16,9 @@ class CreateServiceFeesTable extends Migration
Schema::create('service_fees', function (Blueprint $table) { Schema::create('service_fees', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('name')->nullable(); $table->string('name')->nullable();
$table->string('type')->nullable(); $table->integer('type')->nullable();
$table->string('description')->nullable(); $table->string('description')->nullable();
$table->float('cost')->nullable(); $table->decimal('cost', 7, 2)->nullable();
$table->integer('forwarder_id')->unsigned()->nullable(); $table->integer('forwarder_id')->unsigned()->nullable();
$table->timestamps(); $table->timestamps();
}); });
@@ -17,8 +17,8 @@ class CreateCustomerRelationTable extends Migration
$table->increments('id'); $table->increments('id');
$table->integer('forwarder_id')->unsigned()->nullable(); $table->integer('forwarder_id')->unsigned()->nullable();
$table->integer('company_id')->unsigned()->nullable(); $table->integer('company_id')->unsigned()->nullable();
$table->float('customer_rate')->nullable(); $table->float('customer_rate')->default(0);
$table->float('wave')->nullable(); $table->boolean('wave')->default(0);
$table->timestamps(); $table->timestamps();
}); });
} }