mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
261 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b9c411c3d | |||
| 6b5ae9b0b7 | |||
| eb92a76a0b | |||
| a1bc3aa652 | |||
| e5af2bf171 | |||
| 2443575744 | |||
| 864bbc70b6 | |||
| c439bb5d61 | |||
| 82b99a40cf | |||
| 272ce5fa39 | |||
| c16a49d55c | |||
| c85b603b81 | |||
| 6c6b104dff | |||
| 430b26def0 | |||
| 2d9482feb6 | |||
| 615e3e7683 | |||
| 32936af538 | |||
| 7f4fdf0191 | |||
| 1c4d9520f9 | |||
| 6c7685dac2 | |||
| 4653e8403b | |||
| a648a11567 | |||
| a78ed8271f | |||
| 16ce06ba7e | |||
| 5335b8affb | |||
| 6d1153298c | |||
| 8f65767996 | |||
| 4bba550b9e | |||
| b33b780563 | |||
| 342285247a | |||
| 0c82aa17fc | |||
| ed36b85a3d | |||
| 4f8e9fbd5f | |||
| ee575c21ea | |||
| f4f8c34cb9 | |||
| 7cb27a6114 | |||
| 2f4b568c9a | |||
| a23e0b35a2 | |||
| 598ca3807e | |||
| 0654f0335b | |||
| e4610e1a53 | |||
| 38ae8f72eb | |||
| cbdd4e8137 | |||
| c4d2b4e476 | |||
| 7eab58b45e | |||
| a9b21e9566 | |||
| 9aec5a71f1 | |||
| 771b10ffc9 | |||
| a9d4806a4a | |||
| 0d0048eb6c | |||
| d5f3e9ba71 | |||
| 5144e940f2 | |||
| 8dac196cb9 | |||
| e1bc996efb | |||
| ed7019f75e | |||
| 0f0a32488a | |||
| b3cc805e78 | |||
| fd8a09d443 | |||
| 8d5603c756 | |||
| c3de10f676 | |||
| 80a47f05f7 | |||
| 53cc2ee493 | |||
| fadef468bb | |||
| 3f0028aaf1 | |||
| 7ea7db9f49 | |||
| 7a95741af9 | |||
| 75c7772d98 | |||
| 851489bd12 | |||
| 666b5a7791 | |||
| a1461f899b | |||
| 2fda9e0c46 | |||
| ec2b46b192 | |||
| 833c4c5905 | |||
| 1aea633375 | |||
| cc90c16d9a | |||
| 10af83056a | |||
| cd930dbaf0 | |||
| 2bf3e38ced | |||
| 5f4010bb50 | |||
| 5955c1a633 | |||
| 7ece4f6470 | |||
| e0e82634d3 | |||
| 988e798cf1 | |||
| 4ce8440724 | |||
| e2f5097882 | |||
| 9f96caad7c | |||
| 3046530f71 | |||
| 84a6cb85dd | |||
| c86ea9cee4 | |||
| ac15f76c4f | |||
| 1fc176296e | |||
| 3f911f145a | |||
| d5c28df748 | |||
| 9bfe943898 | |||
| dbcbabec93 | |||
| e24cdd82d4 | |||
| 01854a3292 | |||
| 679bae6fe8 | |||
| f567995202 | |||
| 35b3cb4515 | |||
| 196cf3d58a | |||
| b12a862903 | |||
| f586314cd8 | |||
| 16f41482ad | |||
| 95866b0789 | |||
| fb2ba2a3c7 | |||
| 3041144968 | |||
| 2efdb33b71 | |||
| 5716050694 | |||
| e22c7c7e8b | |||
| d9972a8a95 | |||
| 6dbafde89c | |||
| 680ddd5066 | |||
| f6b5eb3098 | |||
| 82f8cae4a8 | |||
| 4c868de356 | |||
| c44278fe26 | |||
| 43c8530e6d | |||
| 198e0674bd | |||
| 7d09205817 | |||
| 5f5dbeb3d1 | |||
| 67a877ca15 | |||
| 88e7bf44b5 | |||
| 86461c19a1 | |||
| 18d1841a30 | |||
| 990508501d | |||
| dfec2073b0 | |||
| 2300d237d3 | |||
| a62e5d95fb | |||
| 2d8535b7f5 | |||
| 3f21802090 | |||
| e8191df0e9 | |||
| 02064ad68e | |||
| 13319aacff | |||
| 996ef4205f | |||
| 0aaa7f486a | |||
| 35dc74c3bb | |||
| 0310138644 | |||
| 7e439a38fd | |||
| 1c800b70ec | |||
| c614190de8 | |||
| 551fb7deaa | |||
| d91e0e56c3 | |||
| 2248e76bd4 | |||
| df283e54a2 | |||
| 769b5dd050 | |||
| 4c023aa393 | |||
| 7922c10e2c | |||
| 742fdf307b | |||
| df993fe491 | |||
| 5f5707718f | |||
| d7d9a065fd | |||
| 568d45808a | |||
| 715051076c | |||
| 7642f6e9d3 | |||
| 84ad39ac11 | |||
| 03b44cf71d | |||
| 0b577c22f4 | |||
| cabb7b7d63 | |||
| 880d3fc8ce | |||
| 8d901505fe | |||
| 489216e7be | |||
| e413dfa795 | |||
| 4ff5c6df80 | |||
| 851e2e1815 | |||
| 503bc90556 | |||
| 762add8e5c | |||
| 96723461e4 | |||
| 2c1431a813 | |||
| 90ca018e81 | |||
| 60c51419bb | |||
| 69f98125a0 | |||
| f56bfb0309 | |||
| aedd836211 | |||
| abfb0ea47b | |||
| 09461e5bef | |||
| d5b16f288a | |||
| 7c1a77089b | |||
| 505d924eec | |||
| d0dd802693 | |||
| 3113cc9fc0 | |||
| 840e1147c8 | |||
| 5c89471e14 | |||
| fbc73e040f | |||
| 414f22ab05 | |||
| d7328bafdc | |||
| 5c5505174a | |||
| 6b73d13c33 | |||
| 8a62807356 | |||
| acca5192b6 | |||
| dfbf22951b | |||
| cc26e67340 | |||
| 15db2715f5 | |||
| 2fc54f796a | |||
| 91b14b3820 | |||
| 7dc549ab2e | |||
| 5480a55edc | |||
| 0cb3bd6ce3 | |||
| f2cc45303c | |||
| e0db537931 | |||
| 53b4af2b5c | |||
| c9d2041653 | |||
| 53e9fcaeb8 | |||
| 7e007e7d78 | |||
| 7c879c8633 | |||
| 9f255664ac | |||
| 63918b4eb0 | |||
| ae36513635 | |||
| 7ac66080ec | |||
| 4b699345b8 | |||
| 634a97f3b4 | |||
| 8a4810d961 | |||
| ab3ba64d31 | |||
| 7bca4be9b9 | |||
| 4f12c7c8ac | |||
| 759a9c19d7 | |||
| 6fa72a4195 | |||
| c82581dcc4 | |||
| d4a63c0095 | |||
| 22b03669c6 | |||
| 58e9e80fd9 | |||
| 4dab73fc8e | |||
| 9b87f26ca3 | |||
| cd81683816 | |||
| 169fac4ab0 | |||
| 34b4482139 | |||
| 945e8585d4 | |||
| 68cb7b7df1 | |||
| 84b6750bcc | |||
| 7f766cde6a | |||
| 5d1bb976f8 | |||
| 529eb1be93 | |||
| 95fd0aa45d | |||
| 64a7e4e0b7 | |||
| de4577346c | |||
| 0ac9ca38f2 | |||
| 4b79039a18 | |||
| 4b32a48e07 | |||
| eb09993397 | |||
| 627d782e5d | |||
| 04771cec4f | |||
| d7630af675 | |||
| 37c710def6 | |||
| 7423588324 | |||
| cb76e86c75 | |||
| cb862123b5 | |||
| 032efcb96b | |||
| a90730d616 | |||
| d5026df3a5 | |||
| 6dd3849bff | |||
| 9e4bad1eee | |||
| e356573715 | |||
| de6cb6a75f | |||
| 524da42526 | |||
| 1abc99fe10 | |||
| e91e770bf3 | |||
| 2e5d39fe96 | |||
| 6efa78e40d | |||
| df862b7107 | |||
| 9df97f3db5 | |||
| aa2ce980bc |
@@ -95,4 +95,4 @@ abstract class AbstractControllerLogic
|
||||
return $this->response(json_decode($collection->response()->getContent(), true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,11 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
||||
$query = $query->orderBy($filters->get('order_by')->column, $filters->get('order_by')->DESC ? 'DESC': 'ASC');
|
||||
}
|
||||
|
||||
if($filters->has('group_by')){
|
||||
$query = $query->groupBy($filters->get('group_by')->column);
|
||||
}
|
||||
|
||||
//dd($query->toSql());
|
||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreditTerm implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder;
|
||||
|
||||
return $builder->whereHas('packingLists.owner', function($query) use($value) {
|
||||
$query->whereHas('companyModule.connections', function($query) use($value){
|
||||
if ($value) {
|
||||
$query->whereHas('segments', function($query) {
|
||||
$query->where('segments.id' , 3);
|
||||
});
|
||||
}else{
|
||||
$query->whereDoesntHave('segments', function($query) {
|
||||
$query->where('segments.id' , 3);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OrderMarkingIn implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('owner', function($query) use ($value) {
|
||||
$query->where('reference', 'LIKE', '%' . $value . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PackingListOrderedByInvoiceDate implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->select('packing_lists.*')->join('transactions', function($join){
|
||||
$join->on('transactions.owner_id', '=', 'packing_lists.id');
|
||||
$join->where('transactions.owner_type', '=', PackingList::class);
|
||||
$join->where('transactions.status', '=', ApprovalStatus::APPROVED);
|
||||
})->orderBy('transactions.updated_at', 'DESC');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PaymentDay implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('transactions', function (Builder $query) use($value) {
|
||||
$query->where('transactions.type', 1)->where('status', ApprovalStatus::APPROVED)->whereDate('updated_at', '<=', Carbon::now()->subdays($value));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class Receiver implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('receiver', '=', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Traits;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait LogData
|
||||
{
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
|
||||
static::updating(function($model)
|
||||
{
|
||||
|
||||
$tableName = Str::singular($model->table).'_logs';
|
||||
$relationshipColumn = Str::singular($model->table).'_id';
|
||||
|
||||
$originalData = $model->getRawOriginal();
|
||||
|
||||
$originalData[$relationshipColumn] = $originalData['id'];
|
||||
unset($originalData['id']);
|
||||
|
||||
if (!Schema::hasTable($tableName)) {
|
||||
DB::statement('CREATE TABLE '.$tableName.' LIKE '.$model->table);
|
||||
|
||||
$indexs = DB::select('SHOW INDEX FROM '.$tableName.';');
|
||||
|
||||
$removedIndexes = [];
|
||||
foreach ($indexs as $index){
|
||||
if($index->Column_name === 'id' || in_array($index->Key_name, $removedIndexes)) continue;
|
||||
DB::statement('ALTER TABLE '.$tableName.' drop index '.$index->Key_name);
|
||||
$removedIndexes[] = $index->Key_name;
|
||||
}
|
||||
|
||||
DB::statement('ALTER TABLE '.$tableName.' ADD COLUMN `'.$relationshipColumn.'` BIGINT NOT NULL AFTER `id`');
|
||||
}
|
||||
|
||||
DB::table($tableName)->insert($originalData);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryUpdatesFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -25,8 +29,12 @@ class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
||||
|
||||
(App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanFetchUser;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Http\Resources\UserCompanyResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchUserByEmailLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Fetch Users',
|
||||
'message' => 'You have successfully retrieved the user by email'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchUser */
|
||||
private $canFetchUser;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/**
|
||||
* FetchUserByEmailLogic constructor.
|
||||
* @param CanFetchUser $canFetchUser
|
||||
* @param FetchesUser $fetchessUser
|
||||
*/
|
||||
public function __construct(CanFetchUser $canFetchUser, FetchesUser $fetchesUser)
|
||||
{
|
||||
$this->canFetchUser = $canFetchUser;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->canFetchUser->passes();
|
||||
|
||||
$query = $this->fetchesUser->execute(['email' => $request->route('email')]);
|
||||
|
||||
return $this->resourceResponse(new UserCompanyResource($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,4 +67,4 @@ class AuthenticationProcessor
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ class AuthenticatesUser
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleName;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyDebtor;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyNameAndDebtorLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Company Name and Debtor',
|
||||
'message' => 'You have successfully updated the Company'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateCompany */
|
||||
private $canUpdateCompany;
|
||||
|
||||
/** @var UpdatesCompany */
|
||||
private $updatesCompany;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyDebtor */
|
||||
private $updatesCompanyDebtor;
|
||||
|
||||
/** @var UpdatesCompanyModuleName */
|
||||
private $updatesCompanyModuleName;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyDebtor $updatesCompanyDebtor
|
||||
* @param UpdatesCompanyModuleName $updatesCompanyModuleName
|
||||
*/
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany, UpdatesCompanyDebtor $updatesCompanyDebtor, UpdatesCompanyModuleName $updatesCompanyModuleName)
|
||||
{
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyDebtor = $updatesCompanyDebtor;
|
||||
$this->updatesCompanyModuleName = $updatesCompanyModuleName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('type'));
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->updatesCompanyModuleName->execute($query->companyModules()->first(), $object->getName());
|
||||
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
if ($request->input('debtor') || $query->first()->debtor !== null) {
|
||||
$this->updatesCompanyDebtor->execute($query, $request->input('debtor'));
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesCompanyDebtor extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $model
|
||||
* @param CompanyObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, ?string $debtor)
|
||||
{
|
||||
$model->debtor = $debtor;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Company;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ExportsCustomerTotalOrderByYear implements FromCollection, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'CompanyId',
|
||||
'CompanyName',
|
||||
'CompanyReference',
|
||||
'TotalCbm'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->whereHas('containers', function($container){
|
||||
return $container->where('loading_date', '>=', Carbon::parse('01-01-' . $this->request->route('year')))
|
||||
->where('loading_date', '<=', Carbon::parse('31-12-' . $this->request->route('year')));
|
||||
})->get();
|
||||
|
||||
$packingLists = $packingLists->groupBy(function ($packingList){
|
||||
return $packingList->owner->company_module_id;
|
||||
})->sortByDesc(function($companyModule){
|
||||
return $companyModule->sum(function($packingList){
|
||||
return $packingList->packages->sum(function ($package){
|
||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
});
|
||||
});
|
||||
})->take(10);
|
||||
return $packingLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $row
|
||||
* @return array
|
||||
*/
|
||||
public function map($row): array
|
||||
{
|
||||
|
||||
$companyModule = $row[0]->owner->companyModule;
|
||||
$marking = $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
|
||||
$cbm = $row->sum(function($packingList){
|
||||
return $packingList->packages->sum(function ($package){
|
||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
});
|
||||
});
|
||||
|
||||
return [
|
||||
$companyModule->company_id,
|
||||
$companyModule->name,
|
||||
$marking,
|
||||
$cbm
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\Package;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsOrderSummaryByMarking implements FromCollection, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
protected $customerMarking;
|
||||
protected $dateFrom;
|
||||
protected $dateTo;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Date',
|
||||
'Container',
|
||||
'Order Marking',
|
||||
'Packing List Reference',
|
||||
'Description',
|
||||
'Quantity',
|
||||
'L (cm)',
|
||||
'H (cm)',
|
||||
'W (cm)',
|
||||
'CBM'
|
||||
];
|
||||
}
|
||||
|
||||
public function setParameters($customerMarking, $dateFrom, $dateTo)
|
||||
{
|
||||
$this->customerMarking = $customerMarking;
|
||||
$this->dateFrom = $dateFrom;
|
||||
$this->dateTo = $dateTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$connection = CompanyConnection::where('invitee_reference', $this->customerMarking)->first();
|
||||
|
||||
$company_id = $connection->invitee->company->id;
|
||||
$company_module_id = $connection->invitee->id;
|
||||
$packagesArray = collect();
|
||||
$orders = Order::where('company_module_id', $company_module_id);
|
||||
|
||||
if (isset($this->dateFrom) && isset($this->dateTo)) {
|
||||
$from = Carbon::createFromFormat('d-m-Y', $this->dateFrom);
|
||||
$to = Carbon::createFromFormat('d-m-Y', $this->dateTo);
|
||||
$orders = $orders->whereBetween('created_at', [$from, $to]);
|
||||
}
|
||||
|
||||
$orders = $orders->get();
|
||||
|
||||
foreach ($orders as $order){
|
||||
$packingLists = $order->packingLists;
|
||||
foreach ($packingLists as $packingList){
|
||||
if($packingList->packingLists->first()){
|
||||
$packingList = $packingList->packingLists->first();
|
||||
}
|
||||
$packages = $packingList->packages;
|
||||
foreach ($packages as $package){
|
||||
$packagesArray->push($package);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Package $package
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($package): array
|
||||
{
|
||||
$packinglist = ($package->packingList()->first()->owner->owner_type == Order::class) ? $package->packingList()->first(): $package->packingList->owner;
|
||||
$order = $packinglist->owner;
|
||||
|
||||
return [
|
||||
Carbon::parse($package->created_at)->format('d-m-Y'),
|
||||
'',
|
||||
$order->reference,
|
||||
$package->packingList->reference,
|
||||
$package->description,
|
||||
$package->quantity,
|
||||
$package->length,
|
||||
$package->height,
|
||||
$package->width,
|
||||
((($package->length / 100) * ($package->height / 100) * ($package->width / 100)) * $package->quantity)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -60,19 +60,32 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
|
||||
$query = Transaction::query();
|
||||
|
||||
$query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED]);
|
||||
// paidInvoiceSection
|
||||
$approvalStatus = ApprovalStatus::COMPLETED;
|
||||
|
||||
if ($this->request->route('section') == 'pendingPaymentSection') {
|
||||
// pendingPaymentSection
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
$query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [$approvalStatus]);
|
||||
|
||||
if($start_date && $end_date) {
|
||||
$query->whereBetween('created_at', [
|
||||
$query->whereBetween('updated_at', [
|
||||
Carbon::parse($start_date)->format('Y-m-d 0:00:00'),
|
||||
Carbon::parse($end_date)->format('Y-m-d 23:59:59')
|
||||
]);
|
||||
}
|
||||
elseif($start_date && !$end_date) {
|
||||
$query->where('created_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00'));
|
||||
$query->whereHas('transactions', function($transaction) use ($start_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00'));
|
||||
});
|
||||
|
||||
}
|
||||
elseif(!$start_date && $end_date) {
|
||||
$query->where('created_at', '<=', Carbon::parse($end_date)->format('Y-m-d 23:59:59'));
|
||||
$query->whereHas('transactions', function($transaction) use ($end_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($end_date)->format('Y-m-d 0:00:00'));
|
||||
});
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\State;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Customer Marking',
|
||||
'Order Number'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$johor_state_id = State::where('name', 'johor')->first()->id;
|
||||
|
||||
return Order::whereHas('addresses', function($address) use ($johor_state_id){
|
||||
$address->where('status', ApprovalStatus::APPROVED)->where('state_id', $johor_state_id);
|
||||
})->whereHas('packingLists', function($packingLists) {
|
||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($order): array
|
||||
{
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
|
||||
return [
|
||||
$marking,
|
||||
$order->reference,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,11 @@ class FetchesDataFromYDPortal
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function clientRequest(string $url, string $method, $body){
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$body['apicode'] = env('YD_API_CODE');
|
||||
|
||||
$request = $client->requestAsync($method, $url, ['query' => $body]);
|
||||
$request = $client->requestAsync($method, $url, ['query' => $body, 'timeout' => 15]);
|
||||
|
||||
return $request->wait();
|
||||
}
|
||||
@@ -32,6 +31,7 @@ class FetchesDataFromYDPortal
|
||||
$content = $request->getBody()->getContents();
|
||||
$content = str_replace("\r",'', $content);
|
||||
$content = str_replace("\n",'', $content);
|
||||
$content = str_replace("\t",'', $content);
|
||||
return json_decode($content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,15 +51,15 @@ class CreatePackingListProcessor
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createsPackingList->execute($object, $packable);
|
||||
|
||||
$appointee_id = $packingList->owner_id == 1 ? 2037 : $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
$appointee_id = $packingList->owner_id == 1 ? 2307 : $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
|
||||
$type = $object->getType() === PackingListType::SHIPPING_PACKING_LIST ? PackingListType::SHIPPING_PACKING_LIST_REPLICA : PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA;
|
||||
|
||||
/** create packing list replica */
|
||||
$object = new PackingListObject($object->getReference().'_01', $appointee_id, $type, ApprovalStatus::PENDING_SUBMISSION);
|
||||
$this->createsPackingList->execute($object, $packingList);
|
||||
|
||||
|
||||
return $packingList;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||
|
||||
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\Schedules\DataTransferObjects\ScheduleObject;
|
||||
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\DataTransferObjects\TransportObject;
|
||||
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\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
||||
use App\Classes\Notifications\ShipmentRescheduleEmail;
|
||||
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\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FetchContainersFromYdPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromYDPortal */
|
||||
private $fetchesDataFRomYDPortal;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/** @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;
|
||||
|
||||
/**
|
||||
* FetchOrderListsFromYdPortalProcessor constructor.
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
* @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(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, FetchesOrder $fetchesOrder, UpdatesContractObligation $updatesContractObligations, 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->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
$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 void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->doesntHave('containers')->get();
|
||||
|
||||
foreach ($packingLists as $packingList) {
|
||||
$time_start = microtime(true);
|
||||
|
||||
$containerReference = null;
|
||||
$loadingDate = null;
|
||||
$etd = null;
|
||||
$eta = null;
|
||||
|
||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||
'trakingno' => $packingList->reference
|
||||
]);
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||
|
||||
if(!$rows->data){
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
||||
if (strpos($trackingRow->tracking, '货物装柜完成。') !== false) {
|
||||
$tracking = explode(':', $trackingRow->tracking);
|
||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
||||
$eta = Carbon::parse($tracking[2])->addDays(2);
|
||||
}
|
||||
}
|
||||
|
||||
if($containerReference) {
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
|
||||
$originWarehouse = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
|
||||
|
||||
|
||||
$containerObject = new ContainerObject($containerReference, '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
/** @var Container $container */
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
|
||||
$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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$time_end = microtime(true);
|
||||
|
||||
$execution_time = ($time_end - $time_start)/60;
|
||||
|
||||
echo 'successful => <b>Total Execution Time:</b> '.$execution_time.' Mins<br>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\Notifications\ShipmentRescheduleEmail;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class FetchContainersUpdatesFromYdPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromYDPortal */
|
||||
private $fetchesDataFRomYDPortal;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/**
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, UpdatesContractObligation $updatesContractObligations, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$containers = Container::where('status', ApprovalStatus::PENDING_VERIFICATION)->get();
|
||||
|
||||
foreach ($containers as $container) {
|
||||
$time_start = microtime(true);
|
||||
|
||||
$packingList = $container->packingLists()->first();
|
||||
|
||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||
'trakingno' => $packingList->reference
|
||||
]);
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||
|
||||
if(!$rows->data){
|
||||
continue;
|
||||
}
|
||||
|
||||
$unstuffingDate = null;
|
||||
$delayDate = null;
|
||||
|
||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
||||
$rescheduleETA = strpos($trackingRow->remark, '到港');
|
||||
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
|
||||
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
|
||||
$dates = collect();
|
||||
|
||||
foreach($matches[0] as $date){
|
||||
try {
|
||||
$dates->push(Carbon::parse(str_replace('.', '/', $date).Carbon::now()->format('Y')));
|
||||
} catch (\Exception $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rescheduleDate = $dates->sortDesc()->first();
|
||||
|
||||
if(!$delayDate || $rescheduleDate > $delayDate){
|
||||
/** @var Carbon $delayDate */
|
||||
$delayDate = $rescheduleDate;
|
||||
|
||||
if($rescheduleETA === false && $delayDate) {
|
||||
$delayDate = $delayDate->addDays('5');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '到港') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '已开船') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
}
|
||||
|
||||
if($delayDate){
|
||||
$delayDate = $delayDate->addDays(2);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport->schedules()->whereDate('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));
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
$user = $packingList->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new ShipmentRescheduleEmail($user, $packingList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($unstuffingDate){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($container->packingLists as $packingList){
|
||||
|
||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
|
||||
$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]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$time_end = microtime(true);
|
||||
|
||||
$execution_time = ($time_end - $time_start)/60;
|
||||
|
||||
echo 'successful => <b>Total Execution Time:</b> '.$execution_time.' Mins<br>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
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\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FetchDeliveryUpdatesFromYdPortalProcessor
|
||||
{
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/**
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(UpdatesContractObligation $updatesContractObligations, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws MalformedRequestException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->whereRaw('LENGTH(reference) > 12')->whereHas('containers', function ($container){
|
||||
return $container->where('status', 3);
|
||||
})->doesntHave('transports')->get()->reverse();
|
||||
foreach ($packingLists->chunk(50) as $chunk) {
|
||||
|
||||
|
||||
foreach ($chunk as $packingList){
|
||||
if(!$packingList->reference) continue;
|
||||
$time_start = microtime(true);
|
||||
|
||||
$deliveryDate = null;
|
||||
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
||||
|
||||
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$packingList->reference.'&sOrgId=sti', ['timeout' => 3]);
|
||||
$deliveryTracking = json_decode($request->getBody()->getContents());
|
||||
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
||||
$trackingDate = Carbon::createFromFormat('d/m/y H:i', $trackingRow->LocalDateTime);
|
||||
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
||||
$deliveryDate = $trackingDate;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
dump($exception);
|
||||
Log::debug('failed to fetch delivery tracking');
|
||||
}
|
||||
|
||||
if($deliveryDate){
|
||||
$packingList->status = ApprovalStatus::COMPLETED;
|
||||
$packingList->save();
|
||||
|
||||
$deliveryDate = Carbon::parse($deliveryDate);
|
||||
$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));
|
||||
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
|
||||
$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]);
|
||||
|
||||
}
|
||||
|
||||
$time_end = microtime(true);
|
||||
|
||||
$execution_time = ($time_end - $time_start)/60;
|
||||
|
||||
echo 'successful => <b>Total Execution Time:</b> '.$execution_time.' Mins<br>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -264,7 +264,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
//
|
||||
// $this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||
} else {
|
||||
$appointee_id = 2037;
|
||||
$appointee_id = 2307;
|
||||
}
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, null);
|
||||
|
||||
+306
-269
@@ -24,6 +24,8 @@ use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
||||
use App\Classes\Notifications\ShipmentRescheduleEmail;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
@@ -137,325 +139,360 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
*/
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
try {
|
||||
$start = $start ? $start : Carbon::today()->subDays(5);
|
||||
ini_set('max_execution_time', '900');
|
||||
// $missingOrders = ['M202302161513122', 'YW202302161027442', 'YW202302151637022', 'M202302151605025', 'M202302151527103', 'M202302151527356', 'M202302151556019', 'YW202302151520241', 'YW202302151445068', 'M202302151359169', 'YW202302151349223', 'YW202302151336520', 'M202302151334316', 'YW202302151148129', 'M202302151145379', 'M202302151142411', 'M202302151037036', 'M202302151036398', 'M202302150919406', 'M202302141535009', 'YW202302141532318', 'M202302141319463', 'M202302141319045', 'YW202302141405471', 'M202302141334494', 'YW202302141321569', 'YW202302141323005', 'M202302141309053', 'M202302140905116', 'M202302141039558', 'M202302141022333', 'YW202302140943182', 'YW202302140923485', 'YW202302131728233', 'YW202302131702040', 'M202302131649417', 'M202302131638056', 'YW202302131601110', 'YW202302131530436', 'YW202302131411338', 'YW202302131355161', 'YW202302131312526', 'M202302130859076', 'M202302111708070', 'M202302111455134', 'M202302111457501', 'M202302111444041', 'M202302111506514', 'M202302111440286', 'M202302111354585', 'M202302111055551', 'M202302110900216', 'YW202302101743112', 'M202302091559443', 'M202302101716374', 'M202302101700402', 'M202302101633570', 'M202302101612095', 'M202302101611408', 'M202302101542340', 'M202302101408370', 'M202302101323341', 'M202302101129532', 'M202302101025109', 'M202302101006595', 'M202302091706357', 'YW202302091255022', 'YW202302091448196', 'YW202302091446431', 'M202302091138154', 'M202302091129396', 'YW202302091028175', 'M202302091006545', 'YW202302090942033', 'YW202302081743094', 'M202302081530599', 'M202302081531210', 'M202302081508571', 'YW202302081530492', 'M202302081500361', 'M202302081253105', 'M202302081303370', 'M202302071636303', 'M202302071741187', 'YW202302071735407', 'M202302071706323', 'M202302071537501', 'M202302071538092', 'YW202302071516453', 'M202302071311314', 'M202302071148154', 'YW202302071136018', 'M202302071036027', 'M202302071008010', 'M202302061742178', 'M202302061615198', 'M202302061502093', 'M202302061458532', 'M202302061552141', 'M202302061548431', 'M202302061555033', 'YW202302061404567', 'M202302061322463', 'M202302061042556', 'M202302061021277', 'M202302060917276', 'M202302041551570', 'M202302041552382', 'YW202302041515257', 'M202302041405502', 'M202302041030185', 'YW202302041215576', 'YW202302041058469', 'YW202302041024459', 'YW202302040939568', 'M202302031701053', 'M202302031700316', 'M202302031430562', 'M202302031431535', 'M202302031147213', 'YW202302031406529', 'YW202302031322256', 'M202302021718554', 'M202302021417415', 'YW202302021404542', 'M202302021055324', 'YW202302021037462', 'M202302011613381', 'M202302011347586', 'M202302011348245', 'M202301151635132', 'M202301141803516', 'YW202301141653536', 'M202301131504477', 'M202301131538220', 'M202301121327453', 'YW202301111153183', 'M202301091649543', 'M202212311641071', 'YW202212211532191', 'YW202212191605226'];
|
||||
|
||||
$startLimit = Carbon::parse('01-12-2021');
|
||||
$from = $end ? Carbon::today()->diff($end)->days : 0;
|
||||
$to = $start ? Carbon::today()->diff($start)->days : 10;
|
||||
|
||||
if($start->isBefore($startLimit)){
|
||||
$start = $startLimit;
|
||||
}
|
||||
for ($x = $from; $x <= $to; $x++) {
|
||||
try {
|
||||
$startDate = Carbon::today()->subDays($x);
|
||||
|
||||
$end = $end ? $end : Carbon::today()->addDay();
|
||||
$startLimit = Carbon::parse('01-12-2021');
|
||||
|
||||
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
||||
'begintime' => $start->timestamp,
|
||||
'endtime' => $end->timestamp,
|
||||
]);
|
||||
if($startDate->isBefore($startLimit)){
|
||||
$startDate = $startLimit;
|
||||
}
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||
$endDate = Carbon::today()->subDays($x - 1);
|
||||
|
||||
foreach($rows->data as $row){
|
||||
|
||||
$containerReference = null;
|
||||
$loadingDate = null;
|
||||
$unstuffingDate = null;
|
||||
$deliveryDate = null;
|
||||
$etd = null;
|
||||
$eta = null;
|
||||
$delayDate = null;
|
||||
|
||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||
'trakingno' => $row->expressno
|
||||
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
||||
'begintime' => $startDate->timestamp,
|
||||
'endtime' => $endDate->timestamp,
|
||||
]);
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||
|
||||
if(!$rows){
|
||||
continue;
|
||||
}
|
||||
if(!$rows->data) continue;
|
||||
|
||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
||||
if ($trackingRow->tracking === '货物已送达仓库准备入库中') {
|
||||
$receiveDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
foreach($rows->data as $row){
|
||||
$time_start = microtime(true);
|
||||
|
||||
if (strpos($trackingRow->tracking, '货物装柜完成。') !== false) {
|
||||
$tracking = explode(':', $trackingRow->tracking);
|
||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
||||
$eta = Carbon::parse($tracking[2])->addDays(2);
|
||||
}
|
||||
$containerReference = null;
|
||||
$loadingDate = null;
|
||||
$unstuffingDate = null;
|
||||
$deliveryDate = null;
|
||||
$etd = null;
|
||||
$eta = null;
|
||||
$delayDate = null;
|
||||
$status = $row->status;
|
||||
|
||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
||||
$rescheduleETA = strpos($trackingRow->remark, '到港');
|
||||
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
|
||||
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
|
||||
$dates = collect();
|
||||
|
||||
foreach($matches[0] as $date){
|
||||
try {
|
||||
$dates->push(Carbon::parse(str_replace('.', '/', $date).Carbon::now()->format('Y')));
|
||||
} catch (\Exception $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rescheduleDate = $dates->sortDesc()->first();
|
||||
|
||||
if(!$delayDate || $rescheduleDate > $delayDate){
|
||||
/** @var Carbon $delayDate */
|
||||
$delayDate = $rescheduleDate;
|
||||
|
||||
if($rescheduleETA === false && $delayDate) {
|
||||
$delayDate = $delayDate->addDays('5');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '到港') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '已开船') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if (Str::contains($trackingRow->tracking, ['派送中', '已签收', '签收完成', ' 第三方提货', '货物已派送完成', '派送', 'delivery', 'delivered'])) {
|
||||
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
}
|
||||
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
||||
|
||||
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$row->expressno.'&sOrgId=sti');
|
||||
$deliveryTracking = json_decode($request->getBody()->getContents());
|
||||
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
||||
$trackingDate = Carbon::createFromFormat('d/m/y H:i', $trackingRow->LocalDateTime);
|
||||
if (Str::contains($trackingRow->PublicDescription, ['accepted/picked'])){
|
||||
$unstuffingDate = $trackingDate;
|
||||
}
|
||||
|
||||
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
||||
$deliveryDate = $trackingDate;
|
||||
}
|
||||
}
|
||||
|
||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||
|
||||
$orderNumber = $customerno[array_key_last($customerno)];
|
||||
$allow_contract = true;
|
||||
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
||||
$allow_contract = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$packingListReference = $row->expressno;
|
||||
|
||||
try{
|
||||
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
||||
|
||||
$packingList->packages()->delete();
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
$warehouseReceiveList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::WAREHOUSE_RECEIVE_LIST]);
|
||||
$warehouseReceiveList->packages()->delete();
|
||||
$replica = $warehouseReceiveList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
if (!$allow_contract) {
|
||||
$appointee_id = 2037;
|
||||
} else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
}
|
||||
|
||||
$warehouseReceiveObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
/** @var PackingList $warehouseReceiveList */
|
||||
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||
|
||||
if ($allow_contract) {
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, !$allow_contract ? null : $contractReference);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
if ($allow_contract) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($row->deliverysize as $package) {
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $package->width, (float) $package->height, (float) $package->length, 0, (float) $package->num, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if(!count($row->deliverysize)){
|
||||
$measurement = round(((float) $row->volume / (float) $row->goodcount) ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $measurement, (float) $measurement, (float) $measurement, 0, (float) $row->goodcount, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
$weightCbm = (float) $row->weight / 500;
|
||||
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
||||
|
||||
if($overWeightCbm > 0){
|
||||
$measurement = round($overWeightCbm ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::OVER_WEIGHT, 'Overweight CBM', (float) $measurement, (float) $measurement, (float) $measurement, 0, 1, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if($order instanceof Order){
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
if(!in_array($marking, ['2192KAA', '2353GFE', '6866DTR', '153DSR', '1291NSC', '8288MIB', '1152AAT', '962LOW', '3992WHE', '1290CSW', '9493TYS', '3397GSH'])){
|
||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
||||
'expressno' => $row->expressno
|
||||
if($status >= 3){
|
||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||
'trakingno' => $row->expressno
|
||||
]);
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||
|
||||
if(!$rows){
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
||||
if ($trackingRow->tracking === '货物已送达仓库准备入库中') {
|
||||
$receiveDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if (strpos($trackingRow->tracking, '货物装柜完成。') !== false) {
|
||||
$tracking = explode(':', $trackingRow->tracking);
|
||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
||||
$eta = Carbon::parse($tracking[2])->addDays(2);
|
||||
}
|
||||
|
||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
||||
$rescheduleETA = strpos($trackingRow->remark, '到港');
|
||||
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
|
||||
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
|
||||
$dates = collect();
|
||||
|
||||
foreach($matches[0] as $date){
|
||||
try {
|
||||
$dates->push(Carbon::parse(str_replace('.', '/', $date).Carbon::now()->format('Y')));
|
||||
} catch (\Exception $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rescheduleDate = $dates->sortDesc()->first();
|
||||
|
||||
if(!$delayDate || $rescheduleDate > $delayDate){
|
||||
/** @var Carbon $delayDate */
|
||||
$delayDate = $rescheduleDate;
|
||||
|
||||
if($rescheduleETA === false && $delayDate) {
|
||||
$delayDate = $delayDate->addDays('5');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '到港') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '已开船') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if (Str::contains($trackingRow->tracking, ['派送中', '已签收', '签收完成', ' 第三方提货', '货物已派送完成', '派送', 'delivery', 'delivered'])) {
|
||||
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($status >= 5){
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
||||
|
||||
try {
|
||||
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$row->expressno.'&sOrgId=sti');
|
||||
$deliveryTracking = json_decode($request->getBody()->getContents());
|
||||
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
||||
$trackingDate = Carbon::createFromFormat('d/m/y H:i', $trackingRow->LocalDateTime);
|
||||
if (Str::contains($trackingRow->PublicDescription, ['accepted/picked'])){
|
||||
$unstuffingDate = $trackingDate;
|
||||
}
|
||||
|
||||
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
||||
$deliveryDate = $trackingDate;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::debug('failed to fetch delivery tracking');
|
||||
}
|
||||
}
|
||||
|
||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||
|
||||
$orderNumber = $customerno[array_key_last($customerno)];
|
||||
$allow_contract = true;
|
||||
|
||||
if($containerReference) {
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
||||
$allow_contract = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$packingListReference = $row->expressno;
|
||||
|
||||
try{
|
||||
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
||||
|
||||
$packingList->packages()->delete();
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
$warehouseReceiveList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::WAREHOUSE_RECEIVE_LIST]);
|
||||
$warehouseReceiveList->packages()->delete();
|
||||
$replica = $warehouseReceiveList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
if (!$allow_contract) {
|
||||
$appointee_id = 2037;
|
||||
}
|
||||
else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id;
|
||||
$appointee_id = 2307;
|
||||
} else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
}
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $appointee_id]);
|
||||
$warehouseReceiveObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
$containerObject = new ContainerObject($containerReference, '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
||||
/** @var Container $container */
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
/** @var PackingList $warehouseReceiveList */
|
||||
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||
|
||||
$transport = $container->transports()->first();
|
||||
if ($allow_contract) {
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
|
||||
if($delayDate){
|
||||
$delayDate = $delayDate->addDays(2);
|
||||
$transport = $container->transports()->first();
|
||||
$contractReference = $contract->hash_id;
|
||||
$contractObligations = $contract->contract_obligation_list;
|
||||
|
||||
if(!$transport->schedules()->whereDate('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));
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($unstuffingDate && $container->status !== ApprovalStatus::COMPLETED){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]);
|
||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, !$allow_contract ? null : $contractReference);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($container->packingLists as $packingList){
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
if ($allow_contract) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($row->deliverysize as $package) {
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $package->width, (float) $package->height, (float) $package->length, 0, (float) $package->num, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if(!count($row->deliverysize)){
|
||||
$measurement = round(((float) $row->volume / (float) $row->goodcount) ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $measurement, (float) $measurement, (float) $measurement, 0, (float) $row->goodcount, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
$weightCbm = (float) $row->weight / 500;
|
||||
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
||||
|
||||
if($overWeightCbm > 0){
|
||||
$measurement = round($overWeightCbm ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::OVER_WEIGHT, 'Overweight CBM', (float) $measurement, (float) $measurement, (float) $measurement, 0, 1, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if($order instanceof Order){
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
if(!in_array($marking, ['1290CSW', '8997ITB', '3992WHE', '962LOW', '1152AAT'])){
|
||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
||||
'expressno' => $row->expressno
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($containerReference) {
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
if (!$allow_contract) {
|
||||
$appointee_id = 2307;
|
||||
}
|
||||
else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id;
|
||||
}
|
||||
|
||||
if ($allow_contract) {
|
||||
$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]);
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $appointee_id]);
|
||||
|
||||
$containerObject = new ContainerObject($containerReference, '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
||||
/** @var Container $container */
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
|
||||
$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 = $delayDate->addDays(2);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport->schedules()->whereDate('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));
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
$user = $packingList->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new ShipmentRescheduleEmail($user, $packingList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($unstuffingDate && $container->status !== ApprovalStatus::COMPLETED){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($container->packingLists as $packingList){
|
||||
|
||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
if ($allow_contract) {
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($deliveryDate && !$packingList->transports()->exists()){
|
||||
$packingList->status = ApprovalStatus::COMPLETED;
|
||||
$packingList->save();
|
||||
if($deliveryDate && !$packingList->transports()->exists()){
|
||||
$packingList->status = ApprovalStatus::COMPLETED;
|
||||
$packingList->save();
|
||||
|
||||
$deliveryDate = Carbon::parse($deliveryDate);
|
||||
$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));
|
||||
$deliveryDate = Carbon::parse($deliveryDate);
|
||||
$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));
|
||||
|
||||
|
||||
if ($allow_contract) {
|
||||
$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]);
|
||||
if ($allow_contract) {
|
||||
$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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$time_end = microtime(true);
|
||||
|
||||
$execution_time = ($time_end - $time_start)/60;
|
||||
|
||||
echo '<b>Total Execution Time:</b> '.$execution_time.' Mins';
|
||||
echo 'successful';
|
||||
|
||||
}
|
||||
|
||||
echo 'successful';
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
Log::debug($exception);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Log::debug($exception);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ class FetchPackingListFromVTPortalProcessor
|
||||
}
|
||||
|
||||
} catch (GuzzleException $exception) {
|
||||
dd($exception);
|
||||
Log::error($exception);
|
||||
continue;
|
||||
}
|
||||
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
<?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\FetchesDataFromYDPortal;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
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\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
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\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
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 FetchPackingListsFromYdPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromYDPortal */
|
||||
private $fetchesDataFRomYDPortal;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
|
||||
private $fetchesCompanyModule;
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
|
||||
/** @var AssignContractEntityProcessor */
|
||||
private $unityAssignContractEntity;
|
||||
|
||||
/** @var CreateContractEntityProcessor */
|
||||
private $unityCreateContractEntity;
|
||||
|
||||
/** @var CreatesStep */
|
||||
private $createsStep;
|
||||
|
||||
/** @var ActivateContractProcessor */
|
||||
private $unityActivateContract;
|
||||
|
||||
/**
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
* @param CreatesStep $createsStep
|
||||
* @param ActivateContractProcessor $unityActivateContract
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, FetchesOrder $fetchesOrder, CreatePackingListProcessor $createPackingListProcessor, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, CreatesStep $createsStep, ActivateContractProcessor $unityActivateContract)
|
||||
{
|
||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
$this->createsStep = $createsStep;
|
||||
$this->unityActivateContract = $unityActivateContract;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
$from = $end ? Carbon::today()->diff($end)->days : 0;
|
||||
$to = $start ? Carbon::today()->diff($start)->days : 10;
|
||||
|
||||
for ($x = $from; $x <= $to; $x++) {
|
||||
try {
|
||||
$startDate = Carbon::today()->subDays($x);
|
||||
|
||||
$startLimit = Carbon::parse('01-12-2021');
|
||||
|
||||
if($startDate->isBefore($startLimit)){
|
||||
$startDate = $startLimit;
|
||||
}
|
||||
|
||||
$endDate = Carbon::today()->subDays($x - 1);
|
||||
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
||||
'begintime' => $startDate->timestamp,
|
||||
'endtime' => $endDate->timestamp,
|
||||
]);
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||
|
||||
if(!$rows->data) continue;
|
||||
|
||||
foreach($rows->data as $row){
|
||||
|
||||
$time_start = microtime(true);
|
||||
|
||||
$receiveDate = Carbon::parse(substr(preg_replace("/[^0-9]/", "", $row->expressno), 0, 8));
|
||||
|
||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||
|
||||
$orderNumber = $customerno[array_key_last($customerno)];
|
||||
$allow_contract = true;
|
||||
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
||||
$allow_contract = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$packingListReference = $row->expressno;
|
||||
|
||||
try{
|
||||
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
||||
|
||||
$packingList->packages()->delete();
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
$warehouseReceiveList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::WAREHOUSE_RECEIVE_LIST]);
|
||||
$warehouseReceiveList->packages()->delete();
|
||||
$replica = $warehouseReceiveList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
if (!$allow_contract) {
|
||||
$appointee_id = 2307;
|
||||
} else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
}
|
||||
|
||||
$warehouseReceiveObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
/** @var PackingList $warehouseReceiveList */
|
||||
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||
|
||||
if ($allow_contract) {
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, !$allow_contract ? null : $contractReference);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
if ($allow_contract) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($row->deliverysize as $package) {
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $package->width, (float) $package->height, (float) $package->length, 0, (float) $package->num, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if(!count($row->deliverysize)){
|
||||
$measurement = round(((float) $row->volume / (float) $row->goodcount) ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $measurement, (float) $measurement, (float) $measurement, 0, (float) $row->goodcount, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
$weightCbm = (float) $row->weight / 500;
|
||||
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
||||
|
||||
if($overWeightCbm > 0){
|
||||
$measurement = round($overWeightCbm ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::OVER_WEIGHT, 'Overweight CBM', (float) $measurement, (float) $measurement, (float) $measurement, 0, 1, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if($order instanceof Order){
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
if(!in_array($marking, ['1290CSW', '8997ITB', '3992WHE', '962LOW', '1152AAT'])){
|
||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
||||
'expressno' => $row->expressno
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$time_end = microtime(true);
|
||||
|
||||
$execution_time = ($time_end - $time_start)/60;
|
||||
|
||||
echo 'successful => <b>Total Execution Time:</b> '.$execution_time.' Mins<br>';
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
Log::debug($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
$allow_contract = false;
|
||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
||||
$appointee_id = 2037;
|
||||
$appointee_id = 2307;
|
||||
}
|
||||
|
||||
$packingListReference = $parcel[0];
|
||||
|
||||
+10
-38
@@ -3,11 +3,13 @@
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Modules\Transactions\Processors\ApproveShippingInvoiceTransactionProcessor;
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
@@ -35,29 +37,17 @@ class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
/** @var ApproveShippingInvoiceTransactionProcessor */
|
||||
private $approveShippingInvoiceTransactionProcessor;
|
||||
|
||||
/**
|
||||
* ApprovePaymentVerificationLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||
* @param ApproveShippingInvoiceTransactionProcessor $approveShippingInvoiceTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, ApproveShippingInvoiceTransactionProcessor $approveShippingInvoiceTransactionProcessor)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
$this->approveShippingInvoiceTransactionProcessor = $approveShippingInvoiceTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,27 +58,9 @@ class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||
|
||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
$this->approveShippingInvoiceTransactionProcessor->execute($packing_list);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
+12
-226
@@ -5,40 +5,15 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -52,215 +27,26 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
/** @var CreateInvoiceTransactionProcessor */
|
||||
private $createInvoiceTransactionProcessor;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var CreatesTransactionDetail */
|
||||
private $createsTransactionDetail;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFile;
|
||||
|
||||
public function __construct(
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesSegmentConstant $fetchesSegmentConstant,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
CreatesTransactionDetail $createsTransactionDetail,
|
||||
CreatesDocument $createsDocument,
|
||||
CreatesFiles $createsFile
|
||||
)
|
||||
/**
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor)
|
||||
{
|
||||
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||
$packing_list = PackingList::where('reference', $packing_list->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first();
|
||||
|
||||
$billable_packing_list = $packing_list->packingLists()->first();
|
||||
|
||||
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packing_list;
|
||||
|
||||
$cbm = $billable_packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
});
|
||||
|
||||
$over_weight_cbm = $billable_packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
});
|
||||
|
||||
$order = $packing_list->owner;
|
||||
$companyModule = $order->companyModule;
|
||||
$connection = $companyModule->connections()->first();
|
||||
$address = $order->addresses()->first();
|
||||
|
||||
$base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]);
|
||||
$warehouse_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::WAREHOUSE_RATE]);
|
||||
$state_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::STATE_RATE]);
|
||||
$center_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::CENTER_POSTCODE]);
|
||||
$outstation_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::OUTSTATION_POSTCODE]);
|
||||
|
||||
$noMinimumCharge = $connection->segments()->where('segments.id', 2)->first();
|
||||
|
||||
$base_price = 0;
|
||||
$warehouse_rate = 0;
|
||||
$state_rate = 0;
|
||||
$minimum_cbm = 0.3;
|
||||
$segment_price = 0;
|
||||
$state_select = '';
|
||||
|
||||
$segment_price = $connection->segments()->whereHas('constants', function($query){
|
||||
return $query->where('reference', SegmentConstants::CUSTOM_PRICE);
|
||||
})->get()->map(function($segment){
|
||||
return (float) $segment->constants()->first()->value[0];
|
||||
})->sort()->first();
|
||||
$segment_price = $segment_price ? $segment_price : 0;
|
||||
|
||||
$packing_list_drop_date = PackingList::where('reference', $packing_list->reference)->where('type', 1)->first()->transports->first()->drop_date->format('Y-m-d');
|
||||
$base_price = $this->getConstantByKey($base_price_constant, $packing_list_drop_date);
|
||||
|
||||
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
|
||||
$selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId);
|
||||
$warehouse_rate = is_object($selected_warehouse_rate) ? $selected_warehouse_rate->amount : 0;
|
||||
|
||||
$stateId = $address->state_id;
|
||||
$state_rate_constant = $this->getConstantByKey($state_rate_constant, $stateId);
|
||||
|
||||
// get $state_rate
|
||||
$postcode = $address->postcode;
|
||||
$this->checkPostcodeExistInConstant($center_postcode_constant, $postcode) === true ? $state_select = 'center' : '' ;
|
||||
$this->checkPostcodeExistInConstant($outstation_postcode_constant, $postcode) === true ? $state_select = 'outstation' : '' ;
|
||||
$state_rate_constant = (array)$state_rate_constant;
|
||||
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
|
||||
|
||||
$container = $packing_list->containers()->first();
|
||||
$containerPackingLists = collect();
|
||||
$hasMinimumCharge = null;
|
||||
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if($packingList->owner->companyModule->id !== $companyModule->id) continue;
|
||||
$containerPackingLists->push($packingList);
|
||||
|
||||
if(!$hasMinimumCharge) {
|
||||
$hasMinimumCharge = $packingList->transactions()->whereHas('transactionDetails', function ($query){
|
||||
$query->where('reference', 'MIN_CBM_CHARGES');
|
||||
})->first();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$totalContainerCbm = $containerPackingLists->sum(function($packingList){
|
||||
$billable_packing_list = $packingList->packingLists()->first();
|
||||
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packingList;
|
||||
return $billable_packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
});
|
||||
});
|
||||
|
||||
$minimum_charge = $minimum_cbm - $totalContainerCbm;
|
||||
$minimum_charge = $minimum_charge < 0 ? 0 : $minimum_charge;
|
||||
$minimum_charge = $noMinimumCharge ? 0 : $minimum_charge;
|
||||
|
||||
|
||||
if($hasMinimumCharge) {
|
||||
$minimum_charge = 0;
|
||||
}
|
||||
|
||||
$price_cbm = $base_price + $segment_price + $warehouse_rate + $state_rate;
|
||||
|
||||
$total_cbm = $price_cbm * ($cbm + $minimum_charge + $over_weight_cbm);
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::SHIPPING_INVOICE,
|
||||
1,
|
||||
$order->company_module_id,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$total_cbm,
|
||||
$total_cbm,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
/** @var Transaction $invoice_transaction */
|
||||
$invoice_transaction = $this->createsTransaction->execute($packing_list, $object);
|
||||
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'SHIPPING_FEE',
|
||||
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||
$cbm,
|
||||
$price_cbm
|
||||
);
|
||||
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
|
||||
if ($over_weight_cbm > 0) {
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'OVER_WEIGHT_CHARGES',
|
||||
TransactionDetailType::OVER_WEIGHT_CHARGES,
|
||||
$over_weight_cbm,
|
||||
$price_cbm
|
||||
);
|
||||
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
}
|
||||
|
||||
if ($minimum_charge > 0) {
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'MIN_CBM_CHARGES',
|
||||
TransactionDetailType::MIN_CBM_CHARGES,
|
||||
$minimum_charge,
|
||||
$price_cbm
|
||||
);
|
||||
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
}
|
||||
$this->createInvoiceTransactionProcessor->execute($packing_list);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
function getConstantByKey($segmentConstantObject, $key) {
|
||||
if ($segmentConstantObject) {
|
||||
$base_rate = (array) $segmentConstantObject->value;
|
||||
$base_rate = array_key_exists($key, $base_rate) === true ? $base_rate[$key] : 0;
|
||||
|
||||
return $base_rate;
|
||||
}
|
||||
}
|
||||
|
||||
function checkPostcodeExistInConstant($segmentConstantObject, $postcode) {
|
||||
$segmentConstantObject = $segmentConstantObject->value;
|
||||
if (!empty($segmentConstantObject)) {
|
||||
return in_array($postcode, $segmentConstantObject);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateSupplierTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use App\Models\Transaction;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
|
||||
class ApproveShippingInvoiceTransactionProcessor
|
||||
{
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
/**
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
*/
|
||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PackingList $packingList
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $packingList)
|
||||
{
|
||||
|
||||
/** @var Transaction $invoice_transaction */
|
||||
$invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||
|
||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
$user = $packingList->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new InvoiceIssuedEmail($user, $packingList));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
+194
-176
@@ -1,229 +1,247 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingTransferredAmount;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceConfigurations;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingPaidAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingCurrencyAverageRate;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Bookings\Services\UpdatesBookingStatus;
|
||||
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Booking;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Document;
|
||||
use App\Models\SegmentConstant;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateInvoiceTransactionProcessor
|
||||
{
|
||||
/** @var ListsTransactions */
|
||||
private $listsTransactions;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CalculatesBookingPaidAmount */
|
||||
private $calculatesBookingPaidAmount;
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var CalculatesBookingTransferredAmount */
|
||||
private $calculatesBookingTransferredAmount;
|
||||
|
||||
/** @var FetchesServiceConfigurations */
|
||||
private $fetchesServiceConfigurations;
|
||||
|
||||
/** @var CalculatesBookingCurrencyAverageRate */
|
||||
private $calculatesBookingCurrencyAverageRate;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFile;
|
||||
|
||||
/** @var UpdatesBookingStatus */
|
||||
private $updatesBookingStatus;
|
||||
/** @var CreatesTransactionDetail */
|
||||
private $createsTransactionDetail;
|
||||
|
||||
/**
|
||||
* CreateInvoiceTransactionProcessor constructor.
|
||||
* @param ListsTransactions $listsTransactions
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesSegmentConstant $fetchesSegmentConstant
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CalculatesBookingPaidAmount $calculatesBookingPaidAmount
|
||||
* @param CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount
|
||||
* @param FetchesServiceConfigurations $fetchesServiceConfigurations
|
||||
* @param CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
* @param UpdatesBookingStatus $updatesBookingStatus
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param CreatesTransactionDetail $createsTransactionDetail
|
||||
*/
|
||||
public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount, FetchesServiceConfigurations $fetchesServiceConfigurations, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesBookingStatus $updatesBookingStatus)
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, FetchesSegmentConstant $fetchesSegmentConstant, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CreatesTransactionDetail $createsTransactionDetail)
|
||||
{
|
||||
$this->listsTransactions = $listsTransactions;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->calculatesBookingPaidAmount = $calculatesBookingPaidAmount;
|
||||
$this->calculatesBookingTransferredAmount = $calculatesBookingTransferredAmount;
|
||||
$this->fetchesServiceConfigurations = $fetchesServiceConfigurations;
|
||||
$this->calculatesBookingCurrencyAverageRate = $calculatesBookingCurrencyAverageRate;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->updatesBookingStatus = $updatesBookingStatus;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Booking $booking
|
||||
* @return void
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Booking $booking)
|
||||
public function execute(PackingList $packingList)
|
||||
{
|
||||
$payment_amount = $this->calculatesBookingTransferredAmount->execute($booking, $booking->fix_currency_id);
|
||||
$booking_amount = $booking->fix_amount;
|
||||
$packing_list = PackingList::where('reference', $packingList->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first();
|
||||
|
||||
$billable_packing_list = $packing_list->packingLists()->first();
|
||||
|
||||
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packing_list;
|
||||
|
||||
$cbm = round($billable_packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
}), 3);
|
||||
|
||||
$over_weight_cbm = round($billable_packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
}), 3);
|
||||
|
||||
$order = $packing_list->owner;
|
||||
$companyModule = $order->companyModule;
|
||||
$connection = $companyModule->connections()->first();
|
||||
$address = $order->addresses()->first();
|
||||
|
||||
$base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]);
|
||||
$warehouse_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::WAREHOUSE_RATE]);
|
||||
$state_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::STATE_RATE]);
|
||||
$center_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::CENTER_POSTCODE]);
|
||||
$outstation_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::OUTSTATION_POSTCODE]);
|
||||
|
||||
$noMinimumCharge = $connection->segments()->where('segments.id', 2)->first();
|
||||
|
||||
$minimum_cbm = 0.3;
|
||||
$state_select = '';
|
||||
|
||||
$segment_price = $connection->segments()->whereHas('constants', function($query){
|
||||
return $query->where('reference', SegmentConstants::CUSTOM_PRICE);
|
||||
})->get()->map(function($segment){
|
||||
return (float) $segment->constants()->first()->value[0];
|
||||
})->sort()->first();
|
||||
$segment_price = $segment_price ? $segment_price : 0;
|
||||
|
||||
$arrivalTransport = PackingList::where('reference', $packing_list->reference)->where('type', 1)->first()->transports->first();
|
||||
if(!$arrivalTransport) {
|
||||
throw new MalformedRequestException('Arrival date is unknow can\'t generate invoice');
|
||||
}
|
||||
$packing_list_drop_date = $arrivalTransport->drop_date->format('Y-m-d');
|
||||
$base_price = $this->getConstantByKey($base_price_constant, $packing_list_drop_date);
|
||||
|
||||
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
|
||||
$selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId);
|
||||
$warehouse_rate = is_object($selected_warehouse_rate) ? $selected_warehouse_rate->amount : 0;
|
||||
|
||||
$stateId = $address->state_id;
|
||||
$state_rate_constant = $this->getConstantByKey($state_rate_constant, $stateId);
|
||||
|
||||
// get $state_rate
|
||||
$postcode = $address->postcode;
|
||||
$this->checkPostcodeExistInConstant($center_postcode_constant, $postcode) === true ? $state_select = 'center' : '' ;
|
||||
$this->checkPostcodeExistInConstant($outstation_postcode_constant, $postcode) === true ? $state_select = 'outstation' : '' ;
|
||||
$state_rate_constant = (array)$state_rate_constant;
|
||||
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
|
||||
|
||||
$container = $packing_list->containers()->first();
|
||||
$containerPackingLists = collect();
|
||||
$hasMinimumCharge = null;
|
||||
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if($packingList->owner instanceof CompanyModule) continue;
|
||||
if($packingList->owner->companyModule->id !== $companyModule->id) continue;
|
||||
$containerPackingLists->push($packingList);
|
||||
|
||||
if(!$hasMinimumCharge) {
|
||||
$hasMinimumCharge = $packingList->transactions()->whereHas('transactionDetails', function ($query){
|
||||
$query->where('reference', 'MIN_CBM_CHARGES');
|
||||
})->first();
|
||||
}
|
||||
|
||||
if ((float) $booking_amount !== (float) $payment_amount) {
|
||||
return;
|
||||
}
|
||||
|
||||
$po_order_transaction = $booking->transactions()
|
||||
->where('type', TransactionType::PURCHASE_ORDER)
|
||||
->complete()
|
||||
->first();
|
||||
$totalContainerCbm = $containerPackingLists->sum(function($packingList){
|
||||
$billable_packing_list = $packingList->packingLists()->first();
|
||||
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packingList;
|
||||
return $billable_packing_list->packages->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
});
|
||||
});
|
||||
|
||||
$constants = SegmentConstant::where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->id', $booking->service->id)->first();
|
||||
$minimum_charge = $minimum_cbm - $totalContainerCbm;
|
||||
$minimum_charge = ($minimum_charge < 0) ? 0 : $minimum_charge;
|
||||
$minimum_charge = $noMinimumCharge ? 0 : $minimum_charge;
|
||||
|
||||
if($constants->detail->is_billable && !$po_order_transaction) {
|
||||
return;
|
||||
$minimum_charge = $noMinimumCharge ? 0 : round($minimum_charge, 3);
|
||||
|
||||
|
||||
if($hasMinimumCharge) {
|
||||
$minimum_charge = 0;
|
||||
}
|
||||
|
||||
$transaction = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->first();
|
||||
$price_cbm = $base_price + $segment_price + $warehouse_rate + $state_rate;
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('INV-');
|
||||
$total_cbm = $price_cbm * ($cbm + $minimum_charge + $over_weight_cbm);
|
||||
|
||||
$booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::PAYMENT);
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
||||
|
||||
$total_service_charge = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->sum('service_charge');
|
||||
|
||||
$total_tax = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->sum('tax');
|
||||
|
||||
$transaction_object = new TransactionObject(
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::INVOICE,
|
||||
$transaction->issuer,
|
||||
$transaction->receiver,
|
||||
$transaction->recipient_bank_account_id,
|
||||
$transaction->payment_method,
|
||||
$payment_amount,
|
||||
$booking_amount,
|
||||
$transaction->currency_id,
|
||||
$transaction->original_currency_id,
|
||||
$booking_currency_average_rate,
|
||||
$total_tax,
|
||||
$total_service_charge,
|
||||
TransactionType::SHIPPING_INVOICE,
|
||||
1,
|
||||
$order->company_module_id,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$total_cbm,
|
||||
$total_cbm,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$invoice_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
|
||||
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||
|
||||
$purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.purchase_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::PURCHASE_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'purchase_orders'
|
||||
);
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
|
||||
$deliver_order_pdf = LaravelMpdf::loadView('pages.pdfs.deliver_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::DELIVER_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($deliver_order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'delivery_orders'
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
/** @var Transaction $invoice_transaction */
|
||||
$invoice_transaction = $this->createsTransaction->execute($packing_list, $object);
|
||||
|
||||
|
||||
$invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'invoices'
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'SHIPPING_FEE',
|
||||
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||
$cbm,
|
||||
$price_cbm
|
||||
);
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('SPDO-');
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
|
||||
$booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::BILL);
|
||||
if ($over_weight_cbm > 0) {
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'OVER_WEIGHT_CHARGES',
|
||||
TransactionDetailType::OVER_WEIGHT_CHARGES,
|
||||
$over_weight_cbm,
|
||||
$price_cbm
|
||||
);
|
||||
|
||||
$transaction_object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::SUPPLIER_DELIVER,
|
||||
$transaction->issuer,
|
||||
$transaction->receiver,
|
||||
$transaction->recipient_bank_account_id,
|
||||
$transaction->payment_method,
|
||||
$payment_amount,
|
||||
$booking_amount,
|
||||
$transaction->currency_id,
|
||||
$transaction->original_currency_id,
|
||||
$booking_currency_average_rate,
|
||||
$total_tax,
|
||||
$total_service_charge,
|
||||
null,
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$supplier_deliver_order_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
}
|
||||
|
||||
$supplier_order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $supplier_deliver_order_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SUPPLIER_DELIVER_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'supplier_delivery_orders'
|
||||
);
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
if ($minimum_charge > 0) {
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'MIN_CBM_CHARGES',
|
||||
TransactionDetailType::MIN_CBM_CHARGES,
|
||||
$minimum_charge,
|
||||
$price_cbm
|
||||
);
|
||||
|
||||
$this->updatesBookingStatus->execute($booking, ApprovalStatus::COMPLETED);
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function getConstantByKey($segmentConstantObject, $key) {
|
||||
if ($segmentConstantObject) {
|
||||
$base_rate = (array) $segmentConstantObject->value;
|
||||
$base_rate = array_key_exists($key, $base_rate) === true ? $base_rate[$key] : 0;
|
||||
|
||||
return $base_rate;
|
||||
}
|
||||
}
|
||||
|
||||
function checkPostcodeExistInConstant($segmentConstantObject, $postcode) {
|
||||
$segmentConstantObject = $segmentConstantObject->value;
|
||||
if (!empty($segmentConstantObject)) {
|
||||
return in_array($postcode, $segmentConstantObject);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
|
||||
namespace App\Classes\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class AbstractEmail extends Notification
|
||||
class AbstractEmail extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function via()
|
||||
{
|
||||
return 'mail';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Notifications;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\PasswordReset;
|
||||
use App\Models\User;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class InvoiceIssuedEmail extends AbstractEmail
|
||||
{
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/** @var PackingList */
|
||||
private $packingList;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param PackingList $packingList
|
||||
*/
|
||||
public function __construct(User $user, PackingList $packingList)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->packingList = $packingList;
|
||||
}
|
||||
|
||||
|
||||
public function toMail()
|
||||
{
|
||||
$invoice = $this->packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::APPROVED)->first();
|
||||
$invoiceDocument = $invoice->documents()->first()->files;
|
||||
|
||||
|
||||
return (new MailMessage)
|
||||
->subject('Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference)
|
||||
->attach(Storage::disk('documents')->get($invoiceDocument->file->file_info->original->file), [
|
||||
'as' => 'name.pdf',
|
||||
'mime' => 'application/pdf',
|
||||
])->view('emails.shipment.invoice', ['user' => $this->user, 'packingList' => $this->packingList]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Notifications;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\PasswordReset;
|
||||
use App\Models\User;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ShipmentDepartureEmail extends AbstractEmail
|
||||
{
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/** @var PackingList */
|
||||
private $packingList;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param PackingList $packingList
|
||||
*/
|
||||
public function __construct(User $user, PackingList $packingList)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->packingList = $packingList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function toMail()
|
||||
{
|
||||
$invoice = $this->packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
if(!$invoice) return false;
|
||||
|
||||
$invoiceDocument = $invoice->documents()->first()->files;
|
||||
|
||||
|
||||
return (new MailMessage)
|
||||
->subject('Your packages are on the way to malaysia - Invoice pending payment for order no.'. $this->packingList->owner->reference)
|
||||
->attach(Storage::disk('documents')->get($invoiceDocument->file->file_info->original->file), [
|
||||
'as' => 'name.pdf',
|
||||
'mime' => 'application/pdf',
|
||||
])->bcc(['email_test@cief-malaysia.com'])->view('emails.shipment.ETD', ['user' => $this->user, 'packingList' => $this->packingList]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Notifications;
|
||||
|
||||
|
||||
use App\Models\PackingList;
|
||||
use App\Models\PasswordReset;
|
||||
use App\Models\User;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ShipmentRescheduleEmail extends AbstractEmail
|
||||
{
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/** @var PackingList */
|
||||
private $packingList;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param PackingList $packingList
|
||||
*/
|
||||
public function __construct(User $user, PackingList $packingList)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->packingList = $packingList;
|
||||
}
|
||||
|
||||
|
||||
public function toMail()
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject('Update on your recent shipment(s)')
|
||||
->bcc(['email_test@cief-malaysia.com'])->view('emails.shipment.reschedule', ['user' => $this->user, 'packingList' => $this->packingList]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class UserVerificationEmail extends AbstractEmail
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject('Email Verification')
|
||||
->view('emails.accounts.user_verification', ['user' => $this->user, 'attempt' => $this->attempt]);
|
||||
->bcc(['email_test@cief-malaysia.com'])->view('emails.accounts.user_verification', ['user' => $this->user, 'attempt' => $this->attempt]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ final class WarehouseReferences {
|
||||
|
||||
public const MIN_CBM_EXEMPT_LIST = [230, 294, 320, 652, 1248, 1726, 2349, 2574];
|
||||
|
||||
public const REPLICA_WHITE_LIST = [502];
|
||||
public const REPLICA_WHITE_LIST = [502, 2237];
|
||||
|
||||
//2376 qce
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class AutoGenerateInvoice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'invoice:generate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Auto generate invoice';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$packingLists = (App()->make(ListsPackingLists::class))->execute(['does_not_have_transaction_type' => 1, 'type' => 2]);
|
||||
|
||||
if (count($packingLists)) {
|
||||
$this->info(Carbon::now() . ' : Auto generate invoice cron started.');
|
||||
$start = new Carbon();
|
||||
|
||||
foreach ($packingLists as $packingList) {
|
||||
$order = $packingList->owner;
|
||||
if (!($order instanceof Order)) {
|
||||
$this->info('Failed to generate invoice for reference' . $order->reference . '. It is not an instance of Order.');
|
||||
continue;
|
||||
}
|
||||
|
||||
$companyModule = $order->companyModule;
|
||||
$billingAddress = $companyModule->addresses()->where('type', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
$deliveryAddress = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
$postCodes = \App\Models\SegmentConstant::whereIn('reference', ['CENTER_POSTCODE', 'OUTSTATION_POSTCODE'])->get()->pluck('value')->flatten();
|
||||
|
||||
if (!!$billingAddress && in_array($deliveryAddress->postcode, $postCodes->toArray())) {
|
||||
try {
|
||||
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($packingList);
|
||||
$this->info('Invoice generated for reference ' . $order->reference . '.');
|
||||
} catch (Exception $exception) {
|
||||
$this->info('Failed to generate invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
$this->info('Failed to generate invoice for reference ' . $order->reference . '. Billing Address is not defined / Postcode area is not defined.');
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done generating invoice. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
||||
use App\Http\Helpers\General;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Container;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendContainerDepartureEmailCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $signature = 'command:sendContainerDepartureEmailCommand';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$containers = Container::whereHas('transports', function ($transport){
|
||||
return $transport->whereDate('dispatch_date', '=', Carbon::today());
|
||||
})->get();
|
||||
|
||||
foreach ($containers as $container){
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
$user = $packingList->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new ShipmentDepartureEmail($user, $packingList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,15 @@ class Kernel extends ConsoleKernel
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('0 9 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||
|
||||
$schedule->command('invoice:generate')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Accounts;
|
||||
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\FetchUserByEmailLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchUserByEmailController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchUserByEmailLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchUserByEmailLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyNameAndDebtorLogic;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyNameAndDebtorController extends Controller
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateCompanyNameAndDebtorLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Exports;
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsArrivedParcel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsParcel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsWarehousePackingList;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -34,4 +35,11 @@ class ExportArrivedParcelController
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function guangZhou2ToJohor(Request $request) {
|
||||
$exportsWarehousePackingList = new ExportsWarehousePackingList();
|
||||
$response = $exportsWarehousePackingList->download('guangzhou2-to-johor-summary.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Exports;
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsCompanyModuleSummary;
|
||||
use App\Classes\Modules\Exports\Services\ExportsOrderSummaryByMarking;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -27,4 +28,13 @@ class ExportCompanyModuleSummaryController
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function exportOrderSummaryByMarking(Request $request) {
|
||||
$exportsOrderSummaryByMarking = new ExportsOrderSummaryByMarking($request);
|
||||
$customer_marking = $request->route('marking');
|
||||
$exportsOrderSummaryByMarking->setParameters($customer_marking, $request->input('dateFrom'), $request->input('dateTo'));
|
||||
$response = $exportsOrderSummaryByMarking->download($customer_marking . '_order_summary.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Exports;
|
||||
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsCustomersOrderLatestDate;
|
||||
use App\Classes\Modules\Exports\Services\ExportsCustomerTotalOrderByYear;
|
||||
use App\Classes\Modules\Exports\Services\ExportsPaymentTransactions;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -31,4 +32,11 @@ class ExportCustomersToExcelController
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function totalOrders(Request $request){
|
||||
$exportsTotalOrders = new ExportsCustomerTotalOrderByYear($request);
|
||||
$response = $exportsTotalOrders->download('total-orders-' . $request->route('year') . '.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class DownloadOrderQrPdfController
|
||||
{
|
||||
@@ -51,8 +51,11 @@ class DownloadOrderQrPdfController
|
||||
if(strtolower($deliveryAddress->state->name) === 'sarawak' && !in_array(strtolower($deliveryAddress->district->name), ['limbang', 'lawas'])) {
|
||||
$warehousePrefix = 'KU/';
|
||||
}
|
||||
}
|
||||
|
||||
if(strtolower($deliveryAddress->state->name) === 'johor') {
|
||||
$warehousePrefix = 'NX/';
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'order' => $order,
|
||||
|
||||
@@ -6,7 +6,7 @@ use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ class CompanyResource extends JsonResource
|
||||
'id' => $this->id,
|
||||
'hash_id' => Crypt::encryptString($this->id),
|
||||
'name' => $this->name,
|
||||
'debtor' => $this->debtor,
|
||||
'reference' => $this->reference,
|
||||
'type' => (int) $this->type,
|
||||
'business_type' => (int) $this->business_type,
|
||||
|
||||
@@ -29,6 +29,7 @@ class PackageResource extends JsonResource
|
||||
'weight' => $this->weight,
|
||||
'quantity' => $this->quantity,
|
||||
'cbm' => (($this->width / 100) * ($this->height / 100) * ($this->length / 100)) * $this->quantity,
|
||||
'reference' => $this->packingList->reference,
|
||||
'status' => $this->status,
|
||||
$this->mergeWhen($originalPackingList->owner instanceof Order, [
|
||||
'order' => New OrderResource($originalPackingList->owner)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserCompanyResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'reference' => $this->companyModule()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference,
|
||||
'type' => (int) $this->type,
|
||||
'status' => (int) $this->status,
|
||||
'email' => $this->email
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Scopes\CustomerBookingsScope;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
/**
|
||||
* Class Booking
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property \App\Models\Bank transferable_bank_id
|
||||
* @property string marking
|
||||
* @property string reference
|
||||
* @property float fix_amount
|
||||
* @property int convertible_currency_id
|
||||
* @property int conversion_currency_id
|
||||
*/
|
||||
class Booking extends AbstractModel implements Documentable, Transactionable
|
||||
{
|
||||
use HasRelationships;
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'bookings';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Company::class, 'company_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function service(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(ServiceType::class, 'service_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function bank(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Bank::class, 'bank_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function fixedCurrency(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Currency::class, 'fix_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function convertibleCurrency(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Currency::class, 'convertible_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function conversionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Currency::class, 'conversion_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function documents(): MorphMany
|
||||
{
|
||||
return $this->MorphMany(Document::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function transactions(): MorphMany
|
||||
{
|
||||
return $this->MorphMany(Transaction::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasManyDeep
|
||||
*/
|
||||
public function bills(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Transaction::class, [Transaction::class.' as alias'], [['owner_type', 'owner_id'], ['owner_type', 'owner_id']], [null, null]);
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
if (auth()->user()) {
|
||||
if (auth()->user()->type === RoleTypes::USER) {
|
||||
static::addGlobalScope(new CustomerBookingsScope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use App\Classes\General\Interfaces\Transportable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
@@ -14,6 +15,7 @@ class Container extends AbstractModel implements Transportable, Remarkable
|
||||
{
|
||||
use HasRelationships;
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'containers';
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\General\Interfaces\Transportable;
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -23,6 +24,7 @@ class PackingList extends AbstractModel implements Transportable, Steppable, Pac
|
||||
use HasTableAlias;
|
||||
use HasRelationships;
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'packing_lists';
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
@@ -18,6 +19,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
class Transaction extends AbstractModel implements Documentable, Transactionable, Remarkable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'transactions';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -23,6 +24,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -106,7 +106,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'faker_locale' => 'en_US',
|
||||
'faker_locale' => 'ms_MY',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -178,7 +178,7 @@ return [
|
||||
// Third Parties
|
||||
Spatie\Permission\PermissionServiceProvider::class,
|
||||
Barryvdh\DomPDF\ServiceProvider::class,
|
||||
Meneses\LaravelMpdf\LaravelMpdfServiceProvider::class,
|
||||
Mccarlosen\LaravelMpdf\LaravelMpdfServiceProvider::class,
|
||||
Maatwebsite\Excel\ExcelServiceProvider::class,
|
||||
],
|
||||
|
||||
@@ -233,7 +233,7 @@ return [
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
'PDF' => Barryvdh\DomPDF\Facade::class,
|
||||
'MPDF' => Meneses\LaravelMpdf\Facades\LaravelMpdf::class,
|
||||
'MPDF' => Mccarlosen\LaravelMpdf\Facades\LaravelMpdf::class,
|
||||
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
||||
],
|
||||
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ return [
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
|
||||
@@ -13,22 +13,13 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->call(AdminUsersTableSeeder::class);
|
||||
|
||||
$this->call(CountriesTableSeeder::class);
|
||||
|
||||
$this->call(StatesTableSeeder::class);
|
||||
$this->call(DistrictsTableSeeder::class);
|
||||
|
||||
$this->call(CountriesTableSeeder::class);
|
||||
$this->call(CurrenciesTableSeeder::class);
|
||||
|
||||
$this->call(CompaniesTableSeeder::class);
|
||||
|
||||
$this->call(SegmentsTableSeeder::class);
|
||||
|
||||
$this->call(SegmentConstantsTableSeeder::class);
|
||||
|
||||
// $this->call(OrdersTableSeeder::class);
|
||||
$this->call(DummyDataSeeder::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,588 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Services\GeneratesInitials;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUser;
|
||||
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\DataTransferObjects\CompanyModuleObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyModule;
|
||||
use App\Classes\Modules\Companies\Services\GeneratesUniqueAccountNumber;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
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\Processors\CreateContainerProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackageProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
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\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\Address;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Container;
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
class DummyDataSeeder extends Seeder
|
||||
{
|
||||
|
||||
/** @var Faker */
|
||||
public $faker;
|
||||
|
||||
/** @var CreatesUser */
|
||||
public $createsUser;
|
||||
|
||||
/** @var GeneratesUniqueAccountNumber */
|
||||
public $generatesUniqueAccountNumber;
|
||||
|
||||
/** @var CreatesCompany */
|
||||
public $createsCompany;
|
||||
|
||||
/** @var CreatesCompanyModule */
|
||||
public $createsCompanyModule;
|
||||
|
||||
/** @var CreatesContact */
|
||||
public $createsContact;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
public $createsAddress;
|
||||
|
||||
/** @var CreateContainerProcessor */
|
||||
public $createContainerProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
public $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
public $createsSchedule;
|
||||
|
||||
/** @var CreatesCompanyConnection */
|
||||
public $createsCompanyConnection;
|
||||
|
||||
/** @var ApprovesCompanyConnection */
|
||||
public $approvesCompanyConnection;
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
public $assignEmployeeProcessor;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
public $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
public $createsFiles;
|
||||
|
||||
/** @var GeneratesOrderNumber */
|
||||
public $generatesOrderNumber;
|
||||
|
||||
/** @var CreateOrderProcessor */
|
||||
public $createOrderProcessor;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
public $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
public $createPackageProcessor;
|
||||
|
||||
/**
|
||||
* @param Faker $faker
|
||||
* @param CreatesUser $createsUser
|
||||
* @param GeneratesUniqueAccountNumber $generatesUniqueAccountNumber
|
||||
* @param CreatesCompany $createsCompany
|
||||
* @param CreatesCompanyModule $createsCompanyModule
|
||||
* @param CreatesContact $createsContact
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param CreateContainerProcessor $createContainerProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param CreateOrderProcessor $createOrderProcessor
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
*/
|
||||
public function __construct(Faker $faker, CreatesUser $createsUser, GeneratesUniqueAccountNumber $generatesUniqueAccountNumber, CreatesCompany $createsCompany, CreatesCompanyModule $createsCompanyModule, CreatesContact $createsContact, CreatesAddress $createsAddress, CreateContainerProcessor $createContainerProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, CreatesDocument $createsDocument, CreatesFiles $createsFiles, GeneratesOrderNumber $generatesOrderNumber, CreateOrderProcessor $createOrderProcessor, CreatePackingListProcessor $createPackingListProcessor, CreatePackageProcessor $createPackageProcessor)
|
||||
{
|
||||
$this->faker = $faker;
|
||||
$this->createsUser = $createsUser;
|
||||
$this->generatesUniqueAccountNumber = $generatesUniqueAccountNumber;
|
||||
$this->createsCompany = $createsCompany;
|
||||
$this->createsCompanyModule = $createsCompanyModule;
|
||||
$this->createsContact = $createsContact;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->createContainerProcessor = $createContainerProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
* @throws MalformedRequestException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Local Development Default Password Hash
|
||||
$password = '123456abcabc';
|
||||
|
||||
// At the moment we only have 3 different user roles:
|
||||
// RoleTypes::SUPER_ADMIN : Full access, at the moment is not attached to a company but should be in the future.
|
||||
// RoleTypes::ADMIN : Full access except for some sensitive features that require higher level of approval, at the moment is not attached to a company but should be in the future.
|
||||
// RoleTypes::USER : This is the customer, can only access their own orders only, must be attached to a company.
|
||||
|
||||
// User Status
|
||||
// ApprovalStatus::PENDING_VERIFICATION : This should be the default status before the user verifies their email status, but currently this is not being implemented.
|
||||
// ApprovalStatus::APPROVED : This is the status of users with verified emails.
|
||||
// ApprovalStatus::SUSPENDED : This is the status if the users is blocked from the system, but currently this is not being implemented.
|
||||
|
||||
|
||||
// =============================================== //
|
||||
// Create CIEF Entities //
|
||||
// =============================================== //
|
||||
|
||||
// create super admin
|
||||
$userObject = new RegistrationObject($this->faker->name, 'super_admin@izyim.com', $password, $password,RoleTypes::SUPER_ADMIN, ApprovalStatus::APPROVED);
|
||||
$this->createsUser->execute($userObject);
|
||||
|
||||
// create admin
|
||||
$userObject = new RegistrationObject($this->faker->name, 'admin@izyim.com', $password, $password,RoleTypes::ADMIN, ApprovalStatus::APPROVED);
|
||||
$this->createsUser->execute($userObject);
|
||||
|
||||
// create CIEF
|
||||
$company_object = new CompanyObject('CIEF Worldwide Sdn Bhd', 'CIEF',CompanyType::COMPANY_BUSINESS,ApprovalStatus::APPROVED);
|
||||
/** @var Company $company */
|
||||
$company = $this->createsCompany->execute($company_object);
|
||||
|
||||
$companyModuleObject = new CompanyModuleObject('CIEF Worldwide Sdn Bhd', 'CIEF', '', '', BusinessType::FREIGHT_FORWARDER, ApprovalStatus::APPROVED);
|
||||
/** @var CompanyModule $CIEF */
|
||||
$CIEF = $this->createsCompanyModule->execute($company, $companyModuleObject);
|
||||
|
||||
// =============================================== //
|
||||
// Create Supplier Entities //
|
||||
// =============================================== //
|
||||
// supplier entities consist of 2 type of company module [BusinessType::FREIGHT_FORWARDER, BusinessType::FREIGHT_FORWARDER, BusinessType::WAREHOUSE]
|
||||
// in this use case we are creating 3 supplier, with each supplier having 6 company modules, 1 BusinessType::FREIGHT_FORWARDER and 5 BusinessType::WAREHOUSE. 1 warehouse for each location.
|
||||
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
$supplierName = $this->faker->company;
|
||||
$supplierReference = $this->faker->bothify('??-????');
|
||||
|
||||
$company_object = new CompanyObject($supplierName, $supplierReference,CompanyType::COMPANY_BUSINESS,ApprovalStatus::APPROVED);
|
||||
/** @var Company $company */
|
||||
$company = $this->createsCompany->execute($company_object);
|
||||
|
||||
$companyModuleObject = new CompanyModuleObject($supplierName, $supplierReference, '', '', BusinessType::FREIGHT_FORWARDER, ApprovalStatus::APPROVED);
|
||||
$this->createsCompanyModule->execute($company, $companyModuleObject);
|
||||
|
||||
// create supplier warehouses
|
||||
foreach(['Guangzhou', 'Yiwu', 'Klang', 'Sabah', 'Sarawak'] as $name){
|
||||
|
||||
$warehouseReference = '';
|
||||
$isChina = false;
|
||||
|
||||
switch($name) {
|
||||
case 'Guangzhou': $warehouseReference = 'GZ-V0'.$i; $isChina = true; break;
|
||||
case 'Yiwu': $warehouseReference = 'YY-V0'.$i; $isChina = true; break;
|
||||
case 'Klang': $warehouseReference = 'KL-V0'.$i; break;
|
||||
case 'Sabah': $warehouseReference = 'SB-V0'.$i; break;
|
||||
case 'Sarawak':$warehouseReference = 'SRW-V0'.$i; break;
|
||||
}
|
||||
|
||||
$companyModuleObject = new CompanyModuleObject($name, $warehouseReference, '', '', BusinessType::WAREHOUSE, ApprovalStatus::APPROVED);
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createsCompanyModule->execute($company, $companyModuleObject);
|
||||
|
||||
$address = new AddressObject( $this->faker->streetAddress, $this->faker->streetAddress, $isChina ? 2 : 1, $isChina ? 35 : 15, $isChina ? 633 : 412, $isChina ? 510450 : 41400, AddressType::DELIVERY, ApprovalStatus::APPROVED);
|
||||
$this->createsAddress->execute($companyModule, $address);
|
||||
|
||||
$contact = new ContactObject($this->faker->name, $this->faker->phoneNumber, '', '');
|
||||
$this->createsContact->execute($companyModule, $contact);
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================== //
|
||||
// Create Containers //
|
||||
// =============================================== //
|
||||
// Containers belongs to a warehouse, a container will include many packing lists that will be shipped together
|
||||
// when a container is loaded it will be attached to transport arrangement and a schedule to indicate when the container will depart (ETD) and when it will arrive (ETA)
|
||||
// the shipping schedule can be interrupted which will result in a delay for the (ETA)
|
||||
|
||||
for($containerLoop=1; $containerLoop <= rand(15, 60); $containerLoop++) {
|
||||
$loadingDate = Carbon::today()->addDays(10)->subDays(rand(1, 30));
|
||||
$containerObject = new ContainerObject($this->faker->bothify('??-######'), '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
// randomly selects an origin warehouse
|
||||
$warehouse = CompanyModule::where('reference', $this->faker->randomElement(['GZ-V01', 'GZ-V02', 'GZ-V03', 'YY-V01', 'YY-V03', 'YY-V03']))->first();
|
||||
|
||||
/** @var Container $container */
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $warehouse);
|
||||
|
||||
$departureDate = $loadingDate->copy()->addDays(rand(0, 3));
|
||||
$arrivalDate = $departureDate->copy()->addDays(7);
|
||||
|
||||
// Container Shipping Schedule
|
||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $departureDate, null, ApprovalStatus::APPROVED);
|
||||
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($departureDate, $arrivalDate, ApprovalStatus::APPROVED));
|
||||
|
||||
// randomly reschedule some containers
|
||||
if($this->faker->numberBetween(0, 1)){
|
||||
$delayedArrivalDate = $departureDate->copy()->addDay();
|
||||
|
||||
// reschedule shipment
|
||||
for($scheduleLoop=1; $scheduleLoop <= rand(1, 5); $scheduleLoop++) {
|
||||
$delayedArrivalDate = $delayedArrivalDate->copy()->addDays(rand(0, 5));
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($departureDate, $delayedArrivalDate, ApprovalStatus::APPROVED));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// =============================================== //
|
||||
// Create Customer //
|
||||
// =============================================== //
|
||||
// 1. create user
|
||||
// 2. create company
|
||||
|
||||
// 3. create Company Module
|
||||
// 4. Declare Company Relationship with CIEF
|
||||
|
||||
// 5. Attach Employee
|
||||
// 6. create contact
|
||||
// 7. create Address
|
||||
|
||||
// 8. identification verification
|
||||
|
||||
// =============================================== //
|
||||
// Order Workflow //
|
||||
// =============================================== //
|
||||
|
||||
// 9. Create Shipping Label
|
||||
// 10. Receive Goods at warehouse (our record match supplier record + detect any problems)
|
||||
// 11. Load into container for shipping (our record match supplier record + detect any problems)
|
||||
// 12. generate invoice (add billing address + double check price)
|
||||
// 13. additional charges
|
||||
// 12. Un-stuffing Container (our record match supplier record + detect any problems)
|
||||
// 13. last mile delivery (our record match supplier record + on hold)
|
||||
|
||||
// generate random number of users
|
||||
for($userLoop=1; $userLoop <= rand(20, 50); $userLoop++) {
|
||||
|
||||
// === //
|
||||
// 1 // ========== //
|
||||
// Create user //
|
||||
// ================= //
|
||||
$customerName = $this->faker->name;
|
||||
$customerEmail = $this->faker->email;
|
||||
$userObject = new RegistrationObject($customerName, $customerEmail, $password, $password, RoleTypes::USER, ApprovalStatus::APPROVED);
|
||||
/** @var User $user */
|
||||
$user = $this->createsUser->execute($userObject);
|
||||
|
||||
// === //
|
||||
// 2 // ========== //
|
||||
// Create Company //
|
||||
// ================= //
|
||||
|
||||
// CompanyTypes
|
||||
// CompanyType::COMPANY_BUSINESS : For SME Business Entities and requires SSM for identity verification.
|
||||
// CompanyType::PERSONAL_BUSINESS : For Personal Entities and requires IC for identity verification, and the company name will follow the customer name in this case.
|
||||
|
||||
// Company Status
|
||||
// ApprovalStatus::APPROVED : This is the default status of registered company.
|
||||
// ApprovalStatus::SUSPENDED : This is the status if the company is blocked from releasing packages from warehouse due to pending verification.
|
||||
|
||||
$isCompany = $this->faker->numberBetween(0, 1);
|
||||
$companyName = $isCompany ? $this->faker->company : $customerName;
|
||||
$companyAccountNumber = $this->generatesUniqueAccountNumber->execute();
|
||||
$company_object = new CompanyObject($companyName,
|
||||
$companyAccountNumber,
|
||||
$isCompany ? CompanyType::COMPANY_BUSINESS : CompanyType::PERSONAL_BUSINESS,
|
||||
ApprovalStatus::APPROVED);
|
||||
|
||||
/** @var Company $company */
|
||||
$company = $this->createsCompany->execute($company_object);
|
||||
|
||||
// === //
|
||||
// 3 // =================//
|
||||
// Create Company Module //
|
||||
// ========================//
|
||||
// Company Module are sub entities of the company, and is used to declare what kind of business role this sub entity is in "Like Departments"
|
||||
// one company can have multiple company module if they play multiple roles in the process:
|
||||
// BusinessType::IMPORTER :
|
||||
// BusinessType::FREIGHT_FORWARDER :
|
||||
// BusinessType::WAREHOUSE :
|
||||
$companyModuleObject = new CompanyModuleObject($companyName, $companyAccountNumber, '', '', BusinessType::IMPORTER, ApprovalStatus::APPROVED);
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createsCompanyModule->execute($company, $companyModuleObject);
|
||||
|
||||
// === //
|
||||
// 4 // ================================== //
|
||||
// Declare Company Relationship with CIEF //
|
||||
// ========================================= //
|
||||
// In order for 2 entities to work together they must both agree to the relationship "Like facebook friend requests".
|
||||
// But at the moment since CIEF is the only Entity that has a direct relationship with importers we just declare this relationship by default.
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, $CIEF, mt_rand(1000, 9999) . (new GeneratesInitials())->name($companyName)->length(3)->generate(), 'CIEF');
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
|
||||
// === //
|
||||
// 5 // ===========//
|
||||
// Attach Employee //
|
||||
// ==================//
|
||||
// employees are attached to company modules not companies, because an employee maybe working for one or many "Departments".
|
||||
$Object = new EmploymentObject($companyModule, $user);
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
// === //
|
||||
// 6 // =========== //
|
||||
// Create Contact //
|
||||
// ================= //
|
||||
// Contacts uses eloquent polymorphic relationship to declare its owner. and for this use case it will be attached to the company not the company module.
|
||||
$contactObject = new ContactObject($customerName, $this->faker->phoneNumber, $customerEmail, null);
|
||||
$this->createsContact->execute($company, $contactObject);
|
||||
|
||||
// === //
|
||||
// 7 // ========== //
|
||||
// Create Address //
|
||||
// ================= //
|
||||
// Addresses uses eloquent polymorphic relationship to declare its owner. and for this use case it will be attached to the company module.
|
||||
// an address has at least 1 contact for the PIC.
|
||||
// there are 2 type of address we use:
|
||||
// AddressType::DELIVERY : for the orders delivery address
|
||||
// AddressType::BILLING : for the invoice billing address
|
||||
|
||||
foreach ([AddressType::DELIVERY, AddressType::BILLING] as $type) {
|
||||
// create delivery address
|
||||
$addressObject = new AddressObject($this->faker->streetAddress, '', 1, $this->faker->numberBetween(1, 15), $this->faker->numberBetween(1, 442), $this->faker->postcode, $type, ApprovalStatus::APPROVED);
|
||||
/** @var Address $address */
|
||||
$address = $this->createsAddress->execute($companyModule, $addressObject);
|
||||
|
||||
// create delivery address contact for person in charge
|
||||
$contact = new ContactObject($this->faker->name, $this->faker->phoneNumber, '', '');
|
||||
$this->createsContact->execute($address, $contact);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// === //
|
||||
// 8 // ======================= //
|
||||
// identification verification //
|
||||
// ============================== //
|
||||
// please refer to company types section for more insight
|
||||
$object = new DocumentObject($isCompany ? DocumentType::SSM_REGISTRATION : DocumentType::IDENTITY_CARD, ['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAANGklEQVR4nOzXDa/fdX3G8R44Ww54BIFV2wFyoxUoKmsFhA0zEGQj1jOMo5o5IQPmYE5wrSvjdhbHAGWt0BWEwmChuHEjSF2LrY6tlmFjJbblprQstD21UFzbrBhX1tKyR3ElJtfr9QCu78k/v5N3PoOzbv/SmKR/mv94dP+FN9dH95+7+J7o/sjse6P7y3d/Orq/6qKTovtLN94f3Z9w39nR/XeFv/+nrlse3V/xhbXR/Xuv/kx0f3TDjuj+oltviO7PHJf9/veJrgPwK0sAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQafOeyu6MPPP9by6L7f7n/yuj+rWN/Et3/xiu/Gd3/xQduju7ve+KE6P7wc6dG9yde/lx0f86J2e/nO38yLrq/ftXT0f0/m7wzuj9jw4vR/V2n74jub7v8zOi+CwCglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKDWw40dD0Qc2PP+O6P6cJauj+zP+dVl0//izT47uv+eazdH9bf+3I7r/xhFXR/dnzjwmun/lJ56N7n/vA/Oi+5NmnxDdf3jqtuj+8j0PRPfnzPtUdP/Jt++K7rsAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSgwsfXhl94KuHrIjuHzvmxuj+g6+9EN1//Pz/jO5P/2x2f/dTL0X3f+e9S6L7f3zJHdH9jafOjO6/7/LDo/s3bL4+un/rnNOi+yMXDUX3Bw6YFt2/+IyTovsuAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACg1OCEe34UfWDn+SPR/bcWrY3u//DMbdH94w4diu4/sPTo6P7tNx0Z3V92wrzo/k8/uzu6f8DwndH9v5i1ILq/+UO3Rfd3Lz4nuv+VRx6K7s9Y+nJ0f+HKsdF9FwBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUGrw9+84JfrAof89P7r/wf8aG90/d8//RvdvXf/30f3JI8ui+8ceeUd0/+DPr4nuf3jX56L7p168Krr/rcfOiu6PHvhqdH/xLauj+8+Mbozur/vpj6P7E8edH913AQCUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQYXb9kafeDSf/lWdP/fdx4c3X9k60vR/b13Xxjdnzb1Z9H90ctWRfffmvRGdP+8e96M7m+avT26/45vnh3d/9rNY6P7Tz/5w+j+e6bMj+4f8rHro/vHH579/l0AAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAECpwb037R994NK5a6P7/7zgvuj+JTNPiO7/7fKjo/t7H7wmuj/8+pnR/f2nbojuH33tndH9333536L7E25+Kro//NuTo/vLT1oe3f+jNZdG9y+ffHB0f972e6L7LgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoNTgYcd8LvrA9IGd0f3jh6+K7l8/d010f5/hrdH98euGovuf+OvbovsHnPpSdP/p6X8e3d8ztD26v+bJydH9GQfcG91/+MWPRve/vPSX0f2P/OmC6P7AdYdF910AAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAECpgXMG3x59YPXKWdH9xc9+P7q/3/SjovvLjjs3uv83E4+N7p904Lej+9MXfCq6//ULvxvdf2D2KdH9afOuiu5PnPm26P7QM1Oy+yPZ7/PItdui+1v+Y1103wUAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQaeOKXH48+sGnNtOj+mGkrovNvm3tddH/MoWOj8y/cckx0/6D5743u/+ydI9H9O/d+JLr/yuwLovtbHhqI7r//wuz3+Z2PfTC6/5VXVkX3/+G+c6L7Xz9vRnTfBQBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBp4/ZC7og/84cLx0f1fX7gyuj/xy6PR/eueuDG6P/6rS6L7t//g8ej+Xa9Niu6/9sSM6P4bmx6L7t+14+Do/se/NBzd3/7Rq6L7a976dHR/xruy/1+jO/aN7rsAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSg48/PyX6wBenDkX3Z607Lbo/d9f7o/tblmd//5u+Oyu6f/rP50X3B1/dEN2/5O6V0f0rLr0tur/omp9E918deT26/+Dpe6P7N179d9H9TdeORvd33XdOdN8FAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUGpgzcW/0gQ9PPyK6P/jtB6P7nzxrU3T/i/dvjO6vPuWQ6P6Z7/616P76T94Q3X/37qHo/rzfmx/dv2V8dv/+/S6L7j/6B0uj+wftuyS6v+KK7O+/++Xs3+8CACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKDTx24TeiDzz68MnR/UU7D4/uH/ah7P6PH5oT3T/viCuj+18b2RTd//7J+0f3L7nipuj+lAueie6PmXpUdH7mpDOi+y/ueiS6f9kP/iq6/+yEn0f3p1x0UXTfBQBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBo86urN0Qemjk6N7n9v+Nzo/uHXfj66P3fF1uj+Pvv9T3T/wBOj82MeOuvR6P64cVdE9/9x4KDo/m+cdmV0f8HSPdH9910wKbo//gv3Rve/+YszovufufO46L4LAKCUAACUEgCAUgIAUEoAAEoJAEApAQAoJQAApQQAoJQAAJQSAIBSAgBQSgAASgkAQCkBACglAAClBACglAAAlBIAgFICAFBKAABKCQBAKQEAKCUAAKUEAKCUAACUEgCAUgIAUEoAAEoJAEApAQAo9f8BAAD//3aYjHM9JD/iAAAAAElFTkSuQmCC'],
|
||||
$isCompany ? $this->faker->bothify('SSM-#######') : $this->faker->bothify('############'), ApprovalStatus::APPROVED, 'identifications');
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($company, $object);
|
||||
$this->createsFiles->execute($document, $object);
|
||||
|
||||
// generate random number of shipping labels
|
||||
for($orderLoop=1; $orderLoop <= rand(1, 30); $orderLoop++) {
|
||||
|
||||
// === //
|
||||
// 9 // ================= //
|
||||
// Create Shipping Label //
|
||||
// ======================== //
|
||||
// The shipping label is stored in the warehouse as an order entity.
|
||||
// the shipping label comes with the warehouse address which will receive the shipment, and
|
||||
// the shipping label comes with a qr code that helps the supplier warehouse to identify
|
||||
// the customer that owns the order and the delivery address.
|
||||
// A shipping label can be re-used, and each batch that arrives at the supplier warehouse
|
||||
// is referred to as a packing list. more on this later.
|
||||
|
||||
$orderNumber = $this->generatesOrderNumber->execute();
|
||||
$deliveryAddress = $company->addresses()->where('type', AddressType::DELIVERY);
|
||||
|
||||
// randomly selects an origin warehouse
|
||||
$originWarehouse = CompanyModule::where('reference', $this->faker->randomElement(['GZ-V01', 'GZ-V02', 'GZ-V03', 'YY-V01', 'YY-V03', 'YY-V03']))->first();
|
||||
|
||||
// creates shipping label
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $orderNumber);
|
||||
|
||||
// Packing List Types
|
||||
// A packing list is a group of packages, there are many type of packing lists, but currently we are only using 4 types of packing list:
|
||||
// PackingListType::WAREHOUSE_RECEIVE_LIST : group of packages that has arrived to the warehouse with the original measurements provided by the warehouse.
|
||||
// PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA : group of packages that has arrived to the warehouse with the modified measurements. e.g. add 1 cm to width, length, and height.
|
||||
// PackingListType::SHIPPING_PACKING_LIST : group of packages that has packed into the container with the original measurements provided by the warehouse.
|
||||
// PackingListType::SHIPPING_PACKING_LIST_REPLICA : group of packages that has packed into the container with the modified measurements. e.g. add 1 cm to width, length, and height.
|
||||
|
||||
if($orderLoop !== 1) {
|
||||
// generate random number of packing lists
|
||||
for($packingListLoop=1; $packingListLoop <= rand(2, 4); $packingListLoop++) {
|
||||
|
||||
// ==== //
|
||||
// 10 // ===================== //
|
||||
// Receive Goods at warehouse //
|
||||
// WAREHOUSE_RECEIVE_LIST //
|
||||
// ============================= //
|
||||
// When a batch of goods arrives to the warehouse a WAREHOUSE_RECEIVE_LIST packing list is created.
|
||||
// A transport arrangement is attached to WAREHOUSE_RECEIVE_LIST packing list to represent the trip
|
||||
// from supplier to the warehouse and is used to record the arrival date.
|
||||
|
||||
|
||||
// create random packages
|
||||
$packages = [];
|
||||
for ($packagesLoop = 1; $packagesLoop <= rand(2, 5); $packagesLoop++) {
|
||||
$packages[] = new PackageObject(PackageType::CARTON, $this->faker->word, (float)$this->faker->numberBetween(1, 100), (float)$this->faker->numberBetween(1, 100), (float)$this->faker->numberBetween(1, 100), 0, (float)$this->faker->numberBetween(1, 10), ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
$packingListReference = $this->faker->bothify('???#########');
|
||||
|
||||
$warehouseReceiveObject = new PackingListObject($packingListReference, $originWarehouse->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::APPROVED);
|
||||
|
||||
// Creates WAREHOUSE_RECEIVE_LIST & WAREHOUSE_RECEIVE_LIST_REPLICA
|
||||
/** @var PackingList $warehouseReceiveList */
|
||||
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
||||
|
||||
// attach packages to packing list
|
||||
foreach ($packages as $package) {
|
||||
// Attach packages to both WAREHOUSE_RECEIVE_LIST & WAREHOUSE_RECEIVE_LIST_REPLICA
|
||||
$this->createPackageProcessor->execute($package, $warehouseReceiveList);
|
||||
}
|
||||
|
||||
// random arrival date in the last 30 days
|
||||
$receiveDate = Carbon::today()->subDays(rand(10, 45));
|
||||
|
||||
// create transport arrangement for the trip from manufacturer to warehouse (to record drop off/ receive date)
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $this->faker->bothify('??#########'), $receiveDate, $receiveDate, ApprovalStatus::APPROVED);
|
||||
$this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||
|
||||
// ==== //
|
||||
// 11 // =========================== //
|
||||
// Load into container for shipping //
|
||||
// SHIPPING_PACKING_LIST //
|
||||
// =================================== //
|
||||
// When a batch of goods is loaded in a container to prepare for shipping a SHIPPING_PACKING_LIST packing list is created.
|
||||
// A SHIPPING_PACKING_LIST is a copy of the WAREHOUSE_RECEIVE_LIST in most cases.
|
||||
|
||||
$shippingPackingListObject = new PackingListObject($packingListReference, $originWarehouse->id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::APPROVED);
|
||||
// Creates SHIPPING_PACKING_LIST & SHIPPING_PACKING_LIST_REPLICA
|
||||
/** @var PackingList $warehouseReceiveList */
|
||||
$shippingPackingList = $this->createPackingListProcessor->execute($shippingPackingListObject, $order);
|
||||
|
||||
// attach packages to packing list
|
||||
foreach ($packages as $package) {
|
||||
// Attach packages to both SHIPPING_PACKING_LIST & SHIPPING_PACKING_LIST_REPLICA
|
||||
$this->createPackageProcessor->execute($package, $shippingPackingList);
|
||||
}
|
||||
|
||||
// select random container
|
||||
$container = $this->faker->randomElement(Container::whereDate('loading_date', '>=', $receiveDate)->get());
|
||||
|
||||
// attach packing list to container
|
||||
$container->packingLists()->attach($shippingPackingList);
|
||||
|
||||
if ($container->status !== ApprovalStatus::COMPLETED) {
|
||||
// ==== //
|
||||
// 12 // ================================= //
|
||||
// Un-stuffing Container //
|
||||
// container arrived to malaysia warehouse //
|
||||
// ========================================= //
|
||||
// when a container arrives to malaysia's warehouse it is un-stuffed, the un-stuffing date will update
|
||||
// the container's transport drop off date and to container status is update to ApprovalStatus::COMPLETE
|
||||
|
||||
$containerTransport = $container->transports()->first();
|
||||
$schedule = $containerTransport->schedules()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
// container Has arrived
|
||||
if ($schedule->eta->isPast()) {
|
||||
// update transport drop date
|
||||
$containerTransport->drop_date = $schedule->eta;
|
||||
$containerTransport->save();
|
||||
|
||||
// update container status to complete
|
||||
$container->status = ApprovalStatus::COMPLETED;
|
||||
$container->save();
|
||||
|
||||
// ==== //
|
||||
// 13 // ================ //
|
||||
// Last Mile Delivery //
|
||||
// ======================== //
|
||||
// after the container is un-stuffed, the malaysian warehouse will arrange for delivery.
|
||||
// to schedule the delivery we will need to attach a transport arrangement with a schedule to the SHIPPING_PACKING_LIST
|
||||
|
||||
$isDelivered = rand(0, 1);
|
||||
if ($isDelivered) {
|
||||
$deliveryDate = $schedule->eta->copy()->addDays(rand(1, 5));
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $shippingPackingList);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //
|
||||
// Missing Functions //
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //
|
||||
// 1. on hold shipments
|
||||
// 2. invoices & payments
|
||||
// 3. overweight cbm
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace Database\Seeders;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
|
||||
use App\Models\SegmentConstant;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -23,105 +24,91 @@ class SegmentConstantsTableSeeder extends Seeder
|
||||
|
||||
public function run()
|
||||
{
|
||||
// insert base prices
|
||||
$n_days = 10; // for the 10 days ahead
|
||||
$today = date("Y-m-d");
|
||||
$prices = [];
|
||||
for($ii=0; $ii<$n_days;$ii++){
|
||||
$prices[date('Y-m-d', strtotime($today. ' + '.$ii.' days'))] = rand(10, 30) / 10;
|
||||
}
|
||||
$this->insertData(1, SegmentConstants::BASE_PRICE, $prices);
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>1,
|
||||
'reference'=>'BASE_PRICE',
|
||||
'value'=>'{"2022-09-21":"330.00","2022-09-22":"330.00","2022-09-23":"330.00","2022-09-24":"330.00","2022-09-25":"330.00","2022-09-26":"330.00","2022-09-27":"315.00","2022-09-28":"315.00","2022-09-29":"315.00","2022-09-30":"315.00","2022-08-22":"330.00","2022-08-23":"330.00","2022-08-24":"330.00","2022-08-25":"330.00","2022-08-26":"330.00","2022-08-27":"330.00","2022-08-28":"330.00","2022-08-29":"330.00","2022-08-30":"330.00","2022-08-31":"330.00","2022-09-01":"330.00","2022-09-02":"330.00","2022-09-03":"330.00","2022-09-04":"330.00","2022-09-05":"330.00","2022-09-06":"330.00","2022-09-07":"330.00","2022-09-08":"330.00","2022-09-09":"330.00","2022-09-10":"330.00","2022-09-11":"330.00","2022-09-12":"330.00","2022-09-13":"330.00","2022-09-14":"330.00","2022-09-15":"330.00","2022-09-16":"330.00","2022-09-17":"330.00","2022-09-18":"330.00","2022-09-19":"330.00","2022-09-20":"330.00","2022-10-01":"315.00","2022-10-02":"315.00","2022-10-03":"315.00","2022-10-04":"315.00","2022-10-05":"315.00","2022-10-06":"315.00","2022-10-07":"315.00","2022-10-08":"315.00","2022-10-09":"315.00","2022-10-10":"315.00","2022-10-11":"315.00","2022-10-12":"315.00","2022-10-13":"315.00","2022-10-14":"315.00","2022-10-15":"315.00","2022-10-16":"315.00","2022-10-17":"315.00","2022-10-18":"315.00","2022-10-19":"315.00","2022-10-20":"315.00","2022-10-21":"315.00","2022-10-22":"315.00","2022-10-23":"315.00","2022-10-24":"315.00","2022-10-25":"315.00","2022-10-26":"315.00","2022-10-27":"315.00","2022-10-28":"315.00","2022-10-29":"315.00","2022-10-30":"315.00","2022-10-31":"315.00","2022-11-01":"315.00","2022-11-02":"315.00","2022-11-03":"315.00","2022-11-04":"315.00","2022-11-05":"315.00","2022-11-06":"315.00","2022-11-07":"315.00","2022-11-08":"315.00","2022-11-09":"315.00","2022-11-10":"315.00","2022-11-11":"315.00","2022-11-12":"315.00","2022-11-13":"315.00","2022-11-14":"315.00","2022-11-15":"315.00","2022-11-16":"315.00","2022-11-17":"315.00","2022-11-18":"315.00","2022-11-19":"315.00","2022-11-20":"315.00","2022-11-21":"315.00","2022-11-22":"315.00","2022-11-23":"315.00","2022-11-24":"315.00","2022-11-25":"315.00","2022-11-26":"315.00","2022-11-27":"315.00","2022-11-28":"315.00","2022-11-29":"315.00","2022-11-30":"315.00","2022-12-01":"315.00","2022-12-02":"315.00","2022-12-03":"315.00","2022-12-04":"315.00","2022-12-05":"315.00","2022-12-06":"315.00","2022-12-07":"315.00","2022-12-08":"315.00","2022-12-09":"315.00","2022-12-10":"315.00","2022-12-11":"315.00","2022-12-12":"315.00","2022-12-13":"315.00","2022-12-14":"315.00","2022-12-15":"315.00","2022-12-16":"315.00","2022-12-17":"315.00","2022-12-18":"315.00","2022-12-19":"315.00","2022-12-20":"315.00","2022-12-21":"315.00","2022-12-22":"315.00","2022-12-23":"315.00","2022-12-24":"315.00","2022-12-25":"315.00","2022-12-26":"315.00","2022-12-27":"315.00","2022-12-28":"315.00","2022-12-29":"315.00","2022-12-30":"315.00","2022-12-31":"315.00"}',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>'2022-09-27 01:16:14'
|
||||
] );
|
||||
|
||||
// insert state prices
|
||||
$prices = [];
|
||||
for($ii=1; $ii<=16;$ii++){
|
||||
$prices[] = [
|
||||
'state_id' => $ii,
|
||||
'center' => '10.00',
|
||||
'outstation'=> '2.00'
|
||||
];
|
||||
}
|
||||
$this->insertData(1, SegmentConstants::STATE_RATE, $prices);
|
||||
|
||||
// insert warehouse prices
|
||||
$prices = [];
|
||||
for($ii=1; $ii<=7;$ii++){
|
||||
$prices[] = [
|
||||
'warehouse_id' => $ii,
|
||||
'amount' => '1.'.$ii
|
||||
];
|
||||
}
|
||||
$this->insertData(1, SegmentConstants::WAREHOUSE_RATE, $prices);
|
||||
|
||||
// insert center postcodes
|
||||
$prices = [
|
||||
[ 'post_code' => '80050' ],
|
||||
[ 'post_code' => '80100' ],
|
||||
[ 'post_code' => '80150' ],
|
||||
[ 'post_code' => '80200' ],
|
||||
[ 'post_code' => '80250' ],
|
||||
[ 'post_code' => '80300' ],
|
||||
[ 'post_code' => '80350' ],
|
||||
[ 'post_code' => '80400' ],
|
||||
[ 'post_code' => '80500' ],
|
||||
[ 'post_code' => '80506' ],
|
||||
[ 'post_code' => '80508' ],
|
||||
[ 'post_code' => '80516' ],
|
||||
[ 'post_code' => '80519' ],
|
||||
[ 'post_code' => '80534' ],
|
||||
[ 'post_code' => '80536' ],
|
||||
[ 'post_code' => '80542' ],
|
||||
[ 'post_code' => '80546' ],
|
||||
[ 'post_code' => '80558' ],
|
||||
[ 'post_code' => '80560' ],
|
||||
[ 'post_code' => '80564' ],
|
||||
[ 'post_code' => '80568' ],
|
||||
[ 'post_code' => '80578' ],
|
||||
[ 'post_code' => '80584' ],
|
||||
[ 'post_code' => '80586' ],
|
||||
[ 'post_code' => '80590' ],
|
||||
[ 'post_code' => '80592' ],
|
||||
[ 'post_code' => '80594' ],
|
||||
[ 'post_code' => '80596' ],
|
||||
[ 'post_code' => '80600' ],
|
||||
[ 'post_code' => '80604' ],
|
||||
[ 'post_code' => '80608' ],
|
||||
[ 'post_code' => '80620' ],
|
||||
[ 'post_code' => '80622' ],
|
||||
[ 'post_code' => '80628' ],
|
||||
[ 'post_code' => '80644' ],
|
||||
[ 'post_code' => '80648' ],
|
||||
[ 'post_code' => '80662' ],
|
||||
[ 'post_code' => '80664' ],
|
||||
[ 'post_code' => '80668' ],
|
||||
[ 'post_code' => '80670' ],
|
||||
[ 'post_code' => '80672' ],
|
||||
[ 'post_code' => '80673' ],
|
||||
[ 'post_code' => '80676' ],
|
||||
[ 'post_code' => '80700' ],
|
||||
[ 'post_code' => '80710' ],
|
||||
[ 'post_code' => '80720' ],
|
||||
[ 'post_code' => '80730' ],
|
||||
[ 'post_code' => '80900' ],
|
||||
[ 'post_code' => '80902' ],
|
||||
[ 'post_code' => '80904' ],
|
||||
[ 'post_code' => '80906' ],
|
||||
[ 'post_code' => '80908' ],
|
||||
[ 'post_code' => '80988' ],
|
||||
[ 'post_code' => '80990' ],
|
||||
[ 'post_code' => '81000' ],
|
||||
[ 'post_code' => '81100' ],
|
||||
[ 'post_code' => '81200' ],
|
||||
[ 'post_code' => '81300' ],
|
||||
[ 'post_code' => '81310' ]
|
||||
];
|
||||
$this->insertData(1, SegmentConstants::CENTER_POSTCODE, $prices);
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>1,
|
||||
'reference'=>'STATE_RATE',
|
||||
'value'=>'[{"state_id":1,"center":"10.00","outstation":"2.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"50.00","outstation":"0.00"},{"center":"0.00","outstation":"0.00"},{"center":"345.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"0.00","outstation":"0.00"},{"center":"185.00","outstation":"0.00"},{"center":"185.00","outstation":"0.00"},{"center":"0.00","outstation":"0.00"},{"center":"50.00","outstation":"0.00"}]',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>'2022-09-27 01:18:15'
|
||||
] );
|
||||
|
||||
// insert outstation prices
|
||||
$prices = [
|
||||
['post_code' => '80000' ]
|
||||
];
|
||||
$this->insertData(1, SegmentConstants::OUTSTATION_POSTCODE, $prices);
|
||||
|
||||
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>1,
|
||||
'reference'=>'WAREHOUSE_RATE',
|
||||
'value'=>'{"4":{"amount":"20.00"},"2358":{"amount":"20.00"}}',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>'2022-09-23 04:22:52'
|
||||
] );
|
||||
|
||||
|
||||
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>1,
|
||||
'reference'=>'CENTER_POSTCODE',
|
||||
'value'=>'["5150","5460","8000","9600","10150","10350","11600","12200","12200","12200","14000","14300","18000","27600","28500","28700","31150","31350","31400","31450","36000","40150","40150","40160","40300","40400","40460","41050","41200","42000","42000","42100","42200","43000","43100","43200","43200","43300","43500","43500","43700","43900","46050","46100","46200","46300","47000","47100","47120","47130","47170","47301","47400","47500","47630","47800","48050","50450","51200","52000","52100","52200","54200","55000","55100","56000","56100","57000","58000","60000","62050","63000","68100","70300","70450","71800","75250","75260","76100","76100","79150","81000","81100","81200","81300","81750","83000","86000","88300","88300","88300","88450","91000","98000","98100"]',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>'2022-11-07 03:01:11'
|
||||
] );
|
||||
|
||||
|
||||
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>1,
|
||||
'reference'=>'OUTSTATION_POSTCODE',
|
||||
'value'=>'["93250","93350","94200","94300","94600","78556","78557","94700","94750","94760","93050","93250","94000","94500","93050","93350","93350","79466","93050","94100","94500","93050","93050","93250","93350","93050","94200","94200","93010","93010","94700","94800","94807","94809","93250","94000","93050","93050","93250","86900","82300","86800","86810","81600","86800","71600","71650","72400","71600","72200","72300","71750","71770","69000","26800","26810","26820","39000","39007","39009","39010","33300","33310","33320","33100"]',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>'2022-09-21 03:35:19'
|
||||
] );
|
||||
|
||||
|
||||
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>4,
|
||||
'reference'=>'CUSTOM_PRICE',
|
||||
'value'=>'["-10.00"]',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>'2022-09-21 02:23:22',
|
||||
'updated_at'=>'2022-09-21 03:50:38'
|
||||
] );
|
||||
|
||||
|
||||
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>5,
|
||||
'reference'=>'CUSTOM_PRICE',
|
||||
'value'=>'["-20.00"]',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>'2022-09-21 03:51:23',
|
||||
'updated_at'=>'2022-09-21 03:51:59'
|
||||
] );
|
||||
|
||||
|
||||
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>6,
|
||||
'reference'=>'CUSTOM_PRICE',
|
||||
'value'=>'["-30.00"]',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>'2022-09-21 03:51:46',
|
||||
'updated_at'=>'2022-09-21 03:52:05'
|
||||
] );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -9,24 +10,52 @@ class SegmentsTableSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
DB::table('segments')->insert(
|
||||
[
|
||||
[
|
||||
'id' => 1,
|
||||
'company_module_id' => 1,
|
||||
'name' => 'Default Segment',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'company_module_id' => 1,
|
||||
'name' => 'No Minimum Charge',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'company_module_id' => 1,
|
||||
'name' => 'Auto Release',
|
||||
]
|
||||
]
|
||||
);
|
||||
Segment::create( [
|
||||
'company_module_id'=>1,
|
||||
'name'=>'Default Segment',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>NULL
|
||||
] );
|
||||
|
||||
Segment::create( [
|
||||
'company_module_id'=>1,
|
||||
'name'=>'No Minimum Charge',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>NULL
|
||||
] );
|
||||
|
||||
Segment::create( [
|
||||
'company_module_id'=>1,
|
||||
'name'=>'Auto Release',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>NULL
|
||||
] );
|
||||
|
||||
Segment::create( [
|
||||
'company_module_id'=>1,
|
||||
'name'=>'Gold Member',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>'2022-09-21 02:22:58',
|
||||
'updated_at'=>'2022-09-21 02:22:58'
|
||||
] );
|
||||
|
||||
Segment::create( [
|
||||
'company_module_id'=>1,
|
||||
'name'=>'Platinium Member',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>'2022-09-21 03:51:09',
|
||||
'updated_at'=>'2022-09-21 03:51:09'
|
||||
] );
|
||||
|
||||
Segment::create( [
|
||||
'company_module_id'=>1,
|
||||
'name'=>'Titanium Member',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>'2022-09-21 03:51:34',
|
||||
'updated_at'=>'2022-09-21 03:51:34'
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,12 +208,12 @@
|
||||
<input class="form-control" v-model="parameters.email">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-4 p-l-5">
|
||||
<!-- <div class="col-4 p-l-5">
|
||||
<validation-wrapper-component :validator="$v.parameters.wechat_id">
|
||||
<label>WeChat ID</label>
|
||||
<input class="form-control" v-model="parameters.wechat_id">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div class="row m-b-15">
|
||||
|
||||
@@ -13,7 +13,14 @@
|
||||
<div class="col-auto">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-20 light">{{item.name}}</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="changeCustomerName">
|
||||
<change-customer-name-form-component :section="'customerProfileSection'" :data="item"></change-customer-name-form-component>
|
||||
</modal-component>
|
||||
<div class="font-heading fs-20 light">{{item.name}}
|
||||
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary" data-type="changeCustomerName" >
|
||||
<i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -32,6 +39,12 @@
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="row align-items-center parentContainer">
|
||||
<div class="col-auto padding-5 b-a b-grey b-rad-lg pointer m-r-15" @click="hrefPaymenBillingPage">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="35" height="35"
|
||||
viewBox="0 0 172 172"
|
||||
style=" fill:#000000;"><defs><linearGradient x1="69.875" y1="96.52694" x2="69.875" y2="108.37075" gradientUnits="userSpaceOnUse" id="color-1_44039_gr1"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="86" y1="21.05119" x2="86" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-2_44039_gr2"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="80.625" y1="21.05119" x2="80.625" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-3_44039_gr3"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="75.25" y1="21.05119" x2="75.25" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-4_44039_gr4"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="69.875" y1="21.05119" x2="69.875" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-5_44039_gr5"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="129" y1="21.05119" x2="129" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-6_44039_gr6"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="139.75" y1="21.05119" x2="139.75" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-7_44039_gr7"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="118.25" y1="21.05119" x2="118.25" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-8_44039_gr8"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M86,104.8125c0,1.4835 -1.204,2.6875 -2.6875,2.6875h-26.875c-1.4835,0 -2.6875,-1.204 -2.6875,-2.6875v-5.375c0,-1.4835 1.204,-2.6875 2.6875,-2.6875h26.875c1.4835,0 2.6875,1.204 2.6875,2.6875z" fill="url(#color-1_44039_gr1)"></path><path d="M154.0045,83.57856c-1.58025,-1.87856 -3.913,-2.95356 -6.407,-2.95356h-5.16v-8.0625c0,-4.44513 -4.03125,-8.0625 -8.0625,-8.0625v-26.875c0,-2.96431 -2.41069,-5.375 -5.375,-5.375h-38.65162l-3.88881,-7.77762c-0.91375,-1.83288 -2.75469,-2.97237 -4.80794,-2.97237h-18.17825h-1.66088h-18.8125c-2.96431,0 -5.375,2.41069 -5.375,5.375v96.75h-21.5v13.4375c0,7.40944 6.02806,13.4375 13.4375,13.4375h91.375c7.40944,0 13.4375,-6.02806 13.4375,-13.4375v-18.8125h4.74344c6.80475,0 12.55869,-4.71119 13.68475,-11.20419l2.95625,-17.02263c0.39775,-2.29512 -0.23919,-4.644 -1.75494,-6.44463zM137.0625,72.5625v8.0625h-16.125v-8.0625c0,-1.4835 1.20669,-2.6875 2.6875,-2.6875h10.75c1.4835,0 2.6875,1.204 2.6875,2.6875zM129,43h-5.375v-5.375h5.375zM81.65163,26.875l2.6875,5.375h-15.49344l-2.6875,-5.375zM60.15163,26.875l3.88881,7.78031c0.91913,1.83019 2.76275,2.96969 4.81063,2.96969h49.39894v5.375h-75.25v-16.125zM29.5625,145.125c-4.44513,0 -8.0625,-3.61469 -8.0625,-8.0625v-8.0625h86v8.0625c0,3.02344 1.00244,5.375 2.69288,8.0625zM129,137.0625c0,4.44512 -3.61738,8.0625 -8.0625,8.0625c-4.44512,0 -8.0625,-3.61738 -8.0625,-8.0625v-13.4375h-69.875v-75.25h86v16.125h-5.375c-4.44512,0 -8.0625,3.61737 -8.0625,8.0625v8.0625h-5.16c-2.494,0 -4.82675,1.075 -6.407,2.95356c-1.51306,1.80062 -2.15269,4.1495 -1.75225,6.44194l2.95625,17.02531c1.12606,6.493 6.87731,11.20419 13.68475,11.20419h10.11575zM150.46237,89.10138l-2.95625,17.02531c-0.67725,3.91031 -4.20325,6.74831 -8.38769,6.74831h-20.23419c-4.18444,0 -7.71044,-2.838 -8.38769,-6.74831l-2.95625,-17.028c-0.172,-0.99706 0.28219,-1.72 0.57244,-2.064c0.55362,-0.65575 1.38675,-1.03469 2.28975,-1.03469h37.195c0.903,0 1.73613,0.37894 2.29244,1.03738c0.28756,0.344 0.74444,1.06425 0.57244,2.064z" fill="url(#color-2_44039_gr2)"></path><path d="M53.75,59.125h53.75v5.375h-53.75z" fill="url(#color-3_44039_gr3)"></path><path d="M53.75,69.875h43v5.375h-43z" fill="url(#color-4_44039_gr4)"></path><path d="M53.75,80.625h32.25v5.375h-32.25z" fill="url(#color-5_44039_gr5)"></path><path d="M126.3125,91.375h5.375v16.125h-5.375z" fill="url(#color-6_44039_gr6)"></path><path d="M137.0625,91.375h5.375v10.75h-5.375z" fill="url(#color-7_44039_gr7)"></path><path d="M115.5625,91.375h5.375v10.75h-5.375z" fill="url(#color-8_44039_gr8)"></path></g></g></svg>
|
||||
</div>
|
||||
<div class="col-auto padding-5 b-a b-grey b-rad-lg pointer requestModal" data-type="assignSegment">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="30" height="30"
|
||||
@@ -181,7 +194,10 @@
|
||||
delay: 1000
|
||||
});
|
||||
$(this.$refs.copyButton).tooltip('show');
|
||||
}
|
||||
},
|
||||
hrefPaymenBillingPage(){
|
||||
window.location.href = route('customer.payment-and-billing', this.item.company_module.marking);
|
||||
},
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<div class="row m-b-15 align-items-end">
|
||||
<div class="col-auto">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10 muted all-caps">Name</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-11">{{this.item.name}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2 text-right">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10 muted all-caps">Reference</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-11">{{this.item.reference}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a :href="route('customer.profile', this.item.reference)" target="_blank">
|
||||
<button type="button" class="btn btn-xs btn-primary fs-11">Open in new tab</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
export default {
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
+140
File diff suppressed because one or more lines are too long
@@ -20,15 +20,15 @@
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<p class="no-margin fs-10 all-caps">ETD</p>
|
||||
<p class="no-margin">{{item.transport ? item.transport.current_schedule.etd : 'n/a'}}</p>
|
||||
<p class="no-margin">{{item.transport ? (item.transport.current_schedule ? item.transport.current_schedule.etd : 'n/a') : 'n/a'}}</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<p class="no-margin fs-10 all-caps">ETA</p>
|
||||
<p class="no-margin">{{item.transport ? item.transport.current_schedule.eta : 'n/a'}}</p>
|
||||
<p class="no-margin">{{item.transport ? (item.transport.current_schedule ? item.transport.current_schedule.eta : 'n/a') : 'n/a'}}</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row hide" v-if="item.transport">
|
||||
<div class="col">
|
||||
<div class="col" v-if="item.transport.current_schedule">
|
||||
<p class="no-margin fs-10 all-caps">Days Ago</p>
|
||||
<p class="no-margin" :class="[{'text-success': item.transport.current_schedule.billing_days_left.value === '+'}, {'text-danger': item.transport.current_schedule.billing_days_left.value === '-'}]">
|
||||
{{item.transport.current_schedule.billing_days_left.value}}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{{item.order.address.street_one+' '+(item.order.address.street_two ? item.order.address.street_two : '')+', '+ item.order.address.district.name+', '+item.order.address.post_code+' '+item.order.address.state.name+', '+item.order.address.country.name}}<br>{{item.order.address.remark ? item.order.address.remark.content: ''}}
|
||||
<div class="btn btn-xs btn-primary pointer m-t-10 requestModal hide" data-type="defineLocation">Define Location</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="defineLocation">
|
||||
<declare-postcode-area-form-component :data="item.order.address.post_code"></declare-postcode-area-form-component>
|
||||
<declare-postcode-area-form-component :data="item.order.address"></declare-postcode-area-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
<p class="bold m-b-5 fs-12">{{item.description}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10 align-items-center" v-if="$store.getters.isAdmin">
|
||||
<div class="col-auto">
|
||||
<p class="no-margin all-caps fs-10 lh-10 light">Reference</p>
|
||||
<p class="no-margin fs-12">{{item.reference}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-t b-b b-grey m-b-15">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
@@ -174,4 +180,4 @@
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -67,6 +67,14 @@
|
||||
<p class="no-margin bold text-info fs-12"><a :href="route('customer.profile', item.order.company_module.marking)">{{item.order.company_module.marking}}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5" v-if="$store.getters.isAdmin">
|
||||
<div class="col-auto p-r-5">
|
||||
<p class="no-margin all-caps fs-10 light">Reference</p>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<p class="no-margin bold text-info fs-12">{{item.reference}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5">
|
||||
<div class="col-auto p-r-5">
|
||||
<p class="no-margin all-caps fs-10 light">Order Number</p>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<div class="row" style="width: 450px; margin: auto;" @keyup.enter="submitForm">
|
||||
<div class="col bg-white padding-40 b-rad-lg">
|
||||
<div class="row m-b-10">
|
||||
<div class="col text-center">
|
||||
<h3>Edit Company Details</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component class="m-b-15" :validator="$v.parameters.name">
|
||||
<label class="text-primary">Name</label>
|
||||
<input class="form-control" v-model="parameters.name">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component class="m-b-15" :validator="$v.parameters.debtor">
|
||||
<label class="text-primary">Debtor Code</label>
|
||||
<input class="form-control" v-model="parameters.debtor">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-15">
|
||||
<div class="col-auto p-r-5">
|
||||
<div class="btn btn-lg btn-default b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-primary w-100 btn-lg" @click="submitForm">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required, minLength } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
parameters: {
|
||||
id: this.data.id,
|
||||
name: this.data.name,
|
||||
debtor: this.data.debtor,
|
||||
reference: this.data.reference,
|
||||
type: this.data.type,
|
||||
}
|
||||
};
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
name: {
|
||||
required,
|
||||
// minLength: minLength(8)
|
||||
},
|
||||
debtor: {
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
successHandler(response) {
|
||||
window.location.replace(this.route('customers', response.payload.data.reference));
|
||||
},
|
||||
submitForm() {
|
||||
this.submit(this.route('api.company.update.nameAndDebtor', this.data.id), 'put', this.section, true, true)
|
||||
}
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -45,16 +45,15 @@
|
||||
<div class="col-6">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<!-- <p class="m-b-0 text-danger m-b-15" v-if="parameters.warehouse_id === 3">As the Baiyun district is still under the control management, our warehouse will be temporarily closed until further notice.</p>-->
|
||||
<p class="text-center">最新运费价格 <a href="https://www.cief-malaysia.com/services-sea-shipping/" class="text-underline" target="_blank">点击 “这里 </a><br>For the latest shipping prices <a href="https://www.cief-malaysia.com/services-sea-shipping/" class="text-underline" target="_blank">click here</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center justify-content-center">
|
||||
<div class="row text-center justify-content-center d-none">
|
||||
<div class="col-8">
|
||||
<p class="m-b-0 text-danger m-t-15" v-if="parameters.warehouse_id === 3">近期由于船期的安排和马来西亚海关的运作等一些不可控因数,导致船期延迟,请大家提前做好采购安排。若有不便之处,敬请谅解。 <br>Due to inevitable circumstances, shipping arrangements and Malaysia custom clearance may have delays. Kindly plan your purchases in advance, thank you for your cooperation.</p>
|
||||
<p class="m-b-0 text-danger m-t-15" v-if="false">由于义乌船期不稳定,建议发广州仓库。<br>Due to unexpected shipping delays for Yiwu warehouse, you may select an alternative warehouse.</p>
|
||||
<p class="m-b-0 text-danger m-t-15" v-if="parameters.warehouse_id === 4">由于义乌船期不稳定,建议发广州仓库。<br>Due to unexpected shipping delays for Yiwu warehouse, you may select an alternative warehouse.</p>
|
||||
<!-- set warning text here -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+25
-9
@@ -100,17 +100,33 @@
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center parentContainer m-t-10" v-if="!item.shippng_transaction && item.order && item.order.company_module.billingAddress && $store.getters.isSuperAdmin && ['Pending Invoice', 'Pending Approval'].includes(invoice_status)" >
|
||||
<div class="col-auto requestModal pointer" data-type="editBillingAddress">
|
||||
<i class="fa fa-edit pointer fa-fw m-l-5"></i> Edit billing Address
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" size="extra-large" styleType="fill-in" type="editBillingAddress">
|
||||
<div class="row">
|
||||
<div class="col bg-white">
|
||||
<address-form-component :data="item.order.address" section="editBillingAddress"></address-form-component>
|
||||
<div class="row text-center parentContainer m-t-10" v-if="['Pending Invoice', 'Pending Approval'].includes(invoice_status)" >
|
||||
<div class="col">
|
||||
<div class="row" v-if="!item.order.company_module.billingAddress">
|
||||
<div class="col">
|
||||
<div>
|
||||
<div class="btn btn-primary btn-xs pointer requestModal btn-block" data-type="billingAddressComponent">Add Billing Address</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" size="extra-large" styleType="fill-in" type="billingAddressComponent">
|
||||
<address-form-component :id="item.order.company_module.id" :section="section" :type=1></address-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</modal-component>
|
||||
<div class="row" v-if="item.order.company_module.billingAddress">
|
||||
<div class="col">
|
||||
<div class="col-auto requestModal pointer" data-type="editBillingAddress">
|
||||
<i class="fa fa-edit pointer fa-fw m-l-5"></i> Edit billing Address
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" size="extra-large" styleType="fill-in" type="editBillingAddress">
|
||||
<div class="row">
|
||||
<div class="col bg-white">
|
||||
<address-form-component :id="item.order.company_module.id" :data="item.order.company_module.billingAddress" section="editBillingAddress"></address-form-component>
|
||||
</div>
|
||||
</div>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<div class="row m-t-20" @keyup.enter="search">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md">
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<div class="form-group no-margin form-group-default b-rad-none">
|
||||
<label class="text-primary">Order Number Like</label>
|
||||
<input type="text" class="form-control" v-model="marking" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto p-l-0 p-r-0">
|
||||
<div class="btn btn-primary b-rad-none" @click="search">
|
||||
<i class="fa fa-search lh-40"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto p-l-0">
|
||||
<div class="btn btn-secondary b-rad-none" @click="reset">
|
||||
<i class="fa fa-remove lh-40"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md">
|
||||
<div class="row" v-if="with_export">
|
||||
<div class="col">
|
||||
<download-billing-with-dates-component :section="section"></download-billing-with-dates-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<list-component :key="currentKey" :section="section" :endpoint="route('api.packing_list.list')" :options="options">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></admin-payments-billing-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
invoice_status: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
options: {
|
||||
default () {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
section:{
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
with_export:{
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
marking: '',
|
||||
currentKey: 1,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
this.options['order_marking_in'] = this.marking;
|
||||
this.currentKey+=1;
|
||||
},
|
||||
reset() {
|
||||
this.marking = '';
|
||||
delete(this.options['order_marking_in']);
|
||||
this.currentKey+=1;
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<div class="row" >
|
||||
<div class="col">
|
||||
<loading-component v-if="isLoading"></loading-component>
|
||||
<div class="row" v-if="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-15">
|
||||
<div class="col-8 p-r-0">
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<div class="form-group no-margin form-group-default b-rad-none">
|
||||
<label class="text-primary">Payment Due Days</label>
|
||||
<input type="text" class="form-control" v-model.trim="parameters.due" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class=" no-margin">
|
||||
<input type="checkbox" checked="" value="0" id="checkbox2" v-model.trim="parameters.segment">
|
||||
<label for="checkbox2 bold no-margin">Credit terms</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-0">
|
||||
<div class="btn btn-primary b-rad-none" @click="fetchPaymentList()">
|
||||
<i class="fa fa-filter lh-40"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
import LoadingComponent from "../../general/elements/LoadingComponent";
|
||||
export default {
|
||||
components: {LoadingComponent},
|
||||
props: {
|
||||
endpoint: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
section: 'pendingPaymentSection',
|
||||
isLoading: false,
|
||||
data: null,
|
||||
parameters: {
|
||||
due: '',
|
||||
segment: false
|
||||
},
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
due: {},
|
||||
},
|
||||
methods: {
|
||||
fetchPaymentList(){
|
||||
|
||||
this.$store.dispatch('reloadList', {name: this.section});
|
||||
this.$store.dispatch('updateListQueue', {name: this.section, page:1, filters: {per_page:5, has_invoice_status_in:[2], payment_day:this.parameters.due, credit_term:this.parameters.segment, order_by: {column: 'updated_at', DESC: true}}});
|
||||
|
||||
//this.$store.dispatch('toggleSection', {name: this.section, status: true});
|
||||
//this.$store.dispatch('updateListQueue', {name: this.section, page:1, filters: {per_page:5, group_by: 'transactions.id', payment_day:this.due,has_invoice_status_in:[2] /*,credit_term:[0.0]*/ }});
|
||||
//let a = this.$store.getters.getListData('pendingPaymentSection');
|
||||
//console.log(a);
|
||||
|
||||
// this.$store.dispatch('crudRequest', {endpoint: this.endpoint, method: 'get',parameters:{name: this.section, page:1, filters: {per_page:5, group_by: 'transactions.id', payment_day:this.due,has_invoice_status_in:[2] /*,credit_term:[0.0]*/ }}}).then(response => {
|
||||
|
||||
// console.log(response);
|
||||
// let success = response.ok;
|
||||
// response.json().then(response => {
|
||||
// if(!success){return;}
|
||||
|
||||
|
||||
|
||||
// this.$store.dispatch('completeList', {name: this.section, data: a})
|
||||
|
||||
// });
|
||||
//});
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
+46
-93
@@ -1,113 +1,43 @@
|
||||
<template>
|
||||
<div class="row m-b-15 m-l-5 m-r-10">
|
||||
<div class="col bg-master-lightest rounded" :class="{'b-gray': !selected, 'b-primary': selected, 'bg-primary-lighter': selected}">
|
||||
<div class="col bg-white rounded b-a" :class="{'b-white': !selected, 'b-primary': selected, 'bg-primary-lighter': selected}">
|
||||
<div class="row">
|
||||
<div class="col padding-20">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto pointer align-items-center" @click="selected = !selected">
|
||||
<div class="col-auto pointer align-items-center" @click="activate()">
|
||||
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h5 class="no-margin">{{item.country.id}}05052021</h5>
|
||||
<p class="no-margin fs-10 all-caps">Invoice No</p>
|
||||
<div>{{ item.bill_no }}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h5 class="no-margin">Invoice Date Invoice Date</h5>
|
||||
<p class="no-margin fs-10 all-caps">Order</p>
|
||||
<div><a :href="route('order.show', item.order.reference)">{{item.order.reference}}</a></div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h5 class="no-margin">Status</h5>
|
||||
<p class="no-margin fs-10 all-caps">Invoice Date</p>
|
||||
<div>{{ item.created_at }}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h5 class="no-margin">Amount</h5>
|
||||
<p class="no-margin fs-10 all-caps">Amount</p>
|
||||
<div>MYR {{ item.amount.toFixed(2) }}</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="btn bg-grey no-border" @click="expanded = !expanded">
|
||||
<i class="fa" :class="{'fa-angle-down': !expanded, 'fa-angle-up': expanded}" ></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-t b-grey p-t-10" v-show="expanded">
|
||||
<div class="col p-b-10">
|
||||
<div class="row">
|
||||
<div class="col p-l-20 p-r-20 p-t-10 p-b-10">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto invisible">
|
||||
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="m-b-0">Carrier Tracking Number</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="semi-bold m-t-0 m-b-0 large-text">#1zbr06tw403742920</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="m-b-0">Due Date</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="semi-bold m-t-0 m-b-0 large-text">11.04.2021</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="semi-bold m-t-0 m-b-0 large-text">Outstanding</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="semi-bold m-t-0 m-b-0 large-text">RM0.00</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.documents.length">
|
||||
<div v-for="file in item.documents[0].files" v-bind:key="file.id" class="col-auto no-padding">
|
||||
<document-file-viewer-component :file="file">
|
||||
<template slot="button">
|
||||
<div class="btn btn-success no-border muted">
|
||||
<i class="fa fa-file-pdf-o"></i>
|
||||
</div>
|
||||
</template>
|
||||
</document-file-viewer-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-l-20 p-r-20 p-t-10 p-b-10">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto invisible">
|
||||
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="m-b-0 normal-text">This package was delivered by</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="semi-bold m-t-0 m-b-0 large-text">#1zbr06tw403742920</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="m-b-0">Date Paid</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="semi-bold m-t-0 m-b-0 large-text">21.01.2021</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="btn btn-outline-complete btn-lg">
|
||||
Invoice Detail
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="btn bg-grey no-border muted invisible">
|
||||
<i class="fa fa-file-pdf-o"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -120,10 +50,33 @@
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
export default {
|
||||
props: {
|
||||
selectedInvoice: {
|
||||
type: Array,
|
||||
required: false,
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
expanded: false,
|
||||
selected: false,
|
||||
selectedValue: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
activate(){
|
||||
this.select = !this.select;
|
||||
this.$emit('input', this.data);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
selected() {
|
||||
var response = false;
|
||||
this.selectedInvoice.forEach((value, index) => {
|
||||
if (value.id == this.item.id) {
|
||||
response = true;
|
||||
}
|
||||
});
|
||||
return response;
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
|
||||
+24
-25
@@ -1,28 +1,24 @@
|
||||
<template>
|
||||
<div class="row m-b-20">
|
||||
<div class="row m-b-20" @keyup.enter="downloadReport()">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-l-0 m-r-0">
|
||||
<div class="col-12 col-md mb-2 mb-md-0 p-l-3 p-r-3 p-md-0">
|
||||
<validation-wrapper-component :validator="$v.parameters.startDate">
|
||||
<label class="all-caps">Start Date</label>
|
||||
<date-picker-component :parameters="parameters" v-model.lazy="parameters.startDate"></date-picker-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-12 col-md mb-2 mb-md-0 p-l-3 p-r-3 p-md-0">
|
||||
<validation-wrapper-component :validator="$v.parameters.endDate">
|
||||
<label class="all-caps">End Date</label>
|
||||
<date-picker-component :parameters="parameters" v-model.lazy="parameters.endDate"></date-picker-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-12 col-md-auto p-l-3 p-r-3 p-md-0">
|
||||
<div class="btn btn-lg btn-primary fs-11 w-100 h-100 d-flex justify-content-center align-items-center" @click="downloadReport()">
|
||||
<span>
|
||||
Export
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-l-0 m-r-0">
|
||||
<div class="col p-l-0 p-r-0">
|
||||
<validation-wrapper-component :validator="$v.parameters.startDate">
|
||||
<label class="all-caps">Start Date</label>
|
||||
<date-picker-component :parameters="parameters" v-model.lazy="parameters.startDate"></date-picker-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col p-l-0 p-r-0">
|
||||
<validation-wrapper-component :validator="$v.parameters.endDate">
|
||||
<label class="all-caps">End Date</label>
|
||||
<date-picker-component :parameters="parameters" v-model.lazy="parameters.endDate"></date-picker-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-auto p-l-0 p-r-0">
|
||||
<div class="btn btn-lg btn-primary fs-11 w-100 h-100 d-flex justify-content-center align-items-center" @click="downloadReport()">
|
||||
<span>
|
||||
Export
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -64,8 +60,11 @@ export default {
|
||||
var apiRoute = '';
|
||||
if(!this.validate()){ return; }
|
||||
switch(this.section) {
|
||||
case 'paymentsReportSection':
|
||||
apiRoute = route('paymentTransactions.export');
|
||||
case 'pendingPaymentSection':
|
||||
apiRoute = route('paymentTransactions.export', 'pendingPaymentSection');
|
||||
break;
|
||||
case 'paidInvoiceSection':
|
||||
apiRoute = route('paymentTransactions.export', 'paidInvoiceSection');
|
||||
break;
|
||||
case 'walletsReportSection':
|
||||
apiRoute = route('walletTransactions.export');
|
||||
|
||||
+5
-25
@@ -102,43 +102,23 @@
|
||||
<div class="col bg-master-lightest p-1 p-sm-4">
|
||||
<div class="row tabsContainer tabContent" tab-name="pendingInvoice">
|
||||
<div class="col">
|
||||
<list-component section="pendingInvoiceSection" :endpoint="route('api.packing_list.list')" :options="{does_not_have_transaction_type: 1, type: 2}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<admin-payments-billing-component :data="data" invoice_status="Pending Invoice" section="pendingInvoiceSection" ></admin-payments-billing-component>
|
||||
</template>
|
||||
</list-component>
|
||||
<admin-payments-billing-with-search-component :options="{does_not_have_transaction_type: 1, type: 2, per_page: 5}" section="pendingInvoiceSection" invoice_status="Pending Invoice"></admin-payments-billing-with-search-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="pendingApproval">
|
||||
<div class="col">
|
||||
<list-component section="pendingApprovalSection" :endpoint="route('api.packing_list.list')" :options="{has_invoice_status_in: [0, 1]}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<admin-payments-billing-component :data="data" invoice_status="Pending Approval" section="pendingApprovalSection" ></admin-payments-billing-component>
|
||||
</template>
|
||||
</list-component>
|
||||
<admin-payments-billing-with-search-component :options="{has_invoice_status_in: [0, 1], per_page: 5}" section="pendingApprovalSection" invoice_status="Pending Approval"></admin-payments-billing-with-search-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="pendingPayment">
|
||||
<div class="col">
|
||||
<list-component section="pendingPaymentSection" :endpoint="route('api.packing_list.list')" :options="{has_invoice_status_in: [2]}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<admin-payments-billing-component :data="data" invoice_status="Pending Payment" section="pendingPaymentSection" ></admin-payments-billing-component>
|
||||
</template>
|
||||
</list-component>
|
||||
<payment-filter-component :endpoint="route('api.packing_list.list')" :data="data"></payment-filter-component>
|
||||
<admin-payments-billing-with-search-component :options="{has_invoice_status_in: [2], packing_list_ordered_by_invoice_date: true, per_page: 5}" section="pendingPaymentSection" invoice_status="Pending Payment" :with_export="true"></admin-payments-billing-with-search-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="paidInvoice">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6 no-padding">
|
||||
<download-billing-with-dates-component section="paymentsReportSection" ></download-billing-with-dates-component>
|
||||
</div>
|
||||
</div>
|
||||
<list-component section="paidInvoiceSection" :endpoint="route('api.packing_list.list')" :options="{has_invoice_status_in: [3]}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<admin-payments-billing-component :data="data" invoice_status="Paid Invoice" section="paidInvoiceSection" ></admin-payments-billing-component>
|
||||
</template>
|
||||
</list-component>
|
||||
<admin-payments-billing-with-search-component :options="{has_invoice_status_in: [3], per_page: 5}" section="paidInvoiceSection" invoice_status="Paid Invoice" :with_export="true"></admin-payments-billing-with-search-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="row" @keyup.enter="fetchReport">
|
||||
<div class="col">
|
||||
<div class="row m-b-15">
|
||||
<div class="col-8 p-r-0">
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<div class="form-group no-margin form-group-default b-rad-none">
|
||||
<label class="text-primary">Email</label>
|
||||
<input type="text" class="form-control" v-model="email" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-0">
|
||||
<div class="btn btn-primary b-rad-none" @click="fetchReport()">
|
||||
<i class="fa fa-search lh-40"></i>
|
||||
</div>
|
||||
<div class="btn btn-secondary b-rad-none" @click="resetSearch()">
|
||||
<i class="fa fa-remove lh-40"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="search">
|
||||
<div class="col bg-white padding-25">
|
||||
<p v-if="!userCompany">{{ message }}</p>
|
||||
<loading-component v-if="isLoading"></loading-component>
|
||||
<user-company-component v-if="userCompany" :data="userCompany"></user-company-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
import LoadingComponent from "../../general/elements/LoadingComponent";
|
||||
export default {
|
||||
components: {LoadingComponent},
|
||||
data(){
|
||||
return {
|
||||
section: 'searchUserCompanyByEmailSection',
|
||||
isLoading: false,
|
||||
search: false,
|
||||
email: '',
|
||||
userCompany: null,
|
||||
message: 'Searching...'
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
marking: {},
|
||||
},
|
||||
methods: {
|
||||
fetchReport(){
|
||||
this.isLoading = true;
|
||||
this.search = true;
|
||||
this.userCompany = null;
|
||||
this.message = 'Searching...';
|
||||
this.submit(route('api.account.user.company', this.email), 'get', this.section, false, false);
|
||||
},
|
||||
successHandler(response){
|
||||
this.isLoading = false;
|
||||
this.report = response.payload.data;
|
||||
if(response.payload.data != undefined)
|
||||
this.userCompany = response.payload.data;
|
||||
else
|
||||
this.message = 'Customer not found';
|
||||
},
|
||||
errorHandler(response){
|
||||
this.isLoading = false;
|
||||
this.userCompany = null;
|
||||
this.message = 'Customer not found';
|
||||
},
|
||||
resetSearch() {
|
||||
this.userCompany = null;
|
||||
this.search = false;
|
||||
this.email = '';
|
||||
message: 'Searching...';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
+3
-3
@@ -17,9 +17,9 @@ export default {
|
||||
required: requiredIf(function () { return this.step === 2 }),
|
||||
numeric
|
||||
},
|
||||
wechat_id: {
|
||||
required: requiredIf(function () { return this.step === 2 }),
|
||||
},
|
||||
// wechat_id: {
|
||||
// required: requiredIf(function () { return this.step === 2 }),
|
||||
// },
|
||||
password: {
|
||||
required: requiredIf(function () { return this.step === 2 }),
|
||||
},
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
@extends('emails.layout.base')
|
||||
|
||||
@section('content')
|
||||
<h4 style="font-size: 1em;">Hello, {{ $user->name }}</h4>
|
||||
<p style="font-size: 0.9em">We wanted to send you an update on the recent shipment for you order no. <a href="{{ route('order.show', $packingList->owner->reference) }}">{{ $packingList->owner->reference }}</a> you have placed with us. We've just learned that your shipment has just departed from china's port and is estimated to arrive on {{ $packingList->containers()->first()->transports()->first()->schedules()->where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->first()->eta->format('d-m-Y') }}.</p>
|
||||
<p style="margin-top: 20px; font-size: 0.8em">Meanwhile, we would appreciate if you could make the payment as soon as possible so we can deliver your packages as soon as the shipment arrives. please <a href="{{ route('order.show', $packingList->owner->reference) }}">click here</a> to pay your invoice.</p>
|
||||
<div style="margin-top: 20px;"><small style="font-size: 0.7em">If you wish to ask any additional questions, kindly contact us at our live chat from your account's <a href="{{ route('dashboard') }}">dashboard</a>.</small></div>
|
||||
@endsection
|
||||
@@ -0,0 +1,12 @@
|
||||
@extends('emails.layout.base')
|
||||
|
||||
@section('content')
|
||||
@php
|
||||
$schedule = $packingList->containers()->first()->transports()->first()->schedules()->where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->first();
|
||||
@endphp
|
||||
<h4 style="font-size: 1em;">Hello, {{ $user->name }}</h4>
|
||||
<p style="font-size: 0.9em">Attached is the invoice concerning order no. {{$packingList->owner->reference}}. If the attached file isn't loading, please <a href="{{ route('order.show', $packingList->owner->reference) }}">click here</a> to access your invoice.</p>
|
||||
<p style="margin-top: 30px; font-size: 0.8em">We would like to also inform you that your packages have been loaded into the container and is estimated to depart on: <span style="color: green; font-weight: bold">{{$schedule->etd->format('d-m-Y')}}</span> and is estimated to arrive on <span style="color: green; font-weight: bold">{{$schedule->eta->format('d-m-Y')}}</span>.</p>
|
||||
<p style="margin-top: 15px; font-size: 0.8em">We appreciate you choosing us here at CIEF Worldwide to fulfill your shipping needs. We look forward to doing business with you again in the future.</p>
|
||||
<div style="margin-top: 20px;"><small style="font-size: 0.7em">If you wish to ask any additional questions, kindly contact us at our live chat from your account's <a href="{{ route('dashboard') }}">dashboard</a>.</small></div>
|
||||
@endsection
|
||||
@@ -0,0 +1,14 @@
|
||||
@extends('emails.layout.base')
|
||||
|
||||
@section('content')
|
||||
<h4 style="font-size: 1em;">Hello, {{ $user->name }}</h4>
|
||||
<p style="font-size: 0.9em">We wanted to send you an update on the recent shipment for you order no. <a href="{{ route('order.show', $packingList->owner->reference) }}">{{ $packingList->owner->reference }}</a> you have placed with us. We've just learned that there has been a shipping delay from the shipping liner, and as a result your packages will arrive a few days later the estimated date we gave you when we shipped your order. The new estimated date for arrival will be {{ $packingList->containers()->first()->transports()->first()->schedules()->where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->first()->eta->format('d-m-Y') }}.</p>
|
||||
<p style="margin-top: 30px; font-size: 0.8em">We're very sorry that you are experiencing this delay. and we wanted to let you know as soon as we learned about it. We are working directly with the shipping liner to minimize the impact, but we don't want you to worry your order is still on its way!</p>
|
||||
<p style="margin-top: 20px; font-size: 0.8em">Recently shipping liner facing very frequent delay, it's better to estimate longer ETA while purchase to avoid any inconvenience causes.</p>
|
||||
@if($packingList->transactions()->whereHas('transactions', function ($query){
|
||||
return $query->where('type', \App\Classes\ValueObjects\Constants\TransactionType::SHIPPING_INVOICE)->where('status', '=', 2);
|
||||
})->get())
|
||||
<p style="margin-top: 20px; font-size: 0.8em">Meanwhile, we would appreciate if you could make the payment as soon as possible so we can deliver your packages as soon as the shipment arrives. please <a href="{{ route('order.show', $packingList->owner->reference) }}">click here</a> to pay your invoice.</p>
|
||||
@endif
|
||||
<div style="margin-top: 20px;"><small style="font-size: 0.7em">If you wish to ask any additional questions, kindly contact us at our live chat from your account's <a href="{{ route('dashboard') }}">dashboard</a>.</small></div>
|
||||
@endsection
|
||||
@@ -3,6 +3,7 @@
|
||||
<div class="row" :class="[{'d-flex': $store.getters.isAdmin}]" v-if="$store.getters.isAdmin">
|
||||
<div class="col">
|
||||
<customer-activity-report-section-component></customer-activity-report-section-component>
|
||||
<search-customer-by-email-component></search-customer-by-email-component>
|
||||
<div class="row" v-show="!$store.getters.isShowing('customerActivityReportSection')">
|
||||
<div class="col">
|
||||
<customer-report-section-component></customer-report-section-component>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<h6>Unclaimed Packing Lists</h6>
|
||||
</div>
|
||||
</div>
|
||||
<list-component section="unclaimedPackingListSection" :endpoint="route('api.packing_list.list')" :options="{claimant_id: 2037, owner_id: 1}">
|
||||
<list-component section="unclaimedPackingListSection" :endpoint="route('api.packing_list.list')" :options="{claimant_id: 2307, owner_id: 1}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<unclaimed-packinglist-component :data="data"></unclaimed-packinglist-component>
|
||||
</template>
|
||||
@@ -62,4 +62,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,49 +1,52 @@
|
||||
@extends('layouts.base_portal')
|
||||
@section('inner_content')
|
||||
|
||||
<div class="row m-b-15" v-if="false" v-show="!$store.getters.isShowing('createContainerFormSection')">
|
||||
<div class="row" :class="[{'d-flex': $store.getters.isAdmin}]" v-if="$store.getters.isAdmin">
|
||||
<div class="col">
|
||||
<div data-type="createContainer" class="btn btn-sm btn-primary all-caps b-rad-none pointer m-l-5 rounded btn-lg" @click="$store.dispatch('toggleSection', {name: 'createContainerFormSection', status: true})"><i class="fa fa-plus m-r-10"></i>Add Container</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15" v-if="false" v-show="!$store.getters.isShowing('createContainerFormSection')">
|
||||
<div class="col">
|
||||
<div data-type="createContainer" class="btn btn-sm btn-primary all-caps b-rad-none pointer m-l-5 rounded btn-lg" @click="$store.dispatch('toggleSection', {name: 'createContainerFormSection', status: true})"><i class="fa fa-plus m-r-10"></i>Add Container</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<container-search-component section="containerListSection"></container-search-component>
|
||||
<create-load-container-form-component section="containerListSection" v-show="$store.getters.isShowing('createContainerFormSection')"></create-load-container-form-component>
|
||||
<div class="row tabsContainer" v-show="!$store.getters.isShowing('createContainerFormSection') && !$store.getters.isShowing('searchContainerSection')">
|
||||
<div class="col no-padding">
|
||||
<div class="row m-l-0 m-r-0">
|
||||
<div class="col col-md-4 m-r-5">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton active" tab-name="active">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<img src="https://img.icons8.com/dotty/35/000000/cargo-ship.png"/>
|
||||
<container-search-component section="containerListSection"></container-search-component>
|
||||
<create-load-container-form-component section="containerListSection" v-show="$store.getters.isShowing('createContainerFormSection')"></create-load-container-form-component>
|
||||
<div class="row tabsContainer" v-show="!$store.getters.isShowing('createContainerFormSection') && !$store.getters.isShowing('searchContainerSection')">
|
||||
<div class="col no-padding">
|
||||
<div class="row m-l-0 m-r-0">
|
||||
<div class="col col-md-4 m-r-5">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton active" tab-name="active">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<img src="https://img.icons8.com/dotty/35/000000/cargo-ship.png"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="fs-12 m-t-5 all-caps">Active</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="fs-12 m-t-5 all-caps">Active</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col d-none d-md-inline m-l-5">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="arrived">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="35" height="35"
|
||||
viewBox="0 0 172 172"
|
||||
style=" fill:#000000;"><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g fill="#000000"><path d="M86.06719,12.9c-0.25976,-0.00731 -0.5187,0.03252 -0.76426,0.11758l-68.8,23.65c-0.86858,0.29776 -1.45225,1.11422 -1.45293,2.03242v12.9c-0.00043,0.68443 0.325,1.32819 0.8764,1.73365c0.5514,0.40547 1.2629,0.5242 1.91608,0.31977l1.50752,-0.47031v99.46689h19.35h10.75h36.55h2.15h34.4h12.9h17.2v-99.46689l1.50752,0.47031c0.65319,0.20444 1.36468,0.0857 1.91608,-0.31977c0.5514,-0.40547 0.87683,-1.04922 0.8764,-1.73365v-12.9c-0.00068,-0.9182 -0.58435,-1.73466 -1.45293,-2.03242l-68.8,-23.65c-0.20291,-0.07043 -0.41523,-0.11007 -0.62988,-0.11758zM86,17.32178l66.65,22.91094v8.44043l-7.95752,-2.48174c-0.27786,-0.09509 -0.57226,-0.13224 -0.86504,-0.10918l-0.21416,-0.22676l-0.74326,-0.13437l-1.72168,0.86504l-0.34014,1.89385l1.31436,1.41094l0.67607,0.11758c0.18673,0.12653 0.3922,0.22289 0.60889,0.28555l4.94248,1.54531v96.51064h-10.75v-86h-103.2v86h-10.75v-96.51484l4.94248,-1.54531c0.75045,-0.21514 1.32533,-0.82012 1.50193,-1.58056c0.1766,-0.76044 -0.07284,-1.55685 -0.65168,-2.08069c-0.57883,-0.52383 -1.39612,-0.69278 -2.13521,-0.44139l-7.95752,2.48594v-8.44043zM85.40791,28.13477l-1.72168,0.86084l-0.34014,1.89805l1.31855,1.40674l0.74326,0.13437l1.72588,-0.86504l0.33594,-1.89385l-1.31436,-1.40674zM93.61738,30.33096l-1.72168,0.86084l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13437l1.72168,-0.86504l0.34014,-1.89385l-1.31436,-1.40674zM77.20264,30.70049l-1.72588,0.86084l-0.33594,1.89805l1.31436,1.40674l0.74746,0.13438l1.72168,-0.86504l0.34014,-1.89385l-1.31856,-1.40674zM101.82686,32.89668l-1.72168,0.86084l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13437l1.72168,-0.86504l0.34014,-1.89385l-1.31436,-1.40674zM68.99316,33.26621l-1.72168,0.86084l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13438l1.72168,-0.86504l0.34014,-1.89385l-1.31855,-1.40674zM110.03633,35.4624l-1.72588,0.86084l-0.33594,1.89805l1.31436,1.40674l0.74746,0.13437l1.72168,-0.86504l0.34014,-1.89385l-1.31855,-1.40674zM60.78369,35.83193l-1.72168,0.86084l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13438l1.72168,-0.86504l0.34014,-1.89385l-1.31436,-1.41094zM118.2416,38.02812l-1.72168,0.86084l-0.34014,1.89805l1.31856,1.40674l0.74326,0.13437l1.72588,-0.86504l0.33594,-1.89385l-1.31436,-1.41094zM52.57422,38.39766l-1.72168,0.86084l-0.34014,1.89805l1.31855,1.40674l0.74326,0.13438l1.72168,-0.86504l0.34014,-1.89805l-1.31436,-1.40674zM126.45107,40.59385l-1.72168,0.86084l-0.34014,1.89805l1.31855,1.40674l0.74326,0.13438l1.72168,-0.86504l0.34014,-1.89805l-1.31436,-1.40674zM44.36895,40.95918l-1.72588,0.86504l-0.33594,1.89805l1.31436,1.40674l0.74746,0.13018l1.72168,-0.86084l0.34014,-1.89805l-1.31855,-1.40674zM134.66055,43.15537l-1.72168,0.86504l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13018l1.72168,-0.86084l0.34014,-1.89805l-1.31436,-1.40674zM36.15947,43.5249l-1.72168,0.86504l-0.34014,1.89385l1.31436,1.41094l0.74746,0.13018l1.72168,-0.86084l0.34014,-1.89805l-1.31856,-1.40674zM38.7,66.65h94.6v81.7h-10.75v-34.4h-17.2v-34.4h-38.7v2.15v32.25h-17.2v2.15v32.25h-10.75zM70.95,83.85h30.1v30.1h-12.9h-2.15h-15.05zM53.75,118.25h12.9h17.2v30.1h-30.1zM88.15,118.25h17.2h12.9v30.1h-30.1z"></path></g></g></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="fs-12 m-t-5 all-caps">Un-stuffed</div>
|
||||
<div class="col d-none d-md-inline m-l-5">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="arrived">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="35" height="35"
|
||||
viewBox="0 0 172 172"
|
||||
style=" fill:#000000;"><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g fill="#000000"><path d="M86.06719,12.9c-0.25976,-0.00731 -0.5187,0.03252 -0.76426,0.11758l-68.8,23.65c-0.86858,0.29776 -1.45225,1.11422 -1.45293,2.03242v12.9c-0.00043,0.68443 0.325,1.32819 0.8764,1.73365c0.5514,0.40547 1.2629,0.5242 1.91608,0.31977l1.50752,-0.47031v99.46689h19.35h10.75h36.55h2.15h34.4h12.9h17.2v-99.46689l1.50752,0.47031c0.65319,0.20444 1.36468,0.0857 1.91608,-0.31977c0.5514,-0.40547 0.87683,-1.04922 0.8764,-1.73365v-12.9c-0.00068,-0.9182 -0.58435,-1.73466 -1.45293,-2.03242l-68.8,-23.65c-0.20291,-0.07043 -0.41523,-0.11007 -0.62988,-0.11758zM86,17.32178l66.65,22.91094v8.44043l-7.95752,-2.48174c-0.27786,-0.09509 -0.57226,-0.13224 -0.86504,-0.10918l-0.21416,-0.22676l-0.74326,-0.13437l-1.72168,0.86504l-0.34014,1.89385l1.31436,1.41094l0.67607,0.11758c0.18673,0.12653 0.3922,0.22289 0.60889,0.28555l4.94248,1.54531v96.51064h-10.75v-86h-103.2v86h-10.75v-96.51484l4.94248,-1.54531c0.75045,-0.21514 1.32533,-0.82012 1.50193,-1.58056c0.1766,-0.76044 -0.07284,-1.55685 -0.65168,-2.08069c-0.57883,-0.52383 -1.39612,-0.69278 -2.13521,-0.44139l-7.95752,2.48594v-8.44043zM85.40791,28.13477l-1.72168,0.86084l-0.34014,1.89805l1.31855,1.40674l0.74326,0.13437l1.72588,-0.86504l0.33594,-1.89385l-1.31436,-1.40674zM93.61738,30.33096l-1.72168,0.86084l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13437l1.72168,-0.86504l0.34014,-1.89385l-1.31436,-1.40674zM77.20264,30.70049l-1.72588,0.86084l-0.33594,1.89805l1.31436,1.40674l0.74746,0.13438l1.72168,-0.86504l0.34014,-1.89385l-1.31856,-1.40674zM101.82686,32.89668l-1.72168,0.86084l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13437l1.72168,-0.86504l0.34014,-1.89385l-1.31436,-1.40674zM68.99316,33.26621l-1.72168,0.86084l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13438l1.72168,-0.86504l0.34014,-1.89385l-1.31855,-1.40674zM110.03633,35.4624l-1.72588,0.86084l-0.33594,1.89805l1.31436,1.40674l0.74746,0.13437l1.72168,-0.86504l0.34014,-1.89385l-1.31855,-1.40674zM60.78369,35.83193l-1.72168,0.86084l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13438l1.72168,-0.86504l0.34014,-1.89385l-1.31436,-1.41094zM118.2416,38.02812l-1.72168,0.86084l-0.34014,1.89805l1.31856,1.40674l0.74326,0.13437l1.72588,-0.86504l0.33594,-1.89385l-1.31436,-1.41094zM52.57422,38.39766l-1.72168,0.86084l-0.34014,1.89805l1.31855,1.40674l0.74326,0.13438l1.72168,-0.86504l0.34014,-1.89805l-1.31436,-1.40674zM126.45107,40.59385l-1.72168,0.86084l-0.34014,1.89805l1.31855,1.40674l0.74326,0.13438l1.72168,-0.86504l0.34014,-1.89805l-1.31436,-1.40674zM44.36895,40.95918l-1.72588,0.86504l-0.33594,1.89805l1.31436,1.40674l0.74746,0.13018l1.72168,-0.86084l0.34014,-1.89805l-1.31855,-1.40674zM134.66055,43.15537l-1.72168,0.86504l-0.34014,1.89805l1.31436,1.40674l0.74746,0.13018l1.72168,-0.86084l0.34014,-1.89805l-1.31436,-1.40674zM36.15947,43.5249l-1.72168,0.86504l-0.34014,1.89385l1.31436,1.41094l0.74746,0.13018l1.72168,-0.86084l0.34014,-1.89805l-1.31856,-1.40674zM38.7,66.65h94.6v81.7h-10.75v-34.4h-17.2v-34.4h-38.7v2.15v32.25h-17.2v2.15v32.25h-10.75zM70.95,83.85h30.1v30.1h-12.9h-2.15h-15.05zM53.75,118.25h12.9h17.2v30.1h-30.1zM88.15,118.25h17.2h12.9v30.1h-30.1z"></path></g></g></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="fs-12 m-t-5 all-caps">Un-stuffed</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -53,60 +56,60 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2 ml-auto d-none d-md-inline">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="complete">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<img src="https://img.icons8.com/dotty/35/000000/shipped.png"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="fs-12 m-t-5 all-caps">Delivered</div>
|
||||
<div class="col-2 ml-auto d-none d-md-inline">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" tab-name="complete">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<img src="https://img.icons8.com/dotty/35/000000/shipped.png"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="fs-12 m-t-5 all-caps">Delivered</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row no-margin">
|
||||
<div class="col bg-master-lightest p-1 p-sm-4">
|
||||
<div class="row tabsContainer tabContent" tab-name="active">
|
||||
<div class="col">
|
||||
<list-component section="activeContainerListSection" :endpoint="route('api.packing_list.container.list')" :options="{'per_page': 5, 'status_in': [1], order_by: {column: 'loading_date', DESC: true}}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<container-component section="activeContainerListSection" :data="data"></container-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="arrived">
|
||||
<div class="col">
|
||||
<list-component section="arrivedContainerListSection" :endpoint="route('api.packing_list.container.list')" :options="{'per_page': 5, 'status_in': [3], 'has_pending_delivery': true, order_by: {column: 'loading_date', DESC: true}}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<container-component section="arrivedContainerListSection" :data="data"></container-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="complete">
|
||||
<div class="col">
|
||||
<list-component section="completeContainerListSection" :endpoint="route('api.packing_list.container.list')" :options="{'per_page': 5, 'status_in': [3], 'has_pending_delivery': false, order_by: {column: 'loading_date', DESC: true}}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<container-component section="completeContainerListSection" :data="data"></container-component>
|
||||
</template>
|
||||
</list-component>
|
||||
<div class="row no-margin">
|
||||
<div class="col bg-master-lightest p-1 p-sm-4">
|
||||
<div class="row tabsContainer tabContent" tab-name="active">
|
||||
<div class="col">
|
||||
<list-component section="activeContainerListSection" :endpoint="route('api.packing_list.container.list')" :options="{'per_page': 5, 'status_in': [1], order_by: {column: 'loading_date', DESC: true}}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<container-component section="activeContainerListSection" :data="data"></container-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="arrived">
|
||||
<div class="col">
|
||||
<list-component section="arrivedContainerListSection" :endpoint="route('api.packing_list.container.list')" :options="{'per_page': 5, 'status_in': [3], 'has_pending_delivery': true, order_by: {column: 'loading_date', DESC: true}}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<container-component section="arrivedContainerListSection" :data="data"></container-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent hide" tab-name="complete">
|
||||
<div class="col">
|
||||
<list-component section="completeContainerListSection" :endpoint="route('api.packing_list.container.list')" :options="{'per_page': 5, 'status_in': [3], 'has_pending_delivery': false, order_by: {column: 'loading_date', DESC: true}}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<container-component section="completeContainerListSection" :data="data"></container-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@endsection
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
@extends('layouts.base_portal')
|
||||
@section('inner_content')
|
||||
<div class="row">
|
||||
<div class="col bg-white p-t-15 p-b-15">
|
||||
<div class="row no-margin">
|
||||
<div class="col-12">
|
||||
<form method="post" >
|
||||
@csrf
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input class="form-control" type="text" name="marking" placeholder="Marking" value="{{$marking}}">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input class="form-control" type="text" name="customer_email" placeholder="Email" value="{{$email}}">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input class="form-control" type="text" name="booking_reference" placeholder="Booking Reference" value="{{$bookingReference}}">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-complete" type="submit">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<main>
|
||||
@if($company)
|
||||
@php
|
||||
$employees = $company->employees;
|
||||
$primaryEmployee = $employees->first();
|
||||
$identification = $company->documents->whereIn('document_type', \App\Classes\ValueObjects\Constants\DocumentType::IDENTIFICATION_DOCUMENTS)->first()
|
||||
@endphp
|
||||
<section id="customer-account" class="m-b-50">
|
||||
<h3>Customer Account</h3>
|
||||
<p>Marking: <span><a href="{{route('customer.profile', $company->reference)}}" target="_blank">{{$company->reference}}</a></span></p>
|
||||
<p>Account Type: <span>{{$company->type === 1 ? 'Business' : 'Personal'}}</span></p>
|
||||
@if($company->type === 1)<p>Company's Name: <span>{{$company->name}}</span></p>@endif
|
||||
<p>Customer's Name: <span>{{$employees->pluck('name')->implode(', ')}}</span></p>
|
||||
<p>Email: <span>{{$employees->pluck('email')->implode(', ')}}</span></p>
|
||||
<p>Phone: <span>{{$company->contacts->pluck('phone')->implode(', ')}}</span></p>
|
||||
<p>Registration Date: <span>{{$company->created_at->format('d-m-Y')}}</span></p>
|
||||
</section>
|
||||
<section id="customer-verification" class="m-b-50">
|
||||
<h3>Customer Verification</h3>
|
||||
<p>Email Verification Status: <span>{{ $primaryEmployee->status === 2 ? 'Verified' : 'Pending Verification'}}</span></p>
|
||||
<p>Identification Verification Status: <span>{{$identification ? ($identification->status === 2 ? 'Verified' : 'Pending Verification') : 'Not Submitted'}}</span></p>
|
||||
</section>
|
||||
@if(!$booking)
|
||||
<section>
|
||||
<h3>Customer Bookings</h3>
|
||||
@php
|
||||
$bookings = $company->bookings()->whereIn('status', [2, 3])->get();
|
||||
@endphp
|
||||
<section>
|
||||
@foreach($bookings as $booking)
|
||||
@php
|
||||
$payments = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->get();
|
||||
$purchaseOrder = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->first();
|
||||
@endphp
|
||||
<section class="m-b-50">
|
||||
<h5 class="bold">Booking Reference: {{$booking->marking}}</h5>
|
||||
<p>Amount: <span>{{$booking->fix_amount.' '.$booking->fixedCurrency->short_code}}</span></p>
|
||||
<p>Status: <span>{{$booking->status === 3 ? 'Complete' : 'In Progress'}}</span></p>
|
||||
<p>Purchase Order Status: <span>{{$purchaseOrder ? ($purchaseOrder->status === 3 ? 'Approved' : ($purchaseOrder->status === 1 ? 'Pending Approval' : 'Incomplete Submission')) : 'Pending Submission'}}</span></p>
|
||||
@if($payments)<p class="m-t-35 bold">Payment History:</p>@endif
|
||||
@php $i = 1; @endphp
|
||||
@foreach($payments as $payment)
|
||||
@php
|
||||
$bill = $payment->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::BILL)->first();
|
||||
$transferProof = null;
|
||||
$status = 'Pending Submission';
|
||||
|
||||
if($payment->status === 1) {
|
||||
$status = 'Pending Approval';
|
||||
}
|
||||
|
||||
if($payment->status === 2) {
|
||||
$status = 'Pending Confirmation';
|
||||
}
|
||||
|
||||
if(in_array($payment->status, [4, 5])) {
|
||||
$status = 'Rejected/Failed Payment';
|
||||
}
|
||||
|
||||
if($bill) {
|
||||
if($bill->status === 1) {
|
||||
$status = 'Pending Transfer Proof';
|
||||
}
|
||||
|
||||
if(in_array($bill->status, [2, 3])) {
|
||||
$status = 'Transfer Complete';
|
||||
$transferProof = $bill->documents()->first();
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
<section class="m-b-35">
|
||||
<p>{{$i++}}.</p>
|
||||
<p>Amount: <span>{{$payment->original_amount.' '.$payment->original_currency->short_code}}</span></p>
|
||||
<p>Status: <span>{{$status}}</span></p>
|
||||
<p>Payment Date: <span>{{$payment->created_at->format('d-m-Y')}}</span></p>
|
||||
@if($bill)
|
||||
<p>Supplier: <span>{{$bill->issuerCompany->name}}</span></p>
|
||||
<p>Supplier Order Date: <span>{{$bill->created_at->format('d-m-Y')}}</span></p>
|
||||
@if($transferProof)<p>Transfer Proof Upload Date: <span>{{$transferProof->created_at->format('d-m-Y')}}</span></p>@endif
|
||||
@endif
|
||||
</section>
|
||||
@endforeach
|
||||
</section>
|
||||
@endforeach
|
||||
</section>
|
||||
</section>
|
||||
@endif
|
||||
@endif
|
||||
@if($booking)
|
||||
@php
|
||||
$payments = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->get();
|
||||
$purchaseOrder = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->first();
|
||||
@endphp
|
||||
<section>
|
||||
<h5 class="bold">Booking Reference: {{$booking->marking}}</h5>
|
||||
<p>Amount: <span>{{$booking->fix_amount.' '.$booking->fixedCurrency->short_code}}</span></p>
|
||||
<p>Status: <span>{{$booking->status === 3 ? 'Complete' : 'In Progress'}}</span></p>
|
||||
<p>Purchase Order Status: <span>{{$purchaseOrder ? ($purchaseOrder->status === 3 ? 'Approved' : ($purchaseOrder->status === 1 ? 'Pending Approval' : 'Incomplete Submission')) : 'Pending Submission'}}</span></p>
|
||||
@if($payments)<p class="m-t-35 bold">Payment History:</p>@endif
|
||||
@php $i = 1; @endphp
|
||||
@foreach($payments as $payment)
|
||||
@php
|
||||
$bill = $payment->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::BILL)->first();
|
||||
$transferProof = null;
|
||||
|
||||
$status = 'Pending Submission';
|
||||
|
||||
if($payment->status === 1) {
|
||||
$status = 'Pending Approval';
|
||||
}
|
||||
|
||||
if($payment->status === 2) {
|
||||
$status = 'Pending Confirmation';
|
||||
}
|
||||
|
||||
if(in_array($payment->status, [4, 5])) {
|
||||
$status = 'Rejected/Failed Payment';
|
||||
}
|
||||
|
||||
if($bill) {
|
||||
if($bill->status === 1) {
|
||||
$status = 'Pending Transfer Proof';
|
||||
}
|
||||
|
||||
if(in_array($bill->status, [2, 3])) {
|
||||
$status = 'Transfer Complete';
|
||||
$transferProof = $bill->documents()->first();
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
<section class="m-b-35">
|
||||
<p>{{$i++}}.</p>
|
||||
<p>Amount: <span>{{$payment->original_amount.' '.$payment->original_currency->short_code}}</span></p>
|
||||
<p>Status: <span>{{$status}}</span></p>
|
||||
<p>Payment Date: <span>{{$payment->created_at->format('d-m-Y')}}</span></p>
|
||||
@if($bill)
|
||||
<p>Supplier: <span>{{$bill->issuerCompany->name}}</span></p>
|
||||
<p>Supplier Order Date: <span>{{$bill->created_at->format('d-m-Y')}}</span></p>
|
||||
@if($transferProof)<p>Transfer Proof Upload Date: <span>{{$transferProof->created_at->format('d-m-Y')}}</span></p>@endif
|
||||
@endif
|
||||
</section>
|
||||
@endforeach
|
||||
</section>
|
||||
@endif
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,4 @@
|
||||
@extends('layouts.base_portal')
|
||||
@section('inner_content')
|
||||
<customer-payment-billing-section-component :company_module_id={{$company_module_id}}></customer-payment-billing-section-component>
|
||||
@endsection
|
||||
@@ -5,135 +5,9 @@
|
||||
<br><br>
|
||||
<div class="separator"><strong><i>{{ $invoice_transaction->bill_no }}</i></strong></div>
|
||||
</htmlpageheader>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="header-logo">
|
||||
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
|
||||
</td>
|
||||
<td class="header-cief-address">
|
||||
<span class="company-name">
|
||||
<strong>
|
||||
CIEF WORLDWIDE SDN BHD
|
||||
</strong>
|
||||
</span>
|
||||
<span class="company-reg">(1134596-M)</span><br>
|
||||
No. 72-3, Jalan Jalil 1,<br>
|
||||
The Earth Bukit Jalil,<br>
|
||||
57000 Kuala Lumpur<br>
|
||||
Tel: 03-8082 1252
|
||||
</td>
|
||||
<td class="header-details">
|
||||
<div class="title" style="font-size: 20px; text-transform: uppercase;">
|
||||
<strong>
|
||||
Invoice
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="number">Invoice No: {{ $invoice_transaction->bill_no }}</div>
|
||||
@include('pages.pdfs.shipping_invoice_inner', ['invoice_transaction' => $invoice_transaction])
|
||||
|
||||
@php
|
||||
$companyModule = $invoice_transaction->owner->owner->companyModule;
|
||||
@endphp
|
||||
|
||||
<div class="date">Date: {{ $invoice_transaction->created_at }}</div>
|
||||
<div class="ref">Order No: {{ $invoice_transaction->owner->owner->reference }}</div>
|
||||
<div class="ref">Container Ref: {{ $invoice_transaction->owner->containers()->first()->reference }}</div>
|
||||
{{--<div class="d-none">{{ $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference }}</div>--}}
|
||||
<div> </div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="bill-to">
|
||||
<span class="sub-title">
|
||||
Bill To
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="address">
|
||||
<div class="label">
|
||||
{{ $companyModule->name }}
|
||||
</div>
|
||||
<div class="address">
|
||||
@php
|
||||
$addresses = $companyModule->addresses()->where('status', '=', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->where('type', '=', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
@endphp
|
||||
{{ $addresses->street_one }}
|
||||
{{ $addresses->street_two }} ,
|
||||
{{ $addresses->district()->first()->name }},
|
||||
{{ $addresses->postcode }}
|
||||
{{ $addresses->state()->first()->name }},
|
||||
{{ $addresses->country()->first()->name }}
|
||||
</div>
|
||||
<div>
|
||||
@php
|
||||
$contact = $companyModule->contacts()->first();
|
||||
@endphp
|
||||
Phone: {{ $contact ? $contact->phone : '' }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="15%">Quantity</th>
|
||||
<th width="20%">Unit Price (RM)</th>
|
||||
<th width="20%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($invoice_transaction->transactionDetails as $key => $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td class="description">{!! $transaction_detail->name !!}</td>
|
||||
<td width="15%" class="center top" style="text-align: center">{{ round($transaction_detail->quantity, 3) }}</td>
|
||||
<td width="20%" class="center top" style="text-align: center">
|
||||
{{ round($transaction_detail->price, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ round($transaction_detail->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="subtotal">
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">
|
||||
{{ round($invoice_transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="3"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">
|
||||
{{ round($invoice_transaction->service_charge, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@if($invoice_transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="3"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($invoice_transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ round($invoice_transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td class="header-logo">
|
||||
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
|
||||
</td>
|
||||
<td class="header-cief-address">
|
||||
<span class="company-name">
|
||||
<strong>
|
||||
CIEF WORLDWIDE SDN BHD
|
||||
</strong>
|
||||
</span>
|
||||
<span class="company-reg">(1134596-M)</span><br>
|
||||
No. 72-3, Jalan Jalil 1,<br>
|
||||
The Earth Bukit Jalil,<br>
|
||||
57000 Kuala Lumpur<br>
|
||||
Tel: 03-8082 1252
|
||||
</td>
|
||||
<td class="header-details">
|
||||
<div class="title" style="font-size: 20px; text-transform: uppercase;">
|
||||
<strong>
|
||||
Invoice
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="number">Invoice No: {{ $invoice_transaction->bill_no }}</div>
|
||||
|
||||
@php
|
||||
$companyModule = $invoice_transaction->owner->owner->companyModule;
|
||||
@endphp
|
||||
|
||||
<div class="date">Date: {{ $invoice_transaction->created_at }}</div>
|
||||
<div class="ref">Order No: {{ $invoice_transaction->owner->owner->reference }}</div>
|
||||
<div class="ref">Container Ref: {{ $invoice_transaction->owner->containers()->first()->reference }}</div>
|
||||
{{--<div class="d-none">{{ $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference }}</div>--}}
|
||||
<div> </div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="bill-to">
|
||||
<span class="sub-title">
|
||||
Bill To
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="address">
|
||||
<div class="label">
|
||||
{{ $companyModule->name }}
|
||||
</div>
|
||||
<div class="address">
|
||||
@php
|
||||
$addresses = $companyModule->addresses()->where('status', '=', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->where('type', '=', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
@endphp
|
||||
{{ $addresses->street_one }}
|
||||
{{ $addresses->street_two }} ,
|
||||
{{ $addresses->district()->first()->name }},
|
||||
{{ $addresses->postcode }}
|
||||
{{ $addresses->state()->first()->name }},
|
||||
{{ $addresses->country()->first()->name }}
|
||||
</div>
|
||||
<div>
|
||||
@php
|
||||
$contact = $companyModule->contacts()->first();
|
||||
@endphp
|
||||
Phone: {{ $contact ? $contact->phone : '' }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="15%">Quantity</th>
|
||||
<th width="20%">Unit Price (RM)</th>
|
||||
<th width="20%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($invoice_transaction->transactionDetails as $key => $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td class="description">{!! $transaction_detail->name !!}</td>
|
||||
<td width="15%" class="center top" style="text-align: center">{{ round($transaction_detail->quantity, 3) }}</td>
|
||||
<td width="20%" class="center top" style="text-align: center">
|
||||
{{ round($transaction_detail->price, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ round($transaction_detail->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="subtotal">
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">
|
||||
{{ round($invoice_transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="3"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">
|
||||
{{ round($invoice_transaction->service_charge, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@if($invoice_transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="3"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($invoice_transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ round($invoice_transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -0,0 +1,143 @@
|
||||
@extends('layouts.base_pdf')
|
||||
@section('inner_content')
|
||||
@php
|
||||
$grandTotal = 0;
|
||||
$grandSubTotal = 0;
|
||||
@endphp
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td class="header-logo">
|
||||
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
|
||||
</td>
|
||||
<td class="header-cief-address">
|
||||
<span class="company-name">
|
||||
<strong>
|
||||
CIEF WORLDWIDE SDN BHD
|
||||
</strong>
|
||||
</span>
|
||||
<span class="company-reg">(1134596-M)</span><br>
|
||||
No. 72-3, Jalan Jalil 1,<br>
|
||||
The Earth Bukit Jalil,<br>
|
||||
57000 Kuala Lumpur<br>
|
||||
Tel: 03-8082 1252
|
||||
</td>
|
||||
<td class="header-details">
|
||||
<div class="title" style="font-size: 20px; text-transform: uppercase;">
|
||||
<strong>
|
||||
Summary
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
@php
|
||||
$companyModule = $invoice_transactions[0]->owner->owner->companyModule;
|
||||
@endphp
|
||||
|
||||
{{-- <div class="date">Date: {{ $invoice_transactions[0]->created_at }}</div> --}}
|
||||
<div class="date">Date: {{ \Carbon\Carbon::now() }}</div>
|
||||
<div> </div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="bill-to">
|
||||
<span class="sub-title">
|
||||
Bill To
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="address">
|
||||
<div class="label">
|
||||
{{ $companyModule->name }}
|
||||
</div>
|
||||
<div class="address">
|
||||
@php
|
||||
$addresses = $companyModule->addresses()->where('status', '=', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->where('type', '=', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
@endphp
|
||||
{{ $addresses->street_one }}
|
||||
{{ $addresses->street_two }} ,
|
||||
{{ $addresses->district()->first()->name }},
|
||||
{{ $addresses->postcode }}
|
||||
{{ $addresses->state()->first()->name }},
|
||||
{{ $addresses->country()->first()->name }}
|
||||
</div>
|
||||
<div>
|
||||
@php
|
||||
$contact = $companyModule->contacts()->first();
|
||||
@endphp
|
||||
Phone: {{ $contact ? $contact->phone : '' }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="description">Invoice No</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="15%">Quantity</th>
|
||||
<th width="20%">Unit Price (RM)</th>
|
||||
<th width="20%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($invoice_transactions as $key => $invoice_transaction)
|
||||
@foreach ($invoice_transaction->transactionDetails as $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td width="15%" class="center top">{{ $invoice_transaction->bill_no }}</td>
|
||||
<td class="description">{!! $transaction_detail->name !!}</td>
|
||||
<td width="15%" class="center top" style="text-align: center">{{ round($transaction_detail->quantity, 3) }}</td>
|
||||
<td width="15%" class="center top" style="text-align: center">
|
||||
{{ round($transaction_detail->price, 2) }}
|
||||
</td>
|
||||
<td width="15%" class="right top">
|
||||
{{ round($transaction_detail->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@php
|
||||
$grandSubTotal = $grandSubTotal + round($invoice_transaction->amount, 2);
|
||||
$grandTotal = $grandTotal + round($invoice_transaction->amount, 2);
|
||||
@endphp
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="subtotal">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">
|
||||
{{ round($grandSubTotal, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ round($grandTotal, 2) }}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
@foreach ($invoice_transactions as $transaction)
|
||||
<pagebreak />
|
||||
@include('pages.pdfs.shipping_invoice_inner', ['invoice_transaction' => $transaction])
|
||||
@endforeach
|
||||
|
||||
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
|
||||
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</htmlpagefooter>
|
||||
@endsection
|
||||
@@ -216,6 +216,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer hide tabContent" tab-name="debtor">
|
||||
<div class="col-12 col-md-6 p-r-0" v-if="$store.getters.isSuperAdmin || ([2251]).includes($store.getters.getUserId)" >
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<upload-debtor-excel-component section="uploadDebtorExcelSection"></upload-debtor-excel-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="$store.getters.isSuperAdmin">
|
||||
<div class="row tabsContainer hide tabContent" tab-name="team">
|
||||
<div class="col">
|
||||
@@ -427,15 +436,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabsContainer hide tabContent" tab-name="debtor">
|
||||
<div class="col-12 col-md-6 p-r-0" v-if="$store.getters.isSuperAdmin || ([2251]).includes($store.getters.getUserId)">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<upload-debtor-excel-component section="uploadDebtorExcelSection"></upload-debtor-excel-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Vendored
+2
-2
@@ -8,6 +8,6 @@
|
||||
</script>
|
||||
<script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="665dcd41-1edf-4451-8cb9-f1cf9ed35e15";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>
|
||||
<script src="{{ asset('js/vendor.js') }}" type="text/javascript"></script>
|
||||
<script src="{{mix('vue/app.js')}}"></script>
|
||||
<script src="@if (env('APP_ENV') === 'local') {{asset('vue/app.js')}} @else {{mix('vue/app.js')}} @endif"></script>
|
||||
<script src="{{ asset('js/site.js') }}" type="text/javascript"></script>
|
||||
{{--END VENDOR JS--}}
|
||||
{{--END VENDOR JS--}}
|
||||
|
||||
@@ -35,6 +35,7 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'valid.token', 'prefix' => 'user', 'as' => 'user.'], function () {
|
||||
Route::get('/{email}', 'FetchUserByEmailController@fetch')->name('company');
|
||||
Route::post('/show', 'FetchUserController@fetch')->name('show');
|
||||
Route::get('/list', 'ListUsersController@list')->name('list');
|
||||
Route::put('/update/{id}', 'UpdateUserController@update')->name('update');
|
||||
|
||||
@@ -8,6 +8,7 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
Route::post('/create', 'CreateCompanyController@create')->name('create');
|
||||
Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update');
|
||||
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
|
||||
Route::put('/name-and-debtor/update/{id}', 'UpdateCompanyNameAndDebtorController@update')->name('update.nameAndDebtor');
|
||||
|
||||
Route::post('/team/create', 'AddNewMemberController@create')->name('team.create');
|
||||
|
||||
|
||||
+429
-37
@@ -1,19 +1,51 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Jobs\FetchContainersStatusUpdateFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchDeliveryListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchLoadedContainersFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchOrdersFromYDPortalJob;
|
||||
use App\Classes\Jobs\FetchPackingListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryUpdatesFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchLoadedContainersFromVTPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListFromVTPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\Transactions\Processors\ApproveShippingInvoiceTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Document;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use App\Models\Container;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Models\Company;
|
||||
use App\Models\Booking;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -153,10 +185,16 @@ Route::get('/customer/{marking}/details', function ($marking) {
|
||||
return view('pages.customers.profile_details', ['id' => $id]);
|
||||
})->name('customer.profile.details');
|
||||
|
||||
Route::get('/orders/refresh', function(\Illuminate\Http\Request $request){
|
||||
$packingLists = \App\Models\PackingList::where('type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->has('containers')->get();
|
||||
Route::get('/customer/{marking}/payment-and-billing', function ($marking) {
|
||||
$connection = CompanyConnection::where('invitee_reference', $marking)->first();
|
||||
$company_module_id = $connection->invitee->id;
|
||||
return view('pages.customers.paymentsBilling', ['company_module_id' => $company_module_id]);
|
||||
})->name('customer.payment-and-billing');
|
||||
|
||||
Route::get('/orders/refresh', function(Request $request){
|
||||
$packingLists = PackingList::where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->has('containers')->get();
|
||||
dd($packingLists);
|
||||
$packingLists->each(function (\App\Models\PackingList $packingList) {
|
||||
$packingLists->each(function (PackingList $packingList) {
|
||||
$packingList->containers()->detach();
|
||||
});
|
||||
FetchWarehouseReceiveListFromVTPortalJob::withChain([
|
||||
@@ -170,7 +208,7 @@ Route::get('/orders/refresh', function(\Illuminate\Http\Request $request){
|
||||
|
||||
Route::get('/containers/refresh', function(){
|
||||
|
||||
dd((App()->make(\App\Classes\Modules\PackingLists\Processors\FetchLoadedContainersFromVTPortalProcessor::class))->execute());
|
||||
dd((App()->make(FetchLoadedContainersFromVTPortalProcessor::class))->execute());
|
||||
// FetchLoadedContainersFromVTPortalJob::dispatch();
|
||||
// FetchContainersStatusUpdateFromVTPortalJob::dispatch();
|
||||
|
||||
@@ -191,9 +229,9 @@ Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download
|
||||
Route::get('/report/customclearance/{orderid}', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance');
|
||||
|
||||
Route::group(['prefix' => 'template', 'as' => 'template.'], function () {
|
||||
Route::get('/payments-and-billing', function () {
|
||||
Route::get('/payment-and-billing', function () {
|
||||
return view('pages.templates.paymentsBilling');
|
||||
})->name('payments-and-billing');
|
||||
})->name('payment-and-billing');
|
||||
|
||||
Route::get('/shipping-queue', function () {
|
||||
return view('pages.templates.shippingQueue');
|
||||
@@ -201,8 +239,8 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () {
|
||||
});
|
||||
|
||||
Route::get('/yiwu', function () {
|
||||
$orders = \App\Models\Order::whereHas('OrderRoles', function($query){
|
||||
return $query->where('role_id', \App\Classes\ValueObjects\Constants\OrderRoleTypes::ORIGIN_WAREHOUSE)->where('company_module_id', 2358);
|
||||
$orders = Order::whereHas('OrderRoles', function($query){
|
||||
return $query->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->where('company_module_id', 2358);
|
||||
})->get();
|
||||
|
||||
foreach ($orders as $order){
|
||||
@@ -212,10 +250,10 @@ Route::get('/yiwu', function () {
|
||||
});
|
||||
|
||||
Route::get('/guangzhou', function () {
|
||||
$orders = \App\Models\Order::whereHas('OrderRoles', function($query){
|
||||
return $query->where('role_id', \App\Classes\ValueObjects\Constants\OrderRoleTypes::ORIGIN_WAREHOUSE)->where('company_module_id', 3);
|
||||
$orders = Order::whereHas('OrderRoles', function($query){
|
||||
return $query->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->where('company_module_id', 3);
|
||||
})->whereHas('addresses', function($query){
|
||||
return $query->where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->whereIn('state_id', [5, 13, 14]);
|
||||
return $query->where('status', ApprovalStatus::APPROVED)->whereIn('state_id', [5, 13, 14]);
|
||||
})->get();
|
||||
|
||||
foreach ($orders as $order){
|
||||
@@ -225,7 +263,7 @@ Route::get('/guangzhou', function () {
|
||||
});
|
||||
|
||||
Route::get('/debug', function (){
|
||||
$orders = \App\Models\Order::all();
|
||||
$orders = Order::all();
|
||||
|
||||
$issues = [];
|
||||
foreach ($orders as $order){
|
||||
@@ -243,18 +281,39 @@ Route::get('/debug', function (){
|
||||
dd($issues);
|
||||
});
|
||||
|
||||
Route::get('/yd', function (\Illuminate\Http\Request $request){
|
||||
$start = $request->input('start_date') ? \Carbon\Carbon::parse($request->input('start_date')): null;
|
||||
$end = $request->input('end_date') ? \Carbon\Carbon::parse($request->input('end_date')): null;
|
||||
(App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute($start, $end);
|
||||
(App()->make(FetchPackingListFromVTPortalProcessor::class))->execute();
|
||||
Route::group(['prefix' => 'yd', 'as' => 'yd.'], function () {
|
||||
Route::get('/packingLists', function (Request $request){
|
||||
$start = $request->input('start_date') ? Carbon::parse($request->input('start_date')): null;
|
||||
$end = $request->input('end_date') ? Carbon::parse($request->input('end_date')): null;
|
||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
|
||||
});
|
||||
|
||||
Route::get('/containers', function (){
|
||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
||||
});
|
||||
|
||||
Route::get('/deliveries', function (){
|
||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
||||
});
|
||||
|
||||
});
|
||||
Route::get('/yd', function (Request $request){
|
||||
// $start = $request->input('start_date') ? Carbon::parse($request->input('start_date')): null;
|
||||
// $end = $request->input('end_date') ? Carbon::parse($request->input('end_date')): null;
|
||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute($start, $end);
|
||||
// (App()->make(\App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
|
||||
// (App()->make(\App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor::class))->execute();
|
||||
// (App()->make(\App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
||||
// (App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
||||
// (App()->make(FetchPackingListFromVTPortalProcessor::class))->execute();
|
||||
})->name('yd.refresh');
|
||||
|
||||
Route::get('/container/{reference}/refresh/', function (string $reference){
|
||||
$container = Container::where('reference', $reference)->first();
|
||||
$supplier = in_array($container->owner_id, [3, 4]) ? 'VT' : 'YD';
|
||||
|
||||
$arrivalDates = \App\Models\PackingList::whereIn('reference', $container->packingLists->pluck('reference'))->where('type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->get()->map(function($packingList){
|
||||
$arrivalDates = PackingList::whereIn('reference', $container->packingLists->pluck('reference'))->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->get()->map(function($packingList){
|
||||
return $packingList->transports()->first()->drop_date;
|
||||
})->sortBy(function($date){
|
||||
return $date;
|
||||
@@ -264,7 +323,7 @@ Route::get('/container/{reference}/refresh/', function (string $reference){
|
||||
$endDate = $arrivalDates->last()->addDay()->format('d-m-Y');
|
||||
|
||||
if($supplier === 'VT'){
|
||||
return (App()->make(\App\Classes\Modules\PackingLists\Processors\FetchLoadedContainersFromVTPortalProcessor::class))->execute(\Carbon\Carbon::parse($endDate), \Carbon\Carbon::parse($endDate)->addDays(5));
|
||||
return (App()->make(FetchLoadedContainersFromVTPortalProcessor::class))->execute(Carbon::parse($endDate), Carbon::parse($endDate)->addDays(5));
|
||||
}
|
||||
|
||||
if($supplier === 'YD'){
|
||||
@@ -274,10 +333,10 @@ Route::get('/container/{reference}/refresh/', function (string $reference){
|
||||
})->name('container.refresh');
|
||||
|
||||
Route::get('/min_cbm', function (){
|
||||
$companies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orders', function ($query){
|
||||
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orders', function ($query){
|
||||
return $query->whereHas('packingLists')->whereDoesntHave('packingLists', function($query){
|
||||
return $query->whereHas('packages', function($query){
|
||||
return $query->selectRaw('sum((width/100) * (height/100) * (length/100) * quantity) as cbm')->where('type', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->where('status', '!=', 5)->having('cbm', '>', 0.3);
|
||||
return $query->selectRaw('sum((width/100) * (height/100) * (length/100) * quantity) as cbm')->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', '!=', 5)->having('cbm', '>', 0.3);
|
||||
});
|
||||
});
|
||||
})->limit(1)->get();
|
||||
@@ -305,6 +364,8 @@ Route::get('/export/on-hold-packing-list', 'Exports\ExportPendingArrangementPack
|
||||
Route::get('/export/arrived-parcel', 'Exports\ExportArrivedParcelController@export')->name('packing_list.arrived_parcel.export');
|
||||
Route::get('/export/parcel-summary', 'Exports\ExportArrivedParcelController@summary');
|
||||
Route::get('/export/parcel-postcode', 'Exports\ExportParcelPostcodesController@export');
|
||||
Route::get('/export/{year}/customer-total-order', 'Exports\ExportCustomersToExcelController@totalOrders');
|
||||
Route::get('/export/packing-list-warehouse/guangzhou2-to-johor', 'Exports\ExportArrivedParcelController@guangZhou2ToJohor');
|
||||
|
||||
Route::get('/settings', function () {
|
||||
return view('pages.settings');
|
||||
@@ -314,12 +375,17 @@ Route::get('/settings', function () {
|
||||
})->name('settings');
|
||||
|
||||
Route::get('/customer/{company_module_id}/summary', 'Exports\ExportCompanyModuleSummaryController@export')->name('customer.summary.export');
|
||||
Route::get('/export-customer-order/{marking}', 'Exports\ExportCompanyModuleSummaryController@exportorderSummaryByMarking')->name('customer.orderSummary.export');
|
||||
|
||||
Route::get('/customer/summary/monthly', function () {
|
||||
$containers = Container::whereMonth('loading_date', '>=', ((float)\Carbon\Carbon::now()->format('m') - 2))->whereYear('loading_date', (float)\Carbon\Carbon::now()->format('Y'))->get();
|
||||
// $containers = Container::whereMonth('loading_date', '>=', ((float)Carbon::now()->format('m') - 2))->whereYear('loading_date', (float)Carbon::now()->format('Y'))->get();
|
||||
$containers = Container::whereMonth('loading_date', '>=', 9)->whereYear('loading_date', 2022)->get();
|
||||
$marking = '769SMC';
|
||||
$connection = CompanyConnection::where('invitee_reference', $marking)->first();
|
||||
$companyModuleId = $connection->invitee->id;
|
||||
foreach ($containers as $container){
|
||||
$packingLists = $container->packingLists()->get()->filter(function ($packingList) {
|
||||
return $packingList->owner->company_module_id === 248;
|
||||
$packingLists = $container->packingLists()->get()->filter(function ($packingList) use ($companyModuleId){
|
||||
return $packingList->owner->company_module_id === $companyModuleId;
|
||||
});
|
||||
|
||||
if (!count($packingLists)) continue;
|
||||
@@ -344,7 +410,7 @@ Route::get('/customer/summary/monthly', function () {
|
||||
foreach ($packages as $package){
|
||||
echo '<tr>
|
||||
<td>'.$container->loading_date->format('d-m-Y').'</td>
|
||||
<td>MS/CIEF/769SMC/'.$packingList->owner->reference.'</td>
|
||||
<td>MS/CIEF/769SMC/'.$packingList->owner->owner->reference.'</td>
|
||||
<td>'.$container->reference.'</td>
|
||||
<td>'.$package->description.'</td>
|
||||
<td>'.$package->quantity.'</td>
|
||||
@@ -363,19 +429,19 @@ Route::get('/customer/summary/monthly', function () {
|
||||
});
|
||||
|
||||
Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start=null, $inactive_end=null, $with_cbm = false) {
|
||||
$activeCompanies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
|
||||
return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('drop_date', '>=', \Carbon\Carbon::parse($inactive_start))->where('drop_date', '<=', \Carbon\Carbon::parse($inactive_end)->addDay());
|
||||
$activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay());
|
||||
});
|
||||
})->pluck('id');
|
||||
|
||||
$companies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
|
||||
return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||
return $query->whereDate('drop_date', '>=', \Carbon\Carbon::parse($active_start))->whereDate('drop_date', '<=', \Carbon\Carbon::parse($active_end)->addDay());
|
||||
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
|
||||
});
|
||||
})->whereNotIn('id', $activeCompanies)->get();
|
||||
|
||||
echo '<h4>List of customers active between <span style="color: green; font-weight: bold">'.\Carbon\Carbon::parse($active_start)->format('d/m/Y'). ' - '.\Carbon\Carbon::parse($active_end)->format('d/m/Y').'</span> & inactive between <span style="color: red; font-weight: bold">'.\Carbon\Carbon::parse($inactive_start)->format('d/m/Y'). ' - '.\Carbon\Carbon::parse($inactive_end)->format('d/m/Y').'</span></h4>';
|
||||
echo '<h4>List of customers active between <span style="color: green; font-weight: bold">'. Carbon::parse($active_start)->format('d/m/Y'). ' - '. Carbon::parse($active_end)->format('d/m/Y').'</span> & inactive between <span style="color: red; font-weight: bold">'. Carbon::parse($inactive_start)->format('d/m/Y'). ' - '. Carbon::parse($inactive_end)->format('d/m/Y').'</span></h4>';
|
||||
echo '<table>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
@@ -389,7 +455,7 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina
|
||||
$packingList = collect();
|
||||
$totalCbm = 0;
|
||||
if($with_cbm){
|
||||
$packingList = $company->orderPackingLists()->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get();
|
||||
$packingList = $company->orderPackingLists()->where('packing_lists.type', PackingListType::SHIPPING_PACKING_LIST)->get();
|
||||
$totalCbm = $packingList->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
})->sum(function($package){
|
||||
@@ -424,13 +490,13 @@ Route::get('billplz/bills/{bill_no}', function($bill_no){
|
||||
})->name('billplz.bill');
|
||||
|
||||
Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor')->name('newDebtor.export');
|
||||
Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export');
|
||||
Route::get('/export/payment-transactions/{section}/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export');
|
||||
|
||||
Route::get('/delayed_container/customers', function(){
|
||||
$containers = Container::whereHas('transports', function($query){
|
||||
return $query->whereHas('Schedules', function($query){
|
||||
return $query->where('etd', '>', \Carbon\Carbon::parse('15-10-2022'));
|
||||
});
|
||||
return $query->whereHas('Schedules', function($query){
|
||||
return $query->where('etd', '>', Carbon::parse('15-10-2022'));
|
||||
});
|
||||
})->get();
|
||||
|
||||
$orders = $containers->map(function($container){
|
||||
@@ -448,3 +514,329 @@ Route::get('/delayed_container/customers', function(){
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
Route::get('/container/billing/{month}/{year}', function($month, $year){
|
||||
$containers = Container::whereDate('loading_date', '>=', Carbon::parse('01-'.$month.'-'.$year))->whereDate('loading_date', '<', Carbon::parse('01-'.$month.'-'.$year)->addMonth())->get();
|
||||
|
||||
$totalBillable = 0;
|
||||
$billed = 0;
|
||||
$totalBilled = 0;
|
||||
$totalPaid = 0;
|
||||
|
||||
$basePrice = 315;
|
||||
$bigParcelDiscount = -15;
|
||||
|
||||
$yiwuCost = 15;
|
||||
|
||||
$discount = -20;
|
||||
$yiwuDiscount = -45;
|
||||
|
||||
$outstationStates = [8, 3, 16, 10];
|
||||
|
||||
|
||||
foreach($containers as $container) {
|
||||
$containerTotalBillable = 0;
|
||||
$containerBilled = 0;
|
||||
$containerTotalBilled = 0;
|
||||
$containerTotalPaid = 0;
|
||||
$containerCost = 0;
|
||||
|
||||
$packingLists = $container->packingLists;
|
||||
|
||||
$totalBillable += count($packingLists);
|
||||
$containerTotalBillable += count($packingLists);
|
||||
echo '<h3>'.$container->reference.' ('.$container->loading_date->format('d-m-Y').')</h3>';
|
||||
|
||||
foreach ($packingLists as $packingList) {
|
||||
$invoice = $packingList->transactions()
|
||||
->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->first();
|
||||
|
||||
|
||||
$warehouseList = PackingList::where('reference', $packingList->reference)->where('type', 1)->first();
|
||||
if($warehouseList){
|
||||
$packing_list_drop_date = $warehouseList->transports->first()->drop_date;
|
||||
} else {
|
||||
echo '<------------- can\'t find arrival date -------------->';
|
||||
}
|
||||
|
||||
$order = $packingList->owner;
|
||||
$address = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
|
||||
|
||||
$cbm = round($packingList->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
}), 2);
|
||||
|
||||
$over_weight_cbm = round($packingList->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
}), 2);
|
||||
$price = $basePrice;
|
||||
|
||||
if($warehouseId === 2358){
|
||||
$price += $yiwuCost;
|
||||
if($packing_list_drop_date >= Carbon::parse('19-9-2022')){
|
||||
$price += $yiwuDiscount;
|
||||
}
|
||||
} else {
|
||||
if($cbm >= 2 && in_array($address->state_id, [4, 15])){
|
||||
$price += $bigParcelDiscount;
|
||||
}
|
||||
if($packing_list_drop_date >= Carbon::parse('19-9-2022')){
|
||||
$price += $discount;
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array($address->state_id,$outstationStates)) {
|
||||
$price += 50;
|
||||
}
|
||||
|
||||
$cbm = max($cbm, 0.3);
|
||||
$cost = $price * ($cbm + $over_weight_cbm);
|
||||
|
||||
$containerCost += $cost;
|
||||
|
||||
if(in_array($address->state_id, [13, 14])) {
|
||||
echo 'East Malaysia - ';
|
||||
}
|
||||
echo 'estimated cost: [QTY: '.($cbm + $over_weight_cbm).' | Unit Price: '.$price.' | Total: '.$cost.']';
|
||||
echo '<br>';
|
||||
|
||||
if(!$invoice) {
|
||||
echo '<p style="color: red"><a href="'.route('order.show', $order->reference).'" target="_blank">'.$packingList->reference .'</a> Warning: no billing</p>';
|
||||
continue;
|
||||
}
|
||||
|
||||
$payments = $invoice->transactions()
|
||||
->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->get();
|
||||
|
||||
$billed += 1;
|
||||
$containerBilled += 1;
|
||||
|
||||
$totalBilled += $invoice->amount;
|
||||
$containerTotalBilled += $invoice->amount;
|
||||
|
||||
$totalPaid += $payments->sum('amount');
|
||||
$containerTotalPaid += $payments->sum('amount');
|
||||
|
||||
echo '<span style="color: '.(($invoice->amount - $payments->sum('amount')) < 0.01 ? 'green' : 'red').'"><p style="color: red"><a href="'.route('order.show', $order->reference).'" target="_blank">'.$packingList->reference .'</a> | Amount: '.$invoice->amount.' | Paid: '.$payments->sum('amount').' | Invoice Date: '.$invoice->created_at->format('d-m-Y'). (($invoice->amount - $payments->sum('amount')) < 0.01 ? '' : '('.$invoice->created_at->diffForHumans().')').'</span>';
|
||||
echo '<br><br>';
|
||||
|
||||
}
|
||||
|
||||
echo '<h4>Container Invoices: '.$containerBilled.'/'.$containerTotalBillable.'</h4>';
|
||||
echo '<h4>Billed Total: '.$containerTotalBilled.'</h4>';
|
||||
echo '<h4>Total Paid: '.$containerTotalPaid.'</h4>';
|
||||
echo '<h4>Outstanding: '.($totalBilled - $containerTotalPaid).'</h4>';
|
||||
echo '<h4>Estimated Cost: '.$containerCost.'</h4>';
|
||||
echo '<br><br><br>';
|
||||
}
|
||||
|
||||
echo '<h2>Total Invoices: '.$billed.'/'.$totalBillable.'</h2>';
|
||||
echo '<h2>Billed Total: '.$totalBilled.'</h2>';
|
||||
echo '<h2>Total Paid: '.$totalPaid.'</h2>';
|
||||
echo '<h2>Outstanding: '.($totalBilled - $totalPaid).'</h2>';
|
||||
|
||||
});
|
||||
|
||||
Route::get('/yd/fix', function(){
|
||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED)->where('claimant_id', 2307)->get();
|
||||
$i = 0;
|
||||
echo count($packingLists).'<br><br>';
|
||||
foreach ($packingLists as $packingList){
|
||||
try {
|
||||
(App()->make(UpdateDoFromYDPortalProcessor::class))->execute($packingList);
|
||||
echo 'success'.'<br>';
|
||||
} catch (Exception $exception){
|
||||
echo '<span style="color:red;">'.$packingList->reference.'</span>';
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Route::get('/billplz/fix', function(){
|
||||
$payments = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->get();
|
||||
echo '<h3>fixed orders</h3>';
|
||||
foreach ($payments as $payment){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$payment->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
$invoice = $payment->owner;
|
||||
if(!$invoice){
|
||||
continue;
|
||||
}
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
$orderNumber = $order->reference;
|
||||
if(!$data['paid'] && $payment->status === ApprovalStatus::APPROVED) {
|
||||
echo '<br><span style="color: red">Fraude: <a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a></span><br>';
|
||||
continue;
|
||||
}
|
||||
|
||||
if($data['paid']){
|
||||
if($payment->status !== ApprovalStatus::APPROVED){
|
||||
echo '<a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a><br>';
|
||||
}
|
||||
$payment->status = ApprovalStatus::APPROVED;
|
||||
$payment->save();
|
||||
|
||||
$invoice->status = ApprovalStatus::COMPLETED;
|
||||
$invoice->save();
|
||||
|
||||
$packingList = $payment->owner->owner;
|
||||
if(app()->environment('production')){
|
||||
try {
|
||||
(App()->make(UpdateDoFromVTPortalProcessor::class))->execute($packingList);
|
||||
(App()->make(UpdateDoFromYDPortalProcessor::class))->execute($packingList);
|
||||
} catch (Exception $exception){
|
||||
echo '<br><span style="color: red">Malformed Address: <a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a></span><br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo "billplz error";
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Route::get('/invoices/fix/{company_module_id}', function($company_module_id) {
|
||||
|
||||
$orders = Order::whereIn('company_module_id', json_decode($company_module_id))->get();
|
||||
|
||||
foreach ($orders as $order){
|
||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
|
||||
foreach ($invoices as $invoice){
|
||||
|
||||
$invoice->documents()->delete();
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = (App()->make(CreatesDocument::class))->execute($invoice, $document_object);
|
||||
|
||||
(App()->make(CreatesFiles::class))->execute($document, $document_object);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Route::get('/invoices/combine/{ids}', function($ids){
|
||||
|
||||
$ids = json_decode($ids);
|
||||
|
||||
$transactions = Transaction::whereIn('id', $ids)->get();
|
||||
|
||||
$pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoices_combined', ['invoice_transactions' => $transactions]);
|
||||
return $pdf->download('combined_invoice_.pdf');
|
||||
})->name('invoice.combined_summary');
|
||||
|
||||
Route::get('/generate/invoices', function(){
|
||||
$packingLists = (App()->make(ListsPackingLists::class))->execute(['does_not_have_transaction_type' => 1, 'type' => 2]);
|
||||
foreach ($packingLists as $packingList){
|
||||
$order = $packingList->owner;
|
||||
if(!($order instanceof Order)) {
|
||||
echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
continue;
|
||||
}
|
||||
|
||||
$companyModule = $order->companyModule;
|
||||
$billingAddress = $companyModule->addresses()->where('type', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
$deliveryAddress = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
$postCodes = \App\Models\SegmentConstant::whereIn('reference', ['CENTER_POSTCODE', 'OUTSTATION_POSTCODE'])->get()->pluck('value')->flatten();
|
||||
|
||||
if(!!$billingAddress && in_array($deliveryAddress->postcode, $postCodes->toArray())){
|
||||
try {
|
||||
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($packingList);
|
||||
echo '<span style="color: green;">Invoice Generated...</span><br>';
|
||||
|
||||
} catch (Exception $exception){
|
||||
echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
}
|
||||
}
|
||||
echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
}
|
||||
})->name('generate.invoices');
|
||||
|
||||
Route::get('/invoices/approve', function(Request $request){
|
||||
// whereDoesntHave
|
||||
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
if(in_array($order->reference, json_decode($request->input('exclude')))){
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
(App()->make(ApproveShippingInvoiceTransactionProcessor::class))->execute($packingList);
|
||||
echo '<span style="color: green;">Invoice Approved...</span><br>';
|
||||
|
||||
} catch (Exception $exception){
|
||||
echo '<span style="color: red;">failed to approve...</span><br>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})->name('invoices.approve');
|
||||
|
||||
Route::get('/support', function () {
|
||||
return view('pages.customer_support', [
|
||||
'marking' => null,
|
||||
'email' => null,
|
||||
'bookingReference' => null,
|
||||
'company' => null,
|
||||
'booking' => null
|
||||
]);
|
||||
})->name('support');
|
||||
|
||||
Route::post('/support', function (Request $request) {
|
||||
|
||||
$marking = $request->input('marking');
|
||||
$email = $request->input('customer_email');
|
||||
$bookingReference = $request->input('booking_reference');
|
||||
|
||||
$company = null;
|
||||
$booking = null;
|
||||
|
||||
if($email) {
|
||||
$company = Company::whereHas('Employees', function($user) use($email) {
|
||||
return $user->where('email', $email);
|
||||
})->first();
|
||||
}
|
||||
|
||||
if($marking) {
|
||||
$company = Company::where('reference', $marking)->first();
|
||||
}
|
||||
|
||||
if($bookingReference) {
|
||||
$booking = Booking::where('marking', $bookingReference)->first();
|
||||
$company = $booking->company;
|
||||
}
|
||||
|
||||
return view('pages.customer_support', [
|
||||
'marking' => $marking,
|
||||
'email' => $email,
|
||||
'bookingReference' => $bookingReference,
|
||||
'company' => $company,
|
||||
'booking' => $booking,
|
||||
]);
|
||||
|
||||
})->name('support');
|
||||
Reference in New Issue
Block a user