mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
update replica packages logic and over weight price announcement
This commit is contained in:
@@ -63,7 +63,7 @@ abstract class AbstractControllerLogic
|
||||
|
||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||
$exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,9 @@ class PackingListResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$replica = $this->packingLists()->first();
|
||||
|
||||
$packages = $replica ? $replica->packages : $this->packages;
|
||||
|
||||
if(in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) || in_array(Auth()->user()->id, [1914, 1919])) {
|
||||
$packages = $this->packages;
|
||||
}
|
||||
$exceptionUsers = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) || in_array(Auth()->user()->id, [1914, 1919]);
|
||||
$packages = $this->packingLists()->exists() || $exceptionUsers ? $this->originalPackages : $this->replicatedPackages;
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
@@ -32,7 +28,6 @@ class PackingListResource extends JsonResource
|
||||
'transport' => new TransportResource($this->transports()->first()),
|
||||
'type' => $this->type,
|
||||
'packages' => PackageResource::collection($packages),
|
||||
'packing_list' => new PackingListResource($replica),
|
||||
$this->mergeWhen($this->owner instanceof Order, [
|
||||
'order' => New OrderResource($this->owner)
|
||||
])
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Classes\General\Interfaces\Steppable;
|
||||
use App\Classes\General\Interfaces\Transportable;
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -16,9 +17,11 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
||||
|
||||
class PackingList extends AbstractModel implements Transportable, Steppable, Packable
|
||||
{
|
||||
use HasTableAlias;
|
||||
use HasRelationships;
|
||||
use SoftDeletes;
|
||||
|
||||
@@ -50,11 +53,19 @@ class PackingList extends AbstractModel implements Transportable, Steppable, Pac
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function packages(): hasMany
|
||||
public function originalPackages(): hasMany
|
||||
{
|
||||
return $this->hasMany(Package::class, 'packing_list_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasManyDeep
|
||||
*/
|
||||
public function replicatedPackages(): HasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Package::class, [PackingList::class, PackingList::class.' as alias'], [['owner_type', 'owner_id'], ['owner_type', 'owner_id'], 'packing_list_id'], [null, null, 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return morphMany
|
||||
*/
|
||||
@@ -123,4 +134,20 @@ class PackingList extends AbstractModel implements Transportable, Steppable, Pac
|
||||
return $transport->where('transport_arrangements.status', ApprovalStatus::COMPLETED);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopePackages($query){
|
||||
|
||||
$exceptionUsers = !in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) || in_array(Auth()->user()->id, [1914, 1919]);
|
||||
|
||||
return $query->when($query->has('packingLists') && !$exceptionUsers, function($query){
|
||||
return $query->replicatedPackages;
|
||||
})->when($query->doesntHave('packingLists') || $exceptionUsers, function($query){
|
||||
return $query->originalPackages;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,14 @@
|
||||
<span class="bold text-success">{{parameters.warehouse_id === 4 ? '23':'25'}}/01/2022</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p>请注意!! 由于近期船公司对于重量严格把控,我司对于货物超重的算法也进行了调整。新超重算法将从 2022 年 1 月 20日(货物装箱日期)起实行。</p>
|
||||
<p>Attention!! Due to the shipping liner company are strict on checking the weight recently, our company has modified the calculation formula against overweight goods. The new formula will start to be applied on 20th January 2022 (goods loaded date).</p>
|
||||
<p>For more details: <a href="https://www.cief-malaysia.com/services-sea-shipping/" target="_blank">https://www.cief-malaysia.com/services-sea-shipping/</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row text-center justify-content-center">
|
||||
<div class="col-8">
|
||||
|
||||
Reference in New Issue
Block a user