mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-21 13:34:00 +00:00
Compare commits
353 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6842e3f1db | |||
| 0d6df7ec0c | |||
| dd38f41f47 | |||
| 062b2fb908 | |||
| 7c027ef62f | |||
| 6137012a35 | |||
| c79f4cfdab | |||
| 073f89be12 | |||
| 3752d71b4f | |||
| b82f3b9f45 | |||
| 4a3b3344e7 | |||
| ae42e1e03b | |||
| 8ba5f95690 | |||
| 70cc67a559 | |||
| 149376e4b5 | |||
| d5dd880d9e | |||
| fa628e81ac | |||
| 51a6569cf0 | |||
| 886f091f6a | |||
| b22b4c374a | |||
| 2b065cb4a8 | |||
| bcf7ae4098 | |||
| b355df27db | |||
| c33649fda2 | |||
| 4615843e17 | |||
| 40f51a0f60 | |||
| 2c3dff7e77 | |||
| 8178cda2b4 | |||
| 04215916f5 | |||
| 25f9db99c7 | |||
| 04f248e88d | |||
| 70e53c197c | |||
| 642731b680 | |||
| 7bd3ae056d | |||
| e58805a023 | |||
| fdce49ea82 | |||
| 90a0c4ddf5 | |||
| f963b012ec | |||
| d8289599c9 | |||
| 7965398c5a | |||
| a1b5737935 | |||
| 72400f2ab2 | |||
| 6badfadd2d | |||
| b9a65005e6 | |||
| 190ed6c5f9 | |||
| 7c96f3039a | |||
| fbb7d31726 | |||
| 3d1fb48cfb | |||
| f2e944cc0b | |||
| 44d7507cbd | |||
| 0a32d64e8d | |||
| f1edf72fb8 | |||
| c85248bc0f | |||
| 1aad4de653 | |||
| ae031078bc | |||
| d5d2a13e31 | |||
| 6809bfc693 | |||
| a21465992f | |||
| f844f5d879 | |||
| 959e5dc970 | |||
| 149469598e | |||
| fce976ff6b | |||
| 4b0e1b4b78 | |||
| e6f13fd3d0 | |||
| 8a40ea35ee | |||
| 19d0802d0e | |||
| 95bd1ca6af | |||
| e6c42ef55c | |||
| a9c914b41c | |||
| c00239c959 | |||
| b4844874bb | |||
| 1b3c63e05d | |||
| c3b0e55271 | |||
| 9463bc9478 | |||
| 500917fbba | |||
| 9af8dd0d0e | |||
| 2895acc8fc | |||
| 33cd2cef7d | |||
| d2485eaae7 | |||
| 0a5aa9843d | |||
| 0dbdeba0d2 | |||
| fbd108e8e8 | |||
| 52ec457b52 | |||
| f159bf7982 | |||
| 5386700762 | |||
| 5aefef5366 | |||
| 943ec5f7f7 | |||
| 647103f387 | |||
| 9340d4360e | |||
| ebbe2c7863 | |||
| 73dbb41044 | |||
| 3dfceeaf37 | |||
| 509f14c790 | |||
| 33a8d370c5 | |||
| ad4b8a821c | |||
| 6c276b59b1 | |||
| b57a511bb6 | |||
| 8314820204 | |||
| a2cc1e5e4f | |||
| 17fb297942 | |||
| b12da6ff44 | |||
| cf78e92c5f | |||
| 7db7553dca | |||
| fa1871d712 | |||
| 16b35b34b3 | |||
| 33f152ae9c | |||
| 93c9412298 | |||
| c74e2927ad | |||
| 95f52b3a62 | |||
| 24a286a5a2 | |||
| bbc247d67e | |||
| 019073afc5 | |||
| feb04e8498 | |||
| 557d85ef8d | |||
| 1e5df1d64b | |||
| 186d6f71c6 | |||
| 2f11666539 | |||
| 87e9dbe3ec | |||
| 626ba6bbf4 | |||
| 8b5ac008d3 | |||
| ccd7d91076 | |||
| 7bde77036d | |||
| bf7443887c | |||
| 933f39d280 | |||
| 463d342441 | |||
| 27e856bc4d | |||
| 8f381b42f3 | |||
| 1af45e5132 | |||
| 6c5bbf842e | |||
| 96d701bc80 | |||
| 9221bd094c | |||
| c76271d8ab | |||
| 26a0bc186e | |||
| 2305ddb39d | |||
| c66273874d | |||
| 9ef636c5d5 | |||
| 9b9292546b | |||
| 2974fe4e9a | |||
| e93da67ec1 | |||
| 7c14b74dd1 | |||
| b9b05dfdbe | |||
| e5e00bb9ac | |||
| c6e222caf2 | |||
| 973ab58818 | |||
| 2ae879fd51 | |||
| 8e9db507f6 | |||
| 943f5ce64e | |||
| 2c3ea9e3f1 | |||
| a69ecc2825 | |||
| d13aad9566 | |||
| 579200fd61 | |||
| 37d06798aa | |||
| 09a3654e2f | |||
| 1c5fbec0b9 | |||
| c8820ad39e | |||
| 4122ac4153 | |||
| 6959370b7a | |||
| d7b4e716d8 | |||
| d7f3b656f7 | |||
| 3b20e240ee | |||
| aa39adaeb8 | |||
| f0ebd20c5e | |||
| 0b3ae1f8df | |||
| 27684a2940 | |||
| ed637739cc | |||
| a0531e344c | |||
| 9073d86859 | |||
| ce20a941cd | |||
| b98ab2749a | |||
| 5363034649 | |||
| e83ed7a339 | |||
| 09f598ffe5 | |||
| 9719f1da77 | |||
| 0c63a9e7ca | |||
| 7d332f01e5 | |||
| 24ea9d381e | |||
| 9aec13da74 | |||
| 16573e9e00 | |||
| 8039446db5 | |||
| a8e26c4dd6 | |||
| 65493e6c90 | |||
| 36018f48b4 | |||
| bf07a92873 | |||
| fd8d9bd0db | |||
| 5b105caf0b | |||
| 1c5d814790 | |||
| c7b4b75982 | |||
| fbfe68c1c2 | |||
| 06b1258b55 | |||
| b668708bd5 | |||
| 13719d56a4 | |||
| 26b4f012a8 | |||
| ad2d54cf0e | |||
| e84f9d8bef | |||
| d7e2366fed | |||
| f7c6873316 | |||
| b8a145cb5c | |||
| b5076a6f9d | |||
| 2f6055c577 | |||
| 05ee6b3e98 | |||
| 4626eb937e | |||
| 2be9a3dcfe | |||
| 1f05c4b56f | |||
| a3ecda8f8e | |||
| 174992cc65 | |||
| 3e23fa6809 | |||
| 41554be892 | |||
| a7c6c29c25 | |||
| 31c0b315b0 | |||
| 465c111bf1 | |||
| 0884bcf47a | |||
| 64f108163a | |||
| e80dbf4b49 | |||
| a203c5bf12 | |||
| 18b19fd90a | |||
| 2d1ec679eb | |||
| e43f7e2880 | |||
| 335a9f845e | |||
| a5c652ef91 | |||
| 00c9fbfdca | |||
| 69180ef937 | |||
| bcffe4ef3e | |||
| b9794c8ff3 | |||
| 47f00e135b | |||
| f0c5ea8617 | |||
| 688832445a | |||
| f064ef2eff | |||
| c652d8df1a | |||
| fa5f129af0 | |||
| 06ac4c4e62 | |||
| b57f56dd8f | |||
| 1939f64cdf | |||
| 1ba5282244 | |||
| 1c9fba7f19 | |||
| 512cca3445 | |||
| 54211a5b72 | |||
| ade8b0fe4f | |||
| 3d46895328 | |||
| 9970277411 | |||
| d77c0b1c06 | |||
| ea08d1d998 | |||
| d6915bc22f | |||
| b4215a5bde | |||
| ac3e6fba20 | |||
| ee30ebb05d | |||
| f21eb73f4a | |||
| aa26fb97a0 | |||
| 502b702a0a | |||
| e426550c73 | |||
| fab262a959 | |||
| e9b8815f08 | |||
| 8dab2a09ff | |||
| a4b2e02ec3 | |||
| 97adb6b03d | |||
| a531361514 | |||
| b24fbc36f9 | |||
| 600a154714 | |||
| 0a4753579c | |||
| 5c021a4e2e | |||
| 0045fc22e6 | |||
| 77e3641be9 | |||
| 536833fd93 | |||
| f6115c4012 | |||
| 5e416f1760 | |||
| d23b59b8e9 | |||
| 9a047faece | |||
| c6865bb5f6 | |||
| cdaa395824 | |||
| c96a2b71d1 | |||
| 102905df06 | |||
| 7f8a4af3fe | |||
| a2f4e1f3fd | |||
| 1933030e9a | |||
| 50cbafce25 | |||
| 91c8424dc5 | |||
| 6009e82994 | |||
| 7d67e13b9e | |||
| b9ab2e9f36 | |||
| 51d999e3c8 | |||
| b049c95ca2 | |||
| 3ee8afc4a4 | |||
| 1edcb296f3 | |||
| 51f1b3adcb | |||
| 8e05c287b8 | |||
| 050dc8ac7b | |||
| 842fc52b4e | |||
| 7008a01b11 | |||
| 7d47ac14d0 | |||
| 5083ee83ad | |||
| 8363b8ca10 | |||
| 0a89451889 | |||
| 59730e21d2 | |||
| 3887512721 | |||
| e11cc64f89 | |||
| 5ca3a927c1 | |||
| 4246795e14 | |||
| d0a9f1aa9f | |||
| e8a7812583 | |||
| c651b6ca09 | |||
| d9f3ad74ca | |||
| 278145e211 | |||
| 7f0236d8d5 | |||
| 414a042199 | |||
| a85aeb00d7 | |||
| a31d7b7b8b | |||
| aa210c0b6f | |||
| bf0d61c862 | |||
| fae47f4a75 | |||
| 53575cf59a | |||
| 06db3ddf7b | |||
| 15650f53ad | |||
| 514364bb08 | |||
| 46bfe78b77 | |||
| 64ab158991 | |||
| 0255b39f4b | |||
| 94cf4dee1b | |||
| 0a32af0dab | |||
| 3f48d85e31 | |||
| 5e44386b24 | |||
| 11572a5627 | |||
| 30224f9114 | |||
| bf99141304 | |||
| 5b8bfa32d3 | |||
| dd4ecbe743 | |||
| 52cae7f877 | |||
| 5355b31bcb | |||
| c71727c9c0 | |||
| c6e621c4ab | |||
| 7279779377 | |||
| f90f5f7370 | |||
| d353a8629f | |||
| 9c62a792b7 | |||
| 32d3523190 | |||
| b5e2f47b31 | |||
| 82162026b3 | |||
| 3582654861 | |||
| 0772173dd9 | |||
| 61c11aef26 | |||
| 66c3b532cb | |||
| eac5c6d104 | |||
| 46b5d19331 | |||
| bea3836df8 | |||
| c07bcb6334 | |||
| c79443eb62 | |||
| 572cb4ac1d | |||
| 25c95f0843 | |||
| a3cdae6815 | |||
| 276e12679d | |||
| d24fea2910 | |||
| e0405bca1e | |||
| 6fb5d66631 | |||
| 5a043e89a0 | |||
| 3c20386875 |
+2
-1
@@ -24,4 +24,5 @@ db/*
|
||||
docker-compose.yml
|
||||
package-lock.json
|
||||
public/*
|
||||
/public/*
|
||||
/public/*
|
||||
storage/framework/laravel-excel/*
|
||||
|
||||
@@ -43,4 +43,4 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreatedAfter implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('created_at', '>', Carbon::parse($value));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ReferenceLike implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('reference', 'LIKE', '%'.$value.'%');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithConfirmedOrders implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('parcels');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithOwner implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->with('owner');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithPackingLists implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->with('packingLists');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithParcels implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->with('parcels');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithoutConfirmedOrders implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('parcels');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface ContainerOwner
|
||||
{
|
||||
|
||||
public function containers(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Packable
|
||||
{
|
||||
|
||||
public function packingLists(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Remarkable
|
||||
{
|
||||
|
||||
public function remarks(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Steppable
|
||||
{
|
||||
|
||||
public function steps(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Transportable
|
||||
{
|
||||
|
||||
public function transports(): morphMany;
|
||||
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class CurlContainerListJob implements ShouldQueue
|
||||
$last_two_month = Carbon::now()->subMonth(2)->format('Y-m-d');
|
||||
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', [\GuzzleHttp\RequestOptions::JSON => json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":' . $this->page . ',"PageSize":10,"PageOffset":0,"SortExpression":"CreatedOn DESC","GroupExpression":"","Filter":["LoadedTime:<=%js%\"' . $last_two_month . 'T00:00:00.000\"\u0000"],"ContextKey":"view1","FilterIsExternal":false,"LookupContextFieldName":null,"LookupContextController":null,"LookupContextView":null,"LookupContext":null,"Inserting":false,"LastCommandName":null,"ExternalFilter":[],"DoesNotRequireData":false,"LastView":"grid1","Tag":null,"RequiresFirstLetters":false,"ViewType":"Grid","SupportsCaching":true,"SystemFilter":null,"RequiresRowCount":true,"QuickFindHint":null,"RequiresPivot":false,"PivotDefinitions":null,"RequiresMetaData":true}}')]);
|
||||
$res = $client->post('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', [\GuzzleHttp\RequestOptions::JSON => json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":' . $this->page . ',"PageSize":10,"PageOffset":0,"SortExpression":"CreatedOn DESC","GroupExpression":"","Filter":["LoadedTime:<=%js%\"' . $last_two_month . 'T00:00:00.000\"\u0000"],"ContextKey":"view1","FilterIsExternal":false,"LookupContextFieldName":null,"LookupContextController":null,"LookupContextView":null,"LookupContext":null,"Inserting":false,"LastCommandName":null,"ExternalFilter":[],"DoesNotRequireData":false,"LastView":"grid1","Tag":null,"RequiresFirstLetters":false,"ViewType":"Grid","SupportsCaching":true,"SystemFilter":null,"RequiresRowCount":true,"QuickFindHint":null,"RequiresPivot":false,"PivotDefinitions":null,"RequiresMetaData":true}}')]);
|
||||
|
||||
$data = json_decode($res->getBody()->getContents());
|
||||
|
||||
@@ -63,7 +63,7 @@ class CurlContainerListJob implements ShouldQueue
|
||||
{
|
||||
// get latest cookies
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$r = $client->request('GET', 'https://portalvt.azurewebsites.net');
|
||||
$r = $client->request('GET', 'http://portal.vtnation.com.my');
|
||||
$call_cookie = $client->getConfig('cookies');
|
||||
$call_cookie = $call_cookie->toArray();
|
||||
$latest_cookie = [];
|
||||
@@ -79,7 +79,7 @@ class CurlContainerListJob implements ShouldQueue
|
||||
'Cookie' => $latest_cookie,
|
||||
];
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login', [\GuzzleHttp\RequestOptions::JSON => [
|
||||
$res = $client->post('http://portal.vtnation.com.my/Services/DataControllerService.asmx/Login', [\GuzzleHttp\RequestOptions::JSON => [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CurlWarehouseListJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private $page;
|
||||
|
||||
public function __construct($page = -2)
|
||||
{
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$cookies = $this->getCookie();
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $cookies,
|
||||
];
|
||||
|
||||
$yesterday = Carbon::now()->subDays(1)->format('Y-m-d');
|
||||
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', [\GuzzleHttp\RequestOptions::JSON => json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":' . $this->page . ',"PageSize":100,"PageOffset":0,"SortExpression":"ParcelDate DESC,FullMarking DESC","GroupExpression":"","Filter":["ParcelDate:=%js%\"' . $yesterday . 'T00:00:00.000\"\u0000"],"ContextKey":"view1","FilterIsExternal":false,"LookupContextFieldName":null,"LookupContextController":null,"LookupContextView":null,"LookupContext":null,"Inserting":false,"LastCommandName":null,"ExternalFilter":[],"DoesNotRequireData":false,"LastView":"grid1","Tag":null,"RequiresFirstLetters":false,"ViewType":"Grid","SupportsCaching":true,"SystemFilter":null,"RequiresRowCount":true,"QuickFindHint":null,"RequiresPivot":false,"PivotDefinitions":null,"RequiresMetaData":true}}')]);
|
||||
|
||||
$data = json_decode($res->getBody()->getContents());
|
||||
|
||||
if (!empty($data->d->Row)) {
|
||||
// insert data here
|
||||
|
||||
// next page
|
||||
$this->page = $this->page > 0 ? $this->page + 1 : 1;
|
||||
CurlWarehouseListJob::dispatch($this->page + 1)
|
||||
->delay(Carbon::now()->addSeconds(10));
|
||||
}
|
||||
}
|
||||
|
||||
public function getCookie()
|
||||
{
|
||||
// get latest cookies
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$r = $client->request('GET', 'https://portalvt.azurewebsites.net');
|
||||
$call_cookie = $client->getConfig('cookies');
|
||||
$call_cookie = $call_cookie->toArray();
|
||||
$latest_cookie = [];
|
||||
|
||||
foreach ($call_cookie as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
}
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
|
||||
// get access token
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $latest_cookie,
|
||||
];
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login', [\GuzzleHttp\RequestOptions::JSON => [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
]]);
|
||||
|
||||
$token = json_decode($res->getBody()->getContents());
|
||||
$token = $token->d->AccessToken;
|
||||
|
||||
$latest_cookie = $latest_cookie . ';AppVTCC=' . $token;
|
||||
return $latest_cookie;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersStatusUpdateFromVTPortalProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchContainersStatusUpdateFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchContainersStatusUpdateFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryListFromVTPortalProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchDeliveryListFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
(App()->make(FetchDeliveryListFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchLoadedContainersFromVTPortalProcessor;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchLoadedContainersFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchLoadedContainersFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListFromVTPortalProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchPackingListFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 1800;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchPackingListFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchWarehouseReceiveListFromVTPortalProcessor;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchWarehouseReceiveListFromVTPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchWarehouseReceiveListFromVTPortalProcessor::class))->execute();
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
$this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class CreateInvitedCustomerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created User',
|
||||
'message' => 'You have successfully created a new User'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreateUserProcessor */
|
||||
private $createUserProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/** @var AuthenticationProcessor */
|
||||
private $authenticationProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateInvitedCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param AuthenticationProcessor $authenticationProcessor
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateContactProcessor $createContactProcessor, FetchesCompany $fetchesCompany, AssignEmployeeProcessor $assignEmployeeProcessor, AuthenticationProcessor $authenticationProcessor)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->authenticationProcessor = $authenticationProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
/** @var Company $company */
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $company->companyModules()->first();
|
||||
|
||||
if($companyModule->employees()->exists()){
|
||||
throw new AccessForbiddenException('This company\'s account has been claimed by another user already!');
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->createUserProcessor->execute($request, RoleTypes::USER, !App::environment(['production']) ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
$contactObject = new ContactObject($request->input('name'), $request->input('phone'), $request->input('contact_email'), $request->input('wechat_id'));
|
||||
|
||||
$this->createContactProcessor->execute($contactObject, $company);
|
||||
|
||||
$Object = new EmploymentObject($companyModule, $user);
|
||||
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ class LogoutUserLogic extends AbstractControllerLogic
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
|
||||
logger("logout");
|
||||
$this->invalidatesAuthenticationToken->execute();
|
||||
|
||||
return $this->response();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Modules\Addresses\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
class AddressObject implements DataTransferObject
|
||||
{
|
||||
@@ -38,7 +39,7 @@ class AddressObject implements DataTransferObject
|
||||
* @param int $postCode
|
||||
* @param null|string $reference
|
||||
*/
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, ?string $reference = null)
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, ?string $reference = null, ?int $status = ApprovalStatus::APPROVED)
|
||||
{
|
||||
$this->streetOne = $streetOne;
|
||||
$this->streetTwo = $streetTwo;
|
||||
@@ -47,6 +48,7 @@ class AddressObject implements DataTransferObject
|
||||
$this->districtId = $districtId;
|
||||
$this->postCode = $postCode;
|
||||
$this->reference = $reference;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,5 +107,13 @@ class AddressObject implements DataTransferObject
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Processors;
|
||||
|
||||
use App\Classes\General\Interfaces\Addressable;
|
||||
use App\Classes\Modules\Addresses\Services\CleansOldAddress;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Models\OldAddress;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CreateAddressFromOldAddressProcessor
|
||||
{
|
||||
|
||||
/** @var CleansOldAddress */
|
||||
private $cleansOldAddress;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
|
||||
/**
|
||||
* CreateAddressFromOldAddressProcessor constructor.
|
||||
* @param CleansOldAddress $cleansOldAddress
|
||||
* @param CreatesAddress $createsAddress
|
||||
*/
|
||||
public function __construct(CleansOldAddress $cleansOldAddress, CreatesAddress $createsAddress)
|
||||
{
|
||||
$this->cleansOldAddress = $cleansOldAddress;
|
||||
$this->createsAddress = $createsAddress;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param OldAddress $address
|
||||
* @param Addressable $addressable
|
||||
* @return Model|null
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(OldAddress $address, Addressable $addressable): ?Model {
|
||||
|
||||
if(!$object = $this->cleansOldAddress->execute($address)){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if(!$addressable instanceof Order && $address = $addressable->addresses()->where('street_one', $object->getStreetOne())->first()) {
|
||||
return $address;
|
||||
}
|
||||
|
||||
return $this->createsAddress->execute($addressable, $object);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Omair Saleh
|
||||
* Date: 20/8/2021
|
||||
* Time: 1:05 AM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Models\District;
|
||||
use App\Models\OldAddress;
|
||||
|
||||
class CleansOldAddress
|
||||
{
|
||||
|
||||
public function execute(OldAddress $address){
|
||||
if($address->street_one === '' && $address->street_two === ''){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!$address->post_code){
|
||||
return null;
|
||||
}
|
||||
|
||||
$district = District::where('postcode', 'like', '%'. $address->post_code .'%')->first();
|
||||
|
||||
if(!$district) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new AddressObject($this->cleanAddress($address->street_one, $district, $address->post_code), $this->cleanAddress($address->street_two, $district, $address->post_code), $district->country_id, $district->state_id, $district->id, $address->post_code, 'Delivery Address');
|
||||
|
||||
}
|
||||
|
||||
public function cleanAddress($address, $district, $postcode){
|
||||
$address = str_replace('Malaysia', '', str_replace('malaysia', '', str_replace('MALAYSIA', '', $address)));
|
||||
$address = str_replace($district->state->name, '',str_replace($district->name, '', $address));
|
||||
$address = str_replace(strtolower($district->state->name), '',str_replace(strtolower($district->name), '', $address));
|
||||
$address = str_replace(strtoupper($district->state->name), '',str_replace(strtoupper($district->name), '', $address));
|
||||
$address = str_replace($postcode, '', $address);
|
||||
$address = str_replace(', ,', ',', str_replace(', ,', ',', str_replace(', ,', ',', $address)));
|
||||
$address = str_replace(',', ', ', $address);
|
||||
$address = preg_replace('!\s+!', ' ', $address);
|
||||
$address = preg_replace("/,+/", ",", $address);
|
||||
return rtrim(rtrim(rtrim(rtrim($address, '.')), ','));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ class CreatesAddress extends AbstractUpdateRelationshipRecord
|
||||
$model->state_id = $object->getStateId();
|
||||
$model->district_id = $object->getDistrictId();
|
||||
$model->postcode = $object->getPostCode();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($addressable->addresses(), $model);
|
||||
|
||||
|
||||
@@ -53,10 +53,6 @@ class ListCompaniesLogic extends AbstractControllerLogic
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
logger("llogic");
|
||||
|
||||
logger($request->input('filters'));
|
||||
|
||||
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
||||
return $this->collectionResponse(CompanyResource::collection($query));
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Change Order Address Approval',
|
||||
'message' => 'You have successfully change the order address'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ApproveChangeOrderAddressProcessor */
|
||||
private $approveChangeOrderAddressProcessor;
|
||||
|
||||
/**
|
||||
* ApproveChangeOrderAddressLogic constructor.
|
||||
* @param ApproveChangeOrderAddressProcessor $approveChangeOrderAddressProcessor
|
||||
*/
|
||||
|
||||
public function __construct(ApproveChangeOrderAddressProcessor $approveChangeOrderAddressProcessor)
|
||||
{
|
||||
$this->approveChangeOrderAddressProcessor = $approveChangeOrderAddressProcessor;
|
||||
}
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$address = $this->approveChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,11 @@
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
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\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -11,13 +15,6 @@ use Illuminate\Http\JsonResponse;
|
||||
class CreateOrderLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
private $createOrderProcessor;
|
||||
|
||||
public function __construct( CreateOrderProcessor $createsOrderProcessor)
|
||||
{
|
||||
$this->createOrderProcessor = $createsOrderProcessor;
|
||||
}
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order',
|
||||
@@ -25,9 +22,48 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var fetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var CreateOrderProcessor */
|
||||
private $createOrderProcessor;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/**
|
||||
* CreateOrderLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param CreateOrderProcessor $createOrderProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse {
|
||||
|
||||
$order = $this->createOrderProcessor->execute($request);
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('address_id')]);
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackageProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\GeneratesPackingListReferenceNumber;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateShippingPackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created PackingList',
|
||||
'message' => 'You have successfully created a new PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var GeneratesPackingListReferenceNumber */
|
||||
private $generatesPackingListReferenceNumber;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(
|
||||
CreatePackingListProcessor $createPackingListProcessor,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule,
|
||||
CreatePackageProcessor $createPackageProcessor,
|
||||
GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber,
|
||||
FetchesOrder $fetchesOrder
|
||||
)
|
||||
{
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->input('order_id')]);
|
||||
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id,
|
||||
PackingListType::SHIPPING_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$packages = $request->input('packages');
|
||||
|
||||
foreach ($packages as $key => $row) {
|
||||
$packageObject = new PackageObject(
|
||||
$row['type'],
|
||||
$row['description'],
|
||||
$row['width'],
|
||||
$row['height'],
|
||||
$row['length'],
|
||||
$row['weight'],
|
||||
$row['quantity'],
|
||||
ApprovalStatus::APPROVED,
|
||||
$row['reference'],
|
||||
);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackageProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\GeneratesPackingListReferenceNumber;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateWarehousePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Warehouse PackingList',
|
||||
'message' => 'You have successfully created a new Warehouse PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var GeneratesPackingListReferenceNumber */
|
||||
private $generatesPackingListReferenceNumber;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(
|
||||
CreatePackingListProcessor $createPackingListProcessor,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule,
|
||||
CreatePackageProcessor $createPackageProcessor,
|
||||
GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber,
|
||||
FetchesOrder $fetchesOrder
|
||||
)
|
||||
{
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->input('order_id')]);
|
||||
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id,
|
||||
PackingListType::WAREHOUSE_RECEIVE_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $request->input('tracking'), Carbon::parse($request->input('receive_date')), Carbon::parse($request->input('receive_date')), ApprovalStatus::APPROVED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||
|
||||
$scheduleObject = new ScheduleObject(Carbon::parse($request->input('receive_date')), Carbon::parse($request->input('receive_date')), ApprovalStatus::APPROVED);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
$packages = $request->input('packages');
|
||||
|
||||
foreach ($packages as $key => $row) {
|
||||
$packageObject = new PackageObject(
|
||||
$row['type'],
|
||||
$row['description'],
|
||||
$row['width'],
|
||||
$row['height'],
|
||||
$row['length'],
|
||||
$row['weight'],
|
||||
$row['quantity'],
|
||||
ApprovalStatus::APPROVED,
|
||||
$row['reference'],
|
||||
);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class FetchOrderLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canFetchOrder->passes();
|
||||
|
||||
$query = $this->fetchesOrder->execute(['reference' => $request->route('id')]);
|
||||
$query = $this->fetchesOrder->execute(['reference' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($query));
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class ListOrdersLogic extends AbstractControllerLogic
|
||||
{
|
||||
$this->canListOrders->passes();
|
||||
|
||||
$query = $this->listsOrders->execute($this->listsOrders->deserializeFilters($request->input('filters')));
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true]));
|
||||
|
||||
return $this->collectionResponse(OrderResource::collection($query));
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\RequestChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class RequestChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Request To Change Order Address',
|
||||
'message' => 'You have successfully request to change order address'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var RequestChangeOrderAddressProcessor */
|
||||
private $requestChangeOrderAddressProcessor;
|
||||
|
||||
/**
|
||||
* RequestChangeOrderAddressLogic constructor.
|
||||
* @param RequestChangeOrderAddressProcessor $requestChangeOrderAddressProcessor
|
||||
*/
|
||||
|
||||
public function __construct(RequestChangeOrderAddressProcessor $requestChangeOrderAddressProcessor)
|
||||
{
|
||||
$this->requestChangeOrderAddressProcessor = $requestChangeOrderAddressProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$order = $this->requestChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanApproveChangeOrderAddress;
|
||||
use App\Classes\Modules\Orders\Services\UpdatesOrdersAddress;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApproveChangeOrderAddressProcessor
|
||||
{
|
||||
/** @var CanApproveChangeOrderAddress */
|
||||
private $canApproveChangeOrderAddress;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var UpdatesOrdersAddress */
|
||||
private $updatesOrdersAddress;
|
||||
|
||||
/**
|
||||
* ApproveChangeOrderAddressProcessor constructor.
|
||||
* @param CanApproveChangeOrderAddress $canApproveChangeOrderAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param UpdatesOrdersAddress $updatesOrdersAddress
|
||||
*/
|
||||
public function __construct(CanApproveChangeOrderAddress $canApproveChangeOrderAddress, FetchesAddress $fetchesAddress, UpdatesOrdersAddress $updatesOrdersAddress)
|
||||
{
|
||||
$this->canApproveChangeOrderAddress = $canApproveChangeOrderAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->updatesOrdersAddress = $updatesOrdersAddress;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
$status = (int) $request->route('status');
|
||||
|
||||
$this->canApproveChangeOrderAddress->passes();
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
if($status === ApprovalStatus::APPROVED){
|
||||
$address->owner->addresses()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
}
|
||||
|
||||
$this->updatesOrdersAddress->execute($address, $status);
|
||||
|
||||
return $address;
|
||||
}
|
||||
}
|
||||
@@ -13,83 +13,69 @@ use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Models\Address;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateOrderProcessor
|
||||
{
|
||||
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var CanCreateOrder */
|
||||
private $canCreateOrder;
|
||||
|
||||
/** @var CreatesOrder */
|
||||
private $createsOrder;
|
||||
|
||||
/** @var fetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createAddress;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreateOrderRolesProcessor */
|
||||
private $createOrderRolesProcessor;
|
||||
|
||||
/**
|
||||
* CreateOrderProcessor constructor.
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param CanCreateOrder $canCreateOrder
|
||||
* @param CreatesOrder $createsOrder
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param CreatesAddress $createAddress
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreateOrderRolesProcessor $createOrderRolesProcessor
|
||||
*/
|
||||
public function __construct(GeneratesOrderNumber $generatesOrderNumber, CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, FetchesAddress $fetchesAddress, CreatesAddress $createAddress, FetchesCompany $fetchesCompany, CreateOrderRolesProcessor $createOrderRolesProcessor)
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreatesAddress $createAddress, CreateOrderRolesProcessor $createOrderRolesProcessor)
|
||||
{
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->canCreateOrder = $canCreateOrder;
|
||||
$this->createsOrder = $createsOrder;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createAddress = $createAddress;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createOrderRolesProcessor = $createOrderRolesProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Company $company
|
||||
* @param CompanyModule $originWarehouse
|
||||
* @param Address $address
|
||||
* @param int|null $orderNumber
|
||||
* @return Addressable
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request){
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->get('company_id')]);
|
||||
public function execute(Company $company, CompanyModule $originWarehouse, Address $address, int $orderNumber){
|
||||
|
||||
/** @var CompanyModule $importer */
|
||||
$importer = $this->fetchesCompany->execute(['id' => $request->get('company_id')])->companyModules()->importers()->first();
|
||||
$importer = $company->companyModules()->importers()->first();
|
||||
|
||||
$orderObject = new OrderObject($this->generatesOrderNumber->execute(), OrderType::SHARED_CONTAINER, $company->status === ApprovalStatus::APPROVED ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION);
|
||||
$orderObject = new OrderObject($orderNumber, OrderType::SHARED_CONTAINER, $company->status === ApprovalStatus::APPROVED ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
$this->canCreateOrder->passes($orderObject);
|
||||
|
||||
/** @var Order $order */
|
||||
$order = $this->createsOrder->execute($importer, $orderObject);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->get('address_id')]);
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode,$address->reference);
|
||||
|
||||
$this->createAddress->execute($order, $addressObject);
|
||||
|
||||
$this->createOrderRolesProcessor->execute($request, $order);
|
||||
$this->createOrderRolesProcessor->execute($originWarehouse, $order);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Classes\Modules\Orders\Services\CreatesOrder;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder;
|
||||
use App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor;
|
||||
use App\Classes\Modules\OrderSteps\Processors\CreateOrderStepsProcessor;
|
||||
use App\Classes\Modules\Steps\Processors\CreateStepsProcessor;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||
use App\Classes\ValueObjects\Constants\OrderStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderSteps;
|
||||
@@ -33,8 +34,8 @@ class CreateOrderProcessorOld
|
||||
/** @var ConfirmOrderProcessor */
|
||||
private $confirmOrderProcessor;
|
||||
|
||||
/** @var CreateOrderStepsProcessor */
|
||||
private $createOrderStepsProcessor;
|
||||
/** @var CreateStepsProcessor */
|
||||
private $createStepsProcessor;
|
||||
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
@@ -58,11 +59,11 @@ class CreateOrderProcessorOld
|
||||
private $fetchesAddress;
|
||||
|
||||
/**
|
||||
* CreateOrderProcessor constructor.
|
||||
* CreateOrderProcessorOld constructor.
|
||||
* @param CanCreateOrder $canCreateOrder
|
||||
* @param CreatesOrder $createsOrder
|
||||
* @param \App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor $confirmOrderProcessor
|
||||
* @param CreateOrderStepsProcessor $createOrderStepsProcessor
|
||||
* @param CreateStepsProcessor $createStepsProcessor
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
@@ -71,12 +72,12 @@ class CreateOrderProcessorOld
|
||||
* @param CreatesAddress $createAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
*/
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, \App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor $confirmOrderProcessor, CreateOrderStepsProcessor $createOrderStepsProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, ActivateContractProcessor $unityActivateContract, \App\Classes\Modules\Orders\Processors\CreateOrderRolesProcessor $createOrderRoleProcessor, CreatesAddress $createAddress, FetchesAddress $fetchesAddress)
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, \App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor $confirmOrderProcessor, CreateStepsProcessor $createStepsProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, ActivateContractProcessor $unityActivateContract, \App\Classes\Modules\Orders\Processors\CreateOrderRolesProcessor $createOrderRoleProcessor, CreatesAddress $createAddress, FetchesAddress $fetchesAddress)
|
||||
{
|
||||
$this->canCreateOrder = $canCreateOrder;
|
||||
$this->createsOrder = $createsOrder;
|
||||
$this->confirmOrderProcessor = $confirmOrderProcessor;
|
||||
$this->createOrderStepsProcessor = $createOrderStepsProcessor;
|
||||
$this->createStepsProcessor = $createStepsProcessor;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
@@ -120,7 +121,7 @@ class CreateOrderProcessorOld
|
||||
|
||||
//Add processing to order step
|
||||
//Note: For processing apointee_id is CIEF Freight Forward , id is 1, reserved in company table
|
||||
$this->createOrderStepsProcessor->execute($order, OrderSteps::PROCESSING, 1);
|
||||
$this->createStepsProcessor->execute($order, OrderSteps::PROCESSING, 1);
|
||||
|
||||
//Pre-approved order, no need Admin to process it
|
||||
//This processor then calls Generate Order Steps
|
||||
|
||||
@@ -40,17 +40,20 @@ class CreateOrderRolesProcessor
|
||||
}
|
||||
|
||||
|
||||
public function execute(Request $request, Order $order){
|
||||
/**
|
||||
* @param CompanyModule $originWarehouse
|
||||
* @param Order $order
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $originWarehouse, Order $order){
|
||||
|
||||
$address = $order->addresses()->first();
|
||||
|
||||
$importer = $order->companyModule;
|
||||
|
||||
/** @var CompanyModule $originWarehouse */
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->get('warehouse_id')]);
|
||||
|
||||
/** @var CompanyModule $destinationWarehouse */
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => $address->state_id = 13 ? WarehouseReferences::SABAH : ($address->state_id === 14 ? WarehouseReferences::SARAWAK : WarehouseReferences::KLANG)]);
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::DESTINATION_WAREHOUSE[$address->state_id ]]);
|
||||
|
||||
/** @var CompanyModule $freightForwarder */
|
||||
$freightForwarder = $originWarehouse->company->companyModules()->freightForwarders()->first();
|
||||
@@ -76,9 +79,33 @@ class CreateOrderRolesProcessor
|
||||
$roleObject = new OrderRoleObject($order, $destinationWarehouse, OrderRoleTypes::DESTINATION_WAREHOUSE);
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
|
||||
$roleObject = new OrderRoleObject($order, $freightForwarder, OrderRoleTypes::LAST_MILE_DELIVERY_DRIVER);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanChangeOrderAddress;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\DeletesAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RequestChangeOrderAddressProcessor
|
||||
{
|
||||
/** @var CanChangeOrderAddress */
|
||||
private $canChangeOrderAddress;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var DeletesAddress */
|
||||
private $deletesAddress;
|
||||
|
||||
/**
|
||||
* ChangeOrderAddressProcessor constructor.
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param DeletesAddress $deletesAddress
|
||||
*/
|
||||
public function __construct(CanChangeOrderAddress $canChangeOrderAddress, FetchesOrder $fetchesOrder, CreatesAddress $createsAddress, FetchesAddress $fetchesAddress, DeletesAddress $deletesAddress)
|
||||
{
|
||||
|
||||
$this->canChangeOrderAddress = $canChangeOrderAddress;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->deletesAddress = $deletesAddress;
|
||||
}
|
||||
|
||||
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
$this->canChangeOrderAddress->passes();
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->get('order_id')]);
|
||||
foreach ($order->addressesPendingVerification as $address) {
|
||||
$this->deletesAddress->execute($address);
|
||||
}
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->get('address_id')]);
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, $address->reference, ApprovalStatus::PENDING_VERIFICATION);
|
||||
$this->createsAddress->execute($order, $addressObject);
|
||||
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class FetchesDataFromVTPortal
|
||||
{
|
||||
|
||||
/** @var string|null */
|
||||
private $cookies;
|
||||
|
||||
/**
|
||||
* @param string $cookies
|
||||
*/
|
||||
public function setCookies(string $cookies): void
|
||||
{
|
||||
$this->cookies = $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCookies(): ?string
|
||||
{
|
||||
return $this->cookies;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param $body
|
||||
* @param string $cookie
|
||||
* @param bool $requiresAuthentication
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function clientRequest(string $url, string $method, $body, string $cookie, $requiresAuthentication = true){
|
||||
|
||||
if($requiresAuthentication) {
|
||||
if(!$this->getCookies()){
|
||||
$this->remoteLogin();
|
||||
}
|
||||
}
|
||||
|
||||
$client = new \GuzzleHttp\Client(
|
||||
[
|
||||
'cookies' => true,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $this->getCookies() ? $this->getCookies() : $cookie
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$request = $client->requestAsync($method, $url, [\GuzzleHttp\RequestOptions::JSON => $body, 'timeout' => 1200]);
|
||||
|
||||
return $request->wait();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
private function remoteLogin(){
|
||||
|
||||
$latest_cookie = [];
|
||||
$cookieRequest = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
|
||||
$cookieRequest->get('http://portal.vtnation.com.my');
|
||||
foreach ($cookieRequest->getConfig('cookies')->toArray() as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
}
|
||||
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
|
||||
|
||||
/** @var $loginRequest */
|
||||
$loginRequest = $this->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/Login', 'POST', [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
], $latest_cookie, false);
|
||||
|
||||
$this->setCookies($latest_cookie.';AppVTCC='.$this->getResponseBody($loginRequest)->AccessToken);
|
||||
|
||||
}
|
||||
|
||||
public function getResponseBody(ResponseInterface $request){
|
||||
return json_decode($request->getBody()->getContents())->d;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Address;
|
||||
|
||||
class UpdatesOrdersAddress extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Address $address
|
||||
* @param int $type
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Address $address, int $type)
|
||||
{
|
||||
$address->status = $type;
|
||||
return $this->handler($address);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Orders\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
|
||||
class CanApproveChangeOrderAddress extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Orders\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
|
||||
class CanChangeOrderAddress extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingListStatus;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CompletePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated PackingList',
|
||||
'message' => 'You have successfully updated the PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesPackingListStatus */
|
||||
private $updatesPackingListStatus;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* CompletePackingListLogic constructor.
|
||||
* @param CanUpdatePackingList $canUpdatePackingList
|
||||
* @param UpdatesPackingListStatus $updatesPackingListStatus
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(UpdatesPackingListStatus $updatesPackingListStatus, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->updatesPackingListStatus = $updatesPackingListStatus;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesPackingListStatus->execute($packing_list, ApprovalStatus::COMPLETED);
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
}
|
||||
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignPackingListContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Assign Packing List Container',
|
||||
'message' => 'You have successfully assign Packing List to Container'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* DeleteContainerControllersLogic constructor.
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(FetchesContainer $fetchesContainer, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$packing_list = $request->input('packing_list_id');
|
||||
|
||||
foreach ($packing_list as $key => $row) {
|
||||
$packing_list_item = $this->fetchesPackingList->execute(['id' => $row]);
|
||||
$container->packingLists()->attach($packing_list_item);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainerStatus;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CompleteContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesContainerStatus */
|
||||
private $updatesContainerStatus;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* CompleteContainerLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesContainerStatus $updatesContainerStatus
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
*/
|
||||
public function __construct(UpdatesContainerStatus $updatesContainerStatus, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->updatesContainerStatus = $updatesContainerStatus;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
+19
-10
@@ -4,10 +4,12 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanCreateContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanCreateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -21,8 +23,8 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created PackingList',
|
||||
'message' => 'You have successfully created a new PackingList'
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -32,13 +34,17 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsContainer;
|
||||
|
||||
public function __construct(CanCreateContainer $canCreateContainer, FetchesPackingList $fetchesPackingList, CreatesContainer $createsContainer)
|
||||
public function __construct(CanCreateContainer $canCreateContainer, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreatesContainer $createsContainer)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsContainer = $createsContainer;
|
||||
}
|
||||
|
||||
@@ -51,17 +57,20 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||
|
||||
$object = new ContainerObject( $packingList->id , $request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
$request->input('loading_date'),
|
||||
$request->input('status')
|
||||
);
|
||||
|
||||
$this->canCreateContainer->passes($object);
|
||||
|
||||
$query = $this->createsContainer->execute($object);
|
||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanCreateContainer;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateContainer */
|
||||
private $canCreateContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsContainer;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
public function __construct(
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsContainer = $createsContainer;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
|
||||
$this->canCreateContainer->passes($object);
|
||||
|
||||
$container = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
$transportObject = new TransportObject(
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\DeletesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanDeleteContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanDeleteContainer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanFetchContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -53,7 +53,7 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canFetchContainer->passes();
|
||||
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListContainers */
|
||||
private $canListContainers;
|
||||
|
||||
/** @var ListsContainers */
|
||||
private $listsContainers;
|
||||
|
||||
private $fetchInboundCustomCleared;
|
||||
|
||||
/**
|
||||
* ListContainersLogic constructor.
|
||||
* @param CanListContainers $canListContainers
|
||||
* @param ListsContainers $listsContainers
|
||||
*/
|
||||
public function __construct(CanListContainers $canListContainers, ListsContainers $listsContainers, FetchInboundCustomClearedProcessor $fetchInboundCustomCleared)
|
||||
{
|
||||
$this->canListContainers = $canListContainers;
|
||||
$this->listsContainers = $listsContainers;
|
||||
$this->fetchInboundCustomCleared = $fetchInboundCustomCleared;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->fetchInboundCustomCleared->execute();
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
}
|
||||
+7
-11
@@ -5,7 +5,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanListContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -45,21 +45,17 @@ class ListContainersLogic 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
|
||||
{
|
||||
try {
|
||||
$this->canListContainers->passes();
|
||||
|
||||
$this->canListContainers->passes();
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Schedules\Services\UpdatesScheduleStatus;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Reschedule Container',
|
||||
'message' => 'You have successfully Reschedule Container'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var UpdatesScheduleStatus */
|
||||
private $updatesScheduleStatus;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/**
|
||||
* DeleteContainerControllersLogic constructor.
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(FetchesContainer $fetchesContainer, UpdatesScheduleStatus $updatesScheduleStatus, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->updatesScheduleStatus = $updatesScheduleStatus;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
$old_sechedule = $transport->schedules()->first();
|
||||
|
||||
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+13
-4
@@ -6,7 +6,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Containers\Rules\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
@@ -52,14 +52,23 @@ class UpdateContainerLogic 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
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new ContainerObject( $container->packing_list_id , $request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('loading_date'),
|
||||
$container->status,
|
||||
);
|
||||
|
||||
$this->canUpdateContainer->passes($object);
|
||||
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Container',
|
||||
'message' => 'You have successfully updated the Dispatch Date Container'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesDispatchDateTransport */
|
||||
private $updatesDispatchDateTransport;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* UpdateDispatchDateContainerLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesDispatchDateTransport $updatesDispatchDateTransport
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
*/
|
||||
public function __construct(UpdatesDispatchDateTransport $updatesDispatchDateTransport, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->updatesDispatchDateTransport = $updatesDispatchDateTransport;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Drop Date Container',
|
||||
'message' => 'You have successfully updated the Drop Date Container'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesDropDateTransport */
|
||||
private $updatesDropDateTransport;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* UpdateDropDateContainerLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesDropDateTransport $updatesDropDateTransport
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
*/
|
||||
public function __construct(UpdatesDropDateTransport $updatesDropDateTransport, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->updatesDropDateTransport = $updatesDropDateTransport;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
||||
@@ -9,16 +14,17 @@ use App\Classes\Modules\PackingLists\Services\CreatesPackingListPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingListPackage;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListPackageObject;
|
||||
use App\Classes\Modules\Packages\Services\FetchesPackage;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -29,64 +35,37 @@ class CreatePackingListLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreatePackingList */
|
||||
private $canCreatePackingList;
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
private $canCreatePackingListPackage;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesPackage;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsPackingList;
|
||||
|
||||
private $createsPackingListPackage;
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* @param CanCreatePackingList $canCreatePackingList
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesPackingList $createsPackingList
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(CanCreatePackingList $canCreatePackingList, CanCreatePackingListPackage $canCreatePackingListPackage, FetchesPackage $fetchesPackage, CreatesPackingList $createsPackingList, CreatesPackingListPackage $createsPackingListPackage)
|
||||
public function __construct(CreatePackingListProcessor $createPackingListProcessor, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->canCreatePackingList = $canCreatePackingList;
|
||||
$this->canCreatePackingListPackage = $canCreatePackingListPackage;
|
||||
$this->fetchesPackage = $fetchesPackage;
|
||||
$this->createsPackingList = $createsPackingList;
|
||||
$this->createsPackingListPackage = $createsPackingListPackage;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
|
||||
$package = $this->fetchesPackage->execute(['id'=>$request->input('package_id')]);
|
||||
$order = $this->fetchesOrder->execute(['reference' => $request->input('reference_number')]);
|
||||
|
||||
$reference_no = rand(1000000, 9999999);
|
||||
$packingListObject = new PackingListObject($request->input('reference_number'), $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$object = new PackingListObject($reference_no, ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
$this->canCreatePackingList->passes($object);
|
||||
|
||||
$packageList = $this->createsPackingList->execute( $object);
|
||||
|
||||
|
||||
$object = new PackingListPackageObject($packageList->id, $package->id);
|
||||
|
||||
$this->canCreatePackingListPackage->passes($object);
|
||||
|
||||
$query = $this->createsPackingListPackage->execute($object);
|
||||
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($query));
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
|
||||
class CreatePackageLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -61,12 +62,10 @@ class CreatePackageLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->input('order_id')]);
|
||||
|
||||
$object = new PackageObject(
|
||||
$order->id,
|
||||
null,
|
||||
$request->input('type'),
|
||||
$request->input('description'),
|
||||
$request->input('width'),
|
||||
@@ -74,11 +73,11 @@ class CreatePackageLogic extends AbstractControllerLogic
|
||||
$request->input('length'),
|
||||
$request->input('weight'),
|
||||
$request->input('quantity'),
|
||||
ApprovalStatus::PENDING_SUBMISSION);
|
||||
ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
$this->canCreatePackage->passes($object);
|
||||
|
||||
$query = $this->createsPackage->execute($object);
|
||||
$query = $this->createsPackage->execute($object, $order->packingLists()->first());
|
||||
|
||||
return $this->resourceResponse(new PackageResource($query));
|
||||
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Services\CreatesRemark;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Package;
|
||||
use App\Models\Remark;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreatePackageRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Package',
|
||||
'message' => 'You have successfully created a new Package'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesRemark */
|
||||
private $createsRemark;
|
||||
|
||||
/**
|
||||
* CreateContainerRemarkLogic constructor.
|
||||
* @param CreatesRemark $createsRemark
|
||||
*/
|
||||
public function __construct(CreatesRemark $createsRemark, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->createsRemark = $createsRemark;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
$object = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
|
||||
$remark = $this->createsRemark->execute($order ,$object);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,8 +4,8 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Packages\Services\FetchesPackage;
|
||||
use App\Classes\Modules\Packages\Standards\Rules\CanFetchPackage;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanFetchPackage;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Packages\Services\ListsPackages;
|
||||
use App\Classes\Modules\Packages\Standards\Rules\CanListPackages;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\ListsPackages;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanListPackages;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\SwitchesPackagePackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SwitchPackagePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Switched Package Packing List',
|
||||
'message' => 'You have successfully switched the Package Packing List'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var SwitchesPackagePackingList */
|
||||
private $switchesPackagePackingList;
|
||||
|
||||
/** @var FetchesPackage */
|
||||
private $fetchesPackage;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* UpdatePackageLogic constructor.
|
||||
* @param SwitchesPackagePackingList $switchesPackagePackingList
|
||||
* @param FetchesPackage $fetchesPackage
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(SwitchesPackagePackingList $switchesPackagePackingList, FetchesPackage $fetchesPackage, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->switchesPackagePackingList = $switchesPackagePackingList;
|
||||
$this->fetchesPackage = $fetchesPackage;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$package = $this->fetchesPackage->execute(['id' => $request->route('id')]);
|
||||
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||
|
||||
$query = $this->switchesPackagePackingList->execute($package, $packing_list);
|
||||
|
||||
return $this->resourceResponse(new PackageResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Packages\Services\UpdatesPackage;
|
||||
use App\Classes\Modules\Packages\Services\FetchesPackage;
|
||||
use App\Classes\Modules\Packages\Standards\Rules\CanUpdatePackage;
|
||||
use App\Classes\Modules\Packages\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\UpdatesPackage;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanUpdatePackage;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -60,8 +60,6 @@ class UpdatePackageLogic extends AbstractControllerLogic
|
||||
$package = $this->fetchesPackage->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new PackageObject(
|
||||
$package->order_id,
|
||||
null,
|
||||
$request->input('type'),
|
||||
$request->input('description'),
|
||||
$request->input('width'),
|
||||
@@ -69,7 +67,9 @@ class UpdatePackageLogic extends AbstractControllerLogic
|
||||
$request->input('length'),
|
||||
$request->input('weight'),
|
||||
$request->input('quantity'),
|
||||
$request->input('status'));
|
||||
$request->input('status'),
|
||||
$package->reference
|
||||
);
|
||||
|
||||
$this->canUpdatePackage->passes($object);
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Schedules\Services\UpdatesScheduleStatus;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ReschedulePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Reschedule Packing List',
|
||||
'message' => 'You have successfully Reschedule Packing List'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesScheduleStatus */
|
||||
private $updatesScheduleStatus;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/**
|
||||
* DeleteContainerControllersLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesScheduleStatus $updatesScheduleStatus, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesScheduleStatus = $updatesScheduleStatus;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$transport = $packing_list->transports()->first();
|
||||
|
||||
$old_sechedule = $transport->schedules()->first();
|
||||
|
||||
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('eta')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDispatchDatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Packing List',
|
||||
'message' => 'You have successfully updated the Dispatch Date Packing List'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesDispatchDateTransport */
|
||||
private $updatesDispatchDateTransport;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* UpdateDispatchDatePackingListLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesDispatchDateTransport $updatesDispatchDateTransport
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(UpdatesDispatchDateTransport $updatesDispatchDateTransport, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->updatesDispatchDateTransport = $updatesDispatchDateTransport;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
$transport = $packing_list->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDropDatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Drop Date Packing List',
|
||||
'message' => 'You have successfully updated the Drop Date Packing List'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesDropDateTransport */
|
||||
private $updatesDropDateTransport;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* UpdateDispatchDatePackingListLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesDropDateTransport $updatesDropDateTransport
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(UpdatesDropDateTransport $updatesDropDateTransport, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->updatesDropDateTransport = $updatesDropDateTransport;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
$transport = $packing_list->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class UpdatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new PackingListObject($packingList->reference, $request->input('status'));
|
||||
$object = new PackingListObject($packingList->reference, $packingList->claimant_id, $packingList->type, $request->input('status'));
|
||||
|
||||
$this->canUpdatePackingList->passes($object);
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingListStatus;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanUpdatePackingList;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdatePackingListStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated PackingList Status',
|
||||
'message' => 'You have successfully updated the PackingList status'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesPackingListStatus */
|
||||
private $updatesPackingListStatus;
|
||||
|
||||
/**
|
||||
* UpdatePackingListStatusLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param UpdatesPackingListStatus $updatesPackingListStatus
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesPackingListStatus $updatesPackingListStatus)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesPackingListStatus = $updatesPackingListStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->updatesPackingListStatus->execute($packingList, $request->route('status'));
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,43 +3,95 @@
|
||||
namespace App\Classes\Modules\PackingLists\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ContainerObject implements DataTransferObject
|
||||
{
|
||||
|
||||
private $packingListId;
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
private $containerReference;
|
||||
|
||||
private $containerType;
|
||||
/** @var string */
|
||||
private $containerNumber;
|
||||
|
||||
/** @var string */
|
||||
private $sealReference;
|
||||
|
||||
public function __construct(int $packingListId, ?string $containerReference, int $containerType, ?String $sealReference)
|
||||
/** @var int */
|
||||
private $containerType;
|
||||
|
||||
/** @var Carbon */
|
||||
private $loadingDate;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* ContainerObject constructor.
|
||||
* @param string $reference
|
||||
* @param string $containerNumber
|
||||
* @param string $sealReference
|
||||
* @param int $containerType
|
||||
* @param Carbon $loadingDate
|
||||
* @param int $status
|
||||
*/
|
||||
public function __construct(string $reference, string $containerNumber, string $sealReference, int $containerType, Carbon $loadingDate, int $status)
|
||||
{
|
||||
$this->packingListId = $packingListId;
|
||||
$this->containerReference = $containerReference;
|
||||
$this->containerType = $containerType;
|
||||
$this->reference = $reference;
|
||||
$this->containerNumber = $containerNumber;
|
||||
$this->sealReference = $sealReference;
|
||||
$this->containerType = $containerType;
|
||||
$this->loadingDate = $loadingDate;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getPackingListId(): int
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): string
|
||||
{
|
||||
return $this->packingListId;
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
public function getContainerReference(): ?string
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContainerNumber(): string
|
||||
{
|
||||
return $this->containerReference;
|
||||
return $this->containerNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSealReference(): string
|
||||
{
|
||||
return $this->sealReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getContainerType(): int
|
||||
{
|
||||
return $this->containerType;
|
||||
}
|
||||
|
||||
public function getSealReference(): ?string
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getLoadingDate(): Carbon
|
||||
{
|
||||
return $this->sealReference;
|
||||
return $this->loadingDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,30 +7,47 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
class PackageObject implements DataTransferObject
|
||||
{
|
||||
|
||||
private $orderId;
|
||||
|
||||
private $claimantId;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var null|string */
|
||||
private $description;
|
||||
|
||||
/** @var float */
|
||||
private $width;
|
||||
|
||||
/** @var float */
|
||||
private $height;
|
||||
|
||||
/** @var float */
|
||||
private $length;
|
||||
|
||||
/** @var float */
|
||||
private $weight;
|
||||
|
||||
/** @var int */
|
||||
private $quantity;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
public function __construct(int $orderId, ?int $claimantId, int $type, ?string $description, float $width, float $height, float $length, float $weight, int $quantity, int $status)
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/**
|
||||
* PackageObject constructor.
|
||||
* @param int $type
|
||||
* @param null|string $description
|
||||
* @param float $width
|
||||
* @param float $height
|
||||
* @param float $length
|
||||
* @param float $weight
|
||||
* @param int $quantity
|
||||
* @param int $status
|
||||
* @param null|string $reference
|
||||
*/
|
||||
public function __construct(int $type, ?string $description, float $width, float $height, float $length, float $weight, int $quantity, int $status, ?string $reference=null)
|
||||
{
|
||||
$this->orderId = $orderId;
|
||||
$this->claimantId = $claimantId;
|
||||
$this->type = $type;
|
||||
$this->description = $description;
|
||||
$this->width = $width;
|
||||
@@ -39,55 +56,80 @@ class PackageObject implements DataTransferObject
|
||||
$this->weight = $weight;
|
||||
$this->quantity = $quantity;
|
||||
$this->status = $status;
|
||||
$this->reference = $reference;
|
||||
}
|
||||
|
||||
public function getOrderId(): int
|
||||
{
|
||||
return $this->orderId;
|
||||
}
|
||||
|
||||
public function getClaimantId(): ?int
|
||||
{
|
||||
return $this->claimantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth(): float
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight(): float
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getLength(): float
|
||||
{
|
||||
return $this->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getWeight(): float
|
||||
{
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getQuantity(): int
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,31 +7,62 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
class PackingListObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var null|string */
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $claimantId;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
/** @var string|null */
|
||||
private $contractReference;
|
||||
|
||||
/**
|
||||
* PackingListObject constructor.
|
||||
* @param null|string $reference
|
||||
* @param string $reference
|
||||
* @param int $claimantId
|
||||
* @param int $type
|
||||
* @param int $status
|
||||
* @param null|string $contractReference
|
||||
*/
|
||||
public function __construct(?string $reference, int $status)
|
||||
public function __construct(string $reference, int $claimantId, int $type, int $status, ?string $contractReference = null)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
$this->claimantId = $claimantId;
|
||||
$this->type = $type;
|
||||
$this->status = $status;
|
||||
$this->contractReference = $contractReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
public function getReference(): string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getClaimantId(): int
|
||||
{
|
||||
return $this->claimantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@@ -40,5 +71,13 @@ class PackingListObject implements DataTransferObject
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getContractReference(): ?string
|
||||
{
|
||||
return $this->contractReference;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\ContainerOwner;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanCreateContainer;
|
||||
|
||||
class CreateContainerProcessor
|
||||
{
|
||||
/** @var CanCreateContainer */
|
||||
private $canCreateContainer;
|
||||
|
||||
/** @var CreatesContainer */
|
||||
private $createsContainer;
|
||||
|
||||
/**
|
||||
* CreateContainerProcessor constructor.
|
||||
* @param CanCreateContainer $canCreateContainer
|
||||
* @param CreatesContainer $createsContainer
|
||||
*/
|
||||
public function __construct(CanCreateContainer $canCreateContainer, CreatesContainer $createsContainer)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
$this->createsContainer = $createsContainer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ContainerObject $object
|
||||
* @param ContainerOwner $owner
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(ContainerObject $object, ContainerOwner $owner){
|
||||
|
||||
$this->canCreateContainer->passes($object);
|
||||
return $this->createsContainer->execute($object, $owner);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\CreatesPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanCreatePackage;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatePackageProcessor
|
||||
{
|
||||
|
||||
|
||||
/** @var CanCreatePackage */
|
||||
private $canCreatePackage;
|
||||
|
||||
/** @var CreatesPackage */
|
||||
private $createsPackage;
|
||||
|
||||
/**
|
||||
* CreatePackageProcessor constructor.
|
||||
* @param CanCreatePackage $canCreatePackage
|
||||
* @param CreatesPackage $createsPackage
|
||||
*/
|
||||
public function __construct(CanCreatePackage $canCreatePackage, CreatesPackage $createsPackage)
|
||||
{
|
||||
$this->canCreatePackage = $canCreatePackage;
|
||||
$this->createsPackage = $createsPackage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PackageObject $object
|
||||
* @param PackingList $packingList
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(PackageObject $object, PackingList $packingList){
|
||||
|
||||
$this->canCreatePackage->passes($object);
|
||||
|
||||
return $this->createsPackage->execute($object, $packingList);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
|
||||
class CreatePackingListProcessor
|
||||
{
|
||||
|
||||
|
||||
/** @var CanCreatePackingList */
|
||||
private $canCreatePackingList;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsPackingList;
|
||||
|
||||
|
||||
/**
|
||||
* CreatePackingListProcessor constructor.
|
||||
* @param CanCreatePackingList $canCreatePackingList
|
||||
* @param CreatesPackingList $createsPackingList
|
||||
*/
|
||||
public function __construct(CanCreatePackingList $canCreatePackingList, CreatesPackingList $createsPackingList)
|
||||
{
|
||||
$this->canCreatePackingList = $canCreatePackingList;
|
||||
$this->createsPackingList = $createsPackingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param Packable $packable
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(PackingListObject $object, Packable $packable){
|
||||
|
||||
$this->canCreatePackingList->passes($object);
|
||||
return $this->createsPackingList->execute($object, $packable);
|
||||
}
|
||||
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchContainersStatusUpdateFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/**
|
||||
* FetchContainersStatusUpdateFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, UpdatesContractObligation $updatesContractObligations)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
try {
|
||||
$containers = Container::where('status', '=', ApprovalStatus::PENDING_VERIFICATION)->get();
|
||||
|
||||
/** @var Container $container */
|
||||
foreach($containers as $container){
|
||||
try {
|
||||
$filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]';
|
||||
|
||||
$containerDetailsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containerDetails = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailsRequest);
|
||||
|
||||
$containerDetails = $containerDetails->Rows[0];
|
||||
|
||||
if(!$eta = $containerDetails[3]){
|
||||
continue;
|
||||
}
|
||||
|
||||
$eta = Carbon::parse($eta);
|
||||
|
||||
$etd = Carbon::parse($eta)->subDays(5);
|
||||
|
||||
$delayDate = $containerDetails[6];
|
||||
|
||||
$containerStatus = $containerDetails[9];
|
||||
|
||||
$unstuffingDate = $containerDetails[7];
|
||||
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport){
|
||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
if($delayDate){
|
||||
|
||||
$delayDate = Carbon::parse($delayDate);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport->schedules()->where('eta', '=', $delayDate)->first()) {
|
||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($containerStatus === 'Unstuffing'){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => Carbon::parse($unstuffingDate)->subDay(), 'status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($container->packingLists as $packingList){
|
||||
|
||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
||||
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchDeliveryListFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/**
|
||||
* FetchDeliveryListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, UpdatesContractObligation $updatesContractObligations)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
try {
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::SUSPENDED])->get();
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($packingLists as $packingList){
|
||||
try {
|
||||
$filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]';
|
||||
|
||||
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
|
||||
$shippingPackingList = $shippingPackingLists->Rows[0];
|
||||
|
||||
if(!$shippingPackingList[9] && !$shippingPackingList[10]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$packingList->status = ApprovalStatus::COMPLETED;
|
||||
$packingList->save();
|
||||
|
||||
$deliveryDate = Carbon::parse($shippingPackingList[9] ? $shippingPackingList[9]:$shippingPackingList[10]);
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||
|
||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use App\Models\Container;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchInboundCustomClearedProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/**
|
||||
* FetchDeliveryListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, UpdatesContractObligation $updatesContractObligations)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
$packingLists = PackingList::query()->with(['steps' => function ($query) {
|
||||
$query->where('steps.status', '<>', 3);
|
||||
}])
|
||||
->where('type', PackingListType::SHIPPING_PACKING_LIST)
|
||||
->whereHas('containers', function($query) {
|
||||
return $query->whereHas('transports', function($query){
|
||||
return $query->where('type', '=', TransportType::SEA)->where('status', '=', ApprovalStatus::COMPLETED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
})->whereDoesntHave('transports', function($query){
|
||||
return $query->where('type', '=', TransportType::LAND)->where('status', '=', ApprovalStatus::APPROVED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
})->get();
|
||||
|
||||
return $packingLists ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchLoadedContainersFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreateContainerProcessor */
|
||||
private $createContainerProcessor;
|
||||
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
|
||||
/** @var AssignContractEntityProcessor */
|
||||
private $unityAssignContractEntity;
|
||||
|
||||
/** @var CreateContractEntityProcessor */
|
||||
private $unityCreateContractEntity;
|
||||
|
||||
/** @var CreatesStep */
|
||||
private $createsStep;
|
||||
|
||||
/** @var ActivateContractProcessor */
|
||||
private $unityActivateContract;
|
||||
|
||||
/**
|
||||
* FetchLoadedContainersFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreateContainerProcessor $createContainerProcessor
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
* @param CreatesStep $createsStep
|
||||
* @param ActivateContractProcessor $unityActivateContract
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, FetchesOrder $fetchesOrder, CreatePackingListProcessor $createPackingListProcessor, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreateContainerProcessor $createContainerProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, CreatesStep $createsStep, ActivateContractProcessor $unityActivateContract)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createContainerProcessor = $createContainerProcessor;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
$this->createsStep = $createsStep;
|
||||
$this->unityActivateContract = $unityActivateContract;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null){
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$start = $start ? $start : Carbon::now()->subDays(10);
|
||||
|
||||
$startLimit = Carbon::parse('11-08-2021');
|
||||
|
||||
if($start->isBefore($startLimit)){
|
||||
$start = $startLimit;
|
||||
}
|
||||
|
||||
$end = $end ? $end : Carbon::now();
|
||||
$filter = '["LoadedTime:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]';
|
||||
|
||||
$containersRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"LoadedTime asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containers = $this->fetchesDataFRomVTPortal->getResponseBody($containersRequest);
|
||||
|
||||
foreach ($containers->Rows as $container){
|
||||
|
||||
$filter = '["ContainerID:=%js%'.$container[11].'"]';
|
||||
$containerDetailRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containerDetail = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailRequest);
|
||||
|
||||
$containerObject = new ContainerObject($container[0], str_replace(' ', '', $container[24]), str_replace(' ', '', $container[15]), ContainerTypes::FORTY_FEET_DRY_CONTAINER, Carbon::parse($container[5]), ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerObject->getReference()]);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
$warehouseId = $container[12];
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]);
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
}
|
||||
|
||||
foreach($containerDetail->Rows as $packingList){
|
||||
$marking = explode('/', explode('CIEF/', $packingList[13])[1]);
|
||||
|
||||
if(!array_key_exists(1, $marking)){
|
||||
continue;
|
||||
}
|
||||
|
||||
$orderNumber = $marking[1];
|
||||
|
||||
if(!$packingList[22]){
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var Order $order */
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
continue;
|
||||
}
|
||||
|
||||
$packingListReference = $packingList[16];
|
||||
|
||||
try{
|
||||
$this->fetchesPackingList->execute(['reference' => $packingListReference]);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
$contractReference = $contract->hash_id;
|
||||
$contractObligations = $contract->contract_obligation_list;
|
||||
|
||||
$this->unityActivateContract->execute($contractReference);
|
||||
|
||||
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
||||
|
||||
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||
|
||||
$connection = $order->companyModule->connections()->first();
|
||||
$marking = $connection->invitee_reference;
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, (int) filter_var($marking, FILTER_SANITIZE_NUMBER_INT) <= 1000 ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::SUSPENDED, $contractReference);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
$container->packingLists()->attach($packingList);
|
||||
|
||||
foreach($contractObligations as $obligation) {
|
||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||
$this->createsStep->execute($packingList, $stepObject);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\PackingList;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchPackingListFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var ListsPackingLists */
|
||||
private $listsPackingLists;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/**
|
||||
* FetchPackingListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param ListsPackingLists $listsPackingLists
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, ListsPackingLists $listsPackingLists, CreatePackageProcessor $createPackageProcessor)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->listsPackingLists = $listsPackingLists;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->whereDoesntHave('containers', function($query){
|
||||
$query->where('status', '=', ApprovalStatus::COMPLETED);
|
||||
})->get();
|
||||
|
||||
foreach($packingLists as $packingList){
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]';
|
||||
|
||||
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
|
||||
$packingList->packages()->delete();
|
||||
|
||||
foreach($shippingPackingLists->Rows as $shippingPackingList){
|
||||
if(!$shippingPackingList[22]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $shippingPackingList[19], $shippingPackingList[31], $shippingPackingList[30], $shippingPackingList[29], 0, $shippingPackingList[22], ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\PackingList;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchPackingListProcessor
|
||||
{
|
||||
|
||||
/** @var ListsPackingLists */
|
||||
private $listsPackingLists;
|
||||
|
||||
/**
|
||||
* FetchPackingListFromVTPortalProcessor constructor.
|
||||
* @param ListsPackingLists $listsPackingLists
|
||||
*/
|
||||
public function __construct(ListsPackingLists $listsPackingLists)
|
||||
{
|
||||
$this->listsPackingLists = $listsPackingLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute($params){
|
||||
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)
|
||||
->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])
|
||||
->whereDoesntHave('containers', function($query){
|
||||
$query->where('status', '=', ApprovalStatus::COMPLETED);
|
||||
})->orderBy('created_at','desc')->where('owner_id',$params['orderId'])->get();
|
||||
|
||||
//dd($packingLists);
|
||||
$packingListsArray=[];
|
||||
foreach($packingLists as $packingList){
|
||||
|
||||
$address = $packingList->owner->addresses()->first();
|
||||
$packingList->fulladdress = $address->street_one.', '.$address->street_two.', '.$address->district->name.', '.$address->post_code.' '.$address->state->name.', '.$address->country->name;
|
||||
|
||||
$container = $packingList->containers()->first();
|
||||
$packingList->container_reference = $container->reference;
|
||||
$packingList->container_number = $container->container_number;
|
||||
|
||||
$packingListsArray[]=$packingList;
|
||||
|
||||
}
|
||||
|
||||
return $packingListsArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+181
-216
@@ -2,275 +2,240 @@
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\General\Services\GeneratesInitials;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Addresses\Processors\CreateAddressFromOldAddressProcessor;
|
||||
use App\Classes\Modules\Addresses\Services\CleansOldAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\CreatePackageRemarkLogic;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Models\Company;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\District;
|
||||
use App\Models\OldAddress;
|
||||
use App\Models\OldCompany;
|
||||
use App\Models\OldOrders;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
{
|
||||
|
||||
/** @var CreateUserProcessor */
|
||||
private $createUserProcessor;
|
||||
|
||||
/** @var CreateCompanyProcessor */
|
||||
private $createCompanyProcessor;
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var UpdatesCompanyStatus*/
|
||||
private $updatesCompanyStatus;
|
||||
/** @var CleansOldAddress */
|
||||
private $cleansOldAddress;
|
||||
|
||||
/** @var CreateCompanyModuleProcessor */
|
||||
private $createCompanyModuleProcessor;
|
||||
/** @var CreateAddressFromOldAddressProcessor */
|
||||
private $createAddressFromOldAddressProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesCompanyConnection */
|
||||
private $createsCompanyConnection;
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var ApprovesCompanyConnection */
|
||||
private $approvesCompanyConnection;
|
||||
/** @var CreateOrderProcessor */
|
||||
private $createOrderProcessor;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageRemarkLogic */
|
||||
private $createPackage;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/**
|
||||
* FetchWarehouseReceiveListFromVTPortalProcessor constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param CleansOldAddress $cleansOldAddress
|
||||
* @param CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param CreateOrderProcessor $createOrderProcessor
|
||||
* @param FetchesPackingList $fetchesPakcingList
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageRemarkLogic $createPackage
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, UpdatesCompanyStatus $updatesCompanyStatus, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, CreatesAddress $createsAddress)
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CleansOldAddress $cleansOldAddress, CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor, FetchesCompanyModule $fetchesCompanyModule, FetchesOrder $fetchesOrder, CreateOrderProcessor $createOrderProcessor, FetchesPackingList $fetchesPakcingList, CreatePackingListProcessor $createPackingListProcessor, CreatePackageRemarkLogic $createPackage, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->cleansOldAddress = $cleansOldAddress;
|
||||
$this->createAddressFromOldAddressProcessor = $createAddressFromOldAddressProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesPackingList = $fetchesPakcingList;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackage = $createPackage;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(){
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null){
|
||||
|
||||
// $addresses = OldAddress::whereIn('id', [2, 3, 4, 9, 11, 12, 17, 18, 19, 22, 23, 27, 28, 30, 31, 33, 36, 38, 40, 42, 45, 50, 51, 52, 53, 54, 58, 59, 61, 67, 68, 70, 72, 78, 80, 82, 83, 85, 86, 89, 93, 94, 97, 100, 102, 103, 104, 106, 107, 111, 115, 120, 125, 126, 128, 130, 131, 132, 133, 134, 135, 136, 137, 140, 142, 144, 145, 155, 156, 159, 170, 172, 173, 175, 177, 178, 180, 181, 182, 183, 185, 186, 187, 190, 199, 200, 202, 204, 207, 210, 213, 214, 215, 217, 218, 220, 222, 228, 231, 232, 234, 237, 242, 244, 245, 251, 252, 255, 258, 259, 261, 262, 266, 268, 273, 274, 275, 278, 281, 282, 285, 287, 292, 294, 295, 296, 297, 299, 303, 306, 307, 308, 311, 315, 316, 317, 319, 320, 321, 328, 329, 330, 332, 333, 334, 336, 339, 341]);
|
||||
$companies = OldCompany::has('orders')->get();
|
||||
DB::beginTransaction();
|
||||
|
||||
foreach($companies as $company){
|
||||
try {
|
||||
|
||||
$marking = explode("CIEF/", $company->marking);
|
||||
if(count($marking) < 2){
|
||||
continue;
|
||||
$start = $start ? $start : Carbon::now()->subMonth();
|
||||
|
||||
$startLimit = Carbon::parse('11-08-2021');
|
||||
|
||||
if($start->isBefore($startLimit)){
|
||||
$start = $startLimit;
|
||||
}
|
||||
|
||||
/** @var Company $newCompany */
|
||||
$newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION);
|
||||
$end = $end ? $end : Carbon::now();
|
||||
|
||||
$this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED);
|
||||
$filter = '["ParcelDate:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]';
|
||||
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER);
|
||||
$warehouseListRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ParcelDate asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking[1]);
|
||||
$response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest);
|
||||
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
foreach ($response->Rows as $parcel){
|
||||
|
||||
$i = 0;
|
||||
foreach($company->addresses as $address){
|
||||
if($address->street_one === '' && $address->street_two === ''){
|
||||
continue;
|
||||
}
|
||||
$marking = explode('/', explode('CIEF/', $parcel[5])[1]);
|
||||
|
||||
if(!$address->post_code){
|
||||
continue;
|
||||
}
|
||||
|
||||
$district = District::where('postcode', 'like', '%'. $address->post_code .'%')->first();
|
||||
|
||||
if(!$district) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$street_one = str_replace($district->name, '',str_replace($district->state->name, '', $address->street_one));
|
||||
$street_two = str_replace($district->name, '',str_replace($district->state->name, '', $address->street_two));
|
||||
|
||||
$object = new AddressObject($street_one, $street_two, $district->country_id, $district->state_id, $district->id, $address->post_code, 'Business Address');
|
||||
$this->createsAddress->execute($companyModule, $object);
|
||||
|
||||
if($address->contact){
|
||||
$i++;
|
||||
if($i === 1) {
|
||||
$contactObject = new ContactObject('', $address->contact, $company->email, '',);
|
||||
$this->createContactProcessor->execute($contactObject, $newCompany);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
dd('done');
|
||||
|
||||
return '';
|
||||
Cache::forget('VT_COOKIE_CACHE');
|
||||
$loginRequest = $this->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC"}}'), '');
|
||||
$response = $this->getResponseBody($loginRequest);
|
||||
$orders = [];
|
||||
$unknown = 0;
|
||||
|
||||
|
||||
foreach ($response->Rows as $parcel){
|
||||
$marking = explode('/', explode('CIEF/', $parcel[5])[1]);
|
||||
$customerMarking = $marking[0];
|
||||
if($customerMarking === '2752CHG'){
|
||||
if(!array_key_exists(1, $marking)){
|
||||
$unknown++;
|
||||
echo "found and order without order number";
|
||||
continue;
|
||||
}
|
||||
|
||||
$orderNumber = $marking[1];
|
||||
$ctn = $parcel[9];
|
||||
if(!array_key_exists($customerMarking, $orders)){
|
||||
$orders[$customerMarking] = [
|
||||
$orderNumber => [
|
||||
'ctn' => $ctn,
|
||||
'cbm' => $parcel[10],
|
||||
]
|
||||
];
|
||||
|
||||
if(!$parcel[9]){
|
||||
continue;
|
||||
}
|
||||
//
|
||||
|
||||
if(!array_key_exists($orderNumber, $orders[$customerMarking])){
|
||||
$orders[$customerMarking][$orderNumber]['ctn'] = 0;
|
||||
$orders[$customerMarking][$orderNumber]['cbm'] = 0;
|
||||
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
$oldOrder = OldOrders::where('marking', '=', $orderNumber)->first();
|
||||
|
||||
if(!$oldOrder){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$customerMarking = str_replace('/', '', str_replace(' ', '', explode('CIEF/', $oldOrder->company->marking)[1]));
|
||||
|
||||
$companyModule = CompanyModule::whereHas('inviters', function($query) use ($customerMarking) {
|
||||
return $query->where('invitee_reference', '=', $customerMarking);
|
||||
})->first();
|
||||
|
||||
|
||||
if(!$companyModule){
|
||||
log::error('unknown customer: '.$customerMarking);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$oldOrder->address) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @var Address $address */
|
||||
$address = $this->createAddressFromOldAddressProcessor->execute($oldOrder->address, $companyModule);
|
||||
|
||||
if(!$address){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$warehouseId = $parcel[0];
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]);
|
||||
|
||||
$order = $this->createOrderProcessor->execute($companyModule->company, $originWarehouse, $address, $orderNumber);
|
||||
|
||||
$order->created_at = Carbon::parse($parcel[1]);
|
||||
$order->save();
|
||||
|
||||
}
|
||||
|
||||
$orders[$customerMarking][$orderNumber]['ctn'] += $ctn;
|
||||
$orders[$customerMarking][$orderNumber]['cbm'] += $parcel[10];
|
||||
$packingListReference = $parcel[17];
|
||||
$quantity = $parcel[9];
|
||||
$measurement = round(($parcel[10]/$quantity) ** (1/3) * 100, 2);
|
||||
$description = $parcel[7];
|
||||
$tracking = $parcel[6];
|
||||
$receiveDate = $parcel[1];
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::APPROVED);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $order->packingLists()->where('reference', '=', $packingListReference)->first();
|
||||
|
||||
if(!$packingList) {
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $tracking, Carbon::parse($receiveDate), Carbon::parse($receiveDate), ApprovalStatus::APPROVED);
|
||||
|
||||
|
||||
$this->createsTransport->execute($transportObject, $packingList);
|
||||
}
|
||||
|
||||
/** @var Transport $transport */
|
||||
$transport = $packingList->transports()->first();
|
||||
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject(Carbon::parse($receiveDate), Carbon::parse($receiveDate), ApprovalStatus::APPROVED));
|
||||
|
||||
$packingList->packages()->delete();
|
||||
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $description, $measurement, $measurement, $measurement, 0, $quantity, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
|
||||
}
|
||||
|
||||
// $orders[$customerMarking][$orderNumber]['cbm'] += $parcel[10];
|
||||
// $orders[$customerMarking][$orderNumber]['ctn'] += $ctn;
|
||||
// if(!$orders->contains($customerMarking)){
|
||||
// $orders->push(collect([
|
||||
// $customerMarking => collect()
|
||||
// ]));
|
||||
// }
|
||||
// dd($orders);
|
||||
//
|
||||
// if(!$orders[$customerMarking]->contains($orderNumber)){
|
||||
// $orders[$customerMarking]->push(collect([
|
||||
// $orderNumber => [
|
||||
// 'ctn' => $ctn,
|
||||
// 'cbm' => $parcel[10]
|
||||
// ]
|
||||
// ]));
|
||||
// } else {
|
||||
// $orders[$customerMarking][$orderNumber]['ctn'] += $ctn;
|
||||
// $orders[$customerMarking][$orderNumber]['cbm'] += $parcel[10];
|
||||
// }
|
||||
}
|
||||
dd($orders, $unknown);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private function remoteLogin(){
|
||||
|
||||
$latest_cookie = [];
|
||||
$cookieRequest = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$cookieRequest->get('https://portalvt.azurewebsites.net');
|
||||
foreach ($cookieRequest->getConfig('cookies')->toArray() as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception->getMessage());
|
||||
}
|
||||
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
|
||||
|
||||
/** @var $loginRequest */
|
||||
$loginRequest = $this->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login', 'POST', [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
], $latest_cookie, false);
|
||||
|
||||
Cache::store('file')->put('VT_COOKIE_CACHE', $latest_cookie.';AppVTCC='.$this->getResponseBody($loginRequest)->AccessToken, 3000);
|
||||
DB::commit();
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param $body
|
||||
* @param string $cookie
|
||||
* @param bool $requiresAuthentication
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private function clientRequest(string $url, string $method, $body, string $cookie, $requiresAuthentication = true){
|
||||
|
||||
if($requiresAuthentication) {
|
||||
if(!Cache::has('VT_COOKIE_CACHE')){
|
||||
$this->remoteLogin();
|
||||
}
|
||||
}
|
||||
|
||||
$client = new \GuzzleHttp\Client(
|
||||
[
|
||||
'cookies' => true,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => Cache::has('VT_COOKIE_CACHE') ? Cache::get('VT_COOKIE_CACHE'):$cookie
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$request = $client->request($method, $url, [\GuzzleHttp\RequestOptions::JSON => $body]);
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
private function getResponseBody(ResponseInterface $request){
|
||||
return json_decode($request->getBody()->getContents())->d;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingList\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use App\Classes\Modules\Orders\Processors\UpdatesOrderCurrentStepProcessor;
|
||||
use App\Classes\Modules\Steps\Processors\UpdateStepsProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Steps\Services\FetchesSteps;
|
||||
use App\Classes\Modules\Orders\Services\UpdatesCurrentStep;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanUpdateCurrentStep;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesManySteps;
|
||||
use App\Classes\ValueObjects\Constants\OrderStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderSteps;
|
||||
use App\Classes\ValueObjects\Constants\Steps;
|
||||
use App\Classes\Modules\Unity\Processors\GetContractObligationsProcessor;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Order;
|
||||
use App\Models\Step;
|
||||
use App\Classes\Jobs\UnityLogin;
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
|
||||
class GenerateShippingOrderStepsProcessor
|
||||
{
|
||||
/** @var CreatesManySteps */
|
||||
private $createsManyStep;
|
||||
|
||||
/** @var UpdateStepsProcessor */
|
||||
private $updateStepProcessors;
|
||||
|
||||
/**
|
||||
* GenerateShippingOrderStepsProcessor constructor.
|
||||
* @param CreatesManySteps $createsManyStep
|
||||
* @param UpdateStepsProcessor $updateStepProcessors
|
||||
*/
|
||||
public function __construct(CreatesManySteps $createsManyStep, UpdateStepsProcessor $updateStepProcessors)
|
||||
{
|
||||
$this->createsManyStep = $createsManyStep;
|
||||
$this->updateStepProcessors = $updateStepProcessors;
|
||||
}
|
||||
|
||||
|
||||
public function execute(Steppable $owner, CompanyModule $appointee, array $contract_obligation_list = []){
|
||||
|
||||
$obligations = $contract_obligation_list;
|
||||
|
||||
$this->createsManyStep->execute($owner, array_map(function($obligation) use ($appointee) {
|
||||
return new StepsObject($appointee->id, $obligation->name,true, $step->sequence??0, 0,0, null,0, $step->hash_id);
|
||||
}, $obligations));
|
||||
|
||||
$this->updateStepProcessors->execute(OrderSteps::PROCESSING);
|
||||
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
|
||||
use App\Models\Order;
|
||||
|
||||
class ChecksIfPackingListReferenceNumberExists
|
||||
{
|
||||
|
||||
private $repository;
|
||||
|
||||
public function __construct(Order $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(string $reference_number): bool {
|
||||
return $this->repository->where('reference', $reference_number)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,26 +2,30 @@
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services\Containers;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\ContainerOwner;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Models\Container;
|
||||
|
||||
class CreatesContainer extends AbstractUpdateRecord
|
||||
class CreatesContainer extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param ContainerObject $object
|
||||
* @param ContainerOwner $owner
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(ContainerObject $object) {
|
||||
public function execute(ContainerObject $object, ContainerOwner $owner) {
|
||||
$model = new Container();
|
||||
|
||||
$model->packing_list_id = $object->getPackingListId();
|
||||
$model->container_reference = $object->getContainerReference();
|
||||
$model->reference = $object->getReference();
|
||||
$model->container_number = $object->getContainerNumber();
|
||||
$model->container_type = $object->getContainerType();
|
||||
$model->seal_reference = $object->getSealReference();
|
||||
$model->loading_date = $object->getLoadingDate();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
return $this->handler($owner->containers(), $model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class UpdatesContainer extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Container $model, ContainerObject $object) {
|
||||
|
||||
$model->container_reference = $object->getContainerReference();
|
||||
$model->reference = $object->getReference();
|
||||
$model->container_type = $object->getContainerType();
|
||||
$model->seal_reference = $object->getSealReference();
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services\Containers;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Container;
|
||||
|
||||
class UpdatesContainerStatus extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Container $model
|
||||
* @param int $status
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Container $model, int $status) {
|
||||
|
||||
$model->status = $status;
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,27 @@
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatesPackingList extends AbstractUpdateRecord
|
||||
class CreatesPackingList extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
public function execute(PackingListObject $object) {
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param Packable $packable
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingListObject $object, Packable $packable) {
|
||||
$model = new PackingList();
|
||||
|
||||
$model->reference = $object->getReference();
|
||||
$model->claimant_id = $object->getClaimantId();
|
||||
$model->type = $object->getType();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
return $this->handler($packable->packingLists(), $model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
|
||||
|
||||
class GeneratesPackingListReferenceNumber
|
||||
{
|
||||
|
||||
/** @var ChecksIfPackingListReferenceNumberExists */
|
||||
private $checksIfPackingListReferenceNumberExists;
|
||||
|
||||
/**
|
||||
* GeneratesTransactionBillNo constructor.
|
||||
* @param ChecksIfPackingListReferenceNumberExists $checksIfPackingListRefrenceNumberExists
|
||||
*/
|
||||
public function __construct(ChecksIfPackingListReferenceNumberExists $checksIfPackingListReferenceNumberExists)
|
||||
{
|
||||
$this->checksIfPackingListReferenceNumberExists = $checksIfPackingListReferenceNumberExists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function execute(): string {
|
||||
|
||||
$referenceNumber = mt_rand(10000000, 99999999);
|
||||
|
||||
return !$this->checksIfPackingListReferenceNumberExists->execute($referenceNumber) ? $referenceNumber : self::execute();
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,15 @@
|
||||
namespace App\Classes\Modules\PackingLists\Services\Packages;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Models\Package;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatesPackage extends AbstractUpdateRecord
|
||||
class CreatesPackage extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
public function execute(PackageObject $object) {
|
||||
public function execute(PackageObject $object, PackingList $packingList) {
|
||||
$model = new Package();
|
||||
$model->order_id = $object->getOrderId();
|
||||
$model->claimant_id = $object->getClaimantId();
|
||||
$model->type = $object->getType();
|
||||
$model->description = $object->getDescription();
|
||||
$model->width = $object->getWidth();
|
||||
@@ -21,7 +21,7 @@ class CreatesPackage extends AbstractUpdateRecord
|
||||
$model->quantity = $object->getQuantity();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
return $this->handler($packingList->packages(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services\Packages;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Package;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class SwitchesPackagePackingList extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Package $model
|
||||
* @param int $status
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Package $model, PackingList $packing_list) {
|
||||
|
||||
$model->packing_list_id = $packing_list->id;
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ class UpdatesPackage extends AbstractUpdateRecord
|
||||
{
|
||||
public function execute(Package $model, PackageObject $object) {
|
||||
|
||||
$model->claimant_id = $object->getClaimantId();
|
||||
$model->type = $object->getType();
|
||||
$model->description = $object->getDescription();
|
||||
$model->width = $object->getWidth();
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class UpdatesPackingListStatus extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param PackingList $model
|
||||
* @param int $status
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $model, int $status) {
|
||||
|
||||
$model->status = $status;
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
@@ -10,16 +10,16 @@ use App\Classes\Modules\PackingLists\Standards\Validators\ContainerValidation;
|
||||
class CanCreateContainer extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var PackingListValidation */
|
||||
private $containerPackingListValidation;
|
||||
/** @var ContainerValidation */
|
||||
private $containerValidation;
|
||||
|
||||
/**
|
||||
* CanCreatePackingList constructor.
|
||||
* @param PackingListValidation $PackingListValidation
|
||||
* CanCreateContainer constructor.
|
||||
* @param ContainerValidation $containerValidation
|
||||
*/
|
||||
public function __construct(ContainerValidation $containerPackingListValidation)
|
||||
public function __construct(ContainerValidation $containerValidation)
|
||||
{
|
||||
$this->containerPackingListValidation = $containerPackingListValidation;
|
||||
$this->containerValidation = $containerValidation;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,19 +34,19 @@ class CanCreateContainer extends AbstractRule
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param ContainerObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->containerPackingListValidation->validate($object);
|
||||
return $this->containerValidation->validate($object);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param ContainerObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Containers\Rules;
|
||||
namespace App\Classes\Modules\PackingLists\Standards\Rules\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user