mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
337 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 551fb7deaa | |||
| 2248e76bd4 | |||
| 4c023aa393 | |||
| 7922c10e2c | |||
| 742fdf307b | |||
| df993fe491 | |||
| 5f5707718f | |||
| d7d9a065fd | |||
| 568d45808a | |||
| 715051076c | |||
| 7642f6e9d3 | |||
| 84ad39ac11 | |||
| 03b44cf71d | |||
| 0b577c22f4 | |||
| cabb7b7d63 | |||
| 880d3fc8ce | |||
| 8d901505fe | |||
| 489216e7be | |||
| e413dfa795 | |||
| 4ff5c6df80 | |||
| 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 | |||
| a6446b88fd | |||
| be283dee78 | |||
| 2d58db7bd9 | |||
| 2b44254186 | |||
| e99cec81d7 | |||
| 5e810a1c16 | |||
| b5cba80db9 | |||
| 3479aed911 | |||
| f05e96725b | |||
| becb16c674 | |||
| 7e8163166b | |||
| ad21580c3e | |||
| 2f15268897 | |||
| ff4efdcd54 | |||
| fe400264c7 | |||
| cb0189e7d8 | |||
| f5070b2138 | |||
| 6a6497cac3 | |||
| dbf61d3a77 | |||
| 2f1164d606 | |||
| a472ec6684 | |||
| 10403943d0 | |||
| 5d49847f1f | |||
| f96321c854 | |||
| 2e6432f2e5 | |||
| f8c37f4dbc | |||
| 9deed272ad | |||
| 38e7f89293 | |||
| 724861270c | |||
| 88cf72eb75 | |||
| 5fcd11e84c | |||
| 13bd343198 | |||
| d6c5b45b44 | |||
| db0da02e27 | |||
| 6db2675e76 | |||
| 13271f311c | |||
| a2ac87b659 | |||
| 0b317ae1f7 | |||
| 5a0ef40e44 | |||
| 97273a30cb | |||
| c13145ad41 | |||
| 045b0b9878 | |||
| 39a9e45fc4 | |||
| 910fa13867 | |||
| 6f86702df0 | |||
| b79bcdbbb3 | |||
| 086b262fca | |||
| 8396e8dab3 | |||
| 96948c96b5 | |||
| d8386601c3 | |||
| bf2a6e7f23 | |||
| 235b04e395 | |||
| 5ea4044e3f | |||
| 66bbf9934c | |||
| 94a6f0758c | |||
| 04f43d8ea8 | |||
| 0808d86af9 | |||
| 714678fdc1 | |||
| c050444cdb | |||
| bc6c690b54 | |||
| 7cfa328ec0 | |||
| 45685bf2a4 | |||
| 534e02a20f | |||
| 26547328cb | |||
| f92ca756aa | |||
| 5514f3b8e0 | |||
| 14d80fd457 | |||
| c8d621057b | |||
| 6ecfa8e031 | |||
| 975e3d49e7 | |||
| 2bd30492c5 | |||
| c089b5f072 | |||
| fbaa1238cb | |||
| d1cf06d700 | |||
| ff159730e0 | |||
| e59934fa7b | |||
| 650d232ab0 | |||
| 71ae2437a4 | |||
| 17edf59b57 | |||
| 6268cdd21f | |||
| 2ea62bcfb9 | |||
| 1debc8e2d5 | |||
| fb849aa4cc | |||
| 913f6f84e2 | |||
| f28d0382b8 | |||
| 97a568322c | |||
| b01e2022dc | |||
| f7a1ba05f8 | |||
| a05a6381df | |||
| d7c0f7302d | |||
| 78a8451699 | |||
| 5964123c5f | |||
| 28e5fa43a5 | |||
| 4d39d7f43f | |||
| ee65ceac1d | |||
| ee1dfea0c8 | |||
| a90766ba13 | |||
| 6613ca9a86 | |||
| 2839f7855c | |||
| 9b70fdf37f | |||
| 4667d8fbc3 | |||
| 8b3e60a74a | |||
| 1f6c6bf87d | |||
| 8100ea0329 | |||
| 20d706caf8 | |||
| 3fe46f596a | |||
| c22e13f3cb | |||
| e39d364782 | |||
| 47fdac08aa | |||
| d824075e51 | |||
| af5de245ad | |||
| a58a5bd9a6 | |||
| 0493057805 | |||
| b6fc042d07 | |||
| 6bdcc007fc | |||
| 747402a5bc | |||
| c49d43f000 | |||
| 1e06e4db21 | |||
| 3b449fc812 | |||
| a1ea94fa73 | |||
| 79f6637b7b | |||
| dd684531c6 | |||
| 52e95b40ab | |||
| b6269ee369 | |||
| 144b5e7e13 | |||
| a84f44e9b0 | |||
| 32b90a3387 | |||
| 7faf5331e5 | |||
| 9783c76be3 | |||
| 3658991c43 | |||
| d2d82aabac | |||
| 6fe3023abc | |||
| e0356599bb | |||
| 37c3f95eda | |||
| 843b311c77 | |||
| 3fc7ccb51e | |||
| 9216c176f3 | |||
| 021c200d07 | |||
| a795a118a5 | |||
| 9833d07b04 | |||
| 7bf865ed3e | |||
| f7c8f68520 | |||
| 756e1b9419 | |||
| dd28171011 | |||
| 9f6fe2722c | |||
| 25928305ea | |||
| 499d1f9759 | |||
| 0e8c74bec2 | |||
| f774e90d50 | |||
| 6558ce20d9 | |||
| f16a843197 | |||
| 1ea081d831 | |||
| ce4e88fcdc | |||
| 6ca4f235df | |||
| 03843d8726 | |||
| 48b4381ba5 | |||
| 71d45fa100 | |||
| ebd42cfcbe | |||
| 9541f32641 | |||
| 5077e0e8d4 | |||
| c1c2c155be | |||
| c69dcf6ba3 | |||
| 10a95f0b4d | |||
| d8b41cbe55 | |||
| ad15b2f6b8 | |||
| 5a69a31628 | |||
| 65e0fe668d | |||
| 0cd2272e6c | |||
| 2f358c659b | |||
| 3bec5b9c86 | |||
| f499aaa0a7 | |||
| dfcb6064f8 | |||
| 968ff5c02a | |||
| 427bbb9de2 | |||
| dc4fabbf36 | |||
| e5e93e500e | |||
| 924f686381 | |||
| acb334f2c2 | |||
| 35611da094 | |||
| ba192563ba | |||
| 42525a4d32 | |||
| 7af7b28408 | |||
| b90fa86eae | |||
| ba7f9807a7 | |||
| daf5c65bd7 | |||
| 4280a9188c | |||
| 08398c481e | |||
| c8399cc336 | |||
| 84bef88f16 | |||
| 3e45f58b3b | |||
| 856302f480 | |||
| d00620564b | |||
| 68028d5cf3 | |||
| a2c7eddf7b | |||
| 9e756132ca | |||
| 1706e2e1a3 | |||
| e84e39b8a1 | |||
| 6ed383c06c | |||
| b52445f106 | |||
| e7f8b62116 | |||
| cd59debee4 | |||
| f7a2861072 | |||
| 845fdfd5ca | |||
| b984f931e1 | |||
| 2b1fca6b2e | |||
| 433d8e63b4 | |||
| 30bf744854 | |||
| 0bad26e8ff | |||
| c24ddb4fa2 | |||
| ff68ee76ab | |||
| 2a0501ad99 | |||
| 43491223ab | |||
| 436985db8f | |||
| 37887de61d | |||
| 374cc7748a | |||
| af15e462ba | |||
| db6412c5c0 | |||
| afc6595715 | |||
| e77e82bac2 | |||
| ce38d098fd | |||
| 4db4f6094d | |||
| 2a6a980fc3 |
@@ -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);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class DoesNotHaveTransactionType implements Filter
|
||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
||||
$query->where('type', $value);
|
||||
})->whereHas('containers', function ($query){
|
||||
return $query->whereDate('loading_date', '>=', Carbon::parse('08-08-2022'));
|
||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class IsPublished implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDate('starting_on', '<=', Carbon::now())
|
||||
->whereDate('ending_on', '>=', Carbon::now());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerIdNotIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereNotIn('owner_id', $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 PaymentReference implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('payment_reference', '=', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
namespace App\Classes\General;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class ExcelHandel
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function generateFolder($path = '')
|
||||
{
|
||||
$folder = \Storage::disk('public')->makeDirectory($path);
|
||||
return $folder;
|
||||
}
|
||||
|
||||
public static function insertExcel($path = '', $base64Set = [])
|
||||
{
|
||||
$file_info = [];
|
||||
$folder_path = ExcelHandel::generateFolder('excels/' . $path);
|
||||
|
||||
foreach ($base64Set as $key => $row) {
|
||||
|
||||
$exceldata = $row;
|
||||
$filename = (string) Str::uuid();
|
||||
|
||||
$f = finfo_open();
|
||||
$mime_type = finfo_file($f, $exceldata, FILEINFO_MIME_TYPE);
|
||||
|
||||
$extension = 'xls';
|
||||
|
||||
switch ($mime_type) {
|
||||
case 'application/vnd.ms-excel':
|
||||
$extension = 'xls';
|
||||
break;
|
||||
case 'application/zip':
|
||||
$extension = 'xlsx';
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($extension)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$exceldata = explode('base64,', $exceldata);
|
||||
$exceldata = base64_decode($exceldata[1]);
|
||||
|
||||
$filename_with_ext = $filename . '.' . $extension;
|
||||
|
||||
$file = ExcelHandel::generateExcel($path, $exceldata, $filename, $extension);
|
||||
|
||||
$file_info[] = [
|
||||
'path' => $path,
|
||||
'filename' => $filename_with_ext,
|
||||
'mime_type' => $mime_type,
|
||||
'extension' => $extension,
|
||||
'file_info' => empty($file) ? [] : $file,
|
||||
];
|
||||
}
|
||||
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
public static function generateExcel($path = '', $exceldata = '', $filename = '', $extension = '')
|
||||
{
|
||||
$file_info = [];
|
||||
$file = \Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata);
|
||||
$file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension);
|
||||
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
public static function removeExcel($excel_info = [])
|
||||
{
|
||||
$excel_info = json_decode(json_encode($excel_info), true);
|
||||
foreach ($excel_info as $key => $row) {
|
||||
if (!empty($row['path'])) {
|
||||
\File::delete([$row['file_info']['original']['file']]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Announcements\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
use DateTime;
|
||||
|
||||
class CreatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
@@ -18,9 +19,17 @@ class CreatesAnnouncement extends AbstractUpdateRecord
|
||||
$model = new Announcement();
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
// $model->starting_on = $object->getStartingOn();
|
||||
$model->starting_on = $this->convertDateFormat($object->getStartingOn());
|
||||
// $model->ending_on = $object->getEndingOn();
|
||||
$model->ending_on = $this->convertDateFormat($object->getEndingOn());
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
|
||||
public function convertDateFormat($value) {
|
||||
$value = DateTime::createFromFormat('d-m-Y', $value)->format('Y-m-d H:i:s');
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
@@ -21,6 +23,7 @@ use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -35,21 +38,27 @@ class CallbackBillplzLogic
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +67,8 @@ class CallbackBillplzLogic
|
||||
* @return bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws MalformedRequestException
|
||||
* @throws ResourceNotFoundException
|
||||
* @throws \App\Classes\Exceptions\InternalServerErrorException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
@@ -73,6 +84,12 @@ class CallbackBillplzLogic
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
|
||||
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
if($billPlz->state === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
@@ -84,8 +101,23 @@ class CallbackBillplzLogic
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$marking = $transaction->owner()->first()->owner()->first();
|
||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $marking->reference, 'transaction' => $transaction, 'status' => $status]);
|
||||
if(($invoice->amount - $transaction->amount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference, 'transaction' => $transaction, 'status' => $status]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class CreatesBillplzBill
|
||||
try{
|
||||
// config('billplz.maybank')
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||
'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'),
|
||||
'collection_id' => config('billplz.collection_id'),
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'description' => $description,
|
||||
|
||||
@@ -28,7 +28,7 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->getExtension() === 'pdf' ? $this->data : (new imageManager())->make($this->data);
|
||||
return in_array($this->getExtension(), ['pdf', 'excel']) ? $this->data : (new imageManager())->make($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getDecodedData(): string
|
||||
{
|
||||
return $this->getExtension() === 'pdf' ?
|
||||
return in_array($this->getExtension(), ['pdf', 'excel']) ?
|
||||
base64_decode((explode('base64,', $this->getData()))[1]):
|
||||
$this->getData()->encode('data-url')->encoded;
|
||||
}
|
||||
@@ -78,9 +78,4 @@ class FileObject implements DataTransferObject
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ConvertsBase64ToFile
|
||||
foreach ($files as $file) {
|
||||
|
||||
$object = new FileObject($file);
|
||||
$object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object);
|
||||
in_array($object->getExtension(), ['pdf', 'excel']) ? $this->generatePDF($object) : $this->generateImage($object);
|
||||
|
||||
}
|
||||
|
||||
@@ -122,4 +122,4 @@ class ConvertsBase64ToFile
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Company;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ExportsNullDebtors implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Code',
|
||||
'DebtorControlAcc',
|
||||
'ControlAccount',
|
||||
'CompanyName',
|
||||
'Desc2',
|
||||
'DebtorType',
|
||||
'DisplayTerm',
|
||||
'CurrencyCode',
|
||||
'RegisterNo',
|
||||
'Address1',
|
||||
'Address2',
|
||||
'Address3',
|
||||
'PostCode',
|
||||
'DeliverAddr1',
|
||||
'DeliverAddr2',
|
||||
'DeliverAddr3',
|
||||
'DeliverPostCode',
|
||||
'EmailAddress',
|
||||
'Attention',
|
||||
'Phone1',
|
||||
'Phone2',
|
||||
'Fax1'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Company::where(function($query){
|
||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
||||
})->whereHas('companyModules', function($query){
|
||||
$query->where('type', BusinessType::IMPORTER);
|
||||
})->whereHas('parcels')->where('status', ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($company): array
|
||||
{
|
||||
$marking = $company->companyModules()->where('type', BusinessType::IMPORTER)->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
|
||||
return [
|
||||
'<<New>>',
|
||||
'300-0000',
|
||||
'300-0000',
|
||||
$company->name.' (Shipping)',
|
||||
$marking,
|
||||
'',
|
||||
'PIA',
|
||||
'MYR',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',//EmailAddress
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
''
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class ExportsOnHoldPackingList implements FromQuery, WithHeadings, WithHeadingRo
|
||||
|
||||
return [
|
||||
$container->reference,
|
||||
$ContainerTransport ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta : 'n/a',
|
||||
$ContainerTransport ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first() ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta : 'n/a' : 'n/a',
|
||||
$ContainerTransport ? $ContainerTransport->drop_date : 'n/a',
|
||||
$marking,
|
||||
$order->reference,
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\Modules\Exports\Sheets\ContainersSheet;
|
||||
use App\Classes\Modules\Exports\Sheets\PackingListsSheet;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;;
|
||||
|
||||
class ExportsParcel implements WithMultipleSheets
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function sheets(): array
|
||||
{
|
||||
$sheets = [];
|
||||
|
||||
$sheets[] = new ContainersSheet();
|
||||
$sheets[] = new PackingListsSheet();
|
||||
|
||||
return $sheets;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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\PackingList;
|
||||
use Carbon\Carbon;
|
||||
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 App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
|
||||
class ExportsParcelPostcodes implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Order Number',
|
||||
'Postcode'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->whereRaw('LENGTH(reference) > 8')->where('reference', 'not like', "%YW%")->where('owner_type', Order::class)->whereDate('created_at', '>=', Carbon::parse('20-09-2022'))->whereDoesntHave('containers');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $packingList
|
||||
* @return array
|
||||
*/
|
||||
public function map($packingList): array
|
||||
{
|
||||
|
||||
$address = $packingList->owner->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
return [
|
||||
$packingList->reference,
|
||||
$address->postcode
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Transaction;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'DebtorCode',
|
||||
'ShipInfo',
|
||||
'AccNo',
|
||||
'DetailDescription',
|
||||
'FurtherDescription',
|
||||
'ProjNo',
|
||||
'DeptNo',
|
||||
'Qty',
|
||||
'UnitPrice'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$start_date = $this->request->input('startDate', null);
|
||||
if ($start_date) {
|
||||
$start_date = Carbon::parse($this->request->input('startDate'))->format('Y-m-d');
|
||||
}
|
||||
|
||||
$end_date = $this->request->input('endDate', null);
|
||||
if ($end_date) {
|
||||
$end_date = Carbon::parse($this->request->input('endDate'))->format('Y-m-d');
|
||||
}
|
||||
|
||||
$query = Transaction::query();
|
||||
|
||||
$query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED]);
|
||||
|
||||
if($start_date && $end_date) {
|
||||
$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->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->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;
|
||||
}
|
||||
|
||||
public function map($transaction): array
|
||||
{
|
||||
$container = $transaction->owner->containers()->first();
|
||||
$order = $transaction->owner->owner;
|
||||
$company = $order->companyModule->company;
|
||||
$shippingTransactionDetails = $transaction->transactionDetails()->where('reference', 'SHIPPING_FEE')->first();
|
||||
|
||||
$furtherDescription = '';
|
||||
|
||||
foreach ($transaction->transactionDetails as $item){
|
||||
|
||||
if($item->reference === 'SHIPPING_FEE')
|
||||
$furtherDescription .= str_replace('X1 Freight Service Charge<br>', '', $item->name)."\n";
|
||||
elseif($item->reference === 'OVER_WEIGHT_CHARGES')
|
||||
$furtherDescription .= $item->name.' '.$item->quantity.' CBM'."\n";
|
||||
elseif($item->reference === 'MIN_CBM_CHARGES')
|
||||
$furtherDescription .= $item->name.' '.$item->quantity.' CBM'."\n";
|
||||
else
|
||||
$furtherDescription .= $item->name.' '.$item->quantity.' X '.$item->price."\n";
|
||||
}
|
||||
|
||||
return [
|
||||
'<<New>>',
|
||||
$transaction->created_at->format('m/d/Y H:m'),
|
||||
$company->debtor,
|
||||
$order->reference,
|
||||
'500-0000',
|
||||
'X1 Freight Service Charge',
|
||||
$furtherDescription,
|
||||
$container->reference,
|
||||
'CIEF',
|
||||
$shippingTransactionDetails->quantity,
|
||||
$shippingTransactionDetails->price
|
||||
];
|
||||
return [
|
||||
'<<New>>',
|
||||
$transaction->updated_at->format('m/d/Y H:m'),
|
||||
$company->debtor,
|
||||
$container->reference,
|
||||
'500-0000',
|
||||
'X1 Freight Service Charge',
|
||||
'FurtherDescription',
|
||||
$container->reference,
|
||||
'M3',
|
||||
'CIEF',
|
||||
$shippingTransactionDetails->quantity,
|
||||
$shippingTransactionDetails->price,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class ExportsPendingArrangementDeliveryList implements FromQuery, WithHeadings,
|
||||
public function query()
|
||||
{
|
||||
return PackingList::where('type', '=', 2)->whereHas('containers', function ($query){
|
||||
$query->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
$query->where('containers.status', ApprovalStatus::COMPLETED)->where('containers.created_at', '>', Carbon::now()->subMonths(3));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,15 +64,16 @@ class ExportsPendingArrangementDeliveryList implements FromQuery, WithHeadings,
|
||||
$originalPackingList = $packingList->owner instanceof PackingList ? $packingList->owner : $packingList;
|
||||
$transport = $originalPackingList->containers()->first()->transports()->first();
|
||||
$deliveryTransport = $originalPackingList->transports()->first();
|
||||
$schedule = $deliveryTransport ? $deliveryTransport->schedules()->first() : null;
|
||||
|
||||
return [
|
||||
$container->reference,
|
||||
$ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta,
|
||||
$ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first() ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta : '',
|
||||
$ContainerTransport->drop_date,
|
||||
$marking,
|
||||
$order->reference,
|
||||
$deliveryTransport ? (Carbon::parse($deliveryTransport->schedules()->first()->eta) < Carbon::now() ? 'Delivered' : 'Pending Delivery') : 'Pending Arrangement',
|
||||
$deliveryTransport ? $deliveryTransport->schedules()->first()->eta : ($transport ? Carbon::now()->diffInDays($transport->drop_date, false) . ' Days' : ''),
|
||||
$schedule ? (Carbon::parse($schedule->eta) < Carbon::now() ? 'Delivered' : 'Pending Delivery') : 'Pending Arrangement',
|
||||
$schedule ? $schedule->eta : ($transport ? Carbon::now()->diffInDays($transport->drop_date, false) . ' Days' : ''),
|
||||
$packingList->packages()->sum('quantity'),
|
||||
$address->state->name,
|
||||
$address->postcode,
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Omair Saleh
|
||||
* Date: 20/9/2022
|
||||
* Time: 12:20 AM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\Exports\Sheets;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Container;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
|
||||
|
||||
class ContainersSheet implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery, WithTitle
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Container No.',
|
||||
'Loaded Date',
|
||||
'ETD',
|
||||
'ETA',
|
||||
'Delay',
|
||||
'Unstuffing date',
|
||||
'Status',
|
||||
'CTN',
|
||||
'CBM'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Container::query();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $container
|
||||
* @return array
|
||||
*/
|
||||
public function map($container): array
|
||||
{
|
||||
|
||||
$transport = $container->transports()->first();
|
||||
$currentSchedule = $transport ? $transport->schedules()->where('status', '!=', ApprovalStatus::EXPIRED)->first() : null;
|
||||
$scheduleHistory = $transport ? $transport->schedules()->where('status', ApprovalStatus::EXPIRED)->get() : null;
|
||||
|
||||
$status = 'Loaded';
|
||||
|
||||
if($currentSchedule) {
|
||||
if(Carbon::parse($currentSchedule->etd) >= Carbon::today()){
|
||||
$status = 'Shipping';
|
||||
}
|
||||
|
||||
if(Carbon::parse($currentSchedule->eta) >= Carbon::today()){
|
||||
$status = 'Arrived?';
|
||||
}
|
||||
|
||||
if($transport->drop_date){
|
||||
$status = 'Pending deliveries';
|
||||
if(!$container->packinglists()->whereDoesntHave('transports')->get()){
|
||||
$status = 'Complete';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
$container->reference,
|
||||
$container->loading_date,
|
||||
$currentSchedule ? $currentSchedule->etd : null,
|
||||
$currentSchedule ? $currentSchedule->eta : null,
|
||||
$scheduleHistory ? count($scheduleHistory) : 0,
|
||||
$transport ? $transport->drop_date : null,
|
||||
$status,
|
||||
$container->packages()->sum('quantity'),
|
||||
$container->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity')),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Containers';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Omair Saleh
|
||||
* Date: 20/9/2022
|
||||
* Time: 12:20 AM
|
||||
*/
|
||||
|
||||
namespace App\Classes\Modules\Exports\Sheets;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
|
||||
|
||||
|
||||
class PackingListsSheet implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromCollection, WithTitle
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Arrival Date',
|
||||
'Marking',
|
||||
'Order No.',
|
||||
'Reference',
|
||||
'Quantity',
|
||||
'CBM',
|
||||
'Overweight',
|
||||
'Total CBM',
|
||||
'Container No.',
|
||||
'Delivery Date',
|
||||
'Warehouse',
|
||||
'Warehouse District',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$packingLists = PackingList::where('status', '=', 2)->whereIn('type', [PackingListType::WAREHOUSE_RECEIVE_LIST, PackingListType::SHIPPING_PACKING_LIST])->get();
|
||||
|
||||
return $packingLists->filter(function ($packingList) {
|
||||
|
||||
if($packingList->type === PackingListType::SHIPPING_PACKING_LIST){
|
||||
$warehouseArrival = PackingList::where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->where('reference', $packingList->reference)->get();
|
||||
return $warehouseArrival ? false : true;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $packingList
|
||||
* @return array
|
||||
*/
|
||||
public function map($packingList): array
|
||||
{
|
||||
|
||||
$warehouseArrivalList = $packingList;
|
||||
$shippingList = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->where('reference', $packingList->reference)->first();
|
||||
|
||||
if($packingList->type === PackingListType::SHIPPING_PACKING_LIST) {
|
||||
$warehouseArrivalList = null;
|
||||
$shippingList = $packingList;
|
||||
|
||||
}
|
||||
|
||||
$arrivalTransport = null;
|
||||
|
||||
if($warehouseArrivalList){
|
||||
$arrivalTransport = $warehouseArrivalList->transports()->first();
|
||||
}
|
||||
|
||||
$order = null;
|
||||
if($packingList->owner instanceof Order){
|
||||
$order = $packingList->owner;
|
||||
}
|
||||
|
||||
$cbm = $packingList->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
});
|
||||
|
||||
$overWeight = $packingList->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
});
|
||||
|
||||
$container = $shippingList ? $shippingList->container : null;
|
||||
|
||||
$delivery = $shippingList ? $shippingList->transport : null;
|
||||
|
||||
return [
|
||||
$arrivalTransport ? $arrivalTransport->drop_date : null,
|
||||
$order ? $order->reference : 'Unclaimed',
|
||||
$order ? $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : 'Unclaimed',
|
||||
$packingList->reference,
|
||||
$packingList->packages()->sum('quantity'),
|
||||
$cbm,
|
||||
$overWeight ? $overWeight : 0,
|
||||
$cbm + $overWeight,
|
||||
$container ? $container->reference : null,
|
||||
$delivery ? $delivery->drop_date : null,
|
||||
strlen($packingList->reference) > 8 ? 'YD' : 'VT',
|
||||
$order ? $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->name : null,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Packing Lists';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Imports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Models\Company;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithBatchInserts;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
|
||||
class ImportsDebtor implements ToModel, WithHeadingRow, WithBatchInserts, WithValidation
|
||||
{
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public function model($row = [])
|
||||
{
|
||||
try {
|
||||
preg_match_all('/([0-9]{3,4}[a-zA-Z]{3,4})/', $row['desc2'], $matches);
|
||||
|
||||
foreach ($matches[0] as $match){
|
||||
$reference = $match;
|
||||
$debtor = $row['code'];
|
||||
$company = Company::whereNull('debtor')->whereHas('companyModules', function($query) use ($reference) {
|
||||
$query->whereHas('connections', function($query) use ($reference) {
|
||||
$query->where('invitee_reference', $reference);
|
||||
});
|
||||
})->first();
|
||||
|
||||
if ($company) {
|
||||
$company->debtor = $debtor;
|
||||
$company->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $exception){
|
||||
dd($exception);
|
||||
}
|
||||
}
|
||||
|
||||
public function batchSize(): int
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
|
||||
@@ -54,6 +55,7 @@ class UpdateDoFromYDPortalProcessor
|
||||
$reference = $contact ? $contact->reference : null;
|
||||
$remark = $remark ? $remark->content : 'URGENT!!! PLEASE CALL BEFORE ONE DAY DELIVERY.';
|
||||
|
||||
if(!$phone || !$reference) throw new MalformedRequestException('Can\'t release this packing list because it doesn\'t have the person in charge contact information');
|
||||
$this->fetchesDataFRomYDPortal->clientRequest(
|
||||
'http://www.yd-wl.com/api/UpdateOrderAddress.ashx',
|
||||
'POST',
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\DeletesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\PackingList;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -59,11 +60,9 @@ class DeletePackingListLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canDeletePackingList->passes();
|
||||
|
||||
$warehouseList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
$packingList = $this->fetchesPackingList->execute(['reference' => $warehouseList->reference, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesPackingList->execute($warehouseList);
|
||||
$this->deletesPackingList->execute($packingList);
|
||||
PackingList::where('reference', $packingList->reference)->delete();
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
|
||||
+3
-3
@@ -162,8 +162,8 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
}
|
||||
|
||||
$eta = Carbon::parse($containerInfo[4]);
|
||||
$etd = Carbon::parse($eta)->subDays(5);
|
||||
$eta = Carbon::parse($containerInfo[4])->addDays(2);
|
||||
$etd = Carbon::parse($eta)->subDays(7);
|
||||
|
||||
$delayDate = $containerInfo[7];
|
||||
|
||||
@@ -183,7 +183,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
}
|
||||
|
||||
if($delayDate){
|
||||
$delayDate = Carbon::parse($delayDate);
|
||||
$delayDate = Carbon::parse($delayDate)->addDays(2);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport->schedules()->where('eta', '=', $delayDate)->first()) {
|
||||
|
||||
+28
-14
@@ -2,6 +2,7 @@
|
||||
|
||||
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;
|
||||
@@ -23,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,7 +140,7 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
try {
|
||||
$start = $start ? $start : Carbon::today()->subMonths(1);
|
||||
$start = $start ? $start : Carbon::today()->subDays(30);
|
||||
|
||||
$startLimit = Carbon::parse('01-12-2021');
|
||||
|
||||
@@ -184,7 +187,7 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
||||
$eta = Carbon::parse($tracking[2]);
|
||||
$eta = Carbon::parse($tracking[2])->addDays(2);
|
||||
}
|
||||
|
||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
||||
@@ -227,24 +230,28 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if (Str::contains($trackingRow->tracking, ['派送中', '签收完成', ' 第三方提货', '货物已派送完成'])) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
||||
$deliveryDate = $trackingDate;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::debug('failed to fetch delivery tracking');
|
||||
}
|
||||
|
||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||
@@ -351,7 +358,7 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
|
||||
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'])){
|
||||
if(!in_array($marking, ['1290CSW', '8997ITB', '3992WHE', '962LOW', '1152AAT'])){
|
||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
||||
'expressno' => $row->expressno
|
||||
]);
|
||||
@@ -393,13 +400,20 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-2
@@ -116,7 +116,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
|
||||
try {
|
||||
|
||||
$start = $start ? $start : Carbon::today()->subDays(5);
|
||||
$start = $start ? $start : Carbon::today()->subDays(10);
|
||||
|
||||
$startLimit = Carbon::parse('11-08-2021');
|
||||
|
||||
@@ -133,15 +133,19 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
$response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest);
|
||||
|
||||
foreach ($response->Rows as $parcel){
|
||||
|
||||
$allow_contract = true;
|
||||
$marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $parcel[11]));
|
||||
$orderNumber = $marking[array_key_last($marking)];
|
||||
|
||||
$quantity = $parcel[16];
|
||||
|
||||
if(!$quantity){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$parcel[23] || !$parcel[22] || !$parcel[21]) continue;
|
||||
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
@@ -152,7 +156,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
}
|
||||
|
||||
$packingListReference = $parcel[0];
|
||||
// $measurement = round(($parcel[10]/$quantity) ** (1/3) * 100, 2);
|
||||
// $measurement = round(($parcel[26]/$quantity) ** (1/3) * 100, 2);
|
||||
$description = $parcel[13];
|
||||
$tracking = $parcel[37];
|
||||
$receiveDate = $parcel[1];
|
||||
|
||||
@@ -102,7 +102,7 @@ class UpdateConstantLogic extends AbstractControllerLogic
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]);
|
||||
|
||||
$constantValue = $this->updatesConstantValue->execute($constant->value, $request->input('id'), $request->input('value'));
|
||||
$constantValue = $this->updatesConstantValue->execute($constant->value, $request->input('id'), $request->input('rate'));
|
||||
|
||||
$object = new ConstantObject($request->input('reference'), $constantValue);
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Segment Constant',
|
||||
'message' => 'You have successfully updated the Segment Constant'
|
||||
'title' => 'Updated Postcode Constant',
|
||||
'message' => 'You have successfully updated the Postcode Constant'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ class UpdateSegmentLogic extends AbstractControllerLogic
|
||||
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
$segment_object = new SegmentObject(
|
||||
$request->input('name', $segment_query->name)
|
||||
$request->input('name'),
|
||||
$segment_query->company_module_id
|
||||
);
|
||||
$this->canUpdateSegment->passes($segment_object);
|
||||
$segment_query = $this->updatesSegment->execute($segment_query, $segment_object);
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanCreateConstant;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Models\SegmentConstant;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstantValue;
|
||||
|
||||
class UpdateSegmentPriceLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Segment Price',
|
||||
'message' => 'You have successfully updated the Segment Price'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateConstant */
|
||||
private $canUpdateConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var CanCreateConstant */
|
||||
private $canCreateConstant;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
/** @var CreatesSegment */
|
||||
private $createsSegment;
|
||||
|
||||
/** @var UpdatesConstantValue */
|
||||
private $updatesConstantValue;
|
||||
|
||||
/**
|
||||
* UpdateConstantLogic constructor.
|
||||
* @param CanUpdateConstant $canUpdateConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param CanCreateConstant $canCreateConstant
|
||||
* @param CreatesConstant $createsConstant
|
||||
* @param UpdatesConstantValueByState $updatesConstantValueByState
|
||||
* @param CreatesSegment $createsSegment
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateConstant $canUpdateConstant,
|
||||
UpdatesConstant $updatesConstant,
|
||||
FetchesSegment $fetchesSegment,
|
||||
FetchesConstant $fetchesConstant,
|
||||
CanCreateConstant $canCreateConstant,
|
||||
CreatesConstant $createsConstant,
|
||||
UpdatesConstantValue $updatesConstantValue,
|
||||
CreatesSegment $createsSegment
|
||||
)
|
||||
{
|
||||
$this->canUpdateConstant = $canUpdateConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->canCreateConstant = $canCreateConstant;
|
||||
$this->createsConstant = $createsConstant;
|
||||
$this->updatesConstantValue = $updatesConstantValue;
|
||||
$this->createsSegment = $createsSegment;
|
||||
}
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
try {
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]);
|
||||
|
||||
$object = new ConstantObject($request->input('reference'), [$request->input('value')]);
|
||||
|
||||
$this->canUpdateConstant->passes($object);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$object = new ConstantObject(
|
||||
$request->input('reference'),
|
||||
[$request->input('value')]
|
||||
);
|
||||
|
||||
$constant = $this->createsConstant->execute($segment, $object);
|
||||
}
|
||||
|
||||
$constant = $this->updatesConstant->execute($constant, $object);
|
||||
|
||||
return $this->resourceResponse(new ConstantResource($constant));
|
||||
}
|
||||
|
||||
}
|
||||
+37
-7
@@ -9,6 +9,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
use App\Classes\Modules\Documents\Services\RejectsDocument;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
|
||||
@@ -20,20 +22,22 @@ use Illuminate\Http\Request;
|
||||
class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* ApprovePaymentVerificationLogic constructor.
|
||||
* ApprovePaymentTransactionLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param ApprovesDocument $approvesDocument
|
||||
* @param RejectsDocument $rejectsDocument
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument)
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
$this->rejectsDocument = $rejectsDocument;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,10 +62,18 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
||||
/** @var RejectsDocument */
|
||||
private $rejectsDocument;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\InternalServerErrorException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
@@ -69,13 +81,31 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
||||
$status = $request->route('status');
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('transaction_id')]);
|
||||
|
||||
|
||||
$status === 'approve' ? $this->approvesDocument->execute($transaction->documents()->first()) : $this->rejectsDocument->execute($transaction->documents()->first());
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
// $this->createInvoiceTransactionProcessor->execute($transaction->booking);
|
||||
if($transaction->status === ApprovalStatus::APPROVED){
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
|
||||
if(($invoice->amount - $transaction->amount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
@@ -69,7 +70,7 @@ class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$invoice_transaction = $packing_list->transactions->where('type', TransactionType::SHIPPING_INVOICE)->first();
|
||||
$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);
|
||||
|
||||
@@ -87,8 +88,11 @@ class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
|
||||
$user = $packing_list->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new InvoiceIssuedEmail($user, $packing_list));
|
||||
}
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -83,7 +84,7 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
$company_module->employees()->first()->email,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $invoice_transaction->bill_no,
|
||||
$amount,
|
||||
$billNumber,
|
||||
@@ -119,6 +120,6 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
||||
|
||||
return $this->response([]);
|
||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||
}
|
||||
}
|
||||
|
||||
+99
-57
@@ -6,8 +6,6 @@ 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\Segments\Services\ListsConstants;
|
||||
use App\Classes\Modules\Segments\Services\ListsSegments;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
@@ -18,6 +16,7 @@ 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;
|
||||
@@ -26,7 +25,7 @@ use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
@@ -40,6 +39,7 @@ use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -56,9 +56,6 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
|
||||
/** @var ListsConstants */
|
||||
private $listsConstants;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
@@ -74,23 +71,19 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
/** @var CreatesFiles */
|
||||
private $createsFile;
|
||||
|
||||
|
||||
/**
|
||||
* CreateShippingInvoiceTransactionLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesSegmentConstant $fetchesSegmentConstant
|
||||
* @param ListsConstants $listsConstants
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param CreatesTransactionDetail $createsTransactionDetail
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, FetchesSegmentConstant $fetchesSegmentConstant, ListsConstants $listsConstants, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CreatesTransactionDetail $createsTransactionDetail, CreatesDocument $createsDocument, CreatesFiles $createsFile)
|
||||
public function __construct(
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesSegmentConstant $fetchesSegmentConstant,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
CreatesTransactionDetail $createsTransactionDetail,
|
||||
CreatesDocument $createsDocument,
|
||||
CreatesFiles $createsFile
|
||||
)
|
||||
{
|
||||
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
||||
$this->listsConstants = $listsConstants;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
@@ -98,46 +91,49 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$this->createsFile = $createsFile;
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
||||
$cbm = $packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
$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 = $packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
$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);
|
||||
});
|
||||
|
||||
$minimum_charges = ($cbm + $over_weight_cbm) < 0.3 ? (0.3 - ($cbm + $over_weight_cbm)) : 0;
|
||||
}), 3);
|
||||
|
||||
$order = $packing_list->owner;
|
||||
$companyModule = $order->companyModule;
|
||||
$connection = $companyModule->connections()->first();
|
||||
$address = $order->addresses()->first();
|
||||
|
||||
$segments = $order->companyModule->connections->first()->segments->pluck('id');
|
||||
|
||||
$segment_price = 0;
|
||||
$base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]);
|
||||
|
||||
if(count($segments)){
|
||||
$segment_price_constants = $this->listsConstants->execute(['segment_id_in' => $segments, 'reference' => SegmentConstants::CUSTOM_PRICE]);
|
||||
$segment_price_constant = $segment_price_constants->sortBy(function ($constant){
|
||||
return $constant->value[0];
|
||||
})->first();
|
||||
$segment_price = $segment_price_constant->value[0];
|
||||
|
||||
}
|
||||
|
||||
$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 = '';
|
||||
|
||||
$packing_list_drop_date = Carbon::parse(PackingList::where('reference', $packing_list->reference)->where('type', 1)->first()->transports->first()->drop_date)->format('Y-m-d');
|
||||
$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;
|
||||
@@ -150,31 +146,65 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$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['center'] + ($state_select === 'outstation' ? $state_rate_constant['outstation'] : 0);
|
||||
$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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$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);
|
||||
});
|
||||
});
|
||||
|
||||
$minimum_charge = $minimum_cbm - $totalContainerCbm;
|
||||
$minimum_charge = ($minimum_charge < 0) ? 0 : $minimum_charge;
|
||||
$minimum_charge = $noMinimumCharge ? 0 : $minimum_charge;
|
||||
|
||||
$minimum_charge = $noMinimumCharge ? 0 : round($minimum_charge, 3);
|
||||
|
||||
|
||||
if($hasMinimumCharge) {
|
||||
$minimum_charge = 0;
|
||||
}
|
||||
|
||||
$price_cbm = $base_price + $segment_price + $warehouse_rate + $state_rate;
|
||||
|
||||
$total_cbm = $price_cbm * ($cbm + $over_weight_cbm);
|
||||
$total_cbm = $price_cbm * ($cbm + $minimum_charge + $over_weight_cbm);
|
||||
|
||||
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('SI-');
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::SHIPPING_INVOICE,
|
||||
1,
|
||||
$billNumber,
|
||||
TransactionType::SHIPPING_INVOICE,
|
||||
1,
|
||||
$order->company_module_id,
|
||||
1,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$total_cbm,
|
||||
$total_cbm,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
@@ -183,13 +213,13 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'SHIPPING_FEE',
|
||||
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->sum('quantity'), 3).' CTNS - '.$cbm.' CBM',
|
||||
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',
|
||||
@@ -201,13 +231,25 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ class SuspendTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::SUSPENDED);
|
||||
|
||||
return $this->response([]);
|
||||
$transaction = $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::SUSPENDED);
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($transaction));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-6
@@ -85,7 +85,7 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$old_transaction_details = $invoice_transaction->transactionDetails->whereNotIn('reference', ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES'])->pluck('id')->toArray();
|
||||
$old_transaction_details = $invoice_transaction->transactionDetails->whereNotIn('reference', ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES', 'MIN_CBM_CHARGES'])->pluck('id')->toArray();
|
||||
|
||||
$new_transaction_details = collect($request->input('transaction_details'));
|
||||
|
||||
@@ -104,7 +104,7 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
foreach($new_transaction_details as $transaction_detail){
|
||||
$transaction_detail = (object) $transaction_detail;
|
||||
|
||||
if(!in_array($transaction_detail->reference, ['SHIPPING_FEE', 'OVER_WHEIGHT_CHARGES'])){
|
||||
if(!in_array($transaction_detail->reference, ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES', 'MIN_CBM_CHARGES'])){
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'CUSTOM_CHARGES',
|
||||
isset($transaction_detail->name) ? $transaction_detail->name : TransactionDetailType::CUSTOM_CHARGES,
|
||||
@@ -117,8 +117,6 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
}else{
|
||||
$new_transaction_detail = $this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
}
|
||||
|
||||
$total_cbm += $new_transaction_detail->amount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,8 +127,8 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$invoice_transaction->issuer,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$total_cbm,
|
||||
$total_cbm,
|
||||
$invoice_transaction->transactionDetails()->sum('amount'),
|
||||
$invoice_transaction->transactionDetails()->sum('amount'),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\BookingResource;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateTransactionStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Transaction Status',
|
||||
'message' => 'You have successfully updated the Transaction Status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
|
||||
/**
|
||||
* SuspendTransactionLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$approvalArray = [
|
||||
'approve' => ApprovalStatus::APPROVED,
|
||||
'expire' => ApprovalStatus::EXPIRED,
|
||||
'reject' => ApprovalStatus::REJECTED,
|
||||
];
|
||||
|
||||
$approvalStatus = $approvalArray[$request->route('status')];
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
if ($request->route('status') === 'reject') {
|
||||
$transaction->delete();
|
||||
} else {
|
||||
$transaction = $this->updatesTransactionStatus->execute($transaction, $approvalStatus);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($transaction));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ class CreatesPaymentTransaction extends AbstractUpdateRelationshipRecord
|
||||
$model->receiver = $object->getReceiver();
|
||||
$model->recipient_bank_account_id = $object->getRecipientBankAccountId();
|
||||
$model->payment_method = $object->getPaymentMethod();
|
||||
$model->payment_reference = $object->getPaymentReference();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->original_amount = $object->getOriginalAmount();
|
||||
$model->currency_id = $object->getCurrencyId();
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,12 +14,16 @@ class FileType
|
||||
|
||||
public const PDF = 'application/pdf';
|
||||
|
||||
public const EXCEL = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||
|
||||
public const EXTENSION = [
|
||||
'image/gif' => 'gif',
|
||||
'image/png' => 'png',
|
||||
'image/jpeg' => 'jpeg',
|
||||
'application/pdf' => 'pdf',
|
||||
'application/octet-stream' => 'pdf',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'excel',
|
||||
'application/vnd.ms-excel' => 'excel',
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,7 @@ final class TransactionDetailType {
|
||||
|
||||
public const OVER_WEIGHT_CHARGES = 'Overweight Charges';
|
||||
|
||||
public const MIN_CBM_CHARGES = 'Minimum Charge for 0.3 CBM Per Container';
|
||||
|
||||
public const CUSTOM_CHARGES = 'Custom charges';
|
||||
}
|
||||
|
||||
@@ -43,11 +43,11 @@ final class WarehouseReferences {
|
||||
|
||||
public const YD_DESTINATION_WAREHOUSE = self::YD_KLANG;
|
||||
|
||||
public const YD_EXEMPT_LIST = [230, 294, 320, 652, 1248, 1726, 2349, 2574, 652];
|
||||
public const YD_EXEMPT_LIST = [230, 294, 320, 1248, 1726, 2349, 2574];
|
||||
|
||||
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,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,6 +38,11 @@ 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');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Exports;
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsArrivedParcel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsParcel;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -26,4 +27,11 @@ class ExportArrivedParcelController
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function summary(Request $request) {
|
||||
$exportsParcelsSummary = new ExportsParcel();
|
||||
$response = $exportsParcelsSummary->download('parcel-summary.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@ 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;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsNullDebtors;
|
||||
|
||||
class ExportCustomersToExcelController
|
||||
{
|
||||
@@ -16,4 +19,24 @@ class ExportCustomersToExcelController
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
return $exportsCustomers->download('customer-latest-order-date.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
|
||||
}
|
||||
|
||||
public function nullDebtor(ExportsNullDebtors $exportsNullDebtors, Request $request){
|
||||
$response = $exportsNullDebtors->download('nullDebtor.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function paymentTransactions(Request $request){
|
||||
$exportsTransactions = new ExportsPaymentTransactions($request);
|
||||
$response = $exportsTransactions->download('payment-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Exports;
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsParcelPostcodes;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
class ExportParcelPostcodesController
|
||||
{
|
||||
/**
|
||||
* ExportArrivedParcelController constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
}
|
||||
|
||||
public function export(Request $request) {
|
||||
$exportsPendingArrangementDeliveryList = new ExportsParcelPostcodes($request);
|
||||
$response = $exportsPendingArrangementDeliveryList->download('parcel-postcodes.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Imports;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Imports\Services\ImportsDebtor;
|
||||
use App\Classes\General\ExcelHandel;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Maatwebsite\Excel\Excel as ExcelFileTypes;
|
||||
|
||||
class ImportUpdateDebtorController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function import(Request $request) {
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
Excel::import(new ImportsDebtor(), 'documents/'.json_decode($object->getFiles()[0])->file_info->original->file);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\UpdateSegmentPriceLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateSegmentPriceController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateSegmentPriceLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\UpdateTransactionStatusLogic;
|
||||
|
||||
|
||||
class UpdateTransactionStatusController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param SuspendTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateTransactionStatusLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,11 @@ class AddressResource extends JsonResource
|
||||
|
||||
$centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get();
|
||||
$centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value;
|
||||
$postcodeArea = in_array($this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : '';
|
||||
$postcodeArea = in_array((String)$this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : null;
|
||||
|
||||
$outstationPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::OUTSTATION_POSTCODE)->get();
|
||||
$outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value;
|
||||
in_array($this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : '';
|
||||
in_array((String)$this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : null;
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
@@ -34,6 +34,7 @@ class AddressResource extends JsonResource
|
||||
'street_two' => $this->street_two,
|
||||
'district' => $this->district,
|
||||
'state' => $this->state,
|
||||
'postcode' => $this->postcode,
|
||||
'post_code' => $this->postcode,
|
||||
'post_code_area' => $postcodeArea,
|
||||
'country' => $this->country,
|
||||
@@ -41,6 +42,7 @@ class AddressResource extends JsonResource
|
||||
'status' => (int) $this->status,
|
||||
'contact' => new ContactResource($this->contacts->first()),
|
||||
'remark' => new RemarkResource($this->remarks->first()),
|
||||
'type' => $this->type,
|
||||
$this->mergeWhen($this->relationLoaded('owner'), [
|
||||
'owner' => $this->when($this->owner instanceof Order, [
|
||||
'reference' => $this->owner->reference,
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyServices;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BankAccountType;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
@@ -41,6 +43,7 @@ class CompanyModuleResource extends JsonResource
|
||||
'name' => $this->name,
|
||||
'reference' => $this->reference,
|
||||
'address' => new AddressResource($defaultAddress),
|
||||
'billingAddress' => new AddressResource($this->addresses()->where('type', AddressType::BILLING)->where('status', ApprovalStatus::APPROVED)->first()),
|
||||
'company' => new CompanyResource($this->whenLoaded('company')),
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'marking' => $marking,
|
||||
|
||||
@@ -29,23 +29,26 @@ class OrderResource extends JsonResource
|
||||
'warehouse' => new CompanyModuleResource($this->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee),
|
||||
'address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first()),
|
||||
'address_change_request' => new AddressResource($this->addressesPendingVerification()->first()),
|
||||
// 'parcels' => $this->whenLoaded('packingLists', function() {
|
||||
// return [
|
||||
// 'origin_warehouse_packages' => PackingListResource::collection(
|
||||
// $this->originWarehousePackages()->get()
|
||||
// ),
|
||||
// 'in_transit_packages' => PackingListResource::collection(
|
||||
// $this->inTransitPackages()->get()
|
||||
// ),
|
||||
// 'destination_warehouse_packages' => PackingListResource::collection(
|
||||
// $this->destinationWarehousePackages()->get()
|
||||
// ),
|
||||
// 'delivered_packages' => PackingListResource::collection(
|
||||
// $this->deliveredPackages()->get()
|
||||
// ),
|
||||
// 'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()),
|
||||
// ];
|
||||
// }),
|
||||
'parcels' => $this->whenLoaded('packingLists', function() {
|
||||
return [
|
||||
'origin_warehouse_packages' => PackingListResource::collection(
|
||||
$this->originWarehousePackages()->get()
|
||||
),
|
||||
'in_transit_packages' => PackingListResource::collection(
|
||||
$this->inTransitPackages()->get()
|
||||
),
|
||||
'destination_warehouse_packages' => PackingListResource::collection(
|
||||
$this->destinationWarehousePackages()->get()
|
||||
),
|
||||
'delivered_packages' => PackingListResource::collection(
|
||||
$this->deliveredPackages()->get()
|
||||
),
|
||||
'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()),
|
||||
];
|
||||
}),
|
||||
'invoices' => $this->whenLoaded('packingLists', function() {
|
||||
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->get());
|
||||
}),
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'created_at' => $this->created_at->format('d-m-Y')
|
||||
];
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PackingListResource extends JsonResource
|
||||
@@ -29,17 +28,16 @@ class PackingListResource extends JsonResource
|
||||
'claimant_id' => $this->claimant_id,
|
||||
'reference' => $this->reference,
|
||||
'status' => $this->status,
|
||||
// 'transport' => new TransportResource($this->transports()->first()),
|
||||
'transport' => new TransportResource($this->transports()->first()),
|
||||
'type' => $this->type,
|
||||
// 'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListResource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first())),
|
||||
'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListResource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first())),
|
||||
'packages' => PackageResource::collection($packages),
|
||||
$this->mergeWhen($this->owner instanceof Order, [
|
||||
'order' => New OrderResource($this->owner)
|
||||
]),
|
||||
'shippng_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()),
|
||||
'shipping_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()),
|
||||
'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()),
|
||||
// 'suspended_invoices' => TransactionResource::collection($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->get()),
|
||||
'loading_days_ago' => $this->containers()->first()->loading_date->diffForHumans()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class SegmentResource extends JsonResource
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'price' => $constant ? $constant->value : 0
|
||||
'price' => $constant ? $constant->value[0] : 0
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace App\Http\Resources;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -18,15 +20,17 @@ class TransactionResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
// 'booking' => new BookingResource($this->booking),
|
||||
'order' => ($this->owner instanceof Transaction) ? new OrderResource($this->owner->owner->owner) : new OrderResource($this->owner->owner),
|
||||
'documents' => DocumentResource::collection($this->documents),
|
||||
'type' => (int) $this->type,
|
||||
'bill_no' => $this->bill_no,
|
||||
'amount' => (double) $this->amount,
|
||||
'payment_method' => (int) $this->payment_method,
|
||||
'payment_reference' => $this->payment_reference,
|
||||
'outstanding' => (double) $this->amount - ($this->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount')),
|
||||
'floating' => (double) $this->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION])->sum('amount'),
|
||||
'service_charge' => (double) $this->service_charge,
|
||||
'tax' => (double) $this->tax,
|
||||
'original_amount' => (double) $this->original_amount,
|
||||
@@ -47,8 +51,10 @@ class TransactionResource extends JsonResource
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED])
|
||||
->get()
|
||||
),
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:s:i'),
|
||||
'updated_at' => Carbon::parse($this->update_at)->format('d-m-Y')
|
||||
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y'),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -186,6 +186,15 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
|
||||
return $this->morphMany(Remark::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasManyDeep
|
||||
*/
|
||||
public function transactions(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Transaction::class, [Order::class], ['company_module_id', 'owner_id'], ['id', 'id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -16,10 +16,13 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use HasRelationships;
|
||||
|
||||
protected $table = 'orders';
|
||||
|
||||
@@ -160,10 +163,10 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
||||
}
|
||||
|
||||
/**
|
||||
* @return morphMany
|
||||
* @return hasManyDeep
|
||||
*/
|
||||
// public function transactions(): morphMany
|
||||
// {
|
||||
// return $this->morphMany(Transaction::class, 'owner');
|
||||
// }
|
||||
public function transactions(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Transaction::class, [PackingList::class], ['owner_id', 'owner_id'], ['id', 'id']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
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;
|
||||
@@ -12,9 +14,13 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
class Transaction extends AbstractModel implements Documentable, Transactionable, Remarkable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'transactions';
|
||||
|
||||
public function owner(): morphTo
|
||||
@@ -122,4 +128,12 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
{
|
||||
return $query->whereIn('status', [ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function remarks(): morphMany
|
||||
{
|
||||
return $this->morphMany(Remark::class, 'owner');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'faker_locale' => 'en_US',
|
||||
'faker_locale' => 'ms_MY',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
+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'),
|
||||
]) : [],
|
||||
|
||||
@@ -39,8 +39,8 @@ class CreateTransactionsTable extends Migration
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('currency_id')->references('id')->on('currencies');
|
||||
$table->foreign('issuer')->references('id')->on('companies');
|
||||
$table->foreign('receiver')->references('id')->on('companies');
|
||||
$table->foreign('issuer')->references('id')->on('company_modules');
|
||||
$table->foreign('receiver')->references('id')->on('company_modules');
|
||||
$table->foreign('original_currency_id')->references('id')->on('currencies');
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddDebtorToCompaniesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('debtor')->nullable()->after('reference');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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,114 +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" => date('Y-m-d', strtotime($today. ' + '.$ii.' days')),
|
||||
"price" => 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);
|
||||
|
||||
// insert customer prices
|
||||
$prices = [
|
||||
['id'=> 1, 'price' => 15 ]
|
||||
];
|
||||
$this->insertData(2, SegmentConstants::CUSTOMER_RATE, $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,14 +10,52 @@ class SegmentsTableSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
DB::table('segments')->insert(
|
||||
[
|
||||
[
|
||||
'id' => 1,
|
||||
'company_module_id' => 1,
|
||||
'name' => 'Default Segment',
|
||||
]
|
||||
]
|
||||
);
|
||||
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'
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
@@ -52,8 +52,9 @@
|
||||
value: {
|
||||
required: false
|
||||
},
|
||||
'section': {
|
||||
section: {
|
||||
type: String,
|
||||
default: 'addressSection'
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
File diff suppressed because one or more lines are too long
+68
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
||||
<div class="row" v-show="!$store.getters.isLoading(section)">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<h3 class="all-caps m-b-5 bold no-margin">Assign Segment</h3>
|
||||
<!-- <div class="fs-11">Select a segment to view annoucment with title <span class="bold">{{parameters.title | truncate(10) }}</span></div> -->
|
||||
<div class="fs-11">Select a segment to view annoucment with title <span class="bold">{{parameters.title }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component selectable :validator="$v.parameters.segment_id">
|
||||
<label>Segment</label>
|
||||
<selectable-component :endpoint="route('api.segment.list') + '?filters=' + JSON.stringify({'id_not_in': currentSegmentIds})" :section="'segmentsListSection_'+data.id" valueColumn="id" :labelColumn="['name']" v-model="parameters.segment_id"></selectable-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Not Now</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submit(route('api.announcement.segment.assign', data.id), 'post', section, true, false)">Assign Segment</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
parameters: {
|
||||
segment_id: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
segment_id: {
|
||||
required
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
currentSegmentIds(){
|
||||
return this.data.segments.map(function (value){
|
||||
return value.id;
|
||||
})
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
|
||||
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h3 class="all-caps">Are you Sure?</h3>
|
||||
<!-- <div class="fs-11">Are you sure you want to remove <span class="bold">{{this.item.name}}</span>from viewing this annoucment with title <span class="bold">{{ announcement_title | truncate(10)}}</span></div> -->
|
||||
<div class="fs-11">Are you sure you want to remove <span class="bold">{{this.item.name}}</span>from viewing this annoucment with title <span class="bold">{{ announcement_title }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submit(route('api.announcement.segment.detach', announcement_id, item.id), 'delete', section, true, true)">Remove Segment</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
props: {
|
||||
announcement_id: {
|
||||
required: true,
|
||||
type: Number
|
||||
},
|
||||
announcement_title: {
|
||||
required: true,
|
||||
type: String
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="alert alert-info padding-15" role="alert" v-show="!isLoading">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="pull-left">{{item.title}}</h5>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fa fa-times text-info-darker pointer" data-dismiss="modal"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p v-html="item.description"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="row bg-white" v-show="!isLoading">-->
|
||||
<!--<div class="col">-->
|
||||
|
||||
<!--<div class="row m-b-20">-->
|
||||
<!--<div class="col">-->
|
||||
<!--<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="50" height="50" viewBox="0 0 172 172" style=" fill:#000000;"><defs><linearGradient x1="99.4375" y1="43.33594" x2="99.4375" y2="60.14625" gradientUnits="userSpaceOnUse" id="color-1_43971_gr1"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="106.15625" y1="26.875" x2="106.15625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-2_43971_gr2"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="83.3125" y1="26.875" x2="83.3125" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-3_43971_gr3"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="73.90625" y1="26.875" x2="73.90625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-4_43971_gr4"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="51.0625" y1="26.875" x2="51.0625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-5_43971_gr5"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="51.0625" y1="26.875" x2="51.0625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-6_43971_gr6"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="45.6875" y1="26.875" x2="45.6875" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-7_43971_gr7"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="43" y1="26.875" x2="43" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-8_43971_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="M112.875,59.125h-26.875c-1.4835,0 -2.6875,-1.204 -2.6875,-2.6875v-10.75c0,-1.4835 1.204,-2.6875 2.6875,-2.6875h26.875c1.4835,0 2.6875,1.204 2.6875,2.6875v10.75c0,1.4835 -1.204,2.6875 -2.6875,2.6875z" fill="url(#color-1_43971_gr1)"></path><path d="M155.875,96.75c0,-7.97381 -5.82381,-14.59581 -13.4375,-15.88313v-18.82325c0,-2.08819 -1.16906,-3.94525 -3.05031,-4.85094c-1.88125,-0.90031 -4.06081,-0.65575 -5.69481,0.64769l-21.48925,17.18925c-0.08062,0.0645 -0.13975,0.14781 -0.21769,0.21769h-31.36044c-7.40944,0 -13.4375,6.02806 -13.4375,13.4375h-5.375c-2.96431,0 -5.375,2.41069 -5.375,5.375v5.375c0,2.96431 2.41069,5.375 5.375,5.375h5.375c0,7.40944 6.02806,13.4375 13.4375,13.4375v16.125c0,5.92863 4.82138,10.75 10.75,10.75c5.92863,0 10.75,-4.82137 10.75,-10.75v-16.125h9.86044c0.07794,0.06988 0.13706,0.15319 0.22038,0.22037l21.48656,17.18925c0.98094,0.78475 2.16075,1.18519 3.35131,1.18519c0.79281,0 1.59369,-0.17738 2.3435,-0.5375c1.88125,-0.903 3.05031,-2.76275 3.05031,-4.84825v-18.82325c7.61369,-1.28731 13.4375,-7.90931 13.4375,-15.88312zM61.8125,99.4375v-5.375h5.375v5.375zM96.75,134.375c0,2.96431 -2.41069,5.375 -5.375,5.375c-2.96431,0 -5.375,-2.41069 -5.375,-5.375v-16.125h10.75zM80.625,112.875c-4.44513,0 -8.0625,-3.61738 -8.0625,-8.0625v-16.125c0,-4.44513 3.61737,-8.0625 8.0625,-8.0625h29.5625v32.25h-8.0625zM137.05175,131.46175l-21.48925,-17.19462v-35.04231l10.75,-8.59194v26.11713h5.375v-30.41175l5.375,-4.29462l0.00538,69.42887c0,0 -0.00538,-0.00269 -0.01613,-0.01075zM142.4375,107.11837v-20.73675c4.6225,1.20131 8.0625,5.375 8.0625,10.36838c0,4.99337 -3.44,9.16706 -8.0625,10.36838z" fill="url(#color-2_43971_gr2)"></path><path d="M77.9375,91.375v5.375h5.375v-5.375h5.375v-5.375h-5.375c-2.96431,0 -5.375,2.41069 -5.375,5.375z" fill="url(#color-3_43971_gr3)"></path><path d="M21.5,107.5v-67.1875c0,-4.44512 3.61737,-8.0625 8.0625,-8.0625h88.6875c4.44512,0 8.0625,3.61738 8.0625,8.0625v10.75h5.375v-10.75c0,-7.40944 -6.02806,-13.4375 -13.4375,-13.4375h-88.6875c-7.40944,0 -13.4375,6.02806 -13.4375,13.4375v67.1875c0,7.40944 6.02806,13.4375 13.4375,13.4375h32.25v-5.375h-32.25c-4.44513,0 -8.0625,-3.61737 -8.0625,-8.0625z" fill="url(#color-4_43971_gr4)"></path><path d="M32.25,43h37.625v5.375h-37.625z" fill="url(#color-5_43971_gr5)"></path><path d="M32.25,53.75h37.625v5.375h-37.625z" fill="url(#color-6_43971_gr6)"></path><path d="M32.25,64.5h26.875v5.375h-26.875z" fill="url(#color-7_43971_gr7)"></path><path d="M32.25,75.25h21.5v5.375h-21.5z" fill="url(#color-8_43971_gr8)"></path></g></g></svg>-->
|
||||
<!--<label class="fs-20 all-caps"><b>{{item.title}}</b></label>-->
|
||||
<!--<label class="float-right fs-10"><i>{{item.created_at}}</i></label>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--<div class="row m-b-20">-->
|
||||
<!--<div class="col">-->
|
||||
<!--<div class=""><b>{{item.description}}</b></div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--<div class="row justify-content-md-center p-b-10">-->
|
||||
<!--<div class="col-3">-->
|
||||
<!--<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">OK</div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div class="col-12">
|
||||
<div class="b-b b-dashed b-grey p-b-25" v-show="!this.show_details" v-if="company">
|
||||
<div class="row align-items-center m-b-5 parentContainer">
|
||||
<div class="col-10">
|
||||
<div class="font-heading fs-10 muted all-caps">Announcement</div>
|
||||
</div>
|
||||
<div class="col-2 text-right pull-right">
|
||||
<div class="font-heading fs-10 muted all-caps">Action</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<list-component :section="this.section" :endpoint="route('api.announcement.list')" :options="{has_segments:segments,is_published:true}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<announcement-list-component :data="data"></announcement-list-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
section: 'announcementsSection',
|
||||
company: null,
|
||||
show_details: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
segments(){
|
||||
return this.company.segments.map(function (value){
|
||||
|
||||
return value.id;
|
||||
})
|
||||
}
|
||||
},
|
||||
created(){
|
||||
this.$store.dispatch('updateListQueue', {'name': this.section});
|
||||
this.fetchCompany();
|
||||
},
|
||||
methods: {
|
||||
fetchCompany(){
|
||||
this.submit(route('api.company.show', this.$store.getters.getCompanyId), 'get', this.section, false, false)
|
||||
},
|
||||
successHandler(response){
|
||||
this.$store.dispatch('completeList', {'name': this.section, 'data': []});
|
||||
this.company = response.payload.data;
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -46,7 +46,7 @@
|
||||
<i class="fa fa-times muted m-l-10 pointer requestModal" data-type="detachSegment" ></i>
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="detachSegment">
|
||||
<detach-segment-form-component :data="segment" :company_id="item.id" section="customerProfileSection"></detach-segment-form-component>
|
||||
<detach-segment-form-component :data="segment" :company_id="item.id" :connection="item.company_module.connections[0].id" section="customerProfileSection"></detach-segment-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15" v-if="item.owner.type === 1">
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<div class="row m-b-5">
|
||||
<div class="col">
|
||||
|
||||
@@ -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>
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h3 class="all-caps">Are you Sure?</h3>
|
||||
<div class="fs-11">Are you sure you want to detach custom from <span class="bold">{{this.item.name}}</span> segment?</div>
|
||||
<div class="fs-11">Are you sure you want to detach customer from <span class="bold">{{this.item.name}}</span> segment?</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submit(route('api.company.segment.detach', company_id, item.id), 'delete', 'customerProfileSection', true, true)">Remove Segment</div>
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submit(route('api.company.connection.detach', company_id, connection, item.id), 'delete', 'customerProfileSection', true, true)">Remove Segment</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -36,6 +36,10 @@
|
||||
company_id: {
|
||||
required: true,
|
||||
type: Number
|
||||
},
|
||||
connection: {
|
||||
required: true,
|
||||
type: Number
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
+6
-1
@@ -6,6 +6,11 @@
|
||||
<customer-profile-component :data="company"></customer-profile-component>
|
||||
</div>
|
||||
</div>
|
||||
<list-component style="min-height: auto;" section="customerAnnouncements" :emptyListSection=false :endpoint="route('api.announcement.list')" :options="{has_segments:true,is_published:true}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<view-announcement-form-component :data="data" section="customerAnnouncements"></view-announcement-form-component>
|
||||
</template>
|
||||
</list-component>
|
||||
<div class="row" v-show="!$store.getters.isShowing('createOrderForm')">
|
||||
<div class="col">
|
||||
<on-boarding-section-component v-if="!company.last_order"></on-boarding-section-component>
|
||||
@@ -113,4 +118,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<div class="col-2">
|
||||
<div v-if="item.order">
|
||||
<a :href="route('customer.profile', item.order.company_module.marking)">{{item.order.company_module.marking}}</a>/<a :href="route('order.show', item.order.reference)">{{item.order.reference}}</a>
|
||||
<p>{{item.reference}}</p>
|
||||
<p v-if="item.receive_packing_list">{{item.receive_packing_list.transport.drop_date}}</p>
|
||||
</div>
|
||||
<div v-if="!item.order" class="text-danger">Unclaimed Packing List</div>
|
||||
@@ -18,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>
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row" @keyup.enter="submitForm">
|
||||
<div class="col ml-md-3 ml-0 mt-md-0 mt-3 bg-white padding-15">
|
||||
<loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
||||
<div class="row" v-show="!$store.getters.isLoading(section)">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-16 all-caps bold m-b-15">Upload Debtors</div>
|
||||
</div>
|
||||
</div>
|
||||
<error-message-component class="m-b-20" :error="error"></error-message-component>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<file-input-component :validator="$v.files" v-model="files">
|
||||
<template slot="label">
|
||||
<div class="font-heading fs-11 text-primary all-caps">Debtor Excel</div>
|
||||
</template>
|
||||
</file-input-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-block p-t-10 p-b-10 p-r-35 p-l-35 btn-success b-rad-none" @click="submitForm">Upload & Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20">
|
||||
<div class="col ml-md-3 ml-0">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-block p-t-10 p-b-10 p-r-35 p-l-35 btn-primary b-rad-none" @click="downloadReport()">Download New Debtors Report</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ModalFromHandler from '../../../general/mixins/modalFormHandler'
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
files: [],
|
||||
parameters: {}
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
files: {
|
||||
required
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
|
||||
this.parameters = {
|
||||
files: this.files
|
||||
};
|
||||
|
||||
this.submit(this.route('api.debtor.import'), 'post', this.section, true, false)
|
||||
},
|
||||
downloadReport(){
|
||||
window.open(route('newDebtor.export'), '_blank');
|
||||
},
|
||||
},
|
||||
mixins: [ModalFromHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<div class="row w-100">
|
||||
<div class="col">
|
||||
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
|
||||
<!-- <div class="row justify-content-center padding-30" v-show="!isLoading"> -->
|
||||
<div class="row justify-content-center" v-show="!isLoading">
|
||||
|
||||
<div class="col">
|
||||
<div class="row" v-for="remark in data.remarks">
|
||||
<div class="col">
|
||||
<remark-list-component :section="section" :data="remark"></remark-list-component>
|
||||
</div>
|
||||
</div>
|
||||
<remark-comment-form-component :section="section" :module_type="module_type" :id="data.id"></remark-comment-form-component>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
props: {
|
||||
module_type: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
}
|
||||
</script>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user