diff --git a/.env.example b/.env.example
index 696b7171..a75778c8 100644
--- a/.env.example
+++ b/.env.example
@@ -51,3 +51,5 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
UNITY_APP_URL="https://unity.izyim.com"
+EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
+MIX_EXCHANGE_URL="${EXCHANGE_URL}"
diff --git a/app/Classes/General/Eloquent/Filters/HasPendingDelivery.php b/app/Classes/General/Eloquent/Filters/HasPendingDelivery.php
new file mode 100644
index 00000000..c8a5aa3f
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/HasPendingDelivery.php
@@ -0,0 +1,24 @@
+whereHas('packingLists', function (Builder $query) use($value) {
+ $query->whereDoesntHave('transports');
+ }) : $builder->whereDoesntHave('packingLists', function (Builder $query) use($value) {
+ $query->whereDoesntHave('transports');
+ });
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/PackingListStatus.php b/app/Classes/General/Eloquent/Filters/PackingListStatus.php
new file mode 100644
index 00000000..1e20f147
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/PackingListStatus.php
@@ -0,0 +1,20 @@
+where('packing_lists.status', $value);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/PackingListType.php b/app/Classes/General/Eloquent/Filters/PackingListType.php
new file mode 100644
index 00000000..941d6493
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/PackingListType.php
@@ -0,0 +1,20 @@
+where('packing_lists.type', $value);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/Reference.php b/app/Classes/General/Eloquent/Filters/Reference.php
index fe2cbf03..de7c61ca 100644
--- a/app/Classes/General/Eloquent/Filters/Reference.php
+++ b/app/Classes/General/Eloquent/Filters/Reference.php
@@ -14,7 +14,7 @@ class Reference implements Filter
*/
public static function apply(Builder $builder, $value)
{
- return $builder->where('Reference', '=', $value);
+ return $builder->where('reference', '=', $value);
}
}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/ReferenceLike.php b/app/Classes/General/Eloquent/Filters/ReferenceLike.php
index 95bd8d5c..25f8373c 100644
--- a/app/Classes/General/Eloquent/Filters/ReferenceLike.php
+++ b/app/Classes/General/Eloquent/Filters/ReferenceLike.php
@@ -14,7 +14,7 @@ class ReferenceLike implements Filter
*/
public static function apply(Builder $builder, $value)
{
- return $builder->where('Reference', 'LIKE', '%'.$value.'%');
+ return $builder->where('reference', 'LIKE', '%'.$value.'%');
}
}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/WithArrivalDate.php b/app/Classes/General/Eloquent/Filters/WithArrivalDate.php
new file mode 100644
index 00000000..3acb02c4
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/WithArrivalDate.php
@@ -0,0 +1,22 @@
+leftJoin('transport_arrangements', function ($join) {
+ $join->on('packing_lists.id', '=', 'transport_arrangements.owner_id')->where('transport_arrangements.owner_type', 'App\Models\PackingList');
+ })->addSelect(['packing_lists.*', DB::raw('transport_arrangements.drop_date as arrival_date')]);
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/General/Interfaces/Packable.php b/app/Classes/General/Interfaces/Packable.php
index e46e5341..b2e60a10 100644
--- a/app/Classes/General/Interfaces/Packable.php
+++ b/app/Classes/General/Interfaces/Packable.php
@@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
interface Packable
{
-
public function packingLists(): morphMany;
}
\ No newline at end of file
diff --git a/app/Classes/General/Interfaces/Remarkable.php b/app/Classes/General/Interfaces/Remarkable.php
new file mode 100644
index 00000000..dcbd94ce
--- /dev/null
+++ b/app/Classes/General/Interfaces/Remarkable.php
@@ -0,0 +1,13 @@
+ 'Cross Authentication',
+ 'message' => 'You have successfully logged in to your account'
+ ];
+ }
+
+ /** @var CrossAuthenticationProcessor */
+ private $crossAuthenticationProcessor;
+
+
+ /**
+ * CrossAuthenticateUserLogic constructor.
+ * @param CrossAuthenticationProcessor $authenticationProcessor
+ */
+ public function __construct(CrossAuthenticationProcessor $crossAuthenticationProcessor)
+ {
+ $this->crossAuthenticationProcessor = $crossAuthenticationProcessor;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\AccessUnauthorisedException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ protected function logic(Request $request): JsonResponse {
+ return $this->response($this->crossAuthenticationProcessor->execute($request));
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/DataTransferObjects/CrossAuthenticationCredentialsObject.php b/app/Classes/Modules/Accounts/DataTransferObjects/CrossAuthenticationCredentialsObject.php
new file mode 100644
index 00000000..67abf905
--- /dev/null
+++ b/app/Classes/Modules/Accounts/DataTransferObjects/CrossAuthenticationCredentialsObject.php
@@ -0,0 +1,43 @@
+access_token = $access_token;
+ $this->platform = $platform;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAccessToken(): string
+ {
+ return $this->access_token;
+ }
+
+ /**
+ * @return string
+ */
+ public function getPlatform(): int
+ {
+ return $this->platform;
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/DataTransferObjects/UserSocialAccountObject.php b/app/Classes/Modules/Accounts/DataTransferObjects/UserSocialAccountObject.php
new file mode 100644
index 00000000..7740a04e
--- /dev/null
+++ b/app/Classes/Modules/Accounts/DataTransferObjects/UserSocialAccountObject.php
@@ -0,0 +1,54 @@
+app_id = $app_id;
+ $this->user = $user;
+ $this->platform = $platform;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAppId(): String
+ {
+ return $this->app_id;
+ }
+
+ /**
+ * @return User
+ */
+ public function getUser(): User
+ {
+ return $this->user;
+ }
+
+ /**
+ * @return int
+ */
+ public function getPlatform(): int
+ {
+ return $this->platform;
+ }
+}
diff --git a/app/Classes/Modules/Accounts/Processors/CrossAuthenticationProcessor.php b/app/Classes/Modules/Accounts/Processors/CrossAuthenticationProcessor.php
new file mode 100644
index 00000000..5658f932
--- /dev/null
+++ b/app/Classes/Modules/Accounts/Processors/CrossAuthenticationProcessor.php
@@ -0,0 +1,211 @@
+canCrossAuthenticateUser = $canCrossAuthenticateUser;
+ $this->crossAuthenticatesUser = $crossAuthenticatesUser;
+ $this->generatesAuthenticationToken = $generatesAuthenticationToken;
+ $this->fetchesUser = $fetchesUser;
+ $this->authenticationRedirect = $authenticationRedirect;
+ $this->createUserProcessor = $createUserProcessor;
+ $this->createCompanyProcessor = $createCompanyProcessor;
+ $this->createContactProcessor = $createContactProcessor;
+ $this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
+ $this->createsCompanyConnection = $createsCompanyConnection;
+ $this->createsCompanyConnection = $createsCompanyConnection;
+ $this->approvesCompanyConnection = $approvesCompanyConnection;
+ $this->assignEmployeeProcessor = $assignEmployeeProcessor;
+ $this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
+ $this->createsUserSocialAccount = $createsUserSocialAccount;
+ }
+
+
+ /**
+ * @param Request $request
+ * @return array
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\AccessUnauthorisedException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function execute(Request $request): array {
+
+ $object = new CrossAuthenticationCredentialsObject($request->input('access_token'), $request->input('platform'));
+
+ $this->canCrossAuthenticateUser->passes($object);
+
+ $cross = $this->crossAuthenticatesUser->execute($object);
+
+ $user_social_account = UserSocialAccount::where('app_id', $cross->token->user->id)->first();
+ if (!$user_social_account) {
+
+ $request->request->add([
+ 'name' => $cross->token->user->name,
+ 'email' => $cross->token->user->email,
+ 'password' => 'pass123',
+ 'password_confirmation' => 'pass123',
+ ]);
+
+ $user = $this->createUserProcessor->execute(
+ $request,
+ RoleTypes::USER,
+ env('APP_ENV') != 'production' ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION
+ );
+
+ $company = $this->createCompanyProcessor->execute(
+ $cross->payload->data->name,
+ CompanyType::COMPANY_BUSINESS,
+ ApprovalStatus::PENDING_SUBMISSION
+ );
+
+ $contactObject = new ContactObject(
+ $cross->payload->data->contact->reference,
+ $cross->payload->data->contact->phone,
+ $cross->payload->data->contact->email,
+ $cross->payload->data->contact->wechat_id
+ );
+ $contact = $this->createContactProcessor->execute($contactObject, $company);
+
+ $companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::IMPORTER);
+
+ $connectionObject = new CompanyConnectionObject(
+ $companyModule, 'CIEF',
+ mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate()
+ );
+ $connection = $this->createsCompanyConnection->execute($connectionObject);
+
+ $this->approvesCompanyConnection->execute($connection);
+
+ $object = new EmploymentObject($companyModule, $user);
+ $this->assignEmployeeProcessor->execute($object);
+
+ $request->request->add([
+ 'files' => [$cross->document->src],
+ 'identification_no' => $cross->payload->data->identification->reference,
+ ]);
+
+ $this->uploadIdentityDocumentProcessor->execute($request, $company);
+
+ $object = new UserSocialAccountObject(
+ $cross->token->user->id,
+ $user,
+ $request->input('platform')
+ );
+ $this->createsUserSocialAccount->execute($object);
+ }
+ else {
+ $user = $user_social_account->user()->first();
+ }
+
+ return ['access_token' => $this->generatesAuthenticationToken->execute($user), 'redirect_url' => $this->authenticationRedirect->url($user)];
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/Processors/GenerateEmailVerificationAttemptProcessor.php b/app/Classes/Modules/Accounts/Processors/GenerateEmailVerificationAttemptProcessor.php
index 23853f27..4056234c 100644
--- a/app/Classes/Modules/Accounts/Processors/GenerateEmailVerificationAttemptProcessor.php
+++ b/app/Classes/Modules/Accounts/Processors/GenerateEmailVerificationAttemptProcessor.php
@@ -56,4 +56,4 @@ class GenerateEmailVerificationAttemptProcessor
}
-}
\ No newline at end of file
+}
diff --git a/app/Classes/Modules/Accounts/Services/CreatesUserSocialAccount.php b/app/Classes/Modules/Accounts/Services/CreatesUserSocialAccount.php
new file mode 100644
index 00000000..a6fd8fcd
--- /dev/null
+++ b/app/Classes/Modules/Accounts/Services/CreatesUserSocialAccount.php
@@ -0,0 +1,24 @@
+user_id = $object->getUser()->id;
+ $model->app_id = $object->getAppId();
+ $model->platform = $object->getPlatform();
+ return $this->handler($model);
+
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/Services/CrossAuthenticatesUser.php b/app/Classes/Modules/Accounts/Services/CrossAuthenticatesUser.php
new file mode 100644
index 00000000..54835b17
--- /dev/null
+++ b/app/Classes/Modules/Accounts/Services/CrossAuthenticatesUser.php
@@ -0,0 +1,40 @@
+getPlatform() == PlatformType::EXCHANGE) {
+
+ $token = $object->getAccessToken();
+
+ $tokenParts = explode(".", $token);
+ $tokenPayload = base64_decode($tokenParts[1]);
+ $jwtPayload = json_decode($tokenPayload);
+
+ $response = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/company/' . $jwtPayload->user->company_id . '/show')->object();
+
+ $response_document = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/storage/' . $response->payload->data->identification->files[0]->file->file_info[0]->original->file . '/fetch')->object();
+ $response->token = $jwtPayload;
+ $response->document = $response_document->payload;
+ }
+
+ return $response;
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/Services/FetchesUserSocialAccount.php b/app/Classes/Modules/Accounts/Services/FetchesUserSocialAccount.php
new file mode 100644
index 00000000..c2e1c676
--- /dev/null
+++ b/app/Classes/Modules/Accounts/Services/FetchesUserSocialAccount.php
@@ -0,0 +1,33 @@
+repository = $repository;
+ }
+
+
+ /**
+ * @return Builder
+ */
+ public function getRepository(): Builder
+ {
+ return $this->repository->newQuery();
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/Standards/Rules/CanCrossAuthenticateUser.php b/app/Classes/Modules/Accounts/Standards/Rules/CanCrossAuthenticateUser.php
new file mode 100644
index 00000000..115a7ea6
--- /dev/null
+++ b/app/Classes/Modules/Accounts/Standards/Rules/CanCrossAuthenticateUser.php
@@ -0,0 +1,54 @@
+userCrossAuthenticationValidation = $userCrossAuthenticationValidation;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function authorized(): bool
+ {
+ return true;
+
+ }
+
+
+ /**
+ * @param AuthenticationCredentialsObject $object
+ * @return bool
+ * @throws RequestValidationException
+ */
+ protected function validators($object): bool
+ {
+ return $this->userCrossAuthenticationValidation->validate($object);
+ }
+
+ /**
+ * @param AuthenticationCredentialsObject $object
+ * @return bool
+ */
+ protected function criteria($object): bool
+ {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/Standards/Validators/UserCrossAuthenticationValidation.php b/app/Classes/Modules/Accounts/Standards/Validators/UserCrossAuthenticationValidation.php
new file mode 100644
index 00000000..ec170dc7
--- /dev/null
+++ b/app/Classes/Modules/Accounts/Standards/Validators/UserCrossAuthenticationValidation.php
@@ -0,0 +1,43 @@
+ $object->getAccesstoken(),
+ 'platform' => $object->getPlatform()
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function rules(): array {
+ return [
+ 'access_token' => 'required',
+ 'platform' => 'required'
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function messages(): array {
+ return [];
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php b/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php
new file mode 100644
index 00000000..cee72e84
--- /dev/null
+++ b/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php
@@ -0,0 +1,67 @@
+ 'Assign Company Connection To Connection Segment',
+ 'message' => 'You have successfully assigned Company Connection to Connection segment'
+ ];
+ }
+
+ /** @var FetchesCompany */
+ private $fetchesCompany;
+
+ /** @var FetchesCompanyConnection */
+ private $fetchesCompanyConnection;
+
+ /** @var AssignConnectionSegmentProcessor */
+ private $assignCompanyConnectionToConnectionSegmentProcessor;
+
+ /**
+ * AssignCompanyToSegmentLogic constructor.
+ * @param FetchesCompany $fetchesCompany
+ * @param FetchesCompanyConnection $fetchesCompanyConnection
+ * @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor
+ */
+ public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor)
+ {
+ $this->fetchesCompany = $fetchesCompany;
+ $this->fetchesCompanyConnection = $fetchesCompanyConnection;
+ $this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+
+ $company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
+
+ $companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]);
+
+ $this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id'));
+
+ return $this->resourceResponse(new CompanyResource($company));
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Companies/ControllersLogic/RemoveCompanyConnectionFromConnectionSegmentLogic.php b/app/Classes/Modules/Companies/ControllersLogic/RemoveCompanyConnectionFromConnectionSegmentLogic.php
new file mode 100644
index 00000000..1f423051
--- /dev/null
+++ b/app/Classes/Modules/Companies/ControllersLogic/RemoveCompanyConnectionFromConnectionSegmentLogic.php
@@ -0,0 +1,73 @@
+ 'Detach Company Connection From Connection Segment',
+ 'message' => 'You have successfully detached Company Connection from Connection segment'
+ ];
+ }
+
+ /** @var FetchesCompany */
+ private $fetchesCompany;
+
+ /** @var FetchesCompanyConnection */
+ private $fetchesCompanyConnection;
+
+ /** @var FetchesSegment */
+ private $fetchesSegment;
+
+ /** @var RemovesCompanyConnectionFromConnectionSegment */
+ private $removesCompanyConnectionFromConnectionSegment;
+
+ /**
+ * RemoveCompanyFromSegmentLogic constructor.
+ * @param FetchesCompany $fetchesCompany
+ * @param FetchesCompanyConnection $fetchesCompanyConnection
+ * @param FetchesSegment $fetchesSegment
+ * @param RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment
+ */
+ public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, FetchesSegment $fetchesSegment, RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment)
+ {
+ $this->fetchesCompany = $fetchesCompany;
+ $this->fetchesCompanyConnection = $fetchesCompanyConnection;
+ $this->fetchesSegment = $fetchesSegment;
+ $this->removesCompanyConnectionFromConnectionSegment = $removesCompanyConnectionFromConnectionSegment;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+
+ $company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
+
+ $companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]);
+
+ $segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
+
+ $this->removesCompanyConnectionFromConnectionSegment->execute($companyConnection, $segment);
+
+ return $this->resourceResponse(new CompanyResource($company));
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Companies/Processors/AssignConnectionSegmentProcessor.php b/app/Classes/Modules/Companies/Processors/AssignConnectionSegmentProcessor.php
new file mode 100644
index 00000000..8b6f9294
--- /dev/null
+++ b/app/Classes/Modules/Companies/Processors/AssignConnectionSegmentProcessor.php
@@ -0,0 +1,56 @@
+canAssignSegment = $canAssignSegment;
+ $this->assignsCompanyConnectionToConnectionSegment = $assignsCompanyConnectionToConnectionSegment;
+ $this->fetchesSegment = $fetchesSegment;
+ }
+
+
+ /**
+ * @param CompanyConnection $companyConnection
+ * @param int|null $segmentId
+ * @return Model
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function execute(CompanyConnection $companyConnection, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model {
+
+ $segment = $this->fetchesSegment->execute(['id' => $segmentId]);
+
+ $this->canAssignSegment->passes();
+
+ return $this->assignsCompanyConnectionToConnectionSegment->execute($companyConnection, $segment);
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Companies/Services/AssignsCompanyConnectionToConnectionSegment.php b/app/Classes/Modules/Companies/Services/AssignsCompanyConnectionToConnectionSegment.php
new file mode 100644
index 00000000..b0a95523
--- /dev/null
+++ b/app/Classes/Modules/Companies/Services/AssignsCompanyConnectionToConnectionSegment.php
@@ -0,0 +1,33 @@
+segments()->attach($segment);
+
+ return $companyConnection;
+
+ } catch (QueryException $exception){
+ throw new MalformedRequestException($exception);
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Companies/Services/FetchesCompanyConnection.php b/app/Classes/Modules/Companies/Services/FetchesCompanyConnection.php
new file mode 100644
index 00000000..9566192d
--- /dev/null
+++ b/app/Classes/Modules/Companies/Services/FetchesCompanyConnection.php
@@ -0,0 +1,34 @@
+repository = $repository;
+ }
+
+
+ /**
+ * @return Builder
+ */
+ public function getRepository(): Builder
+ {
+ return $this->repository->newQuery();
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Companies/Services/RemovesCompanyConnectionFromConnectionSegment.php b/app/Classes/Modules/Companies/Services/RemovesCompanyConnectionFromConnectionSegment.php
new file mode 100644
index 00000000..71e7d423
--- /dev/null
+++ b/app/Classes/Modules/Companies/Services/RemovesCompanyConnectionFromConnectionSegment.php
@@ -0,0 +1,33 @@
+segments()->detach($segment);
+
+ return $companyConnection;
+
+ } catch (QueryException $exception){
+ throw new MalformedRequestException($exception);
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Orders/ControllersLogic/CreateOrderLogic.php b/app/Classes/Modules/Orders/ControllersLogic/CreateOrderLogic.php
index 97506974..856fa15c 100644
--- a/app/Classes/Modules/Orders/ControllersLogic/CreateOrderLogic.php
+++ b/app/Classes/Modules/Orders/ControllersLogic/CreateOrderLogic.php
@@ -8,6 +8,7 @@ use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
+use App\Classes\ValueObjects\Constants\WarehouseReferences;
use App\Http\Resources\OrderResource;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
@@ -63,6 +64,13 @@ class CreateOrderLogic extends AbstractControllerLogic
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
+ if($originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU){
+ $marking = $company->companyModules()->importers()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
+ if(in_array($marking, ['2192KAA', '2353GFE', '6866DTR', '1905JYW', '6218MEN', '9274MEN'])){
+ $originWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::YD_GUANG_ZHOU]);
+ }
+ }
+
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
return $this->resourceResponse(new OrderResource($order));
diff --git a/app/Classes/Modules/Orders/ControllersLogic/CreateOrderRemarkLogic.php b/app/Classes/Modules/Orders/ControllersLogic/CreateOrderRemarkLogic.php
new file mode 100644
index 00000000..e134bcc7
--- /dev/null
+++ b/app/Classes/Modules/Orders/ControllersLogic/CreateOrderRemarkLogic.php
@@ -0,0 +1,60 @@
+ 'Created Order',
+ 'message' => 'You have successfully created a new Order'
+ ];
+ }
+
+ /** @var FetchesOrder */
+ private $fetchesOrder;
+
+ /** @var CreateRemarkProcessor */
+ private $createRemarkProcessor;
+
+ /**
+ * CreateOrderRemarkLogic constructor.
+ * @param FetchesOrder $fetchesOrder
+ * @param CreateRemarkProcessor $createRemarkProcessor
+ */
+ public function __construct(FetchesOrder $fetchesOrder, CreateRemarkProcessor $createRemarkProcessor)
+ {
+ $this->fetchesOrder = $fetchesOrder;
+ $this->createRemarkProcessor = $createRemarkProcessor;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+ $order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
+
+ $object = new RemarkObject($request->input('content'), auth()->user()->id);
+
+ $this->createRemarkProcessor->execute($order, $object);
+
+ return $this->resourceResponse(new OrderResource($order));
+
+ }
+}
diff --git a/app/Classes/Modules/Orders/ControllersLogic/ShippingCostLogic.php b/app/Classes/Modules/Orders/ControllersLogic/ShippingCostLogic.php
new file mode 100644
index 00000000..b406e565
--- /dev/null
+++ b/app/Classes/Modules/Orders/ControllersLogic/ShippingCostLogic.php
@@ -0,0 +1,103 @@
+ 'Order Shipping Cost',
+ 'message' => 'Order shipping cost calculation done'
+ ];
+ }
+
+ /** @var CalculateCBM */
+ private $calculateCBM;
+
+ /** @var CalculatesBaseRate */
+ private $calculateBaseRate;
+
+ /** @var CalculatesSegmentRate */
+ private $calculateSegmentRate;
+
+ /** @var CalculatesStateRate */
+ private $calculateStateRate;
+
+ /** @var CalculatesWarehouse */
+ private $calculateWarehouseRate;
+
+ /** @var FetchesOrder */
+ private $fetchesOrder;
+
+ /** @var ShippingCostTransactionProcessor */
+ private $shippingCostTransactionProcessor;
+
+ /**
+ * ShippingCostLogic constructor.
+ * @param CalculateCBM $calculateCBM
+ * @param FetchesOrder $fetchesOrder
+ */
+ public function __construct(FetchesOrder $fetchesOrder, CalculatesCBM $calculateCBM, CalculatesBaseRate $calculateBaseRate, CalculatesSegmentRate $calculateSegmentRate, CalculatesStateRate $calculateStateRate, CalculatesWarehouseRate $calculateWarehouseRate, CreateShippingCostTransactionProcessor $shippingCostTransactionProcessor)
+ {
+ $this->fetchesOrder = $fetchesOrder;
+ $this->calculateCBM = $calculateCBM;
+ $this->calculatesBaseRate = $calculateBaseRate;
+ $this->calculatesSegmentRate = $calculateSegmentRate;
+ $this->calculatesStateRate = $calculateStateRate;
+ $this->calculateWarehouseRate = $calculateWarehouseRate;
+ $this->shippingCostTransactionProcessor = $shippingCostTransactionProcessor;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+ $order = $this->fetchesOrder->getRepository()->where(['id' => $request->route('id')])->first();
+
+ $baseRate = $this->calculatesBaseRate->execute($order);
+ $segmentRate = $this->calculatesSegmentRate->execute($order, SegmentConstants::STANDARD_SEGMENT) + $this->calculatesSegmentRate->execute($order, SegmentConstants::CUSTOM_SEGMENT);
+ $stateRate = $this->calculatesStateRate->execute($order, false) + $this->calculatesStateRate->execute($order, true);
+ $warehouseRate = $this->calculateWarehouseRate->execute($order);
+
+ $totalShippingCost = 0;
+ $totalCBM = 0;
+ $quantity = 0;
+ foreach($order->parcels as $parcel){
+ $cbm = $this->calculateCBM->execute($order, $parcel);
+
+ if($cbm > 0){
+ $totalCBM += $cbm;
+ $quantity ++;
+ $totalShippingCost += (($segmentRate + $stateRate + $warehouseRate) * $cbm);
+ }
+ }
+
+ $this->shippingCostTransactionProcessor->execute($order, $quantity, round($totalCBM,2), round($totalShippingCost,2));
+ return $this->resourceResponse(new OrderResource($order));
+ }
+
+}
diff --git a/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php b/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php
index 24495752..7ca3603f 100644
--- a/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php
+++ b/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php
@@ -53,7 +53,7 @@ class CreateOrderRolesProcessor
$importer = $order->companyModule;
/** @var CompanyModule $destinationWarehouse */
- $destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::DESTINATION_WAREHOUSE[$address->state_id ]]);
+ $destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::YD_GUANG_ZHOU ? WarehouseReferences::YD_DESTINATION_WAREHOUSE : WarehouseReferences::VT_DESTINATION_WAREHOUSE[$address->state_id]]);
/** @var CompanyModule $freightForwarder */
$freightForwarder = $originWarehouse->company->companyModules()->freightForwarders()->first();
@@ -84,28 +84,5 @@ class CreateOrderRolesProcessor
$this->createsOrderRole->execute($roleObject);
return true;
-
- $companies = $this->fetchesCompany->getRepository()->whereIn('id',[1, $request->get('warehouse_id')])->get();
-
- $cief_company = $companies[0]->id == 1 ? $companies[0] : $companies[1];
- $warehouse_company = $companies[0]->id != 1 ? $companies[0] : $companies[1];
-
- $cief_company_module = $cief_company->companyModule()->first();
- $contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$cief_company_module->unity_hash_id]);
- $contractEntities[0]->{"company_module_id"} = $cief_company_module->id;
-
- $warehouse_company_module = $warehouse_company->companyModule()->first();
- $contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$warehouse_company_module->unity_hash_id]);
- $contractEntities[1]->{"company_module_id"} = $warehouse_company_module->id;
-
- foreach($contractEntities as $entity){
- $order_role_object = new OrderRoleObject($orderId, $entity->company_module_id, $entity->hash_id, $entity->entity_signature_hash_id);
-
- $this->canCreateOrderRole->passes($order_role_object);
-
- $this->createsOrderRole->execute($order_role_object);
- }
-
- return $contractEntities;
}
}
diff --git a/app/Classes/Modules/Orders/Services/CalculatesBaseRate.php b/app/Classes/Modules/Orders/Services/CalculatesBaseRate.php
new file mode 100644
index 00000000..14a354f5
--- /dev/null
+++ b/app/Classes/Modules/Orders/Services/CalculatesBaseRate.php
@@ -0,0 +1,18 @@
+length * $parcel->width * $parcel->height;
+ }
+
+}
diff --git a/app/Classes/Modules/Orders/Services/CalculatesSegmentRate.php b/app/Classes/Modules/Orders/Services/CalculatesSegmentRate.php
new file mode 100644
index 00000000..402d2aab
--- /dev/null
+++ b/app/Classes/Modules/Orders/Services/CalculatesSegmentRate.php
@@ -0,0 +1,20 @@
+ 'Created Container',
+ 'message' => 'You have successfully created a new Container'
+ ];
+ }
+
+
+ /** @var FetchesContainer */
+ private $fetchesContainer;
+
+ /** @var CreateRemarkProcessor */
+ private $createRemarkProcessor;
+
+ /**
+ * CreateContainerRemarkLogic constructor.
+ * @param FetchesContainer $fetchesContainer
+ * @param CreateRemarkProcessor $createRemarkProcessor
+ */
+ public function __construct(FetchesContainer $fetchesContainer, CreateRemarkProcessor $createRemarkProcessor)
+ {
+ $this->fetchesContainer = $fetchesContainer;
+ $this->createRemarkProcessor = $createRemarkProcessor;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+
+ $container = $this->fetchesContainer->execute(['id' => $request->input('container_id')]);
+
+ $object = new RemarkObject($request->input('content'), 1);
+
+ $this->createRemarkProcessor->execute($container, $object);
+
+ return $this->resourceResponse(new ContainerResource($container));
+
+ }
+
+}
diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/CreateDeliverPackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/CreateDeliverPackingListLogic.php
new file mode 100644
index 00000000..0e24c9ed
--- /dev/null
+++ b/app/Classes/Modules/PackingLists/ControllersLogic/CreateDeliverPackingListLogic.php
@@ -0,0 +1,88 @@
+ 'Created Deliver PackingList',
+ 'message' => 'You have successfully created a new Deliver PackingList'
+ ];
+ }
+
+ /** @var CreatePackingListProcessor */
+ private $createPackingListProcessor;
+
+ /** @var FetchesCompanyModule */
+ private $fetchesCompanyModule;
+
+ /** @var GeneratesPackingListReferenceNumber */
+ private $generatesPackingListReferenceNumber;
+
+ /** @var FetchesPackingList */
+ private $fetchesPackingList;
+
+ /**
+ * CreateDeliverPackingListLogic constructor.
+ * @param CreatePackingListProcessor $createPackingListProcessor
+ * @param FetchesCompanyModule $fetchesCompanyModule
+ */
+ public function __construct(CreatePackingListProcessor $createPackingListProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber, FetchesPackingList $fetchesPackingList)
+ {
+ $this->createPackingListProcessor = $createPackingListProcessor;
+ $this->fetchesCompanyModule = $fetchesCompanyModule;
+ $this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
+ $this->fetchesPackingList = $fetchesPackingList;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+ $company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
+ $packing_list_id = $request->input('packing_list_id');
+
+ $reference_number = $this->generatesPackingListReferenceNumber->execute();
+
+ $packingListObject = new PackingListObject(
+ $reference_number,
+ null,
+ PackingListType::DELIVERY_PACKING_LIST,
+ ApprovalStatus::PENDING_SUBMISSION
+ );
+
+ $deliverPackingList = $this->createPackingListProcessor->execute($packingListObject, $company_module);
+
+ foreach ($packing_list_id as $key => $row) {
+ $this->fetchesPackingList->execute(['id' => $row]);
+ }
+
+ $deliverPackingList->packing_list_owner()->sync($packing_list_id);
+
+ return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
+ }
+
+}
diff --git a/app/Classes/Modules/PackingLists/DataTransferObjects/PackingListObject.php b/app/Classes/Modules/PackingLists/DataTransferObjects/PackingListObject.php
index c6e1cbd0..92259878 100644
--- a/app/Classes/Modules/PackingLists/DataTransferObjects/PackingListObject.php
+++ b/app/Classes/Modules/PackingLists/DataTransferObjects/PackingListObject.php
@@ -30,7 +30,7 @@ class PackingListObject implements DataTransferObject
* @param int $status
* @param null|string $contractReference
*/
- public function __construct(string $reference, int $claimantId, int $type, int $status, ?string $contractReference = null)
+ public function __construct(string $reference, ?int $claimantId, int $type, int $status, ?string $contractReference = null)
{
$this->reference = $reference;
$this->claimantId = $claimantId;
@@ -50,7 +50,7 @@ class PackingListObject implements DataTransferObject
/**
* @return int
*/
- public function getClaimantId(): int
+ public function getClaimantId(): ?int
{
return $this->claimantId;
}
diff --git a/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php b/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php
index e9c0738f..f120efab 100644
--- a/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php
+++ b/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php
@@ -51,11 +51,13 @@ class UpdateRemarkLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
- * @throws ErrorException
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
{
- $object = new RemarkObject($request->input('content'), $request->input('commenter_id'));
+ $object = new RemarkObject($request->input('content'), auth()->user()->id);
$this->canUpdateRemark->passes($object);
diff --git a/app/Classes/Modules/Remarks/Processors/CreateRemarkProcessor.php b/app/Classes/Modules/Remarks/Processors/CreateRemarkProcessor.php
new file mode 100644
index 00000000..aadbe502
--- /dev/null
+++ b/app/Classes/Modules/Remarks/Processors/CreateRemarkProcessor.php
@@ -0,0 +1,47 @@
+createsRemark = $createsRemark;
+ $this->canCreateRemark = $canCreateRemark;
+ }
+
+
+ /**
+ * @param Remarkable $remarkable
+ * @param RemarkObject $object
+ * @return \Illuminate\Database\Eloquent\Model
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function execute(Remarkable $remarkable, RemarkObject $object){
+
+ $this->canCreateRemark->passes($object);
+ return $this->createsRemark->execute($remarkable, $object);
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Remarks/Services/CreatesRemark.php b/app/Classes/Modules/Remarks/Services/CreatesRemark.php
index 8c221878..ac0d57a3 100644
--- a/app/Classes/Modules/Remarks/Services/CreatesRemark.php
+++ b/app/Classes/Modules/Remarks/Services/CreatesRemark.php
@@ -4,7 +4,9 @@ namespace App\Classes\Modules\Remarks\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
+use App\Classes\General\Interfaces\Remarkable;
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
+use App\Models\Container;
use App\Models\Remark;
use App\Models\User;
@@ -12,18 +14,18 @@ class CreatesRemark extends AbstractUpdateRelationshipRecord
{
/**
- * @param Company $company
+ * @param Remarkable $remarkable
* @param RemarkObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
- public function execute(User $user, RemarkObject $object) {
+ public function execute(Remarkable $remarkable, RemarkObject $object) {
$model = new Remark();
$model->commenter_id = $object->getCommenterId();
$model->content = $object->getContent();
- return $this->handler($user->remarks(), $model);
+ return $this->handler($remarkable->remarks(), $model);
}
}
diff --git a/app/Classes/Modules/Segments/ControllersLogic/CreateSegmentLogic.php b/app/Classes/Modules/Segments/ControllersLogic/CreateSegmentLogic.php
new file mode 100644
index 00000000..14860207
--- /dev/null
+++ b/app/Classes/Modules/Segments/ControllersLogic/CreateSegmentLogic.php
@@ -0,0 +1,53 @@
+ 'Created Segment',
+ 'message' => 'You have successfully created a new Segment'
+ ];
+ }
+
+
+ /** @var CreateSegmentProcessor */
+ private $createSegmentProcessor;
+
+ /**
+ * CreateSegmentLogic constructor.
+ * @param CreateSegmentProcessor $createSegmentProcessor
+ */
+ public function __construct(CreateSegmentProcessor $createSegmentProcessor)
+ {
+ $this->createSegmentProcessor = $createSegmentProcessor;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+ /** @var Segment $segment */
+ $segment = $this->createSegmentProcessor->execute($request->input('name'));
+
+ return $this->resourceResponse(new SegmentResource($segment));
+ }
+
+}
diff --git a/app/Classes/Modules/Segments/ControllersLogic/DeleteSegmentLogic.php b/app/Classes/Modules/Segments/ControllersLogic/DeleteSegmentLogic.php
new file mode 100644
index 00000000..5d2f6c3b
--- /dev/null
+++ b/app/Classes/Modules/Segments/ControllersLogic/DeleteSegmentLogic.php
@@ -0,0 +1,69 @@
+ 'Deleted Segment',
+ 'message' => 'You have successfully deleted a Segment'
+ ];
+ }
+
+
+ /** @var CanDeleteSegment */
+ private $canDeleteSegment;
+
+ /** @var DeletesSegment */
+ private $deletesSegment;
+
+ /** @var FetchesSegment */
+ private $fetchesSegment;
+
+ /**
+ * DeleteSegmentLogic constructor.
+ * @param CanDeleteSegment $canDeleteSegment
+ * @param DeletesSegment $deletesSegment
+ * @param FetchesSegment $fetchesSegment
+ */
+ public function __construct(CanDeleteSegment $canDeleteSegment, DeletesSegment $deletesSegment, FetchesSegment $fetchesSegment)
+ {
+ $this->canDeleteSegment = $canDeleteSegment;
+ $this->deletesSegment = $deletesSegment;
+ $this->fetchesSegment = $fetchesSegment;
+ }
+
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+
+ $this->canDeleteSegment->passes();
+
+ $query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
+
+ $this->deletesSegment->execute($query);
+
+ return $this->response([]);
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Segments/DataTransferObjects/SegmentObject.php b/app/Classes/Modules/Segments/DataTransferObjects/SegmentObject.php
new file mode 100644
index 00000000..bde3af3c
--- /dev/null
+++ b/app/Classes/Modules/Segments/DataTransferObjects/SegmentObject.php
@@ -0,0 +1,44 @@
+name = $name;
+ $this->company_module_id = $company_module_id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName(): string
+ {
+ return $this->name;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCompanyModuleId(): string
+ {
+ return $this->company_module_id;
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Segments/Processors/CreateSegmentProcessor.php b/app/Classes/Modules/Segments/Processors/CreateSegmentProcessor.php
new file mode 100644
index 00000000..4910afce
--- /dev/null
+++ b/app/Classes/Modules/Segments/Processors/CreateSegmentProcessor.php
@@ -0,0 +1,50 @@
+canCreateSegment = $canCreateSegment;
+ $this->createsSegment = $createsSegment;
+ }
+
+
+ /**
+ * @param string $name
+ * @param int $companyModuleId
+ * @return Model
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function execute(string $name, int $companyModuleId =1): Model {
+
+ $segement_object = new SegmentObject($name, $companyModuleId);
+
+ $this->canCreateSegment->passes($segement_object);
+
+ return $this->createsSegment->execute($segement_object);
+
+ }
+
+}
diff --git a/app/Classes/Modules/Segments/Services/CreatesSegment.php b/app/Classes/Modules/Segments/Services/CreatesSegment.php
new file mode 100644
index 00000000..4dff35a7
--- /dev/null
+++ b/app/Classes/Modules/Segments/Services/CreatesSegment.php
@@ -0,0 +1,25 @@
+name = $object->getName();
+ $model->company_module_id = $object->getCompanyModuleId();
+
+ return $this->handler($model);
+ }
+}
diff --git a/app/Classes/Modules/Segments/Services/DeletesSegment.php b/app/Classes/Modules/Segments/Services/DeletesSegment.php
new file mode 100644
index 00000000..9cc78c59
--- /dev/null
+++ b/app/Classes/Modules/Segments/Services/DeletesSegment.php
@@ -0,0 +1,19 @@
+handler($model);
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php
new file mode 100644
index 00000000..9c5cdc57
--- /dev/null
+++ b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php
@@ -0,0 +1,51 @@
+segmentValidation = $segmentValidation;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function authorized(): bool
+ {
+ // TODO Set Authorization rules
+ return true;
+ }
+
+ /**
+ * @param SegmentObject $object
+ * @return bool
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ protected function validators($object): bool
+ {
+ return $this->segmentValidation->validate($object);
+ }
+
+ /**
+ * @param SegmentObject $object
+ * @return bool
+ */
+ protected function criteria($object): bool
+ {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php
new file mode 100644
index 00000000..d78b2429
--- /dev/null
+++ b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php
@@ -0,0 +1,40 @@
+ $object->getName(),
+ 'company_module_id' => $object->getCompanyModuleId()
+ ];
+ }
+
+ /**
+ * @param string $type
+ * @return array
+ */
+ protected function rules(?string $type = 'POST'): array
+ {
+ if ($type == 'POST') {
+ return [
+ 'name' => 'required',
+ 'company_module_id' => 'required',
+ ];
+ } elseif ($type == 'PUT') {
+ return [
+ ];
+ }
+ }
+
+ /**
+ * @return array
+ */
+ protected function messages(): array
+ {
+ return [];
+ }
+}
diff --git a/app/Classes/Modules/Transactions/DataTransferObjects/TransactionDetailObject.php b/app/Classes/Modules/Transactions/DataTransferObjects/TransactionDetailObject.php
index 9265f56b..ab024596 100644
--- a/app/Classes/Modules/Transactions/DataTransferObjects/TransactionDetailObject.php
+++ b/app/Classes/Modules/Transactions/DataTransferObjects/TransactionDetailObject.php
@@ -7,7 +7,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
class TransactionDetailObject implements DataTransferObject
{
/** @var string|null */
- private $code;
+ private $reference;
/** @var string|null */
private $name;
@@ -20,14 +20,14 @@ class TransactionDetailObject implements DataTransferObject
/**
* TransactionDetailObject constructor.
- * @param string $code
+ * @param string $reference
* @param string $name
* @param int $quantity
* @param float $price
*/
- public function __construct(?string $code, ?string $name , ?int $quantity, ?float $price)
+ public function __construct(?string $reference, ?string $name , ?int $quantity, ?float $price)
{
- $this->code = $code;
+ $this->reference = $reference;
$this->name = $name;
$this->quantity = $quantity;
$this->price = $price;
@@ -36,9 +36,9 @@ class TransactionDetailObject implements DataTransferObject
/**
* @return string
*/
- public function getCode(): ?string
+ public function getReference(): ?string
{
- return $this->code;
+ return $this->reference;
}
/**
@@ -70,4 +70,4 @@ class TransactionDetailObject implements DataTransferObject
return $this->getQuantity() * $this->getPrice();
}
-}
\ No newline at end of file
+}
diff --git a/app/Classes/Modules/Transactions/Processors/CreateShippingCostTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateShippingCostTransactionProcessor.php
new file mode 100644
index 00000000..5591731c
--- /dev/null
+++ b/app/Classes/Modules/Transactions/Processors/CreateShippingCostTransactionProcessor.php
@@ -0,0 +1,66 @@
+generatesTransactionBillNumber = $generatesTransactionBillNumber;
+ $this->createsShippingCostTransaction = $createsShippingCostTransaction;
+ }
+
+
+ /**
+ * @param Order $order
+ * @return void
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ */
+ public function execute(Order $order, int $quantity, float $totalCBM, float $totalShippingCost)
+ {
+ $billNumber = $this->generatesTransactionBillNumber->execute('SHP-');
+
+ $transactionObject = new TransactionObject(
+ $billNumber,
+ TransactionType::SHIPPING_COST,
+ 1,
+ $order->companyModule->company_id,
+ 1,
+ PaymentMethodType::BA,
+ $totalShippingCost,
+ $totalShippingCost,
+ 1,
+ 1,
+ 0,
+ 0,
+ 0,
+ null,
+ ApprovalStatus::PENDING_SUBMISSION
+ );
+
+ $transactionDetailObject = new TransactionDetailObject(
+ TransactionType::SHIPPING_COST,
+ 'Shipping Cost',
+ $quantity,
+ $totalShippingCost/$totalCBM
+ );
+
+ $shippingCostTransaction = $this->createsShippingCostTransaction->execute($order, $transactionObject, $transactionDetailObject);
+
+ }
+}
diff --git a/app/Classes/Modules/Transactions/Services/CreatesShippingCostTransaction.php b/app/Classes/Modules/Transactions/Services/CreatesShippingCostTransaction.php
new file mode 100644
index 00000000..e071d174
--- /dev/null
+++ b/app/Classes/Modules/Transactions/Services/CreatesShippingCostTransaction.php
@@ -0,0 +1,52 @@
+bill_no = $object->getBillNo();
+ $model->type = $object->getTransactionType();
+ $model->issuer = $object->getIssuer();
+ $model->receiver = $object->getReceiver();
+ $model->recipient_bank_account_id = $object->getRecipientBankAccountId();
+ $model->payment_method = $object->getPaymentMethod();
+ $model->amount = $object->getAmount();
+ $model->original_amount = $object->getOriginalAmount();
+ $model->currency_id = $object->getCurrencyId();
+ $model->original_currency_id = $object->getOriginalCurrencyId();
+ $model->currency_rate = $object->getCurrencyRate();
+ $model->tax = $object->getTax();
+ $model->service_charge = $object->getServiceCharge();
+ $model->expires_on = $object->getExpiresOn();
+ $model->status = $object->getStatus();
+
+ $transaction = $this->handler($order->transactions(), $model);
+
+
+ $model = new TransactionDetail();
+ $model->reference = $transactionDetailObject->getReference();
+ $model->name = $transactionDetailObject->getName();
+ $model->quantity = $transactionDetailObject->getQuantity();
+ $model->price = $transactionDetailObject->getPrice();
+ $model->amount = $transactionDetailObject->getAmount();
+
+ return $this->handler($transaction->transactionDetails(), $model);
+
+
+ }
+}
diff --git a/app/Classes/ValueObjects/Constants/BusinessType.php b/app/Classes/ValueObjects/Constants/BusinessType.php
index 376b4807..41c673c6 100644
--- a/app/Classes/ValueObjects/Constants/BusinessType.php
+++ b/app/Classes/ValueObjects/Constants/BusinessType.php
@@ -16,6 +16,6 @@ final class BusinessType {
public const DRIVER = 5;
- public const CURRENCY_VENDOR = 5;
+ public const CURRENCY_VENDOR = 6;
}
diff --git a/app/Classes/ValueObjects/Constants/PlatformType.php b/app/Classes/ValueObjects/Constants/PlatformType.php
new file mode 100644
index 00000000..d9ddd0e3
--- /dev/null
+++ b/app/Classes/ValueObjects/Constants/PlatformType.php
@@ -0,0 +1,9 @@
+ self::KLANG,
- 2 => self::KLANG,
- 3 => self::KLANG,
- 4 => self::KLANG,
- 5 => self::SABAH,
- 6 => self::KLANG,
- 7 => self::KLANG,
- 8 => self::KLANG,
- 9 => self::KLANG,
- 10 => self::KLANG,
- 11 => self::KLANG,
- 12 => self::KLANG,
- 13 => self::SABAH,
- 14 => self::KLANG,
- 15 => self::KLANG,
- 16 => self::KLANG,
+ public const VT_SABAH = 'SB-V01';
+
+ public const VT_SARAWAK = 'SRW-V01';
+
+ public const VT_DESTINATION_WAREHOUSE = [
+ 1 => self::VT_KLANG,
+ 2 => self::VT_KLANG,
+ 3 => self::VT_KLANG,
+ 4 => self::VT_KLANG,
+ 5 => self::VT_SABAH,
+ 6 => self::VT_KLANG,
+ 7 => self::VT_KLANG,
+ 8 => self::VT_KLANG,
+ 9 => self::VT_KLANG,
+ 10 => self::VT_KLANG,
+ 11 => self::VT_KLANG,
+ 12 => self::VT_KLANG,
+ 13 => self::VT_SABAH,
+ 14 => self::VT_KLANG,
+ 15 => self::VT_KLANG,
+ 16 => self::VT_KLANG,
];
+ public const YD_DESTINATION_WAREHOUSE = self::YD_KLANG;
+
}
diff --git a/app/Http/Controllers/Accounts/UserCrossAuthenticationController.php b/app/Http/Controllers/Accounts/UserCrossAuthenticationController.php
new file mode 100644
index 00000000..0d501698
--- /dev/null
+++ b/app/Http/Controllers/Accounts/UserCrossAuthenticationController.php
@@ -0,0 +1,21 @@
+execute($request);
+ }
+
+}
diff --git a/app/Http/Controllers/Companies/AssignCompanyConnectionToConnectionSegmentController.php b/app/Http/Controllers/Companies/AssignCompanyConnectionToConnectionSegmentController.php
new file mode 100644
index 00000000..fab9e692
--- /dev/null
+++ b/app/Http/Controllers/Companies/AssignCompanyConnectionToConnectionSegmentController.php
@@ -0,0 +1,20 @@
+execute($request);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Companies/RemoveCompanyConnectionFromConnectionSegmentController.php b/app/Http/Controllers/Companies/RemoveCompanyConnectionFromConnectionSegmentController.php
new file mode 100644
index 00000000..c3336b8c
--- /dev/null
+++ b/app/Http/Controllers/Companies/RemoveCompanyConnectionFromConnectionSegmentController.php
@@ -0,0 +1,20 @@
+execute($request);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Orders/CreateOrderRemarkController.php b/app/Http/Controllers/Orders/CreateOrderRemarkController.php
new file mode 100644
index 00000000..3464566a
--- /dev/null
+++ b/app/Http/Controllers/Orders/CreateOrderRemarkController.php
@@ -0,0 +1,14 @@
+execute($request);
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Orders/ShippingCostController.php b/app/Http/Controllers/Orders/ShippingCostController.php
new file mode 100644
index 00000000..c86f8735
--- /dev/null
+++ b/app/Http/Controllers/Orders/ShippingCostController.php
@@ -0,0 +1,20 @@
+execute($request);
+ }
+}
diff --git a/app/Http/Controllers/PackingLists/Containers/CreateContainerRemarkController.php b/app/Http/Controllers/PackingLists/Containers/CreateContainerRemarkController.php
new file mode 100644
index 00000000..5f8e5153
--- /dev/null
+++ b/app/Http/Controllers/PackingLists/Containers/CreateContainerRemarkController.php
@@ -0,0 +1,16 @@
+execute($request);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/PackingLists/CreateDeliverPackingListController.php b/app/Http/Controllers/PackingLists/CreateDeliverPackingListController.php
new file mode 100644
index 00000000..0b3751e1
--- /dev/null
+++ b/app/Http/Controllers/PackingLists/CreateDeliverPackingListController.php
@@ -0,0 +1,20 @@
+execute($request);
+ }
+
+}
diff --git a/app/Http/Controllers/Reports/MonthlyReportController.php b/app/Http/Controllers/Reports/MonthlyReportController.php
index 6179dea3..f9335360 100644
--- a/app/Http/Controllers/Reports/MonthlyReportController.php
+++ b/app/Http/Controllers/Reports/MonthlyReportController.php
@@ -5,18 +5,15 @@ namespace App\Http\Controllers\Reports;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\BusinessType;
use App\Classes\ValueObjects\Constants\HttpStatus;
-use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Response\ApiResponseObject;
use App\Models\CompanyConnection;
use App\Models\CompanyModule;
use App\Models\Container;
use App\Models\Order;
use App\Models\Package;
-use App\Models\PackingList;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
-use Illuminate\Support\Facades\DB;
class MonthlyReportController
{
@@ -77,6 +74,50 @@ class MonthlyReportController
]]))->handler();
}
+ public function profitModelReport(Request $request): JsonResponse {
+ $from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth();
+ $to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth();
+ $model = (int) $request->route('model');
+ $value = (float) $request->route('value');
+
+
+ $containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
+
+ $packages = $containers->flatMap(function ($container) {
+ return $container->packages;
+ });
+
+ $totalCbm = $packages->sum(function($package){
+ return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
+ });
+
+ $projectedCbm = $packages->sum(function($package) use ($value, $model) {
+
+ if($model === 2){
+ return (( (float) ($package->width + ($package->width * ($value/100))) / 100) * ( (float) ($package->length + ($package->length * ($value/100))) / 100) * ( (float) ($package->height + ($package->height * ($value/100))) / 100)) * $package->quantity;
+ }
+
+ if($model === 3){
+ return ((( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) + $value) * $package->quantity;
+ }
+
+ if($model === 4){
+ $packageCbm = (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100));
+ return ( $packageCbm + ($packageCbm * ($value/100))) * $package->quantity;
+ }
+
+ return (( (float) ($package->width + $value) / 100) * ( (float) ($package->length + $value) / 100) * ( (float) ($package->height + $value) / 100)) * $package->quantity;
+
+ });
+
+ return (new ApiResponseObject('fetch monthly report Successful',
+ '',
+ HttpStatus::OK_WITH_MESSAGE, ['data' => [
+ 'total_cbm' => $totalCbm,
+ 'projected_cbm' => $projectedCbm,
+ ]]))->handler();
+ }
+
public function customerReport(Request $request): JsonResponse {
$connection = CompanyConnection::where('invitee_reference', $request->route('marking'))->firstOrFail();
diff --git a/app/Http/Controllers/Segments/CreateSegmentController.php b/app/Http/Controllers/Segments/CreateSegmentController.php
new file mode 100644
index 00000000..4e748536
--- /dev/null
+++ b/app/Http/Controllers/Segments/CreateSegmentController.php
@@ -0,0 +1,20 @@
+execute($request);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Segments/DeleteSegmentController.php b/app/Http/Controllers/Segments/DeleteSegmentController.php
new file mode 100644
index 00000000..91e95c5f
--- /dev/null
+++ b/app/Http/Controllers/Segments/DeleteSegmentController.php
@@ -0,0 +1,20 @@
+execute($request);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Http/Resources/CompanyModuleResource.php b/app/Http/Resources/CompanyModuleResource.php
index 31e17598..e1f253be 100644
--- a/app/Http/Resources/CompanyModuleResource.php
+++ b/app/Http/Resources/CompanyModuleResource.php
@@ -35,6 +35,8 @@ class CompanyModuleResource extends JsonResource
return [
'id' => $this->id,
'type' => $this->type,
+ 'name' => $this->name,
+ 'reference' => $this->reference,
'address' => new AddressResource($defaultAddress),
'company' => new CompanyResource($this->whenLoaded('company')),
'marking' => $marking
diff --git a/app/Http/Resources/DeliverPackingListResource.php b/app/Http/Resources/DeliverPackingListResource.php
new file mode 100644
index 00000000..7dd7e658
--- /dev/null
+++ b/app/Http/Resources/DeliverPackingListResource.php
@@ -0,0 +1,27 @@
+ $this->id,
+ 'claimant_id' => $this->claimant_id,
+ 'reference' => $this->reference,
+ 'status' => $this->status,
+ 'transport' => new TransportResource($this->transports()->first()),
+ 'packing_list' => PackingListResource::collection($this->packing_list_owner),
+ 'company' => New CompanyModuleResource($this->owner)
+ ];
+ }
+}
diff --git a/app/Http/Resources/OrderResource.php b/app/Http/Resources/OrderResource.php
index 27dfe4da..0c30bb62 100644
--- a/app/Http/Resources/OrderResource.php
+++ b/app/Http/Resources/OrderResource.php
@@ -29,27 +29,24 @@ class OrderResource extends JsonResource
'warehouse' => new CompanyModuleResource($this->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee),
'address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first()),
'address_change_request' => new AddressResource($this->addressesPendingVerification()->first()),
- 'parcels' => $this->whenLoaded('packingLists', function(){
+ 'parcels' => $this->whenLoaded('packingLists', function() {
return [
- 'origin_warehouse_packages' => PackageResource::collection($this->parcels()->shippingList()->whereDoesntHave('shippingSchedules', function($schedule){
- return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
- })->get()),
- 'in_transit_packages' => PackageResource::collection($this->parcels()->shippingList()->Shipping()->whereHas('shippingSchedules', function($schedule){
- return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
- })->whereDoesntHave('container', function($container){
- return $container->where('containers.status', ApprovalStatus::COMPLETED);
- })->get()),
- 'destination_warehouse_packages' => PackageResource::collection($this->parcels()->shippingList()->whereHas('container', function($container){
- return $container->where('containers.status', ApprovalStatus::COMPLETED);
- })->whereDoesntHave('deliverySchedules', function($schedule){
- return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
- })->get()),
- 'delivered_packages' => PackageResource::collection($this->parcels()->shippingList()->whereHas('deliverySchedules', function($schedule){
- return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
- })->get()),
+ 'origin_warehouse_packages' => PackageResource::collection(
+ $this->originWarehousePackages()->get()
+ ),
+ 'in_transit_packages' => PackageResource::collection(
+ $this->inTransitPackages()->get()
+ ),
+ 'destination_warehouse_packages' => PackageResource::collection(
+ $this->destinationWarehousePackages()->get()
+ ),
+ 'delivered_packages' => PackageResource::collection(
+ $this->deliveredPackages()->get()
+ ),
'received_packages' => PackageResource::collection($this->parcels()->warehouseReceiveList()->get()),
];
}),
+ 'remarks' => RemarkResource::collection($this->remarks),
'created_at' => $this->created_at->format('d-m-Y')
];
diff --git a/app/Http/Resources/SegmentResource.php b/app/Http/Resources/SegmentResource.php
index 58118e08..a4e1c858 100644
--- a/app/Http/Resources/SegmentResource.php
+++ b/app/Http/Resources/SegmentResource.php
@@ -18,10 +18,10 @@ class SegmentResource extends JsonResource
return [
'id' => $this->id,
'name' => $this->name,
- 'time_limit' => $this->when($this->whereHas('constants', function($query){
- $query->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT);
- }), $this->constants->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT)->first()),
- 'services' => CustomServiceTypeResource::collection($this->constants->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE))
+ // 'time_limit' => $this->when($this->whereHas('constants', function($query){
+ // $query->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT);
+ // }), $this->constants->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT)->first()),
+ // 'services' => CustomServiceTypeResource::collection($this->constants->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE))
];
}
}
diff --git a/app/Models/Company.php b/app/Models/Company.php
index c7b5b221..6305b971 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -4,18 +4,11 @@ namespace App\Models;
use App\Classes\General\Interfaces\Documentable;
use App\Classes\General\Interfaces\Contactable;
-use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceConfigurationsObject;
-use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\BusinessType;
-use App\Classes\ValueObjects\Constants\SegmentConstants;
-use Illuminate\Database\Eloquent\Builder;
-use Illuminate\Database\Eloquent\Relations\BelongsToMany;
-
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
-use Illuminate\Support\Collection;
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
diff --git a/app/Models/CompanyConnection.php b/app/Models/CompanyConnection.php
index f1d00276..b382e237 100644
--- a/app/Models/CompanyConnection.php
+++ b/app/Models/CompanyConnection.php
@@ -60,4 +60,13 @@ class CompanyConnection extends AbstractModel
return $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
}
+
+ /**
+ * @return belongsToMany
+ */
+ public function segments(): belongsToMany
+ {
+ return $this->belongsToMany(Segment::class, (new ConnectionSegment())->getTable(), 'company_connection_id', 'segment_id');
+ }
+
}
diff --git a/app/Models/CompanyModule.php b/app/Models/CompanyModule.php
index eecc0118..b0058389 100644
--- a/app/Models/CompanyModule.php
+++ b/app/Models/CompanyModule.php
@@ -6,6 +6,8 @@ use App\Classes\General\Interfaces\Addressable;
use App\Classes\General\Interfaces\Contactable;
use App\Classes\General\Interfaces\ContainerOwner;
use App\Classes\General\Interfaces\Documentable;
+use App\Classes\General\Interfaces\Packable;
+
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\BusinessType;
use Illuminate\Database\Eloquent\Builder;
@@ -28,7 +30,7 @@ use PhpParser\Node\Expr\AssignOp\Mod;
* @property integer type
* @property integer status
*/
-class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable, ContainerOwner
+class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable, ContainerOwner, Packable
{
use SoftDeletes;
@@ -60,6 +62,14 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
return $this->morphMany(Address::class, 'owner');
}
+ /**
+ * @return MorphMany
+ */
+ public function packingLists(): morphMany
+ {
+ return $this->morphMany(PackingList::class, 'owner');
+ }
+
/**
* @return belongsToMany
*/
diff --git a/app/Models/ConnectionSegment.php b/app/Models/ConnectionSegment.php
new file mode 100644
index 00000000..468ba877
--- /dev/null
+++ b/app/Models/ConnectionSegment.php
@@ -0,0 +1,38 @@
+HasMany(Segment::class, 'segment_id', 'id');
+ }
+
+ /**
+ * @return HasMany
+ */
+ public function companyConnections(): HasMany
+ {
+ return $this->HasMany(CompanyConnection::class, 'company_connection_id', 'id');
+ }
+}
diff --git a/app/Models/Container.php b/app/Models/Container.php
index 93aaeee5..21f59843 100644
--- a/app/Models/Container.php
+++ b/app/Models/Container.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use App\Classes\General\Interfaces\Remarkable;
use App\Classes\General\Interfaces\Transportable;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -9,7 +10,7 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
-class Container extends AbstractModel implements Transportable
+class Container extends AbstractModel implements Transportable, Remarkable
{
use HasRelationships;
use SoftDeletes;
@@ -56,4 +57,13 @@ class Container extends AbstractModel implements Transportable
{
return $this->morphMany(Transport::class, 'owner');
}
+
+ /**
+ * @return MorphMany
+ */
+ public function remarks(): morphMany
+ {
+ return $this->morphMany(Remark::class, 'owner');
+ }
+
}
diff --git a/app/Models/Order.php b/app/Models/Order.php
index 9d3099a5..3923d913 100644
--- a/app/Models/Order.php
+++ b/app/Models/Order.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Classes\General\Interfaces\Addressable;
use App\Classes\General\Interfaces\Contactable;
use App\Classes\General\Interfaces\Packable;
+use App\Classes\General\Interfaces\Remarkable;
use App\Classes\ValueObjects\Constants\RoleTypes;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Scopes\CustomerOrdersScope;
@@ -14,7 +15,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
-class Order extends AbstractModel implements Addressable, Packable
+class Order extends AbstractModel implements Addressable, Packable, Remarkable
{
use SoftDeletes;
@@ -88,4 +89,71 @@ class Order extends AbstractModel implements Addressable, Packable
{
return $this->addresses()->where('status','=',ApprovalStatus::APPROVED);
}
+
+ public function originWarehousePackages()
+ {
+ return $this->parcels()->shippingList()
+ ->whereDoesntHave('shippingSchedules',
+ function($schedule) {
+ return $schedule->dispatched()
+ ->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
+ }
+ );
+ }
+
+ public function inTransitPackages()
+ {
+ return $this->parcels()->shippingList()->Shipping()
+ ->whereHas('shippingSchedules',
+ function($schedule) {
+ return $schedule->dispatched()
+ ->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
+ }
+ )
+ ->whereDoesntHave('container', function($container) {
+ return $container->where('containers.status', ApprovalStatus::COMPLETED);
+ }
+ );
+ }
+
+ public function destinationWarehousePackages()
+ {
+ return $this->parcels()->shippingList()
+ ->whereHas('container',
+ function($container) {
+ return $container->where('containers.status', ApprovalStatus::COMPLETED);
+ }
+ )
+ ->whereDoesntHave('deliverySchedules',
+ function($schedule) {
+ return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
+ }
+ );
+ }
+
+ public function deliveredPackages()
+ {
+ return $this->parcels()->shippingList()
+ ->whereHas('deliverySchedules',
+ function($schedule) {
+ return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
+ }
+ );
+ }
+
+ /**
+ * @return morphMany
+ */
+ public function transactions(): morphMany
+ {
+ return $this->morphMany(Transaction::class, 'owner');
+ }
+
+ /**
+ * @return MorphMany
+ */
+ public function remarks(): morphMany
+ {
+ return $this->morphMany(Remark::class, 'owner');
+ }
}
diff --git a/app/Models/PackingList.php b/app/Models/PackingList.php
index 1bbfa6ac..550d5f6f 100644
--- a/app/Models/PackingList.php
+++ b/app/Models/PackingList.php
@@ -56,4 +56,11 @@ class PackingList extends AbstractModel implements Transportable, Steppable
return $this->morphMany(Transport::class, 'owner');
}
+ /**
+ * @return belongsToMany
+ */
+ public function packing_list_owner()
+ {
+ return $this->BelongsToMany(PackingList::class, 'packing_list_owner', 'owner_packing_list_id', 'packing_list_id');
+ }
}
diff --git a/app/Models/PackingListOwner.php b/app/Models/PackingListOwner.php
new file mode 100644
index 00000000..2e64c5f0
--- /dev/null
+++ b/app/Models/PackingListOwner.php
@@ -0,0 +1,11 @@
+HasMany(SegmentConstant::class, 'segment_id', 'id');
}
+
+ /**
+ * @return belongsToMany
+ */
+ public function companyConnections(): belongsToMany
+ {
+ return $this->belongsToMany(CompanyConnection::class, (new ConnectionSegment())->getTable(), 'segment_id', 'company_connection_id');
+ }
}
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index 0e39c289..232964d9 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -16,12 +16,17 @@ class Transaction extends AbstractModel implements Documentable
{
protected $table = 'transactions';
- /**
- * @return BelongsTo
- */
- public function booking(): BelongsTo
+ public function owner(): morphTo
{
- return $this->BelongsTo( Booking::class, 'booking_id', 'id');
+ return $this->morphTo();
+ }
+
+ /**
+ * @return MorphMany
+ */
+ public function order(): morphMany
+ {
+ return $this->morphMany(Order::class, 'owner');
}
/**
diff --git a/app/Models/TransactionDetail.php b/app/Models/TransactionDetail.php
index 8e0a1613..c70f3989 100644
--- a/app/Models/TransactionDetail.php
+++ b/app/Models/TransactionDetail.php
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class TransactionDetail extends AbstractModel
{
- protected $table = 'transaction_detail';
+ protected $table = 'transaction_details';
/**
* @return BelongsTo
diff --git a/app/Models/UserSocialAccount.php b/app/Models/UserSocialAccount.php
new file mode 100644
index 00000000..71aa73d8
--- /dev/null
+++ b/app/Models/UserSocialAccount.php
@@ -0,0 +1,32 @@
+belongsTo(User::class, 'user_id', 'id');
+ }
+}
diff --git a/database/migrations/2021_06_25_014731_create_segments_table.php b/database/migrations/2021_06_25_014731_create_segments_table.php
index 53b78248..e9c3c3eb 100644
--- a/database/migrations/2021_06_25_014731_create_segments_table.php
+++ b/database/migrations/2021_06_25_014731_create_segments_table.php
@@ -19,6 +19,8 @@ class CreateSegmentsTable extends Migration
$table->id();
$table->foreignId('company_module_id');
$table->string('name', '45');
+ $table->softDeletes();
+ $table->timestamps();
});
}
diff --git a/database/migrations/2021_06_25_014830_create_segment_constants_table.php b/database/migrations/2021_06_25_014830_create_segment_constants_table.php
index f62d0308..6ba52998 100644
--- a/database/migrations/2021_06_25_014830_create_segment_constants_table.php
+++ b/database/migrations/2021_06_25_014830_create_segment_constants_table.php
@@ -18,6 +18,8 @@ class CreateSegmentConstantsTable extends Migration
$table->foreignId('segment_id');
$table->string('reference','45');
$table->json('value');
+ $table->softDeletes();
+ $table->timestamps();
});
}
diff --git a/database/migrations/2021_06_25_014835_create_connection_segments_table.php b/database/migrations/2021_06_25_014835_create_connection_segments_table.php
index 92a3d5f1..a454ccd0 100644
--- a/database/migrations/2021_06_25_014835_create_connection_segments_table.php
+++ b/database/migrations/2021_06_25_014835_create_connection_segments_table.php
@@ -17,6 +17,8 @@ class CreateConnectionSegmentsTable extends Migration
$table->id();
$table->foreignId('company_connection_id');
$table->foreignId('segment_id');
+ $table->softDeletes();
+ $table->timestamps();
});
}
diff --git a/database/migrations/2021_09_01_212235_create_user_social_accounts_table.php b/database/migrations/2021_09_01_212235_create_user_social_accounts_table.php
new file mode 100644
index 00000000..612f47c6
--- /dev/null
+++ b/database/migrations/2021_09_01_212235_create_user_social_accounts_table.php
@@ -0,0 +1,35 @@
+id();
+ $table->foreignId('user_id');
+ $table->string('app_id')->nullable();
+ $table->integer('platform')->default(0);
+ $table->softDeletes();
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('user_social_accounts');
+ }
+}
diff --git a/database/migrations/2021_10_06_210435_create_packing_list_owners_table.php b/database/migrations/2021_10_06_210435_create_packing_list_owners_table.php
new file mode 100644
index 00000000..ce290227
--- /dev/null
+++ b/database/migrations/2021_10_06_210435_create_packing_list_owners_table.php
@@ -0,0 +1,31 @@
+foreignId('owner_packing_list_id');
+ $table->foreignId('packing_list_id');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('packing_list_owners');
+ }
+}
diff --git a/database/migrations/2021_10_16_223035_create_transactions_table.php b/database/migrations/2021_10_16_223035_create_transactions_table.php
new file mode 100644
index 00000000..a40b43ea
--- /dev/null
+++ b/database/migrations/2021_10_16_223035_create_transactions_table.php
@@ -0,0 +1,63 @@
+id();
+ $table->morphs('owner');
+ $table->string('type')->default(TransactionType::PAYMENT);
+ $table->foreignId('issuer')->unsigned();
+ $table->foreignId('receiver')->unsigned();
+ $table->foreignId('recipient_bank_account_id')->unsigned();
+ $table->string('payment_method')->nullable();
+ $table->string('payment_reference')->nullable();
+ $table->string('bill_no')->unique();
+ $table->decimal('amount', 25, 5)->default(0.00);
+ $table->decimal('original_amount', 25, 5)->default(0.00);
+ $table->foreignId('currency_id')->unsigned();
+ $table->foreignId('original_currency_id')->unsigned();
+ $table->decimal('currency_rate', 14, 5)->default(0.00);
+ $table->decimal('tax', 14, 5)->default(0.00);
+ $table->decimal('service_charge', 14, 5)->default(0.00);
+ $table->timestamp('expires_on')->nullable();
+ $table->integer('status')->default(ApprovalStatus::PENDING_SUBMISSION);
+ $table->softDeletes();
+ $table->timestamps();
+
+ $table->foreign('currency_id')->references('id')->on('currencies');
+ $table->foreign('issuer')->references('id')->on('companies');
+ $table->foreign('receiver')->references('id')->on('companies');
+ $table->foreign('original_currency_id')->references('id')->on('currencies');
+
+ });
+
+ //In-case the model name lengthy
+ Schema::table('transactions', function (Blueprint $table) {
+ $table->string('owner_type', 250)->change();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('transactions');
+ }
+}
diff --git a/database/migrations/2021_10_16_223129_create_transaction_details_table.php b/database/migrations/2021_10_16_223129_create_transaction_details_table.php
new file mode 100644
index 00000000..d08dd7f1
--- /dev/null
+++ b/database/migrations/2021_10_16_223129_create_transaction_details_table.php
@@ -0,0 +1,41 @@
+id();
+ $table->foreignId('transaction_id')->unsigned();
+ $table->string('reference');
+ $table->string('name');
+ $table->integer('quantity')->default(0);
+ $table->decimal('price', 25, 5)->default(0.00);
+ $table->decimal('amount', 25, 5)->default(0.00);
+ $table->softDeletes();
+ $table->timestamps();
+
+ $table->foreign('transaction_id')->references('id')->on('transactions');
+
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('transaction_details');
+ }
+}
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index bba317e6..983c7aad 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -23,7 +23,7 @@ class DatabaseSeeder extends Seeder
$this->call(CountriesTableSeeder::class);
$this->call(CurrenciesTableSeeder::class);
- $this->call(CompaniesTableSeeder::class);
- $this->call(OrdersTableSeeder::class);
+ // $this->call(CompaniesTableSeeder::class);
+ // $this->call(OrdersTableSeeder::class);
}
}
\ No newline at end of file
diff --git a/database/seeders/ModernWarehouseTableSeeder.php b/database/seeders/ModernWarehouseTableSeeder.php
new file mode 100644
index 00000000..42058cfd
--- /dev/null
+++ b/database/seeders/ModernWarehouseTableSeeder.php
@@ -0,0 +1,122 @@
+createCompanyProcessor = $createCompanyProcessor;
+ $this->updatesCompanyStatus = $updatesCompanyStatus;
+ $this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
+ $this->createContactProcessor = $createContactProcessor;
+ $this->createsCompanyConnection = $createsCompanyConnection;
+ $this->approvesCompanyConnection = $approvesCompanyConnection;
+ $this->createAddressFromOldAddressProcessor = $createAddressFromOldAddressProcessor;
+ $this->createsAddress = $createsAddress;
+ $this->createsCompany = $createsCompany;
+ $this->createsContact = $createsContact;
+ }
+
+
+ /**
+ * Run the database seeds.
+ *
+ * @return void
+ * @throws \App\Classes\Exceptions\AccessForbiddenException
+ * @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ public function run()
+ {
+
+ /** @var Company $company */
+ $company = $this->createsCompany->execute(new CompanyObject('Modern', 'MODERN', CompanyType::COMPANY_BUSINESS, ApprovalStatus::APPROVED));
+
+ /** @var CompanyModule $companyModule */
+ $this->createCompanyModuleProcessor->execute($company, BusinessType::FREIGHT_FORWARDER);
+
+ $companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::WAREHOUSE);
+
+ $companyModule->update(['name' => 'Guangzhou', 'reference' => 'GZ-V02']);
+ $address = new AddressObject('白云区 白云湖街道 大朗北路 大朗生活区 523A', '(公交车总站对面)', 2, 35, 633, 510000);
+
+ $contact = new ContactObject('郑学钟', '18665696389', '', '');
+ $this->createsAddress->execute($companyModule, $address);
+ $this->createsContact->execute($companyModule, $contact);
+
+ $companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::WAREHOUSE);
+ $companyModule->update(['name' => 'Klang', 'reference' => 'KL-V02']);
+
+
+ }
+
+}
diff --git a/resources/assets/sass/modules/_typography.scss b/resources/assets/sass/modules/_typography.scss
index f72c91ce..dbc80e6f 100644
--- a/resources/assets/sass/modules/_typography.scss
+++ b/resources/assets/sass/modules/_typography.scss
@@ -231,7 +231,7 @@ hr{
font-weight: normal;
}
.semi-bold {
- font-weight: 400 !important;
+ font-weight: 600 !important;
}
.bold {
font-weight: bold !important;
diff --git a/resources/assets/vue/components/accounts/forms/CrossPlatformLoginFormComponent.vue b/resources/assets/vue/components/accounts/forms/CrossPlatformLoginFormComponent.vue
new file mode 100644
index 00000000..db4747bf
--- /dev/null
+++ b/resources/assets/vue/components/accounts/forms/CrossPlatformLoginFormComponent.vue
@@ -0,0 +1,66 @@
+
+
ETA
{{item.transport ? item.transport.current_schedule.eta : 'n/a'}}
Packages
+{{ item.packing_lists.reduce((total, obj) => total + obj.packages.reduce((total, obj) => obj.quantity + total, 0), 0) }}
+Loaded CBM
{{ (Math.ceil((item.packing_lists.reduce((total, obj) => total + obj.packages.reduce((total, obj) => obj.cbm + total, 0), 0)) * 1000) / 1000).toFixed(3) }}
@@ -46,7 +50,7 @@Item Returned
+5 September 2021
+Item has been returned due to mismatch
+Client Report
+21 August 2021
+Client report order number #012AS12W
+Item Cancelled
+8 May 2021
+Item has been cancelled by clients number #012ASJ21
+Item Cancelled
+8 May 2021
+Item has been cancelled by clients number #012ASJ21
+Client Report
+21 August 2021
+Client report order number #012AS12W
+Item Returned
-5 September 2021
-Item has been returned due to mismatch
-Client Report
-21 August 2021
-Client report order number #012AS12W
-Item Cancelled
-8 May 2021
-Item has been cancelled by clients number #012ASJ21
-Item Cancelled
-8 May 2021
-Item has been cancelled by clients number #012ASJ21
-Client Report
-21 August 2021
-Client report order number #012AS12W
-Jacob Arlington
+Adipisicing occaecat pariatur id sunt ullamco quis laborum irure ea excepteur enim dolore est. Deserunt do consectetur ex in dolor labore ad reprehenderit velit laboris officia ut.
+Jacob Arlington
-Adipisicing occaecat pariatur id sunt ullamco quis laborum irure ea excepteur enim dolore est. Deserunt do consectetur ex in dolor labore ad reprehenderit velit laboris officia ut.
-Jacob Arlington
Jacob Arlington
-Adipisicing occaecat pariatur id sunt ullamco quis laborum irure ea excepteur enim dolore est. Deserunt do consectetur ex in dolor labore ad reprehenderit velit laboris officia ut.
-Adipisicing occaecat pariatur id sunt ullamco quis laborum irure ea excepteur enim dolore est. Deserunt do consectetur ex in dolor labore ad reprehenderit velit laboris officia ut.
+
+ {{item.length}}
+ +通告!NOTICE!
+!!!! 海运费涨价通知 NOTICE OF PRICE INCREMENT !!!
由于广州地区台风来袭, 广州港口船务公司暂停操作,在此前进仓的货物时效上会受到一些影响。
-年底不定性因素比较多,恳请大家提前做好采购安排,以免货物延迟照成不必要的损失
-Due to the typhoon in Guangzhou area, shipping liners in Guangzhou port suspended its operation, the duration of shipment for your recent goods will be affected.
-As there are many uncertainties during the year end, please ensure your purchase arrangements in advance to avoid unnecessary losses due to cargo delays.
+由于最近船公司正缩减仓位, 导致持续推高海运费。
+所以从 10/11/2021 开始入仓广州仓库的货物会有所调整。
+广州 - 西马运费+RM50/立方
+有造成不便之处,敬请见谅!谢谢合作
+Shortage of container is getting terrible in the whole worldwide due to Shipping liner company consolidating their ship
+Therefore, the shipping fee from Guangzhou to West Malaysia will be adjusted start from good entering warehouse by 10/11/2021
+Guangzhou - West Malaysia +RM50/CBM
+We apologize that any inconvenience caused! Thanks for your cooperation.
仓库地址:
-{{$warehouse_address->street_one.' '.$warehouse_address->street_two.' '.$warehouse_address->district->name.' '.$warehouse_address->state->name.' 邮编:'.$warehouse_address->postcode}}
+{{$warehouse_address->state->name.' '.$warehouse_address->district->name.' '.$warehouse_address->street_one.' '.$warehouse_address->street_two.' 邮编:'.$warehouse_address->postcode}}
联系:@foreach($warehouse_contacts as $contact){{ $loop->first ? '' : ' / ' }}{{ $contact->phone.' '.$contact->reference }}@endforeach